jazz-tools 0.18.37 → 0.19.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.
Files changed (309) hide show
  1. package/.svelte-kit/__package__/jazz.class.svelte.d.ts +8 -8
  2. package/.svelte-kit/__package__/jazz.class.svelte.d.ts.map +1 -1
  3. package/.svelte-kit/__package__/jazz.class.svelte.js +39 -14
  4. package/.svelte-kit/__package__/media/image.svelte +6 -5
  5. package/.svelte-kit/__package__/media/image.svelte.d.ts.map +1 -1
  6. package/.svelte-kit/__package__/tests/AccountCoState.svelte.test-d.d.ts +2 -0
  7. package/.svelte-kit/__package__/tests/AccountCoState.svelte.test-d.d.ts.map +1 -0
  8. package/.svelte-kit/__package__/tests/AccountCoState.svelte.test-d.js +19 -0
  9. package/.svelte-kit/__package__/tests/CoState.svelte.test-d.d.ts +2 -0
  10. package/.svelte-kit/__package__/tests/CoState.svelte.test-d.d.ts.map +1 -0
  11. package/.svelte-kit/__package__/tests/CoState.svelte.test-d.js +16 -0
  12. package/.svelte-kit/__package__/tests/CoState.svelte.test.d.ts +2 -0
  13. package/.svelte-kit/__package__/tests/CoState.svelte.test.d.ts.map +1 -0
  14. package/.svelte-kit/__package__/tests/CoState.svelte.test.js +42 -0
  15. package/.svelte-kit/__package__/tests/TestCoStateWrapper.svelte +23 -0
  16. package/.svelte-kit/__package__/tests/TestCoStateWrapper.svelte.d.ts +12 -0
  17. package/.svelte-kit/__package__/tests/TestCoStateWrapper.svelte.d.ts.map +1 -0
  18. package/.turbo/turbo-build.log +53 -53
  19. package/CHANGELOG.md +33 -0
  20. package/dist/better-auth/database-adapter/index.js +14 -11
  21. package/dist/better-auth/database-adapter/index.js.map +1 -1
  22. package/dist/better-auth/database-adapter/repository/generic.d.ts +1 -1
  23. package/dist/better-auth/database-adapter/repository/generic.d.ts.map +1 -1
  24. package/dist/better-auth/database-adapter/repository/user.d.ts.map +1 -1
  25. package/dist/{chunk-OSQ7S47Q.js → chunk-P3YLNFN4.js} +504 -232
  26. package/dist/chunk-P3YLNFN4.js.map +1 -0
  27. package/dist/index.js +14 -6
  28. package/dist/index.js.map +1 -1
  29. package/dist/inspector/{custom-element-SUVJ7CPN.js → custom-element-QESCMFY7.js} +13 -3
  30. package/dist/inspector/{custom-element-SUVJ7CPN.js.map → custom-element-QESCMFY7.js.map} +1 -1
  31. package/dist/inspector/index.js +12 -2
  32. package/dist/inspector/index.js.map +1 -1
  33. package/dist/inspector/register-custom-element.js +1 -1
  34. package/dist/inspector/viewer/history-view.d.ts.map +1 -1
  35. package/dist/media/{chunk-K6GCHLQU.js → chunk-3LKBM3G3.js} +23 -15
  36. package/dist/media/chunk-3LKBM3G3.js.map +1 -0
  37. package/dist/media/create-image/browser.d.ts +2 -2
  38. package/dist/media/create-image/react-native.d.ts +2 -2
  39. package/dist/media/create-image/server.d.ts +2 -2
  40. package/dist/media/create-image-factory.d.ts +2 -2
  41. package/dist/media/index.browser.js +1 -1
  42. package/dist/media/index.js +1 -1
  43. package/dist/media/index.native.js +1 -1
  44. package/dist/media/index.server.js +1 -1
  45. package/dist/media/utils.d.ts.map +1 -1
  46. package/dist/react/hooks.d.ts +1 -1
  47. package/dist/react/hooks.d.ts.map +1 -1
  48. package/dist/react/index.d.ts +1 -1
  49. package/dist/react/index.d.ts.map +1 -1
  50. package/dist/react/index.js +31 -15
  51. package/dist/react/index.js.map +1 -1
  52. package/dist/react/media/image.d.ts.map +1 -1
  53. package/dist/react-core/hooks.d.ts +126 -224
  54. package/dist/react-core/hooks.d.ts.map +1 -1
  55. package/dist/react-core/index.js +65 -63
  56. package/dist/react-core/index.js.map +1 -1
  57. package/dist/react-core/subscription-provider.d.ts.map +1 -1
  58. package/dist/react-core/tests/createCoValueSubscriptionContext.test.d.ts +2 -0
  59. package/dist/react-core/tests/createCoValueSubscriptionContext.test.d.ts.map +1 -0
  60. package/dist/react-core/tests/useAccount.selector.test.d.ts +2 -0
  61. package/dist/react-core/tests/useAccount.selector.test.d.ts.map +1 -0
  62. package/dist/react-core/tests/useCoState.selector.test.d.ts +2 -0
  63. package/dist/react-core/tests/useCoState.selector.test.d.ts.map +1 -0
  64. package/dist/react-native-core/hooks.d.ts +1 -1
  65. package/dist/react-native-core/hooks.d.ts.map +1 -1
  66. package/dist/react-native-core/index.js +7 -5
  67. package/dist/react-native-core/index.js.map +1 -1
  68. package/dist/react-native-core/media/image.d.ts.map +1 -1
  69. package/dist/svelte/jazz.class.svelte.d.ts +8 -8
  70. package/dist/svelte/jazz.class.svelte.d.ts.map +1 -1
  71. package/dist/svelte/jazz.class.svelte.js +39 -14
  72. package/dist/svelte/media/image.svelte +6 -5
  73. package/dist/svelte/media/image.svelte.d.ts.map +1 -1
  74. package/dist/svelte/tests/AccountCoState.svelte.test-d.d.ts +2 -0
  75. package/dist/svelte/tests/AccountCoState.svelte.test-d.d.ts.map +1 -0
  76. package/dist/svelte/tests/AccountCoState.svelte.test-d.js +19 -0
  77. package/dist/svelte/tests/CoState.svelte.test-d.d.ts +2 -0
  78. package/dist/svelte/tests/CoState.svelte.test-d.d.ts.map +1 -0
  79. package/dist/svelte/tests/CoState.svelte.test-d.js +16 -0
  80. package/dist/svelte/tests/CoState.svelte.test.d.ts +2 -0
  81. package/dist/svelte/tests/CoState.svelte.test.d.ts.map +1 -0
  82. package/dist/svelte/tests/CoState.svelte.test.js +42 -0
  83. package/dist/svelte/tests/TestCoStateWrapper.svelte +23 -0
  84. package/dist/svelte/tests/TestCoStateWrapper.svelte.d.ts +12 -0
  85. package/dist/svelte/tests/TestCoStateWrapper.svelte.d.ts.map +1 -0
  86. package/dist/testing.js +3 -1
  87. package/dist/testing.js.map +1 -1
  88. package/dist/tools/coValues/CoValueBase.d.ts +4 -1
  89. package/dist/tools/coValues/CoValueBase.d.ts.map +1 -1
  90. package/dist/tools/coValues/account.d.ts +6 -6
  91. package/dist/tools/coValues/account.d.ts.map +1 -1
  92. package/dist/tools/coValues/coFeed.d.ts +5 -5
  93. package/dist/tools/coValues/coFeed.d.ts.map +1 -1
  94. package/dist/tools/coValues/coList.d.ts +9 -8
  95. package/dist/tools/coValues/coList.d.ts.map +1 -1
  96. package/dist/tools/coValues/coMap.d.ts +17 -17
  97. package/dist/tools/coValues/coMap.d.ts.map +1 -1
  98. package/dist/tools/coValues/coPlainText.d.ts +3 -3
  99. package/dist/tools/coValues/coPlainText.d.ts.map +1 -1
  100. package/dist/tools/coValues/coVector.d.ts +3 -3
  101. package/dist/tools/coValues/coVector.d.ts.map +1 -1
  102. package/dist/tools/coValues/deepLoading.d.ts +66 -36
  103. package/dist/tools/coValues/deepLoading.d.ts.map +1 -1
  104. package/dist/tools/coValues/extensions/imageDef.d.ts +1 -1
  105. package/dist/tools/coValues/extensions/imageDef.d.ts.map +1 -1
  106. package/dist/tools/coValues/group.d.ts +2 -2
  107. package/dist/tools/coValues/group.d.ts.map +1 -1
  108. package/dist/tools/coValues/inbox.d.ts.map +1 -1
  109. package/dist/tools/coValues/interfaces.d.ts +14 -6
  110. package/dist/tools/coValues/interfaces.d.ts.map +1 -1
  111. package/dist/tools/coValues/request.d.ts.map +1 -1
  112. package/dist/tools/coValues/schemaUnion.d.ts +2 -2
  113. package/dist/tools/coValues/schemaUnion.d.ts.map +1 -1
  114. package/dist/tools/exports.d.ts +3 -3
  115. package/dist/tools/exports.d.ts.map +1 -1
  116. package/dist/tools/implementation/refs.d.ts +3 -3
  117. package/dist/tools/implementation/refs.d.ts.map +1 -1
  118. package/dist/tools/implementation/schema.d.ts +2 -2
  119. package/dist/tools/implementation/schema.d.ts.map +1 -1
  120. package/dist/tools/implementation/schemaUtils.d.ts +8 -0
  121. package/dist/tools/implementation/schemaUtils.d.ts.map +1 -1
  122. package/dist/tools/implementation/zodSchema/runtimeConverters/coValueSchemaTransformation.d.ts.map +1 -1
  123. package/dist/tools/implementation/zodSchema/schemaTypes/AccountSchema.d.ts +33 -18
  124. package/dist/tools/implementation/zodSchema/schemaTypes/AccountSchema.d.ts.map +1 -1
  125. package/dist/tools/implementation/zodSchema/schemaTypes/CoDiscriminatedUnionSchema.d.ts +5 -4
  126. package/dist/tools/implementation/zodSchema/schemaTypes/CoDiscriminatedUnionSchema.d.ts.map +1 -1
  127. package/dist/tools/implementation/zodSchema/schemaTypes/CoFeedSchema.d.ts +23 -12
  128. package/dist/tools/implementation/zodSchema/schemaTypes/CoFeedSchema.d.ts.map +1 -1
  129. package/dist/tools/implementation/zodSchema/schemaTypes/CoListSchema.d.ts +29 -18
  130. package/dist/tools/implementation/zodSchema/schemaTypes/CoListSchema.d.ts.map +1 -1
  131. package/dist/tools/implementation/zodSchema/schemaTypes/CoMapSchema.d.ts +39 -22
  132. package/dist/tools/implementation/zodSchema/schemaTypes/CoMapSchema.d.ts.map +1 -1
  133. package/dist/tools/implementation/zodSchema/schemaTypes/CoOptionalSchema.d.ts +1 -0
  134. package/dist/tools/implementation/zodSchema/schemaTypes/CoOptionalSchema.d.ts.map +1 -1
  135. package/dist/tools/implementation/zodSchema/schemaTypes/CoRecordSchema.d.ts +30 -19
  136. package/dist/tools/implementation/zodSchema/schemaTypes/CoRecordSchema.d.ts.map +1 -1
  137. package/dist/tools/implementation/zodSchema/schemaTypes/CoValueSchema.d.ts +5 -0
  138. package/dist/tools/implementation/zodSchema/schemaTypes/CoValueSchema.d.ts.map +1 -1
  139. package/dist/tools/implementation/zodSchema/schemaTypes/CoVectorSchema.d.ts +6 -5
  140. package/dist/tools/implementation/zodSchema/schemaTypes/CoVectorSchema.d.ts.map +1 -1
  141. package/dist/tools/implementation/zodSchema/schemaTypes/FileStreamSchema.d.ts +3 -2
  142. package/dist/tools/implementation/zodSchema/schemaTypes/FileStreamSchema.d.ts.map +1 -1
  143. package/dist/tools/implementation/zodSchema/schemaTypes/GroupSchema.d.ts +3 -2
  144. package/dist/tools/implementation/zodSchema/schemaTypes/GroupSchema.d.ts.map +1 -1
  145. package/dist/tools/implementation/zodSchema/schemaTypes/PlainTextSchema.d.ts +3 -2
  146. package/dist/tools/implementation/zodSchema/schemaTypes/PlainTextSchema.d.ts.map +1 -1
  147. package/dist/tools/implementation/zodSchema/schemaTypes/RichTextSchema.d.ts +3 -2
  148. package/dist/tools/implementation/zodSchema/schemaTypes/RichTextSchema.d.ts.map +1 -1
  149. package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchema.d.ts +3 -0
  150. package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchema.d.ts.map +1 -1
  151. package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchemaCoValuesMaybeLoaded.d.ts +22 -0
  152. package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchemaCoValuesMaybeLoaded.d.ts.map +1 -0
  153. package/dist/tools/implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchema.d.ts +4 -0
  154. package/dist/tools/implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchema.d.ts.map +1 -1
  155. package/dist/tools/implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchemaCoValuesMaybeLoaded.d.ts +9 -0
  156. package/dist/tools/implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchemaCoValuesMaybeLoaded.d.ts.map +1 -0
  157. package/dist/tools/implementation/zodSchema/zodCo.d.ts.map +1 -1
  158. package/dist/tools/implementation/zodSchema/zodSchema.d.ts +7 -6
  159. package/dist/tools/implementation/zodSchema/zodSchema.d.ts.map +1 -1
  160. package/dist/tools/internal.d.ts +3 -3
  161. package/dist/tools/internal.d.ts.map +1 -1
  162. package/dist/tools/lib/utils.d.ts +14 -0
  163. package/dist/tools/lib/utils.d.ts.map +1 -0
  164. package/dist/tools/lib/utils.test.d.ts +2 -0
  165. package/dist/tools/lib/utils.test.d.ts.map +1 -0
  166. package/dist/tools/subscribe/CoValueCoreSubscription.d.ts +3 -2
  167. package/dist/tools/subscribe/CoValueCoreSubscription.d.ts.map +1 -1
  168. package/dist/tools/subscribe/JazzError.d.ts +4 -3
  169. package/dist/tools/subscribe/JazzError.d.ts.map +1 -1
  170. package/dist/tools/subscribe/SubscriptionScope.d.ts +6 -5
  171. package/dist/tools/subscribe/SubscriptionScope.d.ts.map +1 -1
  172. package/dist/tools/subscribe/index.d.ts.map +1 -1
  173. package/dist/tools/subscribe/types.d.ts +23 -3
  174. package/dist/tools/subscribe/types.d.ts.map +1 -1
  175. package/dist/tools/subscribe/utils.d.ts.map +1 -1
  176. package/dist/tools/testing.d.ts +3 -2
  177. package/dist/tools/testing.d.ts.map +1 -1
  178. package/dist/tools/tests/schema.resolved.test.d.ts +2 -0
  179. package/dist/tools/tests/schema.resolved.test.d.ts.map +1 -0
  180. package/dist/tools/tests/utils.d.ts +2 -1
  181. package/dist/tools/tests/utils.d.ts.map +1 -1
  182. package/package.json +4 -4
  183. package/src/better-auth/database-adapter/index.ts +2 -2
  184. package/src/better-auth/database-adapter/repository/account.ts +3 -3
  185. package/src/better-auth/database-adapter/repository/generic.ts +9 -6
  186. package/src/better-auth/database-adapter/repository/user.ts +6 -2
  187. package/src/better-auth/database-adapter/schema.ts +1 -1
  188. package/src/better-auth/database-adapter/tests/index.test.ts +3 -4
  189. package/src/inspector/tests/viewer/history-view.test.tsx +74 -10
  190. package/src/inspector/viewer/history-view.tsx +14 -5
  191. package/src/media/utils.test.ts +5 -0
  192. package/src/media/utils.ts +25 -16
  193. package/src/react/hooks.tsx +2 -2
  194. package/src/react/index.ts +2 -2
  195. package/src/react/media/image.tsx +10 -2
  196. package/src/react/tests/useAcceptInvite.test.ts +3 -1
  197. package/src/react-core/hooks.ts +226 -304
  198. package/src/react-core/subscription-provider.tsx +14 -7
  199. package/src/react-core/tests/createCoValueSubscriptionContext.test.tsx +233 -0
  200. package/src/react-core/tests/subscription.bench.tsx +32 -15
  201. package/src/react-core/tests/{useAccountWithSelector.test.ts → useAccount.selector.test.ts} +72 -24
  202. package/src/react-core/tests/useAccount.test.ts +92 -106
  203. package/src/react-core/tests/{useCoStateWithSelector.test.ts → useCoState.selector.test.ts} +23 -8
  204. package/src/react-core/tests/useCoState.test.ts +173 -49
  205. package/src/react-core/tests/useInboxSender.test.ts +3 -1
  206. package/src/react-core/tests/usePassPhraseAuth.test.ts +11 -82
  207. package/src/react-core/tests/useSubscriptionSelector.test.ts +48 -14
  208. package/src/react-native-core/hooks.tsx +2 -2
  209. package/src/react-native-core/media/image.tsx +3 -1
  210. package/src/svelte/jazz.class.svelte.ts +103 -27
  211. package/src/svelte/media/image.svelte +6 -5
  212. package/src/svelte/tests/AccountCoState.svelte.test-d.ts +23 -0
  213. package/src/svelte/tests/CoState.svelte.test-d.ts +20 -0
  214. package/src/svelte/tests/CoState.svelte.test.ts +57 -0
  215. package/src/svelte/tests/TestCoStateWrapper.svelte +23 -0
  216. package/src/tools/coValues/CoValueBase.ts +12 -0
  217. package/src/tools/coValues/account.ts +17 -12
  218. package/src/tools/coValues/coFeed.ts +38 -15
  219. package/src/tools/coValues/coList.ts +16 -11
  220. package/src/tools/coValues/coMap.ts +15 -14
  221. package/src/tools/coValues/coPlainText.ts +6 -3
  222. package/src/tools/coValues/coVector.ts +6 -5
  223. package/src/tools/coValues/deepLoading.ts +98 -51
  224. package/src/tools/coValues/group.ts +3 -2
  225. package/src/tools/coValues/inbox.ts +11 -10
  226. package/src/tools/coValues/interfaces.ts +49 -27
  227. package/src/tools/coValues/request.ts +8 -6
  228. package/src/tools/coValues/schemaUnion.ts +2 -1
  229. package/src/tools/exports.ts +11 -1
  230. package/src/tools/implementation/refs.ts +19 -13
  231. package/src/tools/implementation/schema.ts +5 -4
  232. package/src/tools/implementation/schemaUtils.ts +15 -0
  233. package/src/tools/implementation/zodSchema/runtimeConverters/coValueSchemaTransformation.ts +4 -4
  234. package/src/tools/implementation/zodSchema/schemaTypes/AccountSchema.ts +131 -95
  235. package/src/tools/implementation/zodSchema/schemaTypes/CoDiscriminatedUnionSchema.ts +19 -9
  236. package/src/tools/implementation/zodSchema/schemaTypes/CoFeedSchema.ts +73 -22
  237. package/src/tools/implementation/zodSchema/schemaTypes/CoListSchema.ts +86 -28
  238. package/src/tools/implementation/zodSchema/schemaTypes/CoMapSchema.ts +204 -148
  239. package/src/tools/implementation/zodSchema/schemaTypes/CoOptionalSchema.ts +1 -0
  240. package/src/tools/implementation/zodSchema/schemaTypes/CoRecordSchema.ts +71 -27
  241. package/src/tools/implementation/zodSchema/schemaTypes/CoValueSchema.ts +7 -0
  242. package/src/tools/implementation/zodSchema/schemaTypes/CoVectorSchema.ts +8 -6
  243. package/src/tools/implementation/zodSchema/schemaTypes/FileStreamSchema.ts +4 -1
  244. package/src/tools/implementation/zodSchema/schemaTypes/GroupSchema.ts +4 -1
  245. package/src/tools/implementation/zodSchema/schemaTypes/PlainTextSchema.ts +4 -1
  246. package/src/tools/implementation/zodSchema/schemaTypes/RichTextSchema.ts +4 -1
  247. package/src/tools/implementation/zodSchema/typeConverters/InstanceOfSchema.ts +3 -0
  248. package/src/tools/implementation/zodSchema/typeConverters/{InstanceOfSchemaCoValuesNullable.ts → InstanceOfSchemaCoValuesMaybeLoaded.ts} +47 -39
  249. package/src/tools/implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchema.ts +4 -0
  250. package/src/tools/implementation/zodSchema/typeConverters/{InstanceOrPrimitiveOfSchemaCoValuesNullable.ts → InstanceOrPrimitiveOfSchemaCoValuesMaybeLoaded.ts} +7 -3
  251. package/src/tools/implementation/zodSchema/zodSchema.ts +15 -7
  252. package/src/tools/internal.ts +3 -3
  253. package/src/tools/lib/utils.test.ts +56 -0
  254. package/src/tools/lib/utils.ts +32 -0
  255. package/src/tools/subscribe/CoValueCoreSubscription.ts +13 -8
  256. package/src/tools/subscribe/JazzError.ts +8 -2
  257. package/src/tools/subscribe/SubscriptionScope.ts +55 -44
  258. package/src/tools/subscribe/index.ts +12 -4
  259. package/src/tools/subscribe/types.ts +36 -2
  260. package/src/tools/subscribe/utils.ts +2 -1
  261. package/src/tools/testing.ts +5 -0
  262. package/src/tools/tests/CoValueCoreSubscription.test.ts +10 -4
  263. package/src/tools/tests/ContextManager.test.ts +12 -5
  264. package/src/tools/tests/account.test.ts +22 -12
  265. package/src/tools/tests/coDiscriminatedUnion.test.ts +8 -4
  266. package/src/tools/tests/coFeed.branch.test.ts +48 -32
  267. package/src/tools/tests/coFeed.test-d.ts +17 -10
  268. package/src/tools/tests/coFeed.test.ts +52 -30
  269. package/src/tools/tests/coList.branch.test.ts +21 -21
  270. package/src/tools/tests/coList.test-d.ts +39 -23
  271. package/src/tools/tests/coList.test.ts +51 -25
  272. package/src/tools/tests/coList.unique.test.ts +34 -29
  273. package/src/tools/tests/coMap.branch.test.ts +20 -21
  274. package/src/tools/tests/coMap.record.test-d.ts +28 -26
  275. package/src/tools/tests/coMap.record.test.ts +30 -20
  276. package/src/tools/tests/coMap.test-d.ts +31 -29
  277. package/src/tools/tests/coMap.test.ts +67 -40
  278. package/src/tools/tests/coMap.unique.test.ts +25 -24
  279. package/src/tools/tests/coVector.test.ts +29 -15
  280. package/src/tools/tests/createContext.test.ts +5 -3
  281. package/src/tools/tests/deepLoading.test.ts +314 -117
  282. package/src/tools/tests/exportImport.test.ts +16 -15
  283. package/src/tools/tests/groupsAndAccounts.test.ts +39 -16
  284. package/src/tools/tests/inbox.test.ts +3 -1
  285. package/src/tools/tests/load.test.ts +29 -23
  286. package/src/tools/tests/patterns/quest.test.ts +3 -2
  287. package/src/tools/tests/patterns/requestToJoin.test.ts +17 -17
  288. package/src/tools/tests/request.test.ts +12 -2
  289. package/src/tools/tests/schema.resolved.test.ts +723 -0
  290. package/src/tools/tests/schemaUnion.test.ts +7 -3
  291. package/src/tools/tests/subscribe.test.ts +39 -21
  292. package/src/tools/tests/testing.test.ts +3 -2
  293. package/src/tools/tests/utils.ts +15 -2
  294. package/dist/chunk-OSQ7S47Q.js.map +0 -1
  295. package/dist/media/chunk-K6GCHLQU.js.map +0 -1
  296. package/dist/react-core/tests/useAccountWithSelector.test.d.ts +0 -2
  297. package/dist/react-core/tests/useAccountWithSelector.test.d.ts.map +0 -1
  298. package/dist/react-core/tests/useCoStateWithSelector.test.d.ts +0 -2
  299. package/dist/react-core/tests/useCoStateWithSelector.test.d.ts.map +0 -1
  300. package/dist/tools/implementation/errors.d.ts +0 -2
  301. package/dist/tools/implementation/errors.d.ts.map +0 -1
  302. package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchemaCoValuesNullable.d.ts +0 -19
  303. package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchemaCoValuesNullable.d.ts.map +0 -1
  304. package/dist/tools/implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchemaCoValuesNullable.d.ts +0 -5
  305. package/dist/tools/implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchemaCoValuesNullable.d.ts.map +0 -1
  306. package/dist/tools/lib/id.d.ts +0 -2
  307. package/dist/tools/lib/id.d.ts.map +0 -1
  308. package/src/tools/implementation/errors.ts +0 -1
  309. package/src/tools/lib/id.ts +0 -3
