jazz-tools 2.0.0-alpha.60 → 2.0.0-alpha.61

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 (544) hide show
  1. package/README.md +1 -1
  2. package/bin/jazz-tools.js +3 -0
  3. package/dist/_dev/native-account-session.d.ts +8 -1
  4. package/dist/_dev/native-account-session.d.ts.map +1 -1
  5. package/dist/_dev/native-account-session.js +10 -0
  6. package/dist/_dev/native-account-session.js.map +1 -1
  7. package/dist/accounts/account-manager-core.d.ts +6 -0
  8. package/dist/accounts/account-manager-core.d.ts.map +1 -1
  9. package/dist/accounts/account-manager-core.js +26 -2
  10. package/dist/accounts/account-manager-core.js.map +1 -1
  11. package/dist/accounts/enrollment.d.ts.map +1 -1
  12. package/dist/accounts/enrollment.js +11 -4
  13. package/dist/accounts/enrollment.js.map +1 -1
  14. package/dist/accounts/exports.d.ts +1 -2
  15. package/dist/accounts/exports.d.ts.map +1 -1
  16. package/dist/accounts/exports.js +4 -1
  17. package/dist/accounts/exports.js.map +1 -1
  18. package/dist/accounts/persistence.d.ts +8 -0
  19. package/dist/accounts/persistence.d.ts.map +1 -1
  20. package/dist/accounts/persistence.js +12 -0
  21. package/dist/accounts/persistence.js.map +1 -1
  22. package/dist/accounts/registry-client.d.ts +20 -0
  23. package/dist/accounts/registry-client.d.ts.map +1 -1
  24. package/dist/accounts/registry-client.js +34 -0
  25. package/dist/accounts/registry-client.js.map +1 -1
  26. package/dist/accounts/state.d.ts.map +1 -1
  27. package/dist/accounts/state.js +2 -1
  28. package/dist/accounts/state.js.map +1 -1
  29. package/dist/backend/create-jazz-session.d.ts +9 -7
  30. package/dist/backend/create-jazz-session.d.ts.map +1 -1
  31. package/dist/backend/create-jazz-session.js +55 -17
  32. package/dist/backend/create-jazz-session.js.map +1 -1
  33. package/dist/backend/create-jazz.d.ts +122 -34
  34. package/dist/backend/create-jazz.d.ts.map +1 -1
  35. package/dist/backend/create-jazz.js +396 -101
  36. package/dist/backend/create-jazz.js.map +1 -1
  37. package/dist/backend/early-db.d.ts.map +1 -1
  38. package/dist/backend/early-db.js +1 -0
  39. package/dist/backend/early-db.js.map +1 -1
  40. package/dist/backend/from-jwt.d.ts +2 -2
  41. package/dist/backend/from-jwt.d.ts.map +1 -1
  42. package/dist/backend/from-jwt.js +7 -1
  43. package/dist/backend/from-jwt.js.map +1 -1
  44. package/dist/backend/index.d.ts +2 -1
  45. package/dist/backend/index.d.ts.map +1 -1
  46. package/dist/backend/index.js +3 -1
  47. package/dist/backend/index.js.map +1 -1
  48. package/dist/backend/inspect-ui.d.ts +14 -0
  49. package/dist/backend/inspect-ui.d.ts.map +1 -0
  50. package/dist/backend/inspect-ui.js +156 -0
  51. package/dist/backend/inspect-ui.js.map +1 -0
  52. package/dist/backend/inspect.d.ts +129 -0
  53. package/dist/backend/inspect.d.ts.map +1 -0
  54. package/dist/backend/inspect.js +763 -0
  55. package/dist/backend/inspect.js.map +1 -0
  56. package/dist/backend/inspector-ui/0.js +2 -0
  57. package/dist/backend/inspector-ui/1.js +2 -0
  58. package/dist/backend/inspector-ui/10.js +2 -0
  59. package/dist/backend/inspector-ui/11.js +2 -0
  60. package/dist/backend/inspector-ui/12.js +2 -0
  61. package/dist/backend/inspector-ui/13.js +2 -0
  62. package/dist/backend/inspector-ui/14.js +2 -0
  63. package/dist/backend/inspector-ui/15.js +2 -0
  64. package/dist/backend/inspector-ui/16.js +2 -0
  65. package/dist/backend/inspector-ui/17.js +2 -0
  66. package/dist/backend/inspector-ui/18.js +2 -0
  67. package/dist/backend/inspector-ui/19.js +2 -0
  68. package/dist/backend/inspector-ui/2.js +2 -0
  69. package/dist/backend/inspector-ui/20.js +2 -0
  70. package/dist/backend/inspector-ui/3.js +2 -0
  71. package/dist/backend/inspector-ui/4.js +2 -0
  72. package/dist/backend/inspector-ui/5.js +2 -0
  73. package/dist/backend/inspector-ui/6.js +2 -0
  74. package/dist/backend/inspector-ui/7.js +2 -0
  75. package/dist/backend/inspector-ui/8.js +2 -0
  76. package/dist/backend/inspector-ui/9.js +2 -0
  77. package/dist/backend/inspector-ui-files.d.ts +4 -0
  78. package/dist/backend/inspector-ui-files.d.ts.map +1 -0
  79. package/dist/backend/inspector-ui-files.js +25 -0
  80. package/dist/backend/session-expiry.d.ts +61 -0
  81. package/dist/backend/session-expiry.d.ts.map +1 -0
  82. package/dist/backend/session-expiry.js +102 -0
  83. package/dist/backend/session-expiry.js.map +1 -0
  84. package/dist/backend/upgrade-status.d.ts +19 -0
  85. package/dist/backend/upgrade-status.d.ts.map +1 -0
  86. package/dist/backend/upgrade-status.js +55 -0
  87. package/dist/backend/upgrade-status.js.map +1 -0
  88. package/dist/backend/vercel-sockets.d.ts +16 -0
  89. package/dist/backend/vercel-sockets.d.ts.map +1 -0
  90. package/dist/backend/vercel-sockets.js +24 -0
  91. package/dist/backend/vercel-sockets.js.map +1 -0
  92. package/dist/backend/vercel-store.d.ts.map +1 -1
  93. package/dist/backend/vercel-store.js +77 -10
  94. package/dist/backend/vercel-store.js.map +1 -1
  95. package/dist/classic-api.d.ts.map +1 -1
  96. package/dist/classic-api.js +36 -0
  97. package/dist/classic-api.js.map +1 -1
  98. package/dist/cli.d.ts.map +1 -1
  99. package/dist/cli.js +30 -2
  100. package/dist/cli.js.map +1 -1
  101. package/dist/client/index.d.ts +2 -6
  102. package/dist/client/index.d.ts.map +1 -1
  103. package/dist/client/index.js +2 -3
  104. package/dist/client/index.js.map +1 -1
  105. package/dist/cloud/credentials.d.ts +1 -1
  106. package/dist/cloud/credentials.d.ts.map +1 -1
  107. package/dist/cloud/credentials.js.map +1 -1
  108. package/dist/dev/catalogue.d.ts +12 -0
  109. package/dist/dev/catalogue.d.ts.map +1 -1
  110. package/dist/dev/catalogue.js +31 -0
  111. package/dist/dev/catalogue.js.map +1 -1
  112. package/dist/dev/inspector-overlay/embedded/assets/backend-DHeT1LCS.css +1 -0
  113. package/dist/dev/inspector-overlay/embedded/assets/backend-Dt5FYVfX.js +1 -0
  114. package/dist/dev/inspector-overlay/embedded/assets/{create-legacy-browser-delegate-X_T_QKCN.js → create-legacy-browser-delegate-Bf58kV5i.js} +1 -1
  115. package/dist/dev/inspector-overlay/embedded/assets/esm-BQhYkCKN.js +1 -0
  116. package/dist/dev/inspector-overlay/embedded/assets/{esm-aRzpnC3u.js → esm-CI6IodCN.js} +1 -1
  117. package/dist/dev/inspector-overlay/embedded/assets/{esm-ezD5H765.js → esm-D5aLlEYl.js} +1 -1
  118. package/dist/dev/inspector-overlay/embedded/assets/{esm-7mP3GQX4.js → esm-D_R-EGgt.js} +1 -1
  119. package/dist/dev/inspector-overlay/embedded/assets/{esm-BX6IY2Mv.js → esm-WihpI9g6.js} +1 -1
  120. package/dist/dev/inspector-overlay/embedded/assets/index-CjhxdwQ7.js +1 -0
  121. package/dist/dev/inspector-overlay/embedded/assets/jazz-broker-worker-CaVlHITU.js +3 -0
  122. package/dist/dev/inspector-overlay/embedded/assets/{jazz-broker-worker-XRRxJUcx.js → jazz-broker-worker-D-HQuhdu.js} +160 -557
  123. package/dist/dev/inspector-overlay/embedded/assets/jazz_wasm-t1Mm3faf.js +1 -0
  124. package/dist/dev/inspector-overlay/embedded/assets/{jazz_wasm_bg-KR7h3v27.wasm → jazz_wasm_bg-BazWJnU4.wasm} +0 -0
  125. package/dist/dev/inspector-overlay/embedded/assets/{index-C78Pprka.css → src-Cq8gSOLx.css} +1 -1
  126. package/dist/dev/inspector-overlay/embedded/assets/src-Dg6641Mj.js +22 -0
  127. package/dist/dev/inspector-overlay/embedded/assets/{trace-api-B5CaetI0.js → trace-api-BctnwbUf.js} +1 -1
  128. package/dist/dev/inspector-overlay/embedded/backend.html +16 -0
  129. package/dist/dev/inspector-overlay/embedded/embedded.html +3 -2
  130. package/dist/dev/inspector-overlay/host-bridge.d.ts.map +1 -1
  131. package/dist/dev/inspector-overlay/host-bridge.js +4 -1
  132. package/dist/dev/inspector-overlay/host-bridge.js.map +1 -1
  133. package/dist/dev/inspector-overlay/loader.d.ts +12 -1
  134. package/dist/dev/inspector-overlay/loader.d.ts.map +1 -1
  135. package/dist/dev/inspector-overlay/loader.js +31 -4
  136. package/dist/dev/inspector-overlay/loader.js.map +1 -1
  137. package/dist/drivers/schema-wire.d.ts +6 -2
  138. package/dist/drivers/schema-wire.d.ts.map +1 -1
  139. package/dist/drivers/schema-wire.js +6 -2
  140. package/dist/drivers/schema-wire.js.map +1 -1
  141. package/dist/effect/jazz.d.ts +12 -5
  142. package/dist/effect/jazz.d.ts.map +1 -1
  143. package/dist/effect/jazz.js +28 -5
  144. package/dist/effect/jazz.js.map +1 -1
  145. package/dist/expo/create-account-manager.d.ts +1 -1
  146. package/dist/expo/create-account-manager.d.ts.map +1 -1
  147. package/dist/expo/create-jazz-session.d.ts +37 -17
  148. package/dist/expo/create-jazz-session.d.ts.map +1 -1
  149. package/dist/expo/create-jazz-session.js +49 -10
  150. package/dist/expo/create-jazz-session.js.map +1 -1
  151. package/dist/expo/index.d.ts +5 -8
  152. package/dist/expo/index.d.ts.map +1 -1
  153. package/dist/expo/index.js +5 -7
  154. package/dist/expo/index.js.map +1 -1
  155. package/dist/expo/provider.d.ts +6 -3
  156. package/dist/expo/provider.d.ts.map +1 -1
  157. package/dist/expo/provider.js +7 -6
  158. package/dist/expo/provider.js.map +1 -1
  159. package/dist/index.d.ts +2 -2
  160. package/dist/index.d.ts.map +1 -1
  161. package/dist/index.js +2 -1
  162. package/dist/index.js.map +1 -1
  163. package/dist/inspect/cli.d.ts +12 -0
  164. package/dist/inspect/cli.d.ts.map +1 -0
  165. package/dist/inspect/cli.js +292 -0
  166. package/dist/inspect/cli.js.map +1 -0
  167. package/dist/inspect/client.d.ts +60 -0
  168. package/dist/inspect/client.d.ts.map +1 -0
  169. package/dist/inspect/client.js +241 -0
  170. package/dist/inspect/client.js.map +1 -0
  171. package/dist/inspect/mcp.d.ts +17 -0
  172. package/dist/inspect/mcp.d.ts.map +1 -0
  173. package/dist/inspect/mcp.js +308 -0
  174. package/dist/inspect/mcp.js.map +1 -0
  175. package/dist/inspect/protocol.d.ts +218 -0
  176. package/dist/inspect/protocol.d.ts.map +1 -0
  177. package/dist/inspect/protocol.js +357 -0
  178. package/dist/inspect/protocol.js.map +1 -0
  179. package/dist/inspector/index.d.ts +10 -0
  180. package/dist/inspector/index.d.ts.map +1 -0
  181. package/dist/inspector/index.js +27 -0
  182. package/dist/inspector/index.js.map +1 -0
  183. package/dist/migrations.d.ts +1 -1
  184. package/dist/migrations.js +1 -1
  185. package/dist/migrations.js.map +1 -1
  186. package/dist/react/index.d.ts +4 -9
  187. package/dist/react/index.d.ts.map +1 -1
  188. package/dist/react/index.js +4 -6
  189. package/dist/react/index.js.map +1 -1
  190. package/dist/react/provider-props.d.ts +7 -0
  191. package/dist/react/provider-props.d.ts.map +1 -0
  192. package/dist/react/provider-props.js +15 -0
  193. package/dist/react/provider-props.js.map +1 -0
  194. package/dist/react/provider.d.ts +9 -15
  195. package/dist/react/provider.d.ts.map +1 -1
  196. package/dist/react/provider.js +19 -38
  197. package/dist/react/provider.js.map +1 -1
  198. package/dist/react-core/index.d.ts +3 -4
  199. package/dist/react-core/index.d.ts.map +1 -1
  200. package/dist/react-core/index.js +8 -4
  201. package/dist/react-core/index.js.map +1 -1
  202. package/dist/react-core/provider.d.ts +6 -6
  203. package/dist/react-core/provider.d.ts.map +1 -1
  204. package/dist/react-core/provider.js +5 -6
  205. package/dist/react-core/provider.js.map +1 -1
  206. package/dist/react-core/session.d.ts +41 -33
  207. package/dist/react-core/session.d.ts.map +1 -1
  208. package/dist/react-core/session.js +41 -89
  209. package/dist/react-core/session.js.map +1 -1
  210. package/dist/react-native/account-session.js +1 -1
  211. package/dist/react-native/account-session.js.map +1 -1
  212. package/dist/react-native/create-account-manager.d.ts +1 -1
  213. package/dist/react-native/create-account-manager.d.ts.map +1 -1
  214. package/dist/react-native/create-jazz-session.d.ts +37 -17
  215. package/dist/react-native/create-jazz-session.d.ts.map +1 -1
  216. package/dist/react-native/create-jazz-session.js +49 -10
  217. package/dist/react-native/create-jazz-session.js.map +1 -1
  218. package/dist/react-native/index.d.ts +5 -10
  219. package/dist/react-native/index.d.ts.map +1 -1
  220. package/dist/react-native/index.js +5 -7
  221. package/dist/react-native/index.js.map +1 -1
  222. package/dist/react-native/native-foreground-db.d.ts +7 -0
  223. package/dist/react-native/native-foreground-db.d.ts.map +1 -1
  224. package/dist/react-native/native-foreground-db.js +29 -0
  225. package/dist/react-native/native-foreground-db.js.map +1 -1
  226. package/dist/react-native/provider.d.ts +14 -19
  227. package/dist/react-native/provider.d.ts.map +1 -1
  228. package/dist/react-native/provider.js +19 -18
  229. package/dist/react-native/provider.js.map +1 -1
  230. package/dist/react-native/runtime-source.js +1 -1
  231. package/dist/react-native/runtime-source.js.map +1 -1
  232. package/dist/removed-api.d.ts +87 -0
  233. package/dist/removed-api.d.ts.map +1 -0
  234. package/dist/removed-api.js +95 -0
  235. package/dist/removed-api.js.map +1 -0
  236. package/dist/runtime/auth-secret-store.d.ts +0 -44
  237. package/dist/runtime/auth-secret-store.d.ts.map +1 -1
  238. package/dist/runtime/auth-secret-store.js +1 -103
  239. package/dist/runtime/auth-secret-store.js.map +1 -1
  240. package/dist/runtime/client.d.ts +10 -4
  241. package/dist/runtime/client.d.ts.map +1 -1
  242. package/dist/runtime/client.js.map +1 -1
  243. package/dist/runtime/connection-manager/browser-connection-manager.d.ts +4 -1
  244. package/dist/runtime/connection-manager/browser-connection-manager.d.ts.map +1 -1
  245. package/dist/runtime/connection-manager/browser-connection-manager.js +33 -2
  246. package/dist/runtime/connection-manager/browser-connection-manager.js.map +1 -1
  247. package/dist/runtime/connection-manager/types.d.ts +17 -2
  248. package/dist/runtime/connection-manager/types.d.ts.map +1 -1
  249. package/dist/runtime/connection-manager/types.js +19 -5
  250. package/dist/runtime/connection-manager/types.js.map +1 -1
  251. package/dist/runtime/credentialed-transport.d.ts +5 -2
  252. package/dist/runtime/credentialed-transport.d.ts.map +1 -1
  253. package/dist/runtime/credentialed-transport.js +12 -3
  254. package/dist/runtime/credentialed-transport.js.map +1 -1
  255. package/dist/runtime/db-replaced-error.d.ts +3 -1
  256. package/dist/runtime/db-replaced-error.d.ts.map +1 -1
  257. package/dist/runtime/db-replaced-error.js +4 -2
  258. package/dist/runtime/db-replaced-error.js.map +1 -1
  259. package/dist/runtime/db.d.ts +35 -7
  260. package/dist/runtime/db.d.ts.map +1 -1
  261. package/dist/runtime/db.js +65 -9
  262. package/dist/runtime/db.js.map +1 -1
  263. package/dist/runtime/index.d.ts +3 -4
  264. package/dist/runtime/index.d.ts.map +1 -1
  265. package/dist/runtime/index.js +1 -2
  266. package/dist/runtime/index.js.map +1 -1
  267. package/dist/runtime/native-artifact-fingerprint-napi.d.ts +1 -1
  268. package/dist/runtime/native-artifact-fingerprint-napi.js +1 -1
  269. package/dist/runtime/native-artifact-fingerprint-napi.js.map +1 -1
  270. package/dist/runtime/native-artifact-fingerprint-wasm.d.ts +1 -1
  271. package/dist/runtime/native-artifact-fingerprint-wasm.js +1 -1
  272. package/dist/runtime/native-artifact-fingerprint-wasm.js.map +1 -1
  273. package/dist/runtime/native-artifact-fingerprints.d.ts +2 -2
  274. package/dist/runtime/native-runtime/attached-browser-worker-connection.d.ts +3 -1
  275. package/dist/runtime/native-runtime/attached-browser-worker-connection.d.ts.map +1 -1
  276. package/dist/runtime/native-runtime/attached-browser-worker-connection.js.map +1 -1
  277. package/dist/runtime/native-runtime/broker-worker-load-failure.d.ts +31 -0
  278. package/dist/runtime/native-runtime/broker-worker-load-failure.d.ts.map +1 -0
  279. package/dist/runtime/native-runtime/broker-worker-load-failure.js +66 -0
  280. package/dist/runtime/native-runtime/broker-worker-load-failure.js.map +1 -0
  281. package/dist/runtime/native-runtime/browser-follower-connection.d.ts +5 -1
  282. package/dist/runtime/native-runtime/browser-follower-connection.d.ts.map +1 -1
  283. package/dist/runtime/native-runtime/browser-follower-connection.js +4 -3
  284. package/dist/runtime/native-runtime/browser-follower-connection.js.map +1 -1
  285. package/dist/runtime/native-runtime/browser-shared-worker-connection.d.ts +3 -1
  286. package/dist/runtime/native-runtime/browser-shared-worker-connection.d.ts.map +1 -1
  287. package/dist/runtime/native-runtime/browser-shared-worker-connection.js +55 -4
  288. package/dist/runtime/native-runtime/browser-shared-worker-connection.js.map +1 -1
  289. package/dist/runtime/native-runtime/browser-worker-protocol.d.ts +5 -0
  290. package/dist/runtime/native-runtime/browser-worker-protocol.d.ts.map +1 -1
  291. package/dist/runtime/native-runtime/browser-worker-protocol.js.map +1 -1
  292. package/dist/runtime/native-runtime/http-stream-socket.d.ts +25 -7
  293. package/dist/runtime/native-runtime/http-stream-socket.d.ts.map +1 -1
  294. package/dist/runtime/native-runtime/http-stream-socket.js +56 -29
  295. package/dist/runtime/native-runtime/http-stream-socket.js.map +1 -1
  296. package/dist/runtime/native-runtime/native-runtime-adapter.d.ts +13 -5
  297. package/dist/runtime/native-runtime/native-runtime-adapter.d.ts.map +1 -1
  298. package/dist/runtime/native-runtime/native-runtime-adapter.js +38 -10
  299. package/dist/runtime/native-runtime/native-runtime-adapter.js.map +1 -1
  300. package/dist/runtime/native-runtime/websocket.d.ts +13 -0
  301. package/dist/runtime/native-runtime/websocket.d.ts.map +1 -1
  302. package/dist/runtime/native-runtime/websocket.js +23 -4
  303. package/dist/runtime/native-runtime/websocket.js.map +1 -1
  304. package/dist/runtime/page-handle.d.ts +87 -0
  305. package/dist/runtime/page-handle.d.ts.map +1 -0
  306. package/dist/runtime/page-handle.js +144 -0
  307. package/dist/runtime/page-handle.js.map +1 -0
  308. package/dist/runtime/removed-provider-props.d.ts +17 -0
  309. package/dist/runtime/removed-provider-props.d.ts.map +1 -0
  310. package/dist/runtime/removed-provider-props.js +16 -0
  311. package/dist/runtime/removed-provider-props.js.map +1 -0
  312. package/dist/runtime/runtime-source.d.ts +4 -1
  313. package/dist/runtime/runtime-source.d.ts.map +1 -1
  314. package/dist/runtime/runtime-source.js.map +1 -1
  315. package/dist/runtime/store-held-by-another-tab-error.d.ts +11 -0
  316. package/dist/runtime/store-held-by-another-tab-error.d.ts.map +1 -1
  317. package/dist/runtime/store-held-by-another-tab-error.js +11 -0
  318. package/dist/runtime/store-held-by-another-tab-error.js.map +1 -1
  319. package/dist/runtime/sync-status.d.ts +60 -1
  320. package/dist/runtime/sync-status.d.ts.map +1 -1
  321. package/dist/runtime/sync-status.js +64 -4
  322. package/dist/runtime/sync-status.js.map +1 -1
  323. package/dist/session/backend-watch.d.ts +53 -14
  324. package/dist/session/backend-watch.d.ts.map +1 -1
  325. package/dist/session/backend-watch.js +99 -22
  326. package/dist/session/backend-watch.js.map +1 -1
  327. package/dist/session/config-options.d.ts +15 -0
  328. package/dist/session/config-options.d.ts.map +1 -0
  329. package/dist/session/config-options.js +55 -0
  330. package/dist/session/config-options.js.map +1 -0
  331. package/dist/session/consumer.d.ts +1 -1
  332. package/dist/session/consumer.js +1 -1
  333. package/dist/session/consumer.js.map +1 -1
  334. package/dist/session/create-jazz-session.d.ts +57 -21
  335. package/dist/session/create-jazz-session.d.ts.map +1 -1
  336. package/dist/session/create-jazz-session.js +257 -58
  337. package/dist/session/create-jazz-session.js.map +1 -1
  338. package/dist/session/follow-user.d.ts +17 -7
  339. package/dist/session/follow-user.d.ts.map +1 -1
  340. package/dist/session/follow-user.js +23 -2
  341. package/dist/session/follow-user.js.map +1 -1
  342. package/dist/session/jazz-session.d.ts +164 -0
  343. package/dist/session/jazz-session.d.ts.map +1 -0
  344. package/dist/session/jazz-session.js +432 -0
  345. package/dist/session/jazz-session.js.map +1 -0
  346. package/dist/session/left-behind-replicas.d.ts +8 -1
  347. package/dist/session/left-behind-replicas.d.ts.map +1 -1
  348. package/dist/session/left-behind-replicas.js +21 -4
  349. package/dist/session/left-behind-replicas.js.map +1 -1
  350. package/dist/session/state.d.ts +20 -13
  351. package/dist/session/state.d.ts.map +1 -1
  352. package/dist/session/state.js +68 -23
  353. package/dist/session/state.js.map +1 -1
  354. package/dist/solid/index.d.ts +3 -9
  355. package/dist/solid/index.d.ts.map +1 -1
  356. package/dist/solid/index.js +8 -11
  357. package/dist/solid/index.ssr.js +3 -6
  358. package/dist/solid/provider.d.ts +3 -3
  359. package/dist/solid/provider.d.ts.map +1 -1
  360. package/dist/solid/provider.js +23 -39
  361. package/dist/solid/provider.js.map +1 -1
  362. package/dist/solid/provider.ssr.js +6 -23
  363. package/dist/solid/provider.ssr.js.map +1 -1
  364. package/dist/solid/session.d.ts +42 -12
  365. package/dist/solid/session.d.ts.map +1 -1
  366. package/dist/solid/session.js +82 -35
  367. package/dist/solid/session.js.map +1 -1
  368. package/dist/solid/session.ssr.js +85 -22
  369. package/dist/solid/session.ssr.js.map +1 -1
  370. package/dist/svelte/JazzProvider.svelte +54 -20
  371. package/dist/svelte/JazzProvider.svelte.d.ts +14 -4
  372. package/dist/svelte/JazzProvider.svelte.d.ts.map +1 -1
  373. package/dist/svelte/JazzSvelteClientProvider.svelte +1 -7
  374. package/dist/svelte/JazzSvelteClientProvider.svelte.d.ts +0 -1
  375. package/dist/svelte/JazzSvelteClientProvider.svelte.d.ts.map +1 -1
  376. package/dist/svelte/JazzSvelteProvider.svelte +5 -4
  377. package/dist/svelte/JazzSvelteProvider.svelte.d.ts +2 -2
  378. package/dist/svelte/JazzSvelteProvider.svelte.d.ts.map +1 -1
  379. package/dist/svelte/index.d.ts +4 -12
  380. package/dist/svelte/index.d.ts.map +1 -1
  381. package/dist/svelte/index.js +4 -8
  382. package/dist/svelte/session-state.d.ts +14 -4
  383. package/dist/svelte/session-state.d.ts.map +1 -1
  384. package/dist/svelte/session-state.js +10 -4
  385. package/dist/testing/policy-test-app.d.ts.map +1 -1
  386. package/dist/testing/policy-test-app.js +5 -4
  387. package/dist/testing/policy-test-app.js.map +1 -1
  388. package/dist/testing/test-jazz.d.ts +2 -2
  389. package/dist/testing/test-jazz.d.ts.map +1 -1
  390. package/dist/testing/test-jazz.js +5 -2
  391. package/dist/testing/test-jazz.js.map +1 -1
  392. package/dist/thin/index.d.ts +7 -10
  393. package/dist/thin/index.d.ts.map +1 -1
  394. package/dist/thin/index.js +28 -11
  395. package/dist/thin/index.js.map +1 -1
  396. package/dist/thin/thin-runtime.d.ts +22 -2
  397. package/dist/thin/thin-runtime.d.ts.map +1 -1
  398. package/dist/thin/thin-runtime.js +157 -24
  399. package/dist/thin/thin-runtime.js.map +1 -1
  400. package/dist/vue/index.d.ts +3 -8
  401. package/dist/vue/index.d.ts.map +1 -1
  402. package/dist/vue/index.js +3 -5
  403. package/dist/vue/index.js.map +1 -1
  404. package/dist/vue/provider.d.ts +6 -27
  405. package/dist/vue/provider.d.ts.map +1 -1
  406. package/dist/vue/provider.js +10 -19
  407. package/dist/vue/provider.js.map +1 -1
  408. package/dist/vue/session.d.ts +29 -28
  409. package/dist/vue/session.d.ts.map +1 -1
  410. package/dist/vue/session.js +79 -22
  411. package/dist/vue/session.js.map +1 -1
  412. package/dist/window-client-storage.d.ts +4 -30
  413. package/dist/window-client-storage.d.ts.map +1 -1
  414. package/dist/window-client-storage.js +2 -63
  415. package/dist/window-client-storage.js.map +1 -1
  416. package/dist/worker/jazz-broker-worker-core.d.ts.map +1 -1
  417. package/dist/worker/jazz-broker-worker-core.js +16 -19
  418. package/dist/worker/jazz-broker-worker-core.js.map +1 -1
  419. package/dist/worker/jazz-broker-worker.js +160 -557
  420. package/dist/worker/jazz_wasm_bg.wasm +0 -0
  421. package/dist/worker/runtime-admission.d.ts +19 -0
  422. package/dist/worker/runtime-admission.d.ts.map +1 -0
  423. package/dist/worker/runtime-admission.js +34 -0
  424. package/dist/worker/runtime-admission.js.map +1 -0
  425. package/package.json +18 -5
  426. package/dist/backend/session-recheck.d.ts +0 -18
  427. package/dist/backend/session-recheck.d.ts.map +0 -1
  428. package/dist/backend/session-recheck.js +0 -57
  429. package/dist/backend/session-recheck.js.map +0 -1
  430. package/dist/dev/inspector-overlay/embedded/assets/esm-k3rsq4Gn.js +0 -1
  431. package/dist/dev/inspector-overlay/embedded/assets/index-C-btvLcw.js +0 -20
  432. package/dist/dev/inspector-overlay/embedded/assets/jazz-broker-worker-CAMcDeUa.js +0 -3
  433. package/dist/dev/inspector-overlay/embedded/assets/jazz_wasm-Cc71x_6y.js +0 -1
  434. package/dist/dev/inspector-overlay/serve.d.ts +0 -46
  435. package/dist/dev/inspector-overlay/serve.d.ts.map +0 -1
  436. package/dist/dev/inspector-overlay/serve.js +0 -131
  437. package/dist/dev/inspector-overlay/serve.js.map +0 -1
  438. package/dist/dev-tools/auto-attach.d.ts +0 -11
  439. package/dist/dev-tools/auto-attach.d.ts.map +0 -1
  440. package/dist/dev-tools/auto-attach.js +0 -26
  441. package/dist/dev-tools/auto-attach.js.map +0 -1
  442. package/dist/expo/auth-secret-store.d.ts +0 -37
  443. package/dist/expo/auth-secret-store.d.ts.map +0 -1
  444. package/dist/expo/auth-secret-store.js +0 -139
  445. package/dist/expo/auth-secret-store.js.map +0 -1
  446. package/dist/expo/session.d.ts +0 -10
  447. package/dist/expo/session.d.ts.map +0 -1
  448. package/dist/expo/session.js +0 -5
  449. package/dist/expo/session.js.map +0 -1
  450. package/dist/expo/use-local-first-auth.d.ts +0 -12
  451. package/dist/expo/use-local-first-auth.d.ts.map +0 -1
  452. package/dist/expo/use-local-first-auth.js +0 -13
  453. package/dist/expo/use-local-first-auth.js.map +0 -1
  454. package/dist/react/devtools-auto-attach.d.ts +0 -2
  455. package/dist/react/devtools-auto-attach.d.ts.map +0 -1
  456. package/dist/react/devtools-auto-attach.js +0 -11
  457. package/dist/react/devtools-auto-attach.js.map +0 -1
  458. package/dist/react/session.d.ts +0 -18
  459. package/dist/react/session.d.ts.map +0 -1
  460. package/dist/react/session.js +0 -28
  461. package/dist/react/session.js.map +0 -1
  462. package/dist/react/use-local-first-auth.d.ts +0 -11
  463. package/dist/react/use-local-first-auth.d.ts.map +0 -1
  464. package/dist/react/use-local-first-auth.js +0 -13
  465. package/dist/react/use-local-first-auth.js.map +0 -1
  466. package/dist/react-core/app.d.ts +0 -31
  467. package/dist/react-core/app.d.ts.map +0 -1
  468. package/dist/react-core/app.js +0 -65
  469. package/dist/react-core/app.js.map +0 -1
  470. package/dist/react-core/use-account-state.d.ts +0 -4
  471. package/dist/react-core/use-account-state.d.ts.map +0 -1
  472. package/dist/react-core/use-account-state.js +0 -6
  473. package/dist/react-core/use-account-state.js.map +0 -1
  474. package/dist/react-core/use-local-first-auth.d.ts +0 -12
  475. package/dist/react-core/use-local-first-auth.d.ts.map +0 -1
  476. package/dist/react-core/use-local-first-auth.js +0 -14
  477. package/dist/react-core/use-local-first-auth.js.map +0 -1
  478. package/dist/react-native/session.d.ts +0 -10
  479. package/dist/react-native/session.d.ts.map +0 -1
  480. package/dist/react-native/session.js +0 -5
  481. package/dist/react-native/session.js.map +0 -1
  482. package/dist/react-native/use-local-first-auth.d.ts +0 -15
  483. package/dist/react-native/use-local-first-auth.d.ts.map +0 -1
  484. package/dist/react-native/use-local-first-auth.js +0 -14
  485. package/dist/react-native/use-local-first-auth.js.map +0 -1
  486. package/dist/runtime/local-first-auth-controller.d.ts +0 -29
  487. package/dist/runtime/local-first-auth-controller.d.ts.map +0 -1
  488. package/dist/runtime/local-first-auth-controller.js +0 -101
  489. package/dist/runtime/local-first-auth-controller.js.map +0 -1
  490. package/dist/session/app.d.ts +0 -58
  491. package/dist/session/app.d.ts.map +0 -1
  492. package/dist/session/app.js +0 -325
  493. package/dist/session/app.js.map +0 -1
  494. package/dist/session/create-jazz-app.d.ts +0 -11
  495. package/dist/session/create-jazz-app.d.ts.map +0 -1
  496. package/dist/session/create-jazz-app.js +0 -11
  497. package/dist/session/create-jazz-app.js.map +0 -1
  498. package/dist/solid/app.d.ts +0 -30
  499. package/dist/solid/app.d.ts.map +0 -1
  500. package/dist/solid/app.js +0 -95
  501. package/dist/solid/app.js.map +0 -1
  502. package/dist/solid/app.ssr.js +0 -109
  503. package/dist/solid/app.ssr.js.map +0 -1
  504. package/dist/solid/create-account-state.d.ts +0 -4
  505. package/dist/solid/create-account-state.d.ts.map +0 -1
  506. package/dist/solid/create-account-state.js +0 -10
  507. package/dist/solid/create-account-state.js.map +0 -1
  508. package/dist/solid/create-account-state.ssr.js +0 -12
  509. package/dist/solid/create-account-state.ssr.js.map +0 -1
  510. package/dist/solid/use-local-first-auth.d.ts +0 -11
  511. package/dist/solid/use-local-first-auth.d.ts.map +0 -1
  512. package/dist/solid/use-local-first-auth.js +0 -30
  513. package/dist/solid/use-local-first-auth.js.map +0 -1
  514. package/dist/solid/use-local-first-auth.ssr.js +0 -31
  515. package/dist/solid/use-local-first-auth.ssr.js.map +0 -1
  516. package/dist/svelte/JazzSessionClientProvider.svelte +0 -42
  517. package/dist/svelte/JazzSessionClientProvider.svelte.d.ts +0 -13
  518. package/dist/svelte/JazzSessionClientProvider.svelte.d.ts.map +0 -1
  519. package/dist/svelte/JazzSessionProvider.svelte +0 -68
  520. package/dist/svelte/JazzSessionProvider.svelte.d.ts +0 -19
  521. package/dist/svelte/JazzSessionProvider.svelte.d.ts.map +0 -1
  522. package/dist/svelte/account-state.d.ts +0 -5
  523. package/dist/svelte/account-state.d.ts.map +0 -1
  524. package/dist/svelte/account-state.js +0 -9
  525. package/dist/svelte/auth-state.d.ts +0 -23
  526. package/dist/svelte/auth-state.d.ts.map +0 -1
  527. package/dist/svelte/auth-state.js +0 -16
  528. package/dist/svelte/local-first-auth.svelte.d.ts +0 -50
  529. package/dist/svelte/local-first-auth.svelte.d.ts.map +0 -1
  530. package/dist/svelte/local-first-auth.svelte.js +0 -58
  531. package/dist/vue/app.d.ts +0 -76
  532. package/dist/vue/app.d.ts.map +0 -1
  533. package/dist/vue/app.js +0 -100
  534. package/dist/vue/app.js.map +0 -1
  535. package/dist/vue/use-account-state.d.ts +0 -5
  536. package/dist/vue/use-account-state.d.ts.map +0 -1
  537. package/dist/vue/use-account-state.js +0 -10
  538. package/dist/vue/use-account-state.js.map +0 -1
  539. package/dist/vue/use-local-first-auth.d.ts +0 -53
  540. package/dist/vue/use-local-first-auth.d.ts.map +0 -1
  541. package/dist/vue/use-local-first-auth.js +0 -67
  542. package/dist/vue/use-local-first-auth.js.map +0 -1
  543. /package/dist/dev/inspector-overlay/embedded/assets/{esm-CH5eVyQQ.js → esm-xNe3wI_B.js} +0 -0
  544. /package/dist/dev/inspector-overlay/embedded/assets/{node-foreground-node-lease.browser-Bm3gYjlT.js → node-foreground-node-lease.browser-CH8w-D6S.js} +0 -0
