@cf-sync/client 0.3.2 → 0.4.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/index.js CHANGED
@@ -1843,11 +1843,11 @@ const runIntentTransaction = (intent, flush, persist) => {
1843
1843
  });
1844
1844
  tx.mutate(flush);
1845
1845
  if (tx.mutations.length === 0) return persist();
1846
- return tx.isPersisted.promise.then(() => void 0);
1846
+ return tx.when("settled").then(() => void 0);
1847
1847
  };
1848
1848
  /** TanStack enriches rows with virtual props; keep them out of mutator reads and overlays. */
1849
1849
  function stripVirtualProps(row) {
1850
- const { $synced, $origin, $key, $collectionId, ...data } = row;
1850
+ const { $hasPendingWrites, $origin, $key, $collectionId, ...data } = row;
1851
1851
  return data;
1852
1852
  }
1853
1853
  function createHookGate() {
@@ -1953,6 +1953,7 @@ function workspaceCollectionOptions(cfg) {
1953
1953
  getKey,
1954
1954
  schema: tableSchema,
1955
1955
  startSync: cfg.startSync,
1956
+ ...cfg.startSync ? { gcTime: 0 } : {},
1956
1957
  sync: {
1957
1958
  rowUpdateMode: "full",
1958
1959
  sync: (params) => {
@@ -2043,7 +2044,7 @@ function createCollections(client, options) {
2043
2044
  startSync: options?.startSync ?? true
2044
2045
  }));
2045
2046
  client.registerApplier(table, collectionApplier(collection), runIntentTransaction);
2046
- client.onDestroy(() => collection.cleanup());
2047
+ client.onDestroy(() => collection.cleanup({ dependents: true }));
2047
2048
  collections[table] = collection;
2048
2049
  }
2049
2050
  return collections;
@@ -32,7 +32,7 @@ The unit shape is the point for workspace-per-project apps: switching projects i
32
32
 
33
33
  One fully typed collection per table in the client's schema — the one-line alternative to a `createCollection(workspaceCollectionOptions(…))` block per table. Rows are keyed by their `id` field (this engine's row model); a table whose rows key differently needs an individual [`workspaceCollectionOptions`](#workspacecollectionoptions) call with its own `getKey`.
34
34
 
35
- Each collection's lifetime is tied to the client: [`client.destroy()`](/reference/sync-client#destroy) cleans them up too, so switching workspaces is one call. Collection ids are scoped by workspace (`workspace-<workspaceId>-<table>`), so an app with two open workspaces never collides on TanStack DB's app-wide ids. The collections also serve as `mutate`'s optimistic surface — [intent mutations](/guide/mutations) run their shared `apply` against them locally, attached at creation so intents fired before a collection has subscribers still get their optimistic effect.
35
+ Each collection's lifetime is tied to the client: [`client.destroy()`](/reference/sync-client#destroy) cleans them up too, along with any live queries still reading them, so switching workspaces is one call. Collection ids are scoped by workspace (`workspace-<workspaceId>-<table>`), so an app with two open workspaces never collides on TanStack DB's app-wide ids. The collections also serve as `mutate`'s optimistic surface — [intent mutations](/guide/mutations) run their shared `apply` against them locally, attached at creation so intents fired before a collection has subscribers still get their optimistic effect.
36
36
 
37
37
  ### startSync
38
38
 
@@ -72,7 +72,7 @@ Maps a row to its collection key. Required only when the table's row schema has
72
72
 
73
73
  `boolean` · default: TanStack's lazy default
74
74
 
75
- Start the sync pipeline immediately instead of on first subscriber. `createCollections` flips this to `true` for you; here it stays lazy unless you opt in.
75
+ Start the sync pipeline immediately instead of on first subscriber. `createCollections` flips this to `true` for you; here it stays lazy unless you opt in. An eager collection is never garbage-collected for lack of subscribers: it lives until its `cleanup()`, which `createCollections` ties to `client.destroy()`. A lazy one keeps TanStack's `gcTime` default.
76
76
 
77
77
  ## Writes and the wire
78
78
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cf-sync/client",
3
- "version": "0.3.2",
3
+ "version": "0.4.0",
4
4
  "description": "Browser client for cf-sync: SyncClient (optimistic mutations, offline outbox, IndexedDB mirror, presence) and a TanStack DB collection adapter, with React hooks",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -43,8 +43,8 @@
43
43
  "@cf-sync/protocol": "^0.2.1"
44
44
  },
45
45
  "peerDependencies": {
46
- "@tanstack/db": "^0.8.0 || ^0.9.0",
47
- "@tanstack/react-db": "^0.3.0 || ^0.4.0",
46
+ "@tanstack/db": "^1.0.0-rc.1",
47
+ "@tanstack/react-db": "^1.0.0-rc.1",
48
48
  "react": ">=18"
49
49
  },
50
50
  "peerDependenciesMeta": {
@@ -56,7 +56,7 @@
56
56
  }
57
57
  },
58
58
  "devDependencies": {
59
- "@tanstack/db": "^0.9.0",
59
+ "@tanstack/db": "1.0.0-rc.1.5",
60
60
  "@types/react": "^19.0.0",
61
61
  "@types/react-dom": "^19.2.3",
62
62
  "fake-indexeddb": "^6.2.5",