@@ -27,6 +27,7 @@ import {
27
27
  Group,
28
28
  ID,
29
29
  InstanceOrPrimitiveOfSchema,
30
+ MaybeLoaded,
30
31
  Profile,
31
32
  Ref,
32
33
  type RefEncoded,
@@ -53,6 +54,8 @@ import {
53
54
  parseSubscribeRestArgs,
54
55
  subscribeToCoValueWithoutMe,
55
56
  subscribeToExistingCoValue,
57
+ InstanceOfSchemaCoValuesMaybeLoaded,
58
+ LoadedAndRequired,
56
59
  } from "../internal.js";
57
60
 
58
61
  export type AccountCreationProps = {
@@ -84,8 +87,8 @@ export class Account extends CoValueBase implements CoValue {
84
87
  } satisfies RefEncoded<CoMap>,
85
88
  };
86
89
 
87
- declare readonly profile: Profile | null;
88
- declare readonly root: CoMap | null;
90
+ declare readonly profile: MaybeLoaded<Profile>;
91
+ declare readonly root: MaybeLoaded<CoMap>;
89
92
 
90
93
  constructor(options: { fromRaw: RawAccount }) {
91
94
  super();
@@ -128,7 +131,9 @@ export class Account extends CoValueBase implements CoValue {
128
131
  valueID: string,
129
132
  inviteSecret: InviteSecret,
130
133
  coValueClass?: S,
131
- ): Promise<Resolved<InstanceOrPrimitiveOfSchema<S>, true> | null> {
134
+ ): Promise<
135
+ MaybeLoaded<Resolved<InstanceOfSchemaCoValuesMaybeLoaded<S>, true>>
136
+ > {
132
137
  if (!this.$jazz.isLocalNodeOwner) {
133
138
  throw new Error("Only a controlled account can accept invites");
134
139
  }
@@ -144,7 +149,7 @@ export class Account extends CoValueBase implements CoValue {
144
149
  {
145
150
  loadAs: this,
146
151
  },
147
- ) as Resolved<InstanceOrPrimitiveOfSchema<S>, true> | null;
152
+ ) as Resolved<InstanceOfSchemaCoValuesMaybeLoaded<S>, true>;
148
153
  }
149
154
 
150
155
  getRoleOf(member: Everyone | ID<Account> | "me"): "admin" | undefined {
@@ -351,7 +356,7 @@ export class Account extends CoValueBase implements CoValue {
351
356
  resolve?: RefsToResolveStrict<A, R>;
352
357
  loadAs?: Account | AnonymousJazzAgent;
353
358
  },
354
- ): Promise<Resolved<A, R> | null> {
359
+ ): Promise<MaybeLoaded<Resolved<A, R>>> {
355
360
  return loadCoValueWithoutMe(this, id, options);
356
361
  }
357
362
 
@@ -419,7 +424,7 @@ class AccountJazzApi<A extends Account> extends CoValueJazzApi<A> {
419
424
  */
420
425
  set<K extends "root" | "profile">(
421
426
  key: K,
422
- value: CoFieldInit<NonNullable<A[K]>>,
427
+ value: CoFieldInit<LoadedAndRequired<A[K]>>,
423
428
  ) {
424
429
  if (value) {
425
430
  let refId = (value as unknown as CoValue).$jazz?.id as
@@ -470,10 +475,10 @@ class AccountJazzApi<A extends Account> extends CoValueJazzApi<A> {
470
475
  root: RefIfCoValue<CoMap> | undefined;
471
476
  } {
472
477
  const profileID = this.raw.get("profile") as unknown as
473
- | ID<NonNullable<(typeof this.account)["profile"]>>
478
+ | ID<LoadedAndRequired<(typeof this.account)["profile"]>>
474
479
  | undefined;
475
480
  const rootID = this.raw.get("root") as unknown as
476
- | ID<NonNullable<(typeof this.account)["root"]>>
481
+ | ID<LoadedAndRequired<(typeof this.account)["root"]>>
477
482
  | undefined;
478
483
 
479
484
  return {
@@ -482,20 +487,20 @@ class AccountJazzApi<A extends Account> extends CoValueJazzApi<A> {
482
487
  profileID,
483
488
  this.loadedAs,
484
489
  this.schema.profile as RefEncoded<
485
- NonNullable<(typeof this.account)["profile"]> & CoValue
490
+ LoadedAndRequired<(typeof this.account)["profile"]> & CoValue
486
491
  >,
487
492
  this.account,
488
- ) as unknown as RefIfCoValue<(typeof this.account)["profile"]>)
493
+ ) as unknown as RefIfCoValue<Profile> | undefined)
489
494
  : undefined,
490
495
  root: rootID
491
496
  ? (new Ref(
492
497
  rootID,
493
498
  this.loadedAs,
494
499
  this.schema.root as RefEncoded<
495
- NonNullable<(typeof this.account)["root"]> & CoValue
500
+ LoadedAndRequired<(typeof this.account)["root"]> & CoValue
496
501
  >,
497
502
  this.account,
498
- ) as unknown as RefIfCoValue<(typeof this.account)["root"]>)
503
+ ) as unknown as RefIfCoValue<CoMap> | undefined)
499
504
  : undefined,
500
505
  };