@@ -1,7 +1,9 @@
1
+ import type { SignedOutDecision } from "./backend-watch.js";
1
2
  import type { AccountManagerConfig } from "../accounts/create-account-manager.js";
2
3
  import { type JazzClient } from "../web/registered-jazz-client.js";
3
4
  import type { OpenJazzClientConfig } from "../web/create-jazz-client.js";
4
5
  import { type LocalFirstLoader } from "../runtime/local-first-upgrade.js";
6
+ import { type JazzSession } from "./jazz-session.js";
5
7
  import { type UserFollowingSession } from "./follow-user.js";
6
8
  export type { LocalFirstLoader };
7
9
  export type JazzClientConfig = Omit<OpenJazzClientConfig, "account" | "serverUrl" | "appId"> & Omit<AccountManagerConfig, "appId"> & {
@@ -15,31 +17,42 @@ export type JazzClientConfig = Omit<OpenJazzClientConfig, "account" | "serverUrl
15
17
  /**
16
18
  * Your app's Jazz endpoint: by default `"/jazz"`, where `createJazz` is
17
19
  * mounted in your own backend. `null` keeps Jazz on this device only: no
18
- * server, no sign-in, one local-first account per browser profile. That
19
- * needs the local-first client (`client`).
20
+ * server, no sign-in, one device account per browser profile. That needs
21
+ * the local-first client (`client`).
20
22
  */
21
23
  serverUrl?: string | null;
22
24
  /**
23
25
  * Who the app starts as before your backend names a user: signed out
24
- * (the default, also `"signed-out"`), or a `"local-first"` guest, an
25
- * account on this device that can later link to your backend's user
26
- * (`linkWithBackend`). Your backend must accept guests
27
- * (`acceptLocalFirstAuth`). A guest works offline once its client is the
28
- * local-first one (`client`).
26
+ * (the default, also `"signed-out"`), or a `"device"` account: an
27
+ * account whose key lives on this device, which is how you let people
28
+ * start as guests, and which can later link to your backend's user
29
+ * (`linkDeviceAccount()`). Your backend must accept device accounts
30
+ * (`acceptDeviceAccounts`). A device account works offline once its
31
+ * client is the local-first one (`client`).
29
32
  */
30
- initial?: "local-first" | "signed-out";
33
+ initial?: "device" | "signed-out";
31
34
  /**
32
- * When a local-first guest is on this device and the user who signs in
33
- * has no Jazz account yet (they just signed up, or they are an existing
34
- * user signing in to Jazz for the first time), link the guest to them:
35
- * the account and everything the guest wrote become theirs. On by
36
- * default. Turn it off on shared devices, where the guest may be someone
37
- * else's: the session then leaves such a guest as it is, and your app
38
- * decides after its own sign-in, with `linkWithBackend()` (the guest's
39
- * data becomes the user's) or `loginWithBackend()` (an account of the
40
- * user's own; the guest stays on this device).
35
+ * When a device account is on this device and the user who signs in has
36
+ * no Jazz account yet (they just signed up, or they are an existing user
37
+ * signing in to Jazz for the first time), link the device account to
38
+ * them: the account and everything it wrote become theirs. On by
39
+ * default. Turn it off on shared devices, where the device account may be
40
+ * someone else's guest: the session then leaves it as it is, and your
41
+ * app decides after its own sign-in, with `linkDeviceAccount()` (its data
42
+ * becomes the user's) or `refresh()` (an account of the user's own; the
43
+ * device account stays on this device).
41
44
  */
42
- linkGuestOnSignUp?: boolean;
45
+ linkDeviceAccountOnSignUp?: boolean;
46
+ /**
47
+ * Called when your backend says no one is signed in any more (confirmed
48
+ * by a second answer a moment later), before the session signs the
49
+ * user out. Return `"keep"` to stay signed in for now (your app refreshed
50
+ * its session itself, or redirects to sign-in first): the session asks
51
+ * your backend again on the next focus, refusal or `refresh()`.
52
+ * Return `"sign-out"` (or nothing) to sign out. A hook that throws signs
53
+ * out.
54
+ */
55
+ onSignedOut?: () => SignedOutDecision | void | Promise<SignedOutDecision | void>;
43
56
  /**
44
57
  * On sign-out (or a switch to another user), wipe the account's local
45
58
  * storage instead of keeping it for that user's next sign-in. For shared
@@ -60,9 +73,32 @@ export type JazzClientConfig = Omit<OpenJazzClientConfig, "account" | "serverUrl
60
73
  * away, so it works offline.
61
74
  */
62
75
  client?: LocalFirstLoader;
76
+ /**
77
+ * When the local-first client (`client`) opens:
78
+ * - `"background"` (the default): start thin and upgrade once the page
79
+ * has loaded, unless this account upgraded in this browser before.
80
+ * The first paint needs no WASM.
81
+ * - `"now"`: open the local-first client straight away, for every
82
+ * account. For apps that must work offline from the first render, or
83
+ * that use `db.transaction`, which only the local-first client has.
84
+ * If the local-first client can't load, the session fails (`retry()`
85
+ * tries again) rather than running thin.
86
+ *
87
+ * Needs `client`: `"now"` without it is refused.
88
+ */
89
+ localFirst?: "now" | "background";
63
90
  };
