jazz-tools 0.19.7 → 0.19.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 (167) hide show
  1. package/.turbo/turbo-build.log +65 -59
  2. package/CHANGELOG.md +34 -3
  3. package/dist/{chunk-CUS6O5NE.js → chunk-FFEEPZEG.js} +454 -122
  4. package/dist/chunk-FFEEPZEG.js.map +1 -0
  5. package/dist/expo/polyfills.js +22 -0
  6. package/dist/expo/polyfills.js.map +1 -0
  7. package/dist/index.js +26 -6
  8. package/dist/index.js.map +1 -1
  9. package/dist/react/hooks.d.ts +1 -1
  10. package/dist/react/hooks.d.ts.map +1 -1
  11. package/dist/react/index.d.ts +1 -1
  12. package/dist/react/index.d.ts.map +1 -1
  13. package/dist/react/index.js +5 -1
  14. package/dist/react/index.js.map +1 -1
  15. package/dist/react-core/hooks.d.ts +59 -0
  16. package/dist/react-core/hooks.d.ts.map +1 -1
  17. package/dist/react-core/index.js +133 -34
  18. package/dist/react-core/index.js.map +1 -1
  19. package/dist/react-core/tests/testUtils.d.ts +1 -0
  20. package/dist/react-core/tests/testUtils.d.ts.map +1 -1
  21. package/dist/react-core/tests/useSuspenseAccount.test.d.ts +2 -0
  22. package/dist/react-core/tests/useSuspenseAccount.test.d.ts.map +1 -0
  23. package/dist/react-core/tests/useSuspenseCoState.test.d.ts +2 -0
  24. package/dist/react-core/tests/useSuspenseCoState.test.d.ts.map +1 -0
  25. package/dist/react-core/use.d.ts +3 -0
  26. package/dist/react-core/use.d.ts.map +1 -0
  27. package/dist/react-native/index.d.ts +1 -1
  28. package/dist/react-native/index.d.ts.map +1 -1
  29. package/dist/react-native/index.js +717 -9
  30. package/dist/react-native/index.js.map +1 -1
  31. package/dist/react-native/polyfills.js +22 -0
  32. package/dist/react-native/polyfills.js.map +1 -0
  33. package/dist/react-native-core/crypto/RNCrypto.d.ts +2 -0
  34. package/dist/react-native-core/crypto/RNCrypto.d.ts.map +1 -0
  35. package/dist/react-native-core/crypto/RNCrypto.js +3 -0
  36. package/dist/react-native-core/crypto/RNCrypto.js.map +1 -0
  37. package/dist/react-native-core/hooks.d.ts +1 -1
  38. package/dist/react-native-core/hooks.d.ts.map +1 -1
  39. package/dist/react-native-core/index.d.ts.map +1 -1
  40. package/dist/react-native-core/index.js +5 -1
  41. package/dist/react-native-core/index.js.map +1 -1
  42. package/dist/react-native-core/platform.d.ts +2 -1
  43. package/dist/react-native-core/platform.d.ts.map +1 -1
  44. package/dist/testing.js +1 -1
  45. package/dist/testing.js.map +1 -1
  46. package/dist/tools/coValues/account.d.ts +3 -3
  47. package/dist/tools/coValues/account.d.ts.map +1 -1
  48. package/dist/tools/coValues/coFeed.d.ts +3 -3
  49. package/dist/tools/coValues/coFeed.d.ts.map +1 -1
  50. package/dist/tools/coValues/coList.d.ts +4 -4
  51. package/dist/tools/coValues/coList.d.ts.map +1 -1
  52. package/dist/tools/coValues/coMap.d.ts +7 -7
  53. package/dist/tools/coValues/coMap.d.ts.map +1 -1
  54. package/dist/tools/coValues/coPlainText.d.ts +2 -2
  55. package/dist/tools/coValues/coPlainText.d.ts.map +1 -1
  56. package/dist/tools/coValues/coVector.d.ts +2 -2
  57. package/dist/tools/coValues/coVector.d.ts.map +1 -1
  58. package/dist/tools/coValues/deepLoading.d.ts +24 -0
  59. package/dist/tools/coValues/deepLoading.d.ts.map +1 -1
  60. package/dist/tools/coValues/group.d.ts +2 -2
  61. package/dist/tools/coValues/group.d.ts.map +1 -1
  62. package/dist/tools/coValues/interfaces.d.ts +7 -7
  63. package/dist/tools/coValues/interfaces.d.ts.map +1 -1
  64. package/dist/tools/coValues/schemaUnion.d.ts +2 -2
  65. package/dist/tools/coValues/schemaUnion.d.ts.map +1 -1
  66. package/dist/tools/config.d.ts +3 -0
  67. package/dist/tools/config.d.ts.map +1 -0
  68. package/dist/tools/exports.d.ts +2 -0
  69. package/dist/tools/exports.d.ts.map +1 -1
  70. package/dist/tools/implementation/ContextManager.d.ts +3 -0
  71. package/dist/tools/implementation/ContextManager.d.ts.map +1 -1
  72. package/dist/tools/implementation/zodSchema/schemaTypes/AccountSchema.d.ts +2 -2
  73. package/dist/tools/implementation/zodSchema/schemaTypes/AccountSchema.d.ts.map +1 -1
  74. package/dist/tools/implementation/zodSchema/schemaTypes/CoDiscriminatedUnionSchema.d.ts +2 -2
  75. package/dist/tools/implementation/zodSchema/schemaTypes/CoDiscriminatedUnionSchema.d.ts.map +1 -1
  76. package/dist/tools/implementation/zodSchema/schemaTypes/CoFeedSchema.d.ts +2 -2
  77. package/dist/tools/implementation/zodSchema/schemaTypes/CoFeedSchema.d.ts.map +1 -1
  78. package/dist/tools/implementation/zodSchema/schemaTypes/CoListSchema.d.ts +4 -4
  79. package/dist/tools/implementation/zodSchema/schemaTypes/CoListSchema.d.ts.map +1 -1
  80. package/dist/tools/implementation/zodSchema/schemaTypes/CoMapSchema.d.ts +4 -4
  81. package/dist/tools/implementation/zodSchema/schemaTypes/CoMapSchema.d.ts.map +1 -1
  82. package/dist/tools/implementation/zodSchema/schemaTypes/CoRecordSchema.d.ts +4 -4
  83. package/dist/tools/implementation/zodSchema/schemaTypes/CoRecordSchema.d.ts.map +1 -1
  84. package/dist/tools/implementation/zodSchema/schemaTypes/FileStreamSchema.d.ts +2 -2
  85. package/dist/tools/implementation/zodSchema/schemaTypes/FileStreamSchema.d.ts.map +1 -1
  86. package/dist/tools/implementation/zodSchema/schemaTypes/GroupSchema.d.ts +2 -2
  87. package/dist/tools/implementation/zodSchema/schemaTypes/GroupSchema.d.ts.map +1 -1
  88. package/dist/tools/implementation/zodSchema/schemaTypes/PlainTextSchema.d.ts +2 -2
  89. package/dist/tools/implementation/zodSchema/schemaTypes/PlainTextSchema.d.ts.map +1 -1
  90. package/dist/tools/implementation/zodSchema/schemaTypes/RichTextSchema.d.ts +2 -2
  91. package/dist/tools/implementation/zodSchema/schemaTypes/RichTextSchema.d.ts.map +1 -1
  92. package/dist/tools/implementation/zodSchema/zodCo.d.ts.map +1 -1
  93. package/dist/tools/subscribe/CoValueCoreSubscription.d.ts +8 -22
  94. package/dist/tools/subscribe/CoValueCoreSubscription.d.ts.map +1 -1
  95. package/dist/tools/subscribe/JazzError.d.ts.map +1 -1
  96. package/dist/tools/subscribe/SubscriptionCache.d.ts +51 -0
  97. package/dist/tools/subscribe/SubscriptionCache.d.ts.map +1 -0
  98. package/dist/tools/subscribe/SubscriptionScope.d.ts +27 -2
  99. package/dist/tools/subscribe/SubscriptionScope.d.ts.map +1 -1
  100. package/dist/tools/subscribe/errorReporting.d.ts +31 -0
  101. package/dist/tools/subscribe/errorReporting.d.ts.map +1 -0
  102. package/dist/tools/subscribe/utils.d.ts +9 -1
  103. package/dist/tools/subscribe/utils.d.ts.map +1 -1
  104. package/dist/tools/testing.d.ts +2 -2
  105. package/dist/tools/testing.d.ts.map +1 -1
  106. package/dist/tools/tests/SubscriptionCache.test.d.ts +2 -0
  107. package/dist/tools/tests/SubscriptionCache.test.d.ts.map +1 -0
  108. package/dist/tools/tests/errorReporting.test.d.ts +2 -0
  109. package/dist/tools/tests/errorReporting.test.d.ts.map +1 -0
  110. package/package.json +22 -7
  111. package/src/react/hooks.tsx +2 -0
  112. package/src/react/index.ts +1 -14
  113. package/src/react-core/hooks.ts +181 -16
  114. package/src/react-core/tests/createCoValueSubscriptionContext.test.tsx +18 -8
  115. package/src/react-core/tests/testUtils.tsx +67 -5
  116. package/src/react-core/tests/useCoState.test.ts +3 -7
  117. package/src/react-core/tests/useSubscriptionSelector.test.ts +3 -7
  118. package/src/react-core/tests/useSuspenseAccount.test.tsx +343 -0
  119. package/src/react-core/tests/useSuspenseCoState.test.tsx +1182 -0
  120. package/src/react-core/use.ts +46 -0
  121. package/src/react-native/index.ts +1 -1
  122. package/src/react-native-core/crypto/RNCrypto.ts +1 -0
  123. package/src/react-native-core/hooks.tsx +2 -0
  124. package/src/react-native-core/index.ts +2 -0
  125. package/src/react-native-core/platform.ts +2 -1
  126. package/src/react-native-core/polyfills/index.js +28 -0
  127. package/src/tools/coValues/account.ts +3 -4
  128. package/src/tools/coValues/coFeed.ts +3 -2
  129. package/src/tools/coValues/coList.ts +4 -4
  130. package/src/tools/coValues/coMap.ts +4 -4
  131. package/src/tools/coValues/coPlainText.ts +2 -2
  132. package/src/tools/coValues/coVector.ts +2 -2
  133. package/src/tools/coValues/deepLoading.ts +31 -0
  134. package/src/tools/coValues/group.ts +2 -2
  135. package/src/tools/coValues/interfaces.ts +21 -26
  136. package/src/tools/coValues/schemaUnion.ts +2 -2
  137. package/src/tools/config.ts +9 -0
  138. package/src/tools/exports.ts +4 -0
  139. package/src/tools/implementation/ContextManager.ts +13 -0
  140. package/src/tools/implementation/zodSchema/schemaTypes/AccountSchema.ts +2 -2
  141. package/src/tools/implementation/zodSchema/schemaTypes/CoDiscriminatedUnionSchema.ts +2 -2
  142. package/src/tools/implementation/zodSchema/schemaTypes/CoFeedSchema.ts +2 -2
  143. package/src/tools/implementation/zodSchema/schemaTypes/CoListSchema.ts +4 -4
  144. package/src/tools/implementation/zodSchema/schemaTypes/CoMapSchema.ts +4 -4
  145. package/src/tools/implementation/zodSchema/schemaTypes/CoRecordSchema.ts +4 -10
  146. package/src/tools/implementation/zodSchema/schemaTypes/FileStreamSchema.ts +2 -2
  147. package/src/tools/implementation/zodSchema/schemaTypes/GroupSchema.ts +2 -2
  148. package/src/tools/implementation/zodSchema/schemaTypes/PlainTextSchema.ts +2 -2
  149. package/src/tools/implementation/zodSchema/schemaTypes/RichTextSchema.ts +2 -2
  150. package/src/tools/subscribe/CoValueCoreSubscription.ts +71 -100
  151. package/src/tools/subscribe/JazzError.ts +9 -6
  152. package/src/tools/subscribe/SubscriptionCache.ts +272 -0
  153. package/src/tools/subscribe/SubscriptionScope.ts +218 -29
  154. package/src/tools/subscribe/errorReporting.ts +67 -0
  155. package/src/tools/subscribe/utils.ts +77 -0
  156. package/src/tools/testing.ts +0 -3
  157. package/src/tools/tests/CoValueCoreSubscription.test.ts +46 -12
  158. package/src/tools/tests/ContextManager.test.ts +85 -0
  159. package/src/tools/tests/SubscriptionCache.test.ts +237 -0
  160. package/src/tools/tests/coMap.test.ts +5 -7
  161. package/src/tools/tests/deepLoading.test.ts +47 -47
  162. package/src/tools/tests/errorReporting.test.ts +103 -0
  163. package/src/tools/tests/load.test.ts +21 -1
  164. package/src/tools/tests/request.test.ts +2 -1
  165. package/src/tools/tests/subscribe.test.ts +44 -0
  166. package/tsup.config.ts +17 -0
  167. package/dist/chunk-CUS6O5NE.js.map +0 -1
