@automerge/automerge-repo-react-hooks 2.5.2-alpha.1 → 2.5.2-alpha.3

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
@@ -6241,6 +6241,13 @@ const REUSE_BUFFER_MODE = 512;
6241
6241
  const RESET_BUFFER_MODE = 1024;
6242
6242
  const THROW_ON_ITERABLE = 2048;
6243
6243
 
6244
+ /**
6245
+ * FinalizationRegistry for automatic cleanup of Ref instances.
6246
+ * This ensures subscriptions are cleaned up when Refs are garbage collected,
6247
+ * even if dispose() is never called.
6248
+ */
6249
+ new FinalizationRegistry(cleanup => cleanup());
6250
+
6244
6251
  var sha256$1 = {exports: {}};
6245
6252
 
6246
6253
  var sha256 = sha256$1.exports;
@@ -7177,6 +7184,15 @@ function usePresence({
7177
7184
  presence.stop();
7178
7185
  };
7179
7186
  }, [presence, userId, deviceId, firstInitialState, firstOpts]);
7187
+ const start = useCallback(() => {
7188
+ presence.start({
7189
+ initialState: presence.getLocalState(),
7190
+ ...firstOpts.current
7191
+ });
7192
+ }, [presence, firstOpts]);
7193
+ const stop = useCallback(() => {
7194
+ presence.stop();
7195
+ }, [presence]);
7180
7196
  const update = useCallback(
7181
7197
  (channel, msg) => {
7182
7198
  presence.broadcast(channel, msg);
@@ -7188,7 +7204,9 @@ function usePresence({
7188
7204
  return {
7189
7205
  peerStates,
7190
7206
  localState,
7191
- update
7207
+ update,
7208
+ start,
7209
+ stop
7192
7210
  };
7193
7211
  }
7194
7212