64
- /** A browser's Jazz session, which follows your auth's signed-in user. */
91
+ /** @internal A browser session's core, which follows your auth's signed-in user. */
65
92
  export type BrowserJazzSession = UserFollowingSession<JazzClient>;
66
- /** Own one configured client and serialize its account lifecycle. */
67
- export declare function createJazzClient(config: JazzClientConfig): Promise<BrowserJazzSession>;
93
+ /**
94
+ * Open a Jazz session in this browser: who is signed in, and the client that
95
+ * reads and writes as them. Resolves once it started; rejects if it can't.
96
+ * Your backend decides who is signed in; call `session.refresh()` after your
97
+ * own sign-in or sign-out.
98
+ */
99
+ export declare function createJazzClient(config: JazzClientConfig): Promise<JazzSession<JazzClient>>;
100
+ /** @internal The session core `createJazzClient` and `<JazzProvider>` own. */
101
+ export declare function openBrowserSessionCore(config: JazzClientConfig): Promise<BrowserJazzSession>;
102
+ /** How often a page tries again a sign-out's wipe that another tab held off. */
103
+ export declare const WIPE_RETRY_MS = 15000;
68
104
  //# sourceMappingURL=create-jazz-session.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"create-jazz-session.d.ts","sourceRoot":"","sources":["../../src/session/create-jazz-session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AASlF,OAAO,EAGL,KAAK,UAAU,EAChB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAOzE,OAAO,EAEL,KAAK,gBAAgB,EAEtB,MAAM,mCAAmC,CAAC;AAI3C,OAAO,EAKL,KAAK,oBAAoB,EAC1B,MAAM,kBAAkB,CAAC;AAW1B,YAAY,EAAE,gBAAgB,EAAE,CAAC;AAEjC,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,oBAAoB,EAAE,SAAS,GAAG,WAAW,GAAG,OAAO,CAAC,GAC1F,IAAI,CAAC,oBAAoB,EAAE,OAAO,CAAC,GAAG;IACpC;;;;;OAKG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC;IACd;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,aAAa,GAAG,YAAY,CAAC;IACvC;;;;;;;;;;OAUG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;;;;;;;OAQG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;;;;;;;OAQG;IACH,MAAM,CAAC,EAAE,gBAAgB,CAAC;CAC3B,CAAC;AAEJ,0EAA0E;AAC1E,MAAM,MAAM,kBAAkB,GAAG,oBAAoB,CAAC,UAAU,CAAC,CAAC;AAgClE,qEAAqE;AACrE,wBAAsB,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CA4P5F"}