501
506
  }
@@ -15,9 +15,12 @@ import {
15
15
  CoFieldInit,
16
16
  CoValue,
17
17
  CoValueClass,
18
+ CoValueLoadingState,
18
19
  getCoValueOwner,
19
20
  Group,
20
21
  ID,
22
+ MaybeLoaded,
23
+ LoadedAndRequired,
21
24
  unstable_mergeBranch,
22
25
  RefsToResolve,
23
26
  RefsToResolveStrict,
@@ -60,8 +63,12 @@ export type CoFeedEntry<Item> = SingleCoFeedEntry<Item> & {
60
63
  export type SingleCoStreamEntry<Item> = SingleCoFeedEntry<Item>;
61
64
 
62
65
  export type SingleCoFeedEntry<Item> = {
63
- value: NonNullable<Item> extends CoValue ? NonNullable<Item> | null : Item;
64
- ref: NonNullable<Item> extends CoValue ? Ref<NonNullable<Item>> : never;
66
+ value: LoadedAndRequired<Item> extends CoValue
67
+ ? MaybeLoaded<LoadedAndRequired<Item>>
68
+ : Item;
69
+ ref: LoadedAndRequired<Item> extends CoValue
70
+ ? Ref<LoadedAndRequired<Item>>
71
+ : never;
65
72
  by: Account | null;
66
73
  madeAt: Date;
67
74
  tx: CojsonInternalTypes.TransactionID;
@@ -290,7 +297,7 @@ export class CoFeed<out Item = any> extends CoValueBase implements CoValue {
290
297
  resolve?: RefsToResolveStrict<F, R>;
291
298
  loadAs?: Account | AnonymousJazzAgent;
292
299
  },
293
- ): Promise<Resolved<F, R> | null> {
300
+ ): Promise<MaybeLoaded<Resolved<F, R>>> {
294
301
  return loadCoValueWithoutMe(this, id, options ?? {});
295
302
  }
296
303
 
@@ -466,12 +473,12 @@ function entryFromRawEntry<Item>(
466
473
  itemField: Schema,
467
474
  ): Omit<CoFeedEntry<Item>, "all"> {
468
475
  return {
469
- get value(): NonNullable<Item> extends CoValue
470
- ? (CoValue & Item) | null
476
+ get value(): LoadedAndRequired<Item> extends CoValue
477
+ ? MaybeLoaded<CoValue & Item>
471
478
  : Item {
472
479
  if (itemField === "json") {
473
- return rawEntry.value as NonNullable<Item> extends CoValue
474
- ? (CoValue & Item) | null
480
+ return rawEntry.value as LoadedAndRequired<Item> extends CoValue
481
+ ? MaybeLoaded<CoValue & Item>
475
482
  : Item;
476
483
  } else if ("encoded" in itemField) {
477
484
  return itemField.encoded.decode(rawEntry.value);
@@ -480,13 +487,15 @@ function entryFromRawEntry<Item>(
480
487
  accessFrom,
481
488
  rawEntry.value as string,
482
489
  itemField,
483
- ) as NonNullable<Item> extends CoValue ? (CoValue & Item) | null : Item;
490
+ ) as LoadedAndRequired<Item> extends CoValue
491
+ ? MaybeLoaded<CoValue & Item>
492
+ : Item;
484
493
  } else {
485
494
  throw new Error("Invalid item field schema");
486
495
  }
487
496
  },
488
- get ref(): NonNullable<Item> extends CoValue
489
- ? Ref<NonNullable<Item>>
497
+ get ref(): LoadedAndRequired<Item> extends CoValue
498
+ ? Ref<LoadedAndRequired<Item>>
490
499
  : never {
491
500
  if (itemField !== "json" && isRefEncoded(itemField)) {
492
501
  const rawId = rawEntry.value;
@@ -495,7 +504,9 @@ function entryFromRawEntry<Item>(
495
504
  loadedAs,
496
505
  itemField,
497
506
  accessFrom,
498
- ) as NonNullable<Item> extends CoValue ? Ref<NonNullable<Item>> : never;
507
+ ) as LoadedAndRequired<Item> extends CoValue
508
+ ? Ref<LoadedAndRequired<Item>>
509
+ : never;
499
510
  } else {
500
511
  return undefined as never;
501
512
  }
@@ -787,7 +798,11 @@ export class FileStream extends CoValueBase implements CoValue {
787
798
  ): Promise<Blob | undefined> {
788
799
  let stream = await this.load(id, options);
789
800
 
790
- return stream?.toBlob({
801
+ if (!stream.$isLoaded) {
802
+ return undefined;
803
+ }
804
+
805
+ return stream.toBlob({
791
806
  allowUnfinished: options?.allowUnfinished,
792
807
  });
793
808
  }
@@ -802,7 +817,11 @@ export class FileStream extends CoValueBase implements CoValue {
802
817
  ): Promise<string | undefined> {
803
818
  const stream = await this.load(id, options);
804
819
 
805
- return stream?.asBase64(options);
820
+ if (!stream.$isLoaded) {
821
+ return undefined;
822
+ }
823
+
824
+ return stream.asBase64(options);
806
825
  }
807
826
 
808
827
  asBase64(options?: {
@@ -961,14 +980,18 @@ export class FileStream extends CoValueBase implements CoValue {
961
980
  loadAs?: Account | AnonymousJazzAgent;
962
981
  allowUnfinished?: boolean;
963
982
  },
964
- ): Promise<FileStream | null> {
983
+ ): Promise<MaybeLoaded<FileStream>> {
965
984
  const stream = await loadCoValueWithoutMe(this, id, options);
966
985
 
967
986
  /**
968
987
  * If the user hasn't requested an incomplete blob and the
969
988
  * stream isn't complete wait for the stream download before progressing
970
989
  */
971
- if (!options?.allowUnfinished && !stream?.isBinaryStreamEnded()) {
990
+ if (
991
+ !options?.allowUnfinished &&
992
+ stream.$isLoaded &&
993
+ !stream.isBinaryStreamEnded()
994
+ ) {
972
995
  return new Promise<FileStream>((resolve) => {
973
996
  subscribeToCoValueWithoutMe(
974
997
  this,
@@ -10,6 +10,8 @@ import {
10
10
  getCoValueOwner,
11
11
  Group,
12
12
  ID,
13
+ AsLoaded,
14
+ MaybeLoaded,
13
15
  unstable_mergeBranch,
14
16
  RefEncoded,
15
17
  RefsToResolve,
@@ -23,6 +25,7 @@ import {
23
25
  BranchDefinition,
24
26
  getIdFromHeader,
25
27
  internalLoadUnique,
28
+ CoValueLoadingState,
26
29
  } from "../internal.js";
27
30
  import {
28
31
  AnonymousJazzAgent,
@@ -71,6 +74,7 @@ export class CoList<out Item = any>
71
74
  implements ReadonlyArray<Item>, CoValue
72
75
  {
73
76
  declare $jazz: CoListJazzApi<this>;
77
+ declare $isLoaded: true;
74
78
 
75
79
  /**
76
80
  * Declare a `CoList` by subclassing `CoList.Of(...)` and passing the item schema using `co`.
@@ -128,6 +132,7 @@ export class CoList<out Item = any>
128
132
  value: new CoListJazzApi(proxy, () => options.fromRaw),
129
133
  enumerable: false,
130
134
  },
135
+ $isLoaded: { value: true, enumerable: false },
131
136
  });
132
137
  }
133
138
 
@@ -175,6 +180,7 @@ export class CoList<out Item = any>
175
180
  value: new CoListJazzApi(instance, () => raw),
176
181
  enumerable: false,
177
182
  },
183
+ $isLoaded: { value: true, enumerable: false },
178
184
  });
179
185
 
180
186
  const raw = owner.$jazz.raw.createList(
@@ -262,7 +268,7 @@ export class CoList<out Item = any>
262
268
  resolve?: RefsToResolveStrict<L, R>;
263
269
  loadAs?: Account | AnonymousJazzAgent;
264
270
  },
265
- ): Promise<Resolved<L, R> | null> {
271
+ ): Promise<MaybeLoaded<Resolved<L, R>>> {
266
272
  return loadCoValueWithoutMe(this, id, options);
267
273
  }
268
274
 
@@ -346,7 +352,7 @@ export class CoList<out Item = any>
346
352
  /**
347
353
  * Given some data, updates an existing CoList or initialises a new one if none exists.
348
354
  *
349
- * Note: This method respects resolve options, and thus can return `null` if the references cannot be resolved.
355
+ * Note: This method respects resolve options, and thus can return a not-loaded value if the references cannot be resolved.
350
356
  *
351
357
  * @example
352
358
  * ```ts
@@ -374,7 +380,7 @@ export class CoList<out Item = any>
374
380
  owner: Account | Group;
375
381
  resolve?: RefsToResolveStrict<L, R>;
376
382
  },
377
- ): Promise<Resolved<L, R> | null> {
383
+ ): Promise<MaybeLoaded<Resolved<L, R>>> {
378
384
  const header = CoList._getUniqueHeader(
379
385
  options.unique,
380
386
  options.owner.$jazz.id,
@@ -401,7 +407,7 @@ export class CoList<out Item = any>
401
407
  * @param unique The unique identifier of the CoList to load.
402
408
  * @param ownerID The ID of the owner of the CoList.
403
409
  * @param options Additional options for loading the CoList.
404
- * @returns The loaded CoList, or null if unavailable.
410
+ * @returns The loaded CoList, or an not-loaded value if unavailable.
405
411
  */
406
412
  static async loadUnique<
407
413
  L extends CoList,
@@ -414,14 +420,13 @@ export class CoList<out Item = any>
414
420
  resolve?: RefsToResolveStrict<L, R>;
415
421
  loadAs?: Account | AnonymousJazzAgent;
416
422
  },
417
- ): Promise<Resolved<L, R> | null> {
423
+ ): Promise<MaybeLoaded<Resolved<L, R>>> {
418
424
  const header = CoList._getUniqueHeader(unique, ownerID);
419
425
 
420
426
  const owner = await Group.load(ownerID, {
421
427
  loadAs: options?.loadAs,
422
428
  });
423
-
424
- if (!owner) return owner;
429
+ if (!owner.$isLoaded) return owner;
425
430
 
426
431
  return internalLoadUnique(this, {
427
432
  header,
@@ -839,14 +844,14 @@ export class CoListJazzApi<L extends CoList> extends CoValueJazzApi<L> {
839
844
  * @category Content
840
845
  **/
841
846
  get refs(): {
842
- [idx: number]: Exclude<CoListItem<L>, null> extends CoValue
843
- ? Ref<Exclude<CoListItem<L>, null>>
847
+ [idx: number]: AsLoaded<CoListItem<L>> extends CoValue
848
+ ? Ref<AsLoaded<CoListItem<L>>>
844
849
  : never;
845
850
  } & {
846
851
  length: number;
847
852
  [Symbol.iterator](): IterableIterator<
848
- Exclude<CoListItem<L>, null> extends CoValue
849
- ? Ref<Exclude<CoListItem<L>, null>>
853
+ AsLoaded<CoListItem<L>> extends CoValue
854
+ ? Ref<AsLoaded<CoListItem<L>>>
850
855
  : never
851
856
  >;
852
857
  } {
@@ -10,12 +10,15 @@ import {
10
10
  } from "cojson";
11
11
  import {
12
12
  AnonymousJazzAgent,
13
+ AsLoaded,
14
+ LoadedAndRequired,
13
15
  CoFieldInit,
14
16
  CoValue,
15
17
  CoValueClass,
16
18
  getCoValueOwner,
17
19
  Group,
18
20
  ID,
21
+ MaybeLoaded,
19
22
  PartialOnUndefined,
20
23
  RefEncoded,
21
24
  RefIfCoValue,
@@ -30,13 +33,11 @@ import {
30
33
  BranchDefinition,
31
34
  getIdFromHeader,
32
35
  internalLoadUnique,
33
- } from "../internal.js";
34
- import {
35
36
  Account,
36
37
  CoValueBase,
37
38
  CoValueJazzApi,
39
+ CoValueLoadingState,
38
40
  ItemsSym,
39
- NotNull,
40
41
  Ref,
41
42
  RegisteredSchemas,
42
43
  SchemaInit,
@@ -55,7 +56,7 @@ import {
55
56
  subscribeToExistingCoValue,
56
57
  } from "../internal.js";
57
58
 
58
- type CoMapEdit<V> = {
59
+ export type CoMapEdit<V> = {
59
60
  value?: V;
60
61
  ref?: RefIfCoValue<V>;
61
62
  by: Account | null;
@@ -63,9 +64,9 @@ type CoMapEdit<V> = {
63
64
  key?: string;
64
65
  };
65
66
 
66
- type LastAndAllCoMapEdits<V> = CoMapEdit<V> & { all: CoMapEdit<V>[] };
67
+ export type LastAndAllCoMapEdits<V> = CoMapEdit<V> & { all: CoMapEdit<V>[] };
67
68
 
68
- type CoMapEdits<M extends CoMap> = {
69
+ export type CoMapEdits<M extends CoMap> = {
69
70
  [Key in CoKeys<M>]?: LastAndAllCoMapEdits<M[Key]>;
70
71
  };
71
72
 
@@ -376,7 +377,7 @@ export class CoMap extends CoValueBase implements CoValue {
376
377
  loadAs?: Account | AnonymousJazzAgent;
377
378
  skipRetry?: boolean;
378
379
  },
379
- ): Promise<Resolved<M, R> | null> {
380
+ ): Promise<MaybeLoaded<Resolved<M, R>>> {
380
381
  return loadCoValueWithoutMe(this, id, options);
381
382
  }
382
383
 
@@ -460,7 +461,7 @@ export class CoMap extends CoValueBase implements CoValue {
460
461
  /**
461
462
  * Given some data, updates an existing CoMap or initialises a new one if none exists.
462
463
  *
463
- * Note: This method respects resolve options, and thus can return `null` if the references cannot be resolved.
464
+ * Note: This method respects resolve options, and thus can return a not-loaded value if the references cannot be resolved.
464
465
  *
465
466
  * @example
466
467
  * ```ts
@@ -493,7 +494,7 @@ export class CoMap extends CoValueBase implements CoValue {
493
494
  owner: Account | Group;
494
495
  resolve?: RefsToResolveStrict<M, R>;
495
496
  },
496
- ): Promise<Resolved<M, R> | null> {
497
+ ): Promise<MaybeLoaded<Resolved<M, R>>> {
497
498
  const header = CoMap._getUniqueHeader(
498
499
  options.unique,
499
500
  options.owner.$jazz.id,
@@ -520,7 +521,7 @@ export class CoMap extends CoValueBase implements CoValue {
520
521
  * @param unique The unique identifier of the CoMap to load.
521
522
  * @param ownerID The ID of the owner of the CoMap.
522
523
  * @param options Additional options for loading the CoMap.
523
- * @returns The loaded CoMap, or null if unavailable.
524
+ * @returns The loaded CoMap, or an not-loaded value if unavailable.
524
525
  *
525
526
  * @deprecated Use `co.map(...).loadUnique` instead.
526
527
  */
@@ -535,14 +536,14 @@ export class CoMap extends CoValueBase implements CoValue {
535
536
  resolve?: RefsToResolveStrict<M, R>;
536
537
  loadAs?: Account | AnonymousJazzAgent;
537
538
  },
538
- ): Promise<Resolved<M, R> | null> {
539
+ ): Promise<MaybeLoaded<Resolved<M, R>>> {
539
540
  const header = CoMap._getUniqueHeader(unique, ownerID);
540
541
 
541
542
  const owner = await Group.load(ownerID, {
542
543
  loadAs: options?.loadAs,
543
544
  });
544
545
 
545
- if (!owner) return owner;
546
+ if (!owner.$isLoaded) return owner;
546
547
 
547
548
  return internalLoadUnique(this, {
548
549
  header,
@@ -757,12 +758,12 @@ class CoMapJazzApi<M extends CoMap> extends CoValueJazzApi<M> {
757
758
  **/
758
759
  get refs(): Simplify<
759
760
  {
760
- [Key in CoKeys<M> as NonNullable<M[Key]> extends CoValue
761
+ [Key in CoKeys<M> as LoadedAndRequired<M[Key]> extends CoValue
761
762
  ? Key
762
763
  : never]?: RefIfCoValue<M[Key]>;
763
764
  } & {
764
765
  // Non-loaded CoValue refs (i.e. refs with type CoValue | null) are still required refs
765
- [Key in CoKeys<M> as NotNull<M[Key]> extends CoValue
766
+ [Key in CoKeys<M> as AsLoaded<M[Key]> extends CoValue
766
767
  ? Key
767
768
  : never]: RefIfCoValue<M[Key]>;
768
769
  }
@@ -5,15 +5,15 @@ import {
5
5
  CoValue,
6
6
  CoValueClass,
7
7
  CoValueJazzApi,
8
+ CoValueLoadingState,
8
9
  ID,
10
+ MaybeLoaded,
9
11
  Resolved,
10
12
  SubscribeListenerOptions,
11
13
  SubscribeRestArgs,
12
14
  TypeSym,
13
15
  unstable_mergeBranch,
14
16
  parseCoValueCreateOptions,
15
- } from "../internal.js";
16
- import {
17
17
  inspect,
18
18
  loadCoValueWithoutMe,
19
19
  parseSubscribeRestArgs,
@@ -29,6 +29,7 @@ export class CoPlainText extends String implements CoValue {
29
29
  declare [TypeSym]: "CoPlainText";
30
30
 
31
31
  declare $jazz: CoTextJazzApi<this>;
32
+ declare $isLoaded: true;
32
33
 
33
34
  /** @internal */
34
35
  constructor(
@@ -51,6 +52,7 @@ export class CoPlainText extends String implements CoValue {
51
52
  value: new CoTextJazzApi(this, raw),
52
53
  enumerable: false,
53
54
  },
55
+ $isLoaded: { value: true, enumerable: false },
54
56
  });
55
57
  return;
56
58
  }
@@ -64,6 +66,7 @@ export class CoPlainText extends String implements CoValue {
64
66
  value: new CoTextJazzApi(this, raw),
65
67
  enumerable: false,
66
68
  },
69
+ $isLoaded: { value: true, enumerable: false },
67
70
  });
68
71
  return;
69
72
  }
@@ -161,7 +164,7 @@ export class CoPlainText extends String implements CoValue {
161
164
  this: CoValueClass<T>,
162
165
  id: ID<T>,
163
166
  options?: { loadAs?: Account | AnonymousJazzAgent },
164
- ): Promise<T | null> {
167
+ ): Promise<MaybeLoaded<T>> {
165
168
  return loadCoValueWithoutMe(this, id, options);
166
169
  }
167
170
 
@@ -11,8 +11,7 @@ import {
11
11
  SubscribeListenerOptions,
12
12
  SubscribeRestArgs,
13
13
  TypeSym,
14
- } from "../internal.js";
15
- import {
14
+ MaybeLoaded,
16
15
  Account,
17
16
  CoValueJazzApi,
18
17
  inspect,
@@ -33,6 +32,7 @@ export class CoVector
33
32
  implements Readonly<Float32Array>, CoValue
34
33
  {
35
34
  declare $jazz: CoVectorJazzApi<this>;
35
+ declare $isLoaded: true;
36
36
 
37
37
  /** @category Type Helpers */
38
38
  declare [TypeSym]: "BinaryCoStream";
@@ -79,6 +79,7 @@ export class CoVector
79
79
  value: new CoVectorJazzApi(this, raw),
80
80
  enumerable: false,
81
81
  },
82
+ $isLoaded: { value: true, enumerable: false },
82
83
  _isVectorLoaded: { value: false, enumerable: false, writable: true },
83
84
  _requiredDimensionsCount: {
84
85
  value: dimensionsCount,
@@ -231,15 +232,15 @@ export class CoVector
231
232
  options?: {
232
233
  loadAs?: Account | AnonymousJazzAgent;
233
234
  },
234
- ): Promise<C | null> {
235
+ ): Promise<MaybeLoaded<C>> {
235
236
  const coVector = await loadCoValueWithoutMe(this, id, options);
236
237
 
237
238
  /**
238
239
  * We are only interested in the entire vector. Since most vectors are small (<15kB),
239
240
  * we can wait for the stream to be complete before returning the vector
240
241
  */
241
- if (!coVector?.$jazz.raw.isBinaryStreamEnded()) {
242
- return new Promise<C | null>((resolve) => {
242
+ if (!coVector.$isLoaded || !coVector.$jazz.raw.isBinaryStreamEnded()) {
243
+ return new Promise((resolve) => {
243
244
  subscribeToCoValueWithoutMe(
244
245
  this,
245
246
  id,