@@ -0,0 +1,51 @@
1
+ import { LocalNode } from "cojson";
2
+ import type { CoValue, CoValueClassOrSchema, ResolveQuery } from "../internal.js";
3
+ import { SubscriptionScope } from "./SubscriptionScope.js";
4
+ import type { BranchDefinition } from "./types.js";
5
+ export declare class SubscriptionCache {
6
+ private cache;
7
+ private cleanupTimeout;
8
+ constructor(cleanupTimeout?: number);
9
+ /**
10
+ * Get the inner set for a given id (read-only access)
11
+ */
12
+ private getIdSet;
13
+ /**
14
+ * Get the inner set for a given id, creating it if it doesn't exist
15
+ */
16
+ private getIdSetOrCreate;
17
+ /**
18
+ * Check if an entry matches the provided parameters
19
+ */
20
+ private matchesEntry;
21
+ /**
22
+ * Find a matching cache entry by comparing against entry properties
23
+ * Uses id-based nesting to quickly filter candidates
24
+ */
25
+ private findMatchingEntry;
26
+ /**
27
+ * Handle subscriber count changes from SubscriptionScope
28
+ */
29
+ private handleSubscriberChange;
30
+ /**
31
+ * Schedule cleanup timeout for an entry
32
+ */
33
+ private scheduleCleanup;
34
+ /**
35
+ * Cancel pending cleanup timeout for an entry
36
+ */
37
+ private cancelCleanup;
38
+ /**
39
+ * Destroy a cache entry and its SubscriptionScope
40
+ */
41
+ private destroyEntry;
42
+ /**
43
+ * Get or create a SubscriptionScope from the cache
44
+ */
45
+ getOrCreate<S extends CoValueClassOrSchema>(node: LocalNode, schema: S, id: string, resolve: ResolveQuery<S>, skipRetry?: boolean, bestEffortResolution?: boolean, branch?: BranchDefinition): SubscriptionScope<CoValue>;
46
+ /**
47
+ * Clear all cache entries and destroy all SubscriptionScope instances
48
+ */
49
+ clear(): void;
50
+ }
51
+ //# sourceMappingURL=SubscriptionCache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SubscriptionCache.d.ts","sourceRoot":"","sources":["../../../src/tools/subscribe/SubscriptionCache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,KAAK,EACV,OAAO,EACP,oBAAoB,EAGpB,YAAY,EACb,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAanD,qBAAa,iBAAiB;IAE5B,OAAO,CAAC,KAAK,CAA+B;IAC5C,OAAO,CAAC,cAAc,CAAS;gBAEnB,cAAc,GAAE,MAAa;IAKzC;;OAEG;IACH,OAAO,CAAC,QAAQ;IAIhB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IASxB;;OAEG;IACH,OAAO,CAAC,YAAY;IA+BpB;;;OAGG;IACH,OAAO,CAAC,iBAAiB;IAsBzB;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAY9B;;OAEG;IACH,OAAO,CAAC,eAAe;IASvB;;OAEG;IACH,OAAO,CAAC,aAAa;IAOrB;;OAEG;IACH,OAAO,CAAC,YAAY;IA2BpB;;OAEG;IACH,WAAW,CAAC,CAAC,SAAS,oBAAoB,EACxC,IAAI,EAAE,SAAS,EACf,MAAM,EAAE,CAAC,EACT,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,EACxB,SAAS,CAAC,EAAE,OAAO,EACnB,oBAAoB,CAAC,EAAE,OAAO,EAC9B,MAAM,CAAC,EAAE,gBAAgB,GACxB,iBAAiB,CAAC,OAAO,CAAC;IA6D7B;;OAEG;IACH,KAAK,IAAI,IAAI;CAiBd"}
@@ -1,9 +1,10 @@
1
- import type { LocalNode, RawCoValue } from "cojson";
1
+ import { LocalNode, RawCoValue } from "cojson";
2
2
  import { CoList, CoMap, type CoValue, type ID, MaybeLoaded, NotLoaded, type RefEncoded, type RefsToResolve } from "../internal.js";