1
+ {"version":3,"file":"create-jazz-session.d.ts","sourceRoot":"","sources":["../../src/session/create-jazz-session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAUlF,OAAO,EAGL,KAAK,UAAU,EAChB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAOzE,OAAO,EAEL,KAAK,gBAAgB,EAEtB,MAAM,mCAAmC,CAAC;AAE3C,OAAO,EAAyC,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAG5F,OAAO,EAKL,KAAK,oBAAoB,EAC1B,MAAM,kBAAkB,CAAC;AAe1B,YAAY,EAAE,gBAAgB,EAAE,CAAC;AAEjC,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,oBAAoB,EAAE,SAAS,GAAG,WAAW,GAAG,OAAO,CAAC,GAC1F,IAAI,CAAC,oBAAoB,EAAE,OAAO,CAAC,GAAG;IACpC;;;;;OAKG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC;IACd;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B;;;;;;;;OAQG;IACH,OAAO,CAAC,EAAE,QAAQ,GAAG,YAAY,CAAC;IAClC;;;;;;;;;;OAUG;IACH,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC;;;;;;;;OAQG;IACH,WAAW,CAAC,EAAE,MAAM,iBAAiB,GAAG,IAAI,GAAG,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAAC;IACjF;;;;;;;;OAQG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;;;;;;;OAQG;IACH,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B;;;;;;;;;;;;OAYG;IACH,UAAU,CAAC,EAAE,KAAK,GAAG,YAAY,CAAC;CACnC,CAAC;AA8BJ,oFAAoF;AACpF,MAAM,MAAM,kBAAkB,GAAG,oBAAoB,CAAC,UAAU,CAAC,CAAC;AAgClE;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC,CAE3F;AAED,8EAA8E;AAC9E,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,gBAAgB,GACvB,OAAO,CAAC,kBAAkB,CAAC,CA2Z7B;AAMD,gFAAgF;AAChF,eAAO,MAAM,aAAa,QAAS,CAAC"}
@@ -1,15 +1,46 @@
1
- import { clientRegistryUrl, createAccountManagerWithMinter, } from "../accounts/account-manager-core.js";
1
+ import { clientRegistryUrl, createAccountManagerWithMinter, watchStoredSelection, } from "../accounts/account-manager-core.js";
2
2
  import { attachSubscriptionStore, getSubscriptionStore } from "../subscription-store-internal.js";
3
3
  import { bearerFetch } from "../runtime/credentialed-transport.js";
4
4
  import { createRegisteredJazzClient, } from "../web/registered-jazz-client.js";
5
5
  import { createClient as createThinDb, mintLocalFirstTokenInJs, prefetchThinQueries, handOffThinWrites, } from "../thin/index.js";
6
6
  import { setLocalFirstUpgrader, } from "../runtime/local-first-upgrade.js";
7
7
  import { createJazzSessionOwner, replaceJazzSessionClient } from "./state.js";
8
+ import { coreInitial, createStartedJazzSession } from "./jazz-session.js";
8
9
  import { DEFAULT_SERVER_URL, refuseClientAppId } from "../runtime/client-scope.js";
9
10
  import { browserBackendWatchEvents } from "./backend-watch.js";
10
11
  import { backendAnswered, firstBackendAnswer, followUser, signedInIdentity, } from "./follow-user.js";
11
- import { holdReplica, leftBehindReplicas, whileNoTabHolds, wipeLeftBehindReplicas, } from "./left-behind-replicas.js";
12
+ import { holdReplica, leftBehindReplicas, whileNoTabHolds, wipeLeftBehindReplicas, replicaHeld, WIPE_TIMEOUT_MS, } from "./left-behind-replicas.js";
13
+ import { refuseInvalidSessionConfig } from "./config-options.js";
14
+ import { refuseWindowJazzConflict } from "../runtime/page-handle.js";
15
+ import { accountForgotten } from "../accounts/persistence.js";
12
16
  import { rememberBackendUser } from "../accounts/enrollment.js";
17
+ /**
18
+ * Every option `createJazzClient` takes in a browser, checked against the
19
+ * config type both ways (`appId` and `backendSecret` are refused by type, and
20
+ * `appId` by name too).
21
+ */
22
+ const BROWSER_SESSION_OPTIONS = {
23
+ serverUrl: true,
24
+ initial: true,
25
+ linkDeviceAccountOnSignUp: true,
26
+ onSignedOut: true,
27
+ clearOnSignOut: true,
28
+ client: true,
29
+ localFirst: true,
30
+ scope: true,
31
+ driver: true,
32
+ env: true,
33
+ runtimeSources: true,
34
+ dbName: true,
35
+ initialSyncFlushEvery: true,
36
+ logLevel: true,
37
+ telemetryCollectorUrl: true,
38
+ devMode: true,
39
+ slowQueryThresholdMs: true,
40
+ store: true,
41
+ fetch: true,
42
+ bearer: true,
43
+ };
13
44
  /**
14
45
  * A client keeps its options as configuration (`db.getConfig()` clones them),
15
46
  * so one that holds a function or class could only fail later, in whatever
@@ -34,17 +65,34 @@ function refuseUnkeptOptions(clientConfig) {
34
65
  }
35
66
  }
36
67
  }
37
- /** Own one configured client and serialize its account lifecycle. */
38
- export async function createJazzClient(config) {
39
- refuseClientAppId(config);
68
+ /**
69
+ * Open a Jazz session in this browser: who is signed in, and the client that
70
+ * reads and writes as them. Resolves once it started; rejects if it can't.
71
+ * Your backend decides who is signed in; call `session.refresh()` after your
72
+ * own sign-in or sign-out.
73
+ */
74
+ export function createJazzClient(config) {
75
+ return createStartedJazzSession(config, openBrowserSessionCore);
76
+ }
77
+ /** @internal The session core `createJazzClient` and `<JazzProvider>` own. */
78
+ export async function openBrowserSessionCore(config) {
79
+ if (config && typeof config === "object")
80
+ refuseClientAppId(config);
81
+ refuseInvalidSessionConfig(config, BROWSER_SESSION_OPTIONS);
82
+ // `window.__jazz` is Jazz's page handle: an app's own global there would
83
+ // only fail later, when the local-first client opens.
84
+ const page = globalThis.window;
85
+ if (page && typeof page.document !== "undefined")
86
+ refuseWindowJazzConflict(page);
40
87
  if (config.serverUrl === null)
41
88
  return createDeviceOnlySession(config);
42
89
  const serverUrl = config.serverUrl ?? DEFAULT_SERVER_URL;
43
- const { initial, clearOnSignOut, linkGuestOnSignUp, client: loadLocalFirst,
90
+ const { initial, clearOnSignOut, linkDeviceAccountOnSignUp, onSignedOut, client: loadLocalFirst, localFirst,
44
91
  // The account manager's own: neither is client configuration, and a Db
45
92
  // keeps only cloneable data (db.getConfig()).
46
93
  store: _store, fetch: _fetch, bearer, ...clientConfig } = { ...config, serverUrl };
47
94
  refuseUnkeptOptions(clientConfig);
95
+ refuseLocalFirstTiming(localFirst, loadLocalFirst);
48
96
  const accounts = await createAccountManagerWithMinter({ ...config, serverUrl }, mintLocalFirstTokenInJs,
49
97
  // A shared device: never reopen the last user before the backend answers.
50
98
  { rememberBackendUser: !clearOnSignOut });
@@ -54,44 +102,36 @@ export async function createJazzClient(config) {
54
102
  const wipesOnSignOut = !!clearOnSignOut && (config.driver?.type ?? "persistent") === "persistent";
55
103
  // Local-first replicas a sign-out may leave behind (see `leftBehindReplicas`).
56
104
  const leftBehind = wipesOnSignOut && loadLocalFirst ? leftBehindReplicas(registry) : undefined;
57
- // Accounts whose local-first client is (or was) the session's own in this
58
- // page: signing them out here wiped their replica.
59
- const inSession = new Set();
60
105
  // Accounts this page is opening a local-first client for, and replicas
61
106
  // being wiped: an account's open waits for its wipe to finish.
62
107
  const opening = new Set();
63
108
  const wiping = new Map();
64
- // Accounts signed out in this page, whose entry goes once no tab holds
65
- // their replica (another tab may still have it open).
66
- const signedOutHere = new Set();
67
- const forgetSignedOut = (id) => {
68
- if (!leftBehind || !signedOutHere.has(id))
69
- return;
70
- void whileNoTabHolds(registry, id, async () => {
71
- if (!signedOutHere.delete(id) || opening.has(id) || inSession.has(id))
72
- return;
73
- leftBehind.forget(id);
74
- }).catch(() => { });
75
- };
76
- /** Open `account`'s local-first client, recorded and held open against other tabs' wipes. */
109
+ /**
110
+ * Open `account`'s local-first client, held open against other tabs'
111
+ * wipes (a guest's too: its tabs share one store). A user the backend
112
+ * signed in is also recorded, so a later load wipes what a sign-out leaves
113
+ * behind.
114
+ */
77
115
  const openReplica = async (createDb, account) => {
78
- // Only a user the backend signed in: a guest's replica is the device's own.
79
- if (!leftBehind || !rememberBackendUser(account))
116
+ if (!leftBehind)
80
117
  return openLocalFirst(createDb, account);
118
+ // A guest's replica is the device's own: no later load wipes it.
119
+ const recorded = rememberBackendUser(account);
81
120
  opening.add(account.id);
82
- signedOutHere.delete(account.id);
83
121
  try {
84
122
  await wiping.get(account.id)?.catch(() => { });
85
- leftBehind.remember(account);
123
+ if (recorded)
124
+ leftBehind.remember(account);
86
125
  const release = await holdReplica(registry, account.id);
87
- // Again once held: another tab's forget may have run before it was.
88
- leftBehind.remember(account);
126
+ // Again once held: another tab's wipe may have forgotten it before.
127
+ if (recorded)
128
+ leftBehind.remember(account);
89
129
  let client;
90
130
  try {
91
131
  client = await openLocalFirst(createDb, account);
92
132
  }
93
133
  catch (error) {
94
- release();
134
+ await release();
95
135
  throw error;
96
136
  }
97
137
  const shutdown = client.shutdown.bind(client);
@@ -100,8 +140,7 @@ export async function createJazzClient(config) {
100
140
  await shutdown(options);
101
141
  }
102
142
  finally {
103
- release();
104
- forgetSignedOut(account.id);
143
+ await release();
105
144
  }
106
145
  };
107
146
  return client;
@@ -110,6 +149,159 @@ export async function createJazzClient(config) {
110
149
  opening.delete(account.id);
111
150
  }
112
151
  };
152
+ /**
153
+ * Wipe `account`'s replica once no tab has it open, from a client opened
154
+ * only to delete it: never under an open client, so no tab's store is
155
+ * reset beneath it. `"held"` while a tab has it open (that tab's user is
156
+ * still signed in there; the last tab out wipes). `"given-up"` when its
157
+ * open hangs past the timeout before the delete began: it lets go of the
158
+ * lock, so an open of the account doesn't wait on it. `ownPending` is what
159
+ * the signing-out tab counted itself, for a worker that doesn't say.
160
+ */
161
+ const wipeReplica = async (open, account, ownPending = 0) => {
162
+ let wiped = false;
163
+ const ran = await whileNoTabHolds(registry, account, async () => {
164
+ const timeout = AbortSignal.timeout(WIPE_TIMEOUT_MS);
165
+ let deleting = false;
166
+ const run = (async () => {
167
+ // Its socket carries the signed-out user's sign-in, or none: a
168
+ // write the server still accepts may upload meanwhile.
169
+ const client = await open();
170
+ let pendingUploads;
171
+ try {
172
+ // Given up on while it opened: leave the replica for a retry.
173
+ if (timeout.aborted)
174
+ return;
175
+ deleting = true;
176
+ ({ pendingUploads } = await client.db.wipeClientStorage());
177
+ }
178
+ finally {
179
+ await client.shutdown();
180
+ }
181
+ wiped = true;
182
+ leftBehind?.forget(account);
183
+ const lost = Math.max(pendingUploads ?? 0, ownPending);
184
+ if (lost > 0)
185
+ console.warn(`Jazz signed out and wiped ${lost} write(s) the server hadn't confirmed, as clearOnSignOut asks. They are gone from this device; any the server did receive stay there.`);
186
+ })();
187
+ run.catch(() => { });
188
+ wiping.set(account, run);
189
+ // Given up on before its delete began: let go of the lock at once. A
190
+ // delete that began is waited for, however long it takes: an open of
191
+ // the account meanwhile would get half-wiped storage.
192
+ const givenUp = new Promise((resolve) => {
193
+ const giveUp = () => {
194
+ if (!deleting)
195
+ resolve();
196
+ };
197
+ if (timeout.aborted)
198
+ giveUp();
199
+ timeout.addEventListener("abort", giveUp, { once: true });
200
+ });
201
+ try {
202
+ await Promise.race([run, givenUp]);
203
+ }
204
+ finally {
205
+ if (wiping.get(account) === run)
206
+ wiping.delete(account);
207
+ }
208
+ });
209
+ return !ran ? "held" : wiped ? "wiped" : "given-up";
210
+ };
211
+ // Signed-out accounts whose wipe waits for the tabs that still hold them.
212
+ const retrying = new Set();
213
+ /**
214
+ * Try a wipe that couldn't run (a tab held the replica, or its open hung)
215
+ * again every `WIPE_RETRY_MS` in this page, so it doesn't wait for a
216
+ * reload. Only while no tab holds the replica, this page isn't on the
217
+ * account again, and (a user the backend signed in) the backend no longer
218
+ * names them: a tab that closed while still signed in leaves its unsynced
219
+ * writes for that user's next sign-in. `open` gives the client to delete
220
+ * through; `parked`, one opened for that already, is closed when it stops.
221
+ */
222
+ const retryWipe = (account, open, ownPending, parked) => {
223
+ if (retrying.has(account.id)) {
224
+ void parked?.shutdown().catch(() => { });
225
+ return;
226
+ }
227
+ retrying.add(account.id);
228
+ const stop = () => {
229
+ retrying.delete(account.id);
230
+ void parked?.shutdown().catch(() => { });
231
+ };
232
+ const tick = async () => {
233
+ const snapshot = session?.getSnapshot();
234
+ if (!snapshot ||
235
+ snapshot.status === "closed" ||
236
+ snapshot.account?.id === account.id ||
237
+ opening.has(account.id))
238
+ return stop();
239
+ try {
240
+ if (await replicaHeld(registry, account.id))
241
+ return schedule();
242
+ if (rememberBackendUser(account)) {
243
+ const signedIn = await signedInIdentity(registry, config.fetch);
244
+ if (signedIn?.issuer === account.identity.issuer &&
245
+ signedIn.subject === account.identity.subject)
246
+ return schedule();
247
+ }
248
+ if ((await wipeReplica(open, account.id, ownPending)) === "wiped") {
249
+ // Its shutdown was the wipe's.
250
+ parked = undefined;
251
+ return stop();
252
+ }
253
+ }
254
+ catch {
255
+ // The backend or the storage failed this time: try again.
256
+ }
257
+ schedule();
258
+ };
259
+ const schedule = () => void setTimeout(() => void tick(), WIPE_RETRY_MS);
260
+ schedule();
261
+ };
262
+ /**
263
+ * How this page signs a local-first account out under `clearOnSignOut`:
264
+ * upload what the server still accepts, close this tab's client (letting
265
+ * go of its hold), then wipe if no other tab has the account open, or
266
+ * retry until none has. Resolves whether it wiped now.
267
+ */
268
+ const wipeSignedOut = async (client, account) => {
269
+ // Loaded first: a chunk that won't load fails the sign-out while the
270
+ // client still works, rather than after it closed.
271
+ const { createClient } = await loadLocalFirst();
272
+ await client.db.waitForSync({ timeoutMs: 5_000 }).catch(() => { });
273
+ // What this tab counts itself, for a worker too old to count the store.
274
+ const ownPending = client.db.getSyncStatus().pendingUploads;
275
+ await client.shutdown();
276
+ const outcome = await wipeReplica(() => openLocalFirst(createClient, account), account.id, ownPending);
277
+ if (outcome === "held") {
278
+ // The account can't be opened once signed out: open the client the
279
+ // retry deletes through now. It holds no replica, so it keeps no tab's
280
+ // wipe waiting, and it stays a client of the store the other tab has
281
+ // open. Without it, a later load's sweep wipes a recorded user.
282
+ const parked = await openLocalFirst(createClient, account).catch(() => undefined);
283
+ if (parked)
284
+ retryWipe(account, async () => parked, ownPending, parked);
285
+ }
286
+ else if (outcome === "given-up" && rememberBackendUser(account)) {
287
+ // Its open hung: reopen the user from the record, as a later load would.
288
+ retryWipe(account, () => reopenSignedOut(account, createClient), ownPending);
289
+ }
290
+ return outcome === "wiped";
291
+ };
292
+ /** A signed-out backend user's local-first client, reopened from what the record keeps. */
293
+ const reopenSignedOut = async (account, createDb) => {
294
+ const { issuer, subject } = account.identity;
295
+ const remembered = await createAccountManagerWithMinter({
296
+ ...config,
297
+ serverUrl,
298
+ store: rememberedUserStore({ account: account.id, identity: { issuer, subject } }),
299
+ }, mintLocalFirstTokenInJs);
300
+ const reopened = remembered.getLoggedIn();
301
+ if (!reopened)
302
+ throw new Error("Jazz could not reopen the signed-out user to wipe");
303
+ return openLocalFirst(createDb, reopened);
304
+ };
113
305
  let session;
114
306
  const openLocalFirst = (createDb, account) => createRegisteredJazzClient("web", { ...clientConfig, account }, createDb);
115
307
  const upgrade = async (loader) => {
@@ -130,10 +322,8 @@ export async function createJazzClient(config) {
130
322
  }, (current, next) => upgradesInPlace.get(current)(next));
131
323
  // Only once the session took the new client: a superseded upgrade
132
324
  // (a logout or account switch meanwhile) is not remembered.
133
- if (upgraded) {
325
+ if (upgraded)
134
326
  upgrades.remember(upgraded);
135
- inSession.add(upgraded.id);
136
- }
137
327
  };
138
328
  const openThin = async (account) => {
139
329
  const thin = await createRegisteredJazzClient("web-thin", { ...clientConfig, account }, createThinDb);
@@ -147,36 +337,47 @@ export async function createJazzClient(config) {
147
337
  return upgradableClient(thin);
148
338
  };
149
339
  const openClient = async (account) => {
150
- if (loadLocalFirst && upgrades.has(account)) {
340
+ if (loadLocalFirst && (localFirst === "now" || upgrades.has(account))) {
151
341
  let module;
152
342
  try {
153
343
  module = await loadLocalFirst();
154
344
  }
155
345
  catch (error) {
346
+ // Asked for local-first now: running thin would quietly break what
347
+ // the app needs it for (offline, db.transaction).
348
+ if (localFirst === "now")
349
+ throw error;
156
350
  // A chunk that no longer loads (renamed by a deploy, or the network)
157
351
  // costs the app its offline start, not the session: it runs thin,
158
352
  // and the background upgrade tries the loader again.
159
353
  console.warn("Jazz could not load the local-first client; starting thin.", error);
160
354
  return openThin(account);
161
355
  }
162
- const client = await openReplica(module.createClient, account);
163
- inSession.add(account.id);
164
- return client;
356
+ return openReplica(module.createClient, account);
165
357
  }
166
358
  return openThin(account);
167
359
  };
168
360
  session = await createJazzSessionOwner({
169
361
  accounts,
170
- initial,
362
+ initial: coreInitial(initial),
171
363
  // A memory-only client has no storage to wipe.
172
364
  clearOnSignOut: wipesOnSignOut,
365
+ ...(leftBehind ? { wipeSignedOut } : {}),
173
366
  openClient,
174
367
  decorate: followUser({
175
368
  registry,
176
369
  events: browserBackendWatchEvents(`jazz-account:${registry}`),
177
- linkGuest: linkGuestOnSignUp,
178
- // Without cookies, the bearer is what names the user to the backend.
179
- ...(bearer ? { fetch: bearerFetch(bearer, config.fetch) } : {}),
370
+ linkGuest: linkDeviceAccountOnSignUp,
371
+ forgotten: (account) => accountForgotten(accounts, account.id),
372
+ watchAccounts: (changed) => watchStoredSelection(accounts, changed),
373
+ // Ask "who is signed in" the way sign-in asks: through the app's own
374
+ // `fetch` when it gives one, and with its bearer when it has no cookies.
375
+ ...(bearer
376
+ ? { fetch: bearerFetch(bearer, config.fetch) }
377
+ : config.fetch
378
+ ? { fetch: config.fetch }
379
+ : {}),
380
+ onSignedOut,
180
381
  }),
181
382
  });
182
383
  if (loadLocalFirst)
@@ -184,19 +385,6 @@ export async function createJazzClient(config) {
184
385
  if (leftBehind && loadLocalFirst) {
185
386
  const record = leftBehind;
186
387
  const following = session;
187
- // Signed out in this page: the session wiped the replica as it did.
188
- following.subscribe(() => {
189
- const { status, account } = following.getSnapshot();
190
- if (status !== "ready" && status !== "signed-out")
191
- return;
192
- for (const id of inSession) {
193
- if (id === account?.id)
194
- continue;
195
- inSession.delete(id);
196
- signedOutHere.add(id);
197
- forgetSignedOut(id);
198
- }
199
- });
200
388
  const stillLeftBehind = (account) => following.getSnapshot().status !== "closed" &&
201
389
  !opening.has(account) &&
202
390
  following.getSnapshot().account?.id !== account;
@@ -280,6 +468,8 @@ export async function createJazzClient(config) {
280
468
  const LOCAL_FIRST_ISSUER = "urn:jazz:local-first";
281
469
  /** As the backend watch confirms a signed-out answer before it signs anyone out. */
282
470
  const CONFIRM_SIGNED_OUT_MS = 2_000;
471
+ /** How often a page tries again a sign-out's wipe that another tab held off. */
472
+ export const WIPE_RETRY_MS = 15_000;
283
473
  /** Resolves once `session` is ready or signed out. */
284
474
  function settledSession(session) {
285
475
  return new Promise((resolve) => {
@@ -352,12 +542,12 @@ function upgradableClient(thin) {
352
542
  * client straight away, on this browser's local-first account.
353
543
  */
354
544
  async function createDeviceOnlySession(config) {
355
- const { initial, clearOnSignOut, linkGuestOnSignUp: _linkGuestOnSignUp, client: loadLocalFirst, store: _store, fetch: _fetch, ...rest } = config;
545
+ const { initial, clearOnSignOut, linkDeviceAccountOnSignUp: _linkDeviceAccountOnSignUp, localFirst: _localFirst, onSignedOut: _onSignedOut, client: loadLocalFirst, store: _store, fetch: _fetch, ...rest } = config;
356
546
  if (!loadLocalFirst) {
357
547
  throw new Error('serverUrl: null keeps Jazz on this device, which needs the local-first client: pass client: () => import("jazz-tools/local-first")');
358
548
  }
359
- if (initial !== undefined && initial !== "local-first") {
360
- throw new Error('serverUrl: null has no backend to sign in through, so it always opens this device\'s local-first account: leave out initial or set it to "local-first"');
549
+ if (coreInitial(initial) === "signed-out") {
550
+ throw new Error('serverUrl: null has no backend to sign in through, so it always opens this device\'s device account: leave out initial or set it to "device"');
361
551
  }
362
552
  const { serverUrl: _serverUrl, ...clientConfig } = rest;
363
553
  refuseUnkeptOptions(clientConfig);
@@ -445,4 +635,13 @@ function localFirstMemory(registry) {
445
635
  },
446
636
  };
447
637
  }
638
+ /** `localFirst`, checked: a timing the session can't honour fails by name. */
639
+ function refuseLocalFirstTiming(localFirst, loader) {
640
+ if (localFirst === undefined || localFirst === "background")
641
+ return;
642
+ if (localFirst !== "now")
643
+ throw new Error(`Unknown localFirst ${JSON.stringify(localFirst)}; expected "now" or "background"`);
644
+ if (!loader)
645
+ throw new Error('localFirst: "now" opens the local-first client, which needs the `client` loader: pass client: () => import("jazz-tools/local-first")');
646
+ }
448
647
  //# sourceMappingURL=create-jazz-session.js.map