3
3
  import { CoValueCoreSubscription } from "./CoValueCoreSubscription.js";
4
4
  import { JazzError } from "./JazzError.js";
5
5
  import type { BranchDefinition, SubscriptionValue, SubscriptionValueLoading } from "./types.js";
6
6
  import { CoValueLoadingState, NotLoadedCoValueState } from "./types.js";
7
+ import { PromiseWithStatus } from "./utils.js";
7
8
  export declare class SubscriptionScope<D extends CoValue> {
8
9
  node: LocalNode;
9
10
  id: ID<D>;
@@ -38,18 +39,42 @@ export declare class SubscriptionScope<D extends CoValue> {
38
39
  migrating: boolean;
39
40
  closed: boolean;
40
41
  silenceUpdates: boolean;
41
- constructor(node: LocalNode, resolve: RefsToResolve<D>, id: ID<D>, schema: RefEncoded<D>, skipRetry?: boolean, bestEffortResolution?: boolean, unstable_branch?: BranchDefinition | undefined);
42
+ /**
43
+ * Stack trace captured at subscription creation time.
44
+ * This helps identify which component/hook created the subscription
45
+ * when debugging "value unavailable" errors.
46
+ */
47
+ callerStack: Error | undefined;
48
+ constructor(node: LocalNode, resolve: RefsToResolve<D>, id: ID<D>, schema: RefEncoded<D>, skipRetry?: boolean, bestEffortResolution?: boolean, unstable_branch?: BranchDefinition | undefined, callerStack?: Error | undefined);
42
49
  updateValue(value: SubscriptionValue<D, any>): void;
43
50
  handleUpdate(update: RawCoValue | typeof CoValueLoadingState.UNAVAILABLE): void;
44
51
  computeChildErrors(): JazzError | undefined;
45
52
  handleChildUpdate: (id: string, value: SubscriptionValue<any, any> | SubscriptionValueLoading, key?: string) => void;
46
53
  shouldSendUpdates(): boolean;
47
54
  unloadedValue: NotLoaded<D> | undefined;
55
+ lastPromise: {
56
+ value: MaybeLoaded<D> | undefined;
57
+ promise: PromiseWithStatus<MaybeLoaded<D>>;
58
+ } | undefined;
59
+ cachePromise(value: MaybeLoaded<D>, callback: () => PromiseWithStatus<D>): PromiseWithStatus<MaybeLoaded<D>>;
60
+ getPromise(): PromiseWithStatus<unknown>;
48
61
  private getUnloadedValue;
62
+ lastErrorLogged: JazzError | undefined;
49
63
  getCurrentValue(): MaybeLoaded<D>;
50
64
  getCurrentRawValue(): D | NotLoadedCoValueState;
65
+ getCreationStackLines(): string;
66
+ getError(): JazzError | undefined;
67
+ logError(): void;
51
68
  triggerUpdate(): void;
52
69
  subscribers: Set<(value: SubscriptionValue<D, any>) => void>;
70
+ subscriberChangeCallbacks: Set<(count: number) => void>;
71
+ /**
72
+ * Subscribe to subscriber count changes
73
+ * Callback receives the total number of subscribers
74
+ * Returns an unsubscribe function
75
+ */
76
+ onSubscriberChange(callback: (count: number) => void): () => void;
77
+ private notifySubscriberChange;
53
78
  subscribe(listener: (value: SubscriptionValue<D, any>) => void): () => void;
54
79
  setListener(listener: (value: SubscriptionValue<D, any>) => void): void;
55
80
  subscribeToKey(key: string): void;
@@ -1 +1 @@
1
- {"version":3,"file":"SubscriptionScope.d.ts","sourceRoot":"","sources":["../../../src/tools/subscribe/SubscriptionScope.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpD,OAAO,EAEL,MAAM,EACN,KAAK,EACL,KAAK,OAAO,EACZ,KAAK,EAAE,EACP,WAAW,EACX,SAAS,EACT,KAAK,UAAU,EACf,KAAK,aAAa,EAKnB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,SAAS,EAAuB,MAAM,gBAAgB,CAAC;AAChE,OAAO,KAAK,EACV,gBAAgB,EAChB,iBAAiB,EACjB,wBAAwB,EACzB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAGxE,qBAAa,iBAAiB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AC,GAAG,CAAC;IAmDrD,YAAY;IAoHZ,YAAY,CAAC,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI;IA0CvE,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI;IAsC1E,aAAa,CACX,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,aAAa,CAAC,GAAG,CAAC,EACzB,UAAU,EAAE,UAAU,CAAC,GAAG,CAAC,EAC3B,GAAG,CAAC,EAAE,MAAM;IAoDd,OAAO;CAcR"}
@@ -0,0 +1,31 @@
1
+ import type { JazzError } from "./JazzError";
2
+ type CustomErrorReporterProps = {
3
+ getPrettyStackTrace: () => string;
4
+ jazzError: JazzError;
5
+ };
6
+ type CustomErrorReporter = (error: Error, props: CustomErrorReporterProps) => void;
7
+ /**
8
+ * Turns on the additonal debug info coming from React hooks on the original subscription of the errors.
9
+ *
10
+ * Enabled by default in development mode.
11
+ */
12
+ export declare function enableCaptureErrorCause(capture: boolean): void;
13
+ /**
14
+ * Set a custom error reporter to be used instead of the default console.error.
15
+ *
16
+ * Useful for sending errors to a logging service or silence some annoying errors in production.
17
+ */
18
+ export declare function setCustomErrorReporter(reporter?: CustomErrorReporter): void;
19
+ /**
20
+ * Check if we're in development mode.
21
+ * Stack traces are only captured in development to avoid overhead in production.
22
+ */
23
+ export declare function isCustomErrorReportingEnabled(): boolean;
24
+ /**
25
+ * Capture a stack trace only in development mode.
26
+ * Returns undefined in production to avoid overhead.
27
+ */
28
+ export declare function captureStack(): Error | undefined;
29
+ export declare function captureError(error: Error, props: CustomErrorReporterProps): void;
30
+ export {};
31
+ //# sourceMappingURL=errorReporting.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errorReporting.d.ts","sourceRoot":"","sources":["../../../src/tools/subscribe/errorReporting.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAe7C,KAAK,wBAAwB,GAAG;IAC9B,mBAAmB,EAAE,MAAM,MAAM,CAAC;IAClC,SAAS,EAAE,SAAS,CAAC;CACtB,CAAC;AAEF,KAAK,mBAAmB,GAAG,CACzB,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,wBAAwB,KAC5B,IAAI,CAAC;AAKV;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,QAEvD;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,CAAC,EAAE,mBAAmB,QAEpE;AAED;;;GAGG;AACH,wBAAgB,6BAA6B,IAAI,OAAO,CAEvD;AAED;;;GAGG;AACH,wBAAgB,YAAY,sBAE3B;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,wBAAwB,QAIzE"}
@@ -1,5 +1,5 @@
1
1
  import { RawCoValue, Role } from "cojson";
2
- import { CoValue, RefEncoded } from "../internal.js";
2
+ import { CoValue, RefEncoded, RefsToResolve } from "../internal.js";
3
3
  import { SubscriptionScope } from "./SubscriptionScope.js";
4
4
  export declare function myRoleForRawValue(raw: RawCoValue): Role | undefined;
5
5
  export declare function createCoValue<D extends CoValue>(ref: RefEncoded<D>, raw: RawCoValue, subscriptionScope: SubscriptionScope<D>): {
@@ -7,4 +7,12 @@ export declare function createCoValue<D extends CoValue>(ref: RefEncoded<D>, raw
7
7
  value: D;
8
8
  id: string;
9
9
  };
10
+ export type PromiseWithStatus<T> = PromiseLike<T> & {
11
+ status?: "pending" | "fulfilled" | "rejected";
12
+ value?: T;
13
+ reason?: unknown;
14
+ };
15
+ export declare function resolvedPromise<T>(value: T): PromiseWithStatus<T>;
16
+ export declare function rejectedPromise<T>(reason: unknown): PromiseWithStatus<T>;
17
+ export declare function isEqualRefsToResolve(a: RefsToResolve<any>, b: RefsToResolve<any>): boolean;
10
18
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/tools/subscribe/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,UAAU,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAEtD,OAAO,EACL,OAAO,EACP,UAAU,EAGX,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAG3D,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,UAAU,GAAG,IAAI,GAAG,SAAS,CAUnE;AAED,wBAAgB,aAAa,CAAC,CAAC,SAAS,OAAO,EAC7C,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,EAClB,GAAG,EAAE,UAAU,EACf,iBAAiB,EAAE,iBAAiB,CAAC,CAAC,CAAC;;;;EAgBxC"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/tools/subscribe/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,UAAU,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAEtD,OAAO,EACL,OAAO,EACP,UAAU,EACV,aAAa,EAGd,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAG3D,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,UAAU,GAAG,IAAI,GAAG,SAAS,CAUnE;AAED,wBAAgB,aAAa,CAAC,CAAC,SAAS,OAAO,EAC7C,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,EAClB,GAAG,EAAE,UAAU,EACf,iBAAiB,EAAE,iBAAiB,CAAC,CAAC,CAAC;;;;EAgBxC;AAED,MAAM,MAAM,iBAAiB,CAAC,CAAC,IAAI,WAAW,CAAC,CAAC,CAAC,GAAG;IAClD,MAAM,CAAC,EAAE,SAAS,GAAG,WAAW,GAAG,UAAU,CAAC;IAC9C,KAAK,CAAC,EAAE,CAAC,CAAC;IACV,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,wBAAgB,eAAe,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAKjE;AAED,wBAAgB,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAKxE;AAED,wBAAgB,oBAAoB,CAClC,CAAC,EAAE,aAAa,CAAC,GAAG,CAAC,EACrB,CAAC,EAAE,aAAa,CAAC,GAAG,CAAC,WAoDtB"}
@@ -1,6 +1,6 @@
1
1
  import { LocalNode } from "cojson";
2
2
  import { PureJSCrypto } from "cojson/dist/crypto/PureJSCrypto";
3
- import { Account, AccountClass, type AnonymousJazzAgent, CoValueFromRaw, CoreAccountSchema, InstanceOfSchema, JazzContextManager, JazzContextManagerAuthProps, JazzContextManagerBaseProps, CoValue } from "./internal.js";
3
+ import { Account, AccountClass, type AnonymousJazzAgent, CoValueFromRaw, CoreAccountSchema, InstanceOfSchema, JazzContextManager, JazzContextManagerAuthProps, JazzContextManagerBaseProps } from "./internal.js";
4
4
  export { assertLoaded } from "./lib/utils.js";
5
5
  export declare class TestJSCrypto extends PureJSCrypto {
6
6
  static create(): Promise<PureJSCrypto>;
@@ -50,7 +50,7 @@ export declare class TestJazzContextManager<Acc extends Account> extends JazzCon
50
50
  fromNode: (typeof Account)["fromNode"];
51
51
  } & CoValueFromRaw<Acc> extends infer T ? T extends import("./internal.js").CoValueClass<Acc> & {
52
52
  fromNode: (typeof Account)["fromNode"];
53
- } & CoValueFromRaw<Acc> ? T extends import("./internal.js").CoValueClass<CoValue> ? InstanceType<T> : never : never : never;
53
+ } & CoValueFromRaw<Acc> ? T extends import("./internal.js").CoValueClass<import("./internal.js").CoValue> ? InstanceType<T> : never : never : never;
54
54
  node: LocalNode;
55
55
  done: () => void;
56
56
  logOut: () => Promise<void>;
@@ -1 +1 @@
1
- {"version":3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AE,OAAO,EACV,KAAK,GAAE,QAAQ,GAAG,QAAmB,EACrC,KAAK,GAAE,QAAQ,GAAG,QAAmB,iBAgBtC;AAED,wBAAsB,iBAAiB,CAAC,EACtC,UAAkB,GACnB,GAAE;IACD,UAAU,CAAC,EAAE,OAAO,CAAC;CACjB,oBAgBL;AAED,wBAAgB,mBAAmB,SAKlC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=SubscriptionCache.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SubscriptionCache.test.d.ts","sourceRoot":"","sources":["../../../src/tools/tests/SubscriptionCache.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=errorReporting.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errorReporting.test.d.ts","sourceRoot":"","sources":["../../../src/tools/tests/errorReporting.test.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -62,6 +62,10 @@
62
62
  "types": "./dist/expo/testing.d.ts",
63
63
  "default": "./dist/expo/testing.js"
64
64
  },
65
+ "./expo/polyfills": {
66
+ "@jazz-tools/source": "./src/react-native-core/polyfills/index.js",
67
+ "default": "./dist/expo/polyfills.js"
68
+ },
65
69
  "./inspector": {
66
70
  "@jazz-tools/source": "./src/inspector/index.ts",
67
71
  "types": "./dist/inspector/index.d.ts",
@@ -117,6 +121,10 @@
117
121
  "types": "./dist/react-native/testing.d.ts",
118
122
  "default": "./dist/react-native/testing.js"
119
123
  },
124
+ "./react-native/polyfills": {
125
+ "@jazz-tools/source": "./src/react-native-core/polyfills/index.js",
126
+ "default": "./dist/react-native/polyfills.js"
127
+ },
120
128
  "./react-native-core": {
121
129
  "@jazz-tools/source": "./src/react-native-core/index.ts",
122
130
  "types": "./dist/react-native-core/index.d.ts",
@@ -183,11 +191,16 @@
183
191
  "@jazz-tools/source": "./src/worker/napi-crypto.ts",
184
192
  "types": "./dist/worker/napi-crypto.d.ts",
185
193
  "default": "./dist/worker/napi-crypto.js"
194
+ },
195
+ "./react-native-core/crypto/RNCrypto": {
196
+ "@jazz-tools/source": "./src/react-native-core/crypto/RNCrypto.ts",
197
+ "types": "./dist/react-native-core/crypto/RNCrypto.d.ts",
198
+ "default": "./dist/react-native-core/crypto/RNCrypto.js"
186
199
  }
187
200
  },
188
201
  "type": "module",
189
202
  "license": "MIT",
190
- "version": "0.19.7",
203
+ "version": "0.19.10",
191
204
  "dependencies": {
192
205
  "@manuscripts/prosemirror-recreate-steps": "^0.1.4",
193
206
  "@scure/base": "1.2.1",
@@ -204,9 +217,9 @@
204
217
  "prosemirror-transform": "^1.9.0",
205
218
  "use-sync-external-store": "^1.5.0",
206
219
  "zod": "4.1.11",
207
- "cojson": "0.19.7",
208
- "cojson-storage-indexeddb": "0.19.7",
209
- "cojson-transport-ws": "0.19.7"
220
+ "cojson": "0.19.10",
221
+ "cojson-storage-indexeddb": "0.19.10",
222
+ "cojson-transport-ws": "0.19.10"
210
223
  },
211
224
  "devDependencies": {
212
225
  "@scure/bip39": "^1.3.0",
@@ -220,10 +233,12 @@
220
233
  "@types/react-dom": "19.1.0",
221
234
  "@types/use-sync-external-store": "^1.5.0",
222
235
  "@vitest/browser": "^3.2.4",
236
+ "libsql": "^0.5.13",
223
237
  "msw": "^2.10.3",
224
238
  "oauth2-mock-server": "^8.1.0",
225
239
  "playwright": "^1.50.1",
226
240
  "queueueue": "^4.1.2",
241
+ "react-error-boundary": "^6.0.0",
227
242
  "tsup": "8.5.0",
228
243
  "typescript": "5.6.2",
229
244
  "vitest": "3.2.4",
@@ -234,14 +249,14 @@
234
249
  "@op-engineering/op-sqlite": "*",
235
250
  "@react-native-community/netinfo": "*",
236
251
  "better-auth": "^1.3.2",
237
- "expo-image-manipulator": "*",
238
252
  "expo-file-system": "*",
253
+ "expo-image-manipulator": "*",
239
254
  "expo-secure-store": "*",
240
255
  "expo-sqlite": "*",
241
256
  "react": "*",
242
257
  "react-dom": "*",
243
258
  "react-native": "*",
244
- "react-native-fast-encoder": "^0.2.0",
259
+ "react-native-fast-encoder": "^0.3.1",
245
260
  "react-native-mmkv": "^3.3.0",
246
261
  "react-native-nitro-modules": "^0.26.4",
247
262
  "react-native-quick-crypto": "^1.0.0-beta.21",
@@ -305,7 +320,7 @@
305
320
  "check": "tsc --noEmit",
306
321
  "format-and-lint": "biome check .",
307
322
  "format-and-lint:fix": "biome check . --write",
308
- "dev": "tsup --watch --dts",
323
+ "dev": "tsup --watch",
309
324
  "bench": "vitest bench --run --root ../../ --project jazz-tools",
310
325
  "test": "vitest --run --root ../../ --project jazz-tools",
311
326
  "test:watch": "vitest --watch --root ../../ --project jazz-tools",
@@ -56,4 +56,6 @@ export {
56
56
  useCoValueSubscription,
57
57
  useAccountSubscription,
58
58
  useSubscriptionSelector,
59
+ useSuspenseAccount,
60
+ useSuspenseCoState,
59
61
  } from "jazz-tools/react-core";
@@ -1,19 +1,6 @@
1
1
  export { JazzReactProvider } from "./provider.js";
2
2
  export type { JazzProviderProps } from "./provider.js";
3
- export {
4
- useAccount,
5
- useCoState,
6
- useAcceptInvite,
7
- experimental_useInboxSender,
8
- useJazzContext,
9
- useAuthSecretStorage,
10
- useAgent,
11
- useLogOut,
12
- useSyncConnectionStatus,
13
- useCoValueSubscription,
14
- useAccountSubscription,
15
- useSubscriptionSelector,
16
- } from "./hooks.js";
3
+ export * from "./hooks.js";
17
4
 
18
5
  export {
19
6
  createCoValueSubscriptionContext,
@@ -2,6 +2,7 @@ import { useSyncExternalStoreWithSelector } from "use-sync-external-store/shim/w
2
2
  import React, {
3
3
  useCallback,
4
4
  useContext,
5
+ useMemo,
5
6
  useRef,
6
7
  useSyncExternalStore,
7
8
  } from "react";
@@ -22,18 +23,20 @@ import {
22
23
  Loaded,
23
24
  MaybeLoaded,
24
25
  NotLoaded,
26
+ RefsToResolve,
25
27
  ResolveQuery,
26
28
  ResolveQueryStrict,
27
29
  SchemaResolveQuery,
28
30
  SubscriptionScope,
29
- coValueClassFromCoValueClassOrSchema,
30
31
  importContentPieces,
32
+ captureStack,
31
33
  getUnloadedCoValueWithoutId,
32
34
  type BranchDefinition,
33
35
  } from "jazz-tools";
34
36
  import { JazzContext, JazzContextManagerContext } from "./provider.js";
35
37
  import { getCurrentAccountFromContextManager } from "./utils.js";
36
38
  import { CoValueSubscription } from "./types.js";
39
+ import { use } from "./use.js";
37
40
 
38
41
  export function useJazzContext<Acc extends Account>() {
39
42
  const value = useContext(JazzContext) as JazzContextType<Acc>;
@@ -104,6 +107,12 @@ export function useCoValueSubscription<
104
107
  const contextManager = useJazzContextManager();
105
108
  const agent = useAgent();
106
109
 
110
+ const callerStack = React.useRef<Error | undefined>(undefined);
111
+
112
+ if (!callerStack.current) {
113
+ callerStack.current = captureStack();
114
+ }
115
+
107
116
  const createSubscription = () => {
108
117
  if (!id) {
109
118
  return {
@@ -126,19 +135,22 @@ export function useCoValueSubscription<
126
135
  const resolve = getResolveQuery(Schema, options?.resolve);
127
136
 
128
137
  const node = contextManager.getCurrentValue()!.node;
129
- const subscription = new SubscriptionScope<any>(
138
+ const cache = contextManager.getSubscriptionScopeCache();
139
+ const subscription = cache.getOrCreate(
130
140
  node,
131
- resolve,
141
+ Schema,
132
142
  id,
133
- {
134
- ref: coValueClassFromCoValueClassOrSchema(Schema),
135
- optional: true,
136
- },
143
+ resolve,
137
144
  false,
138
145
  false,
139
146
  options?.unstable_branch,
140
147
  );
141
148
 
149
+ // Set callerStack on returned subscription after retrieval
150
+ if (callerStack.current) {
151
+ subscription.callerStack = callerStack.current;
152
+ }
153
+
142
154
  return {
143
155
  value: subscription,
144
156
  contextManager,
@@ -173,7 +185,6 @@ export function useCoValueSubscription<
173
185
  subscription.branchOwnerId !== branchOwnerId ||
174
186
  subscription.agent !== agent
175
187
  ) {
176
- subscription.value?.destroy();
177
188
  subscriptionRef.current = createSubscription();
178
189
  subscription = subscriptionRef.current;
179
190
  }
@@ -433,6 +444,79 @@ export function useCoState<
433
444
  return value;
434
445
  }
435
446
 
447
+ export function useSuspenseCoState<
448
+ S extends CoValueClassOrSchema,
449
+ // @ts-expect-error we can't statically enforce the schema's resolve query is a valid resolve query, but in practice it is
450
+ const R extends ResolveQuery<S> = SchemaResolveQuery<S>,
451
+ TSelectorReturn = Loaded<S, R>,
452
+ >(
453
+ /** The CoValue schema or class constructor */
454
+ Schema: S,
455
+ /** The ID of the CoValue to subscribe to */
456
+ id: string,
457
+ /** Optional configuration for the subscription */
458
+ options?: {
459
+ /** Resolve query to specify which nested CoValues to load */
460
+ resolve?: ResolveQueryStrict<S, R>;
461
+ /** Select which value to return */
462
+ select?: (value: Loaded<S, R>) => TSelectorReturn;
463
+ /** Equality function to determine if the selected value has changed, defaults to `Object.is` */
464
+ equalityFn?: (a: TSelectorReturn, b: TSelectorReturn) => boolean;
465
+ /**
466
+ * Create or load a branch for isolated editing.
467
+ *
468
+ * Branching lets you take a snapshot of the current state and start modifying it without affecting the canonical/shared version.
469
+ * It's a fork of your data graph: the same schema, but with diverging values.
470
+ *
471
+ * The checkout of the branch is applied on all the resolved values.
472
+ *
473
+ * @param name - A unique name for the branch. This identifies the branch
474
+ * and can be used to switch between different branches of the same CoValue.
475
+ * @param owner - The owner of the branch. Determines who can access and modify
476
+ * the branch. If not provided, the branch is owned by the current user.
477
+ *
478
+ * For more info see the [branching](https://jazz.tools/docs/react/using-covalues/version-control) documentation.
479
+ */
480
+ unstable_branch?: BranchDefinition;
481
+ preloaded?: ExportedCoValue<Loaded<S, R>>;
482
+ },
483
+ ): TSelectorReturn {
484
+ useImportCoValueContent(id, options?.preloaded);
485
+
486
+ const subscription = useCoValueSubscription(Schema, id, options);
487
+
488
+ if (!subscription) {
489
+ throw new Error("Subscription not found");
490
+ }
491
+
492
+ use(subscription.getPromise());
493
+
494
+ const getCurrentValue = () => {
495
+ const value = subscription.getCurrentValue();
496
+
497
+ if (!value.$isLoaded) {
498
+ throw new Error("CoValue must be loaded in a suspense context");
499
+ }
500
+
501
+ return value;
502
+ };
503
+
504
+ const value = useSyncExternalStoreWithSelector<Loaded<S, R>, TSelectorReturn>(
505
+ React.useCallback(
506
+ (callback) => {
507
+ return subscription.subscribe(callback);
508
+ },
509
+ [subscription],
510
+ ),
511
+ getCurrentValue,
512
+ getCurrentValue,
513
+ options?.select ?? ((value) => value as TSelectorReturn),
514
+ options?.equalityFn ?? Object.is,
515
+ );
516
+
517
+ return value;
518
+ }
519
+
436
520
  export function useSubscriptionSelector<
437
521
  S extends CoValueClassOrSchema,
438
522
  // @ts-expect-error we can't statically enforce the schema's resolve query is a valid resolve query, but in practice it is
@@ -481,6 +565,12 @@ export function useAccountSubscription<
481
565
  ) {
482
566
  const contextManager = useJazzContextManager();
483
567
 
568
+ // Capture stack trace at hook call time
569
+ const callerStack = React.useRef<Error | undefined>(undefined);
570
+ if (!callerStack.current) {
571
+ callerStack.current = captureStack();
572
+ }
573
+
484
574
  const createSubscription = () => {
485
575
  const agent = getCurrentAccountFromContextManager(contextManager);
486
576
 
@@ -495,19 +585,22 @@ export function useAccountSubscription<
495
585
  const resolve = getResolveQuery(Schema, options?.resolve);
496
586
 
497
587
  const node = contextManager.getCurrentValue()!.node;
498
- const subscription = new SubscriptionScope<any>(
588
+ const cache = contextManager.getSubscriptionScopeCache();
589
+ const subscription = cache.getOrCreate(
499
590
  node,
500
- resolve,
591
+ Schema,
501
592
  agent.$jazz.id,
502
- {
503
- ref: coValueClassFromCoValueClassOrSchema(Schema),
504
- optional: true,
505
- },
593
+ resolve,
506
594
  false,
507
595
  false,
508
596
  options?.unstable_branch,
509
597
  );
510
598
 
599
+ // Set callerStack on returned subscription after retrieval
600
+ if (callerStack.current) {
601
+ subscription.callerStack = callerStack.current;
602
+ }
603
+
511
604
  return {
512
605
  subscription,
513
606
  contextManager,
@@ -529,12 +622,12 @@ export function useAccountSubscription<
529
622
  subscription.branchName !== options?.unstable_branch?.name ||
530
623
  subscription.branchOwnerId !== options?.unstable_branch?.owner?.$jazz.id
531
624
  ) {
532
- subscription.subscription?.destroy();
625
+ // No need to manually destroy - cache handles cleanup via SubscriptionScope lifecycle
533
626
  setSubscription(createSubscription());
534
627
  }
535
628
 
536
629
  return contextManager.subscribe(() => {
537
- subscription.subscription?.destroy();
630
+ // No need to manually destroy - cache handles cleanup via SubscriptionScope lifecycle
538
631
  setSubscription(createSubscription());
539
632
  });
540
633
  }, [Schema, contextManager, branchName, branchOwnerId]);
@@ -689,6 +782,78 @@ export function useAccount<
689
782
  );
690
783
  }
691
784
 
785
+ export function useSuspenseAccount<
786
+ A extends AccountClass<Account> | AnyAccountSchema,
787
+ // @ts-expect-error we can't statically enforce the schema's resolve query is a valid resolve query, but in practice it is
788
+ const R extends ResolveQuery<A> = SchemaResolveQuery<A>,
789
+ TSelectorReturn = Loaded<A, R>,
790
+ >(
791
+ /** The account schema to use. Defaults to the base Account schema */
792
+ AccountSchema: A = Account as unknown as A,
793
+ /** Optional configuration for the subscription */
794
+ options?: {
795
+ /** Resolve query to specify which nested CoValues to load from the account */
796
+ resolve?: ResolveQueryStrict<A, R>;
797
+ /** Select which value to return from the account data */
798
+ select?: (account: Loaded<A, R>) => TSelectorReturn;
799
+ /** Equality function to determine if the selected value has changed, defaults to `Object.is` */
800
+ equalityFn?: (a: TSelectorReturn, b: TSelectorReturn) => boolean;
801
+ /**
802
+ * Create or load a branch for isolated editing.
803
+ *
804
+ * Branching lets you take a snapshot of the current state and start modifying it without affecting the canonical/shared version.
805
+ * It's a fork of your data graph: the same schema, but with diverging values.
806
+ *
807
+ * The checkout of the branch is applied on all the resolved values.
808
+ *
809
+ * @param name - A unique name for the branch. This identifies the branch
810
+ * and can be used to switch between different branches of the same CoValue.
811
+ * @param owner - The owner of the branch. Determines who can access and modify
812
+ * the branch. If not provided, the branch is owned by the current user.
813
+ *
814
+ * For more info see the [branching](https://jazz.tools/docs/react/using-covalues/version-control) documentation.
815
+ */
816
+ unstable_branch?: BranchDefinition;
817
+ },
818
+ ): TSelectorReturn {
819
+ const subscription = useAccountSubscription(AccountSchema, options);
820
+
821
+ if (!subscription) {
822
+ throw new Error(
823
+ "Subscription not found, are you using useSuspenseAccount in guest mode?",
824
+ );
825
+ }
826
+
827
+ use(subscription.getPromise());
828
+
829
+ const getCurrentValue = () => {
830
+ const value = subscription.getCurrentValue();
831
+
832
+ if (!value.$isLoaded) {
833
+ throw new Error("Account must be loaded in a suspense context");
834
+ }
835
+
836
+ return value;
837
+ };
838
+
839
+ return useSyncExternalStoreWithSelector<Loaded<A, R>, TSelectorReturn>(
840
+ React.useCallback(
841
+ (callback) => {
842
+ if (!subscription) {
843
+ return () => {};
844
+ }
845
+
846
+ return subscription.subscribe(callback);
847
+ },
848
+ [subscription],
849
+ ),
850
+ getCurrentValue,
851
+ getCurrentValue,
852
+ options?.select ?? ((value) => value as TSelectorReturn),
853
+ options?.equalityFn ?? Object.is,
854
+ );
855
+ }
856
+
692
857
  /**
693
858
  * Returns a function for logging out of the current account.
694
859
  */