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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"page-handle.js","sourceRoot":"","sources":["../../src/runtime/page-handle.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,sEAAsE;AACtE,6CAA6C;AAC7C,EAAE;AACF,sDAAsD;AACtD,gFAAgF;AAChF,EAAE;AACF,2EAA2E;AAC3E,0EAA0E;AAsE1E,MAAM,UAAU,sBAAsB,CAAC,aAAqB;IAC1D,IAAI,CAAC,aAAa,CAAC,6BAA6B,EAAE,CAAC;QACjD,aAAa,CAAC,6BAA6B,GAAG,IAAI,GAAG,EAAE,CAAC;IAC1D,CAAC;IAED,OAAO,aAAa,CAAC,6BAA6B,CAAC;AACrD,CAAC;AAED,SAAS,yBAAyB,CAAC,aAAqB;IACtD,OAAO;QACL,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,sBAAsB,CAAC,aAAa,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;KACvF,CAAC,IAAI,EAAE,CAAC;AACX,CAAC;AAED,SAAS,yBAAyB,CAAC,UAA6B;IAC9D,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC5B,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,OAAO,0BAA0B,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;AAC5D,CAAC;AAED,SAAS,oBAAoB,CAAC,aAAqB,EAAE,SAAkB;IACrE,MAAM,YAAY,GAAG,CAAC,GAAG,sBAAsB,CAAC,aAAa,CAAC,CAAC,CAAC;IAChE,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BAAmB,EAAE,CAAC;QACpE,CAAC;QACD,yBAAyB;YACvB,OAAO,yBAAyB,CAAC,IAAI,CAAC,CAAC;QACzC,CAAC;QACD,KAAK,CAAC,QAAQ,CAAC,SAAkB;YAC/B,MAAM,QAAQ,GAAG,CAAC,GAAG,sBAAsB,CAAC,IAAI,CAAC,CAAC,CAAC;YACnD,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;gBAAE,OAAO;YAClC,MAAM,OAAO,GAAG,SAAS,EAAE,IAAI,EAAE,CAAC;YAClC,MAAM,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,SAAS,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;YAC7F,MAAM,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;QACjE,CAAC;KACF,CAAyC,CAAC;IAC3C,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC;IAClB,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["// `window.__jazz`: the sync state of the page's Jazz databases, for an agent\n// or a test driving the page through Playwright or a browser, without\n// scraping the UI or reaching into app code:\n//\n// await page.evaluate(() => window.__jazz.status())\n// await page.evaluate(() => window.__jazz.waitForSync({ timeoutMs: 10_000 }))\n//\n// It carries only sync state, never data or credentials, so it is there in\n// production too: any script on the page can already reach the Db itself.\n\nimport type { SyncStatus } from \"./sync-status.js\";\n\n/** What `window.__jazz` needs from a Db. */\nexport interface PageDb {\n getSyncStatus(): SyncStatus;\n waitForSync(options?: { timeoutMs?: number; signal?: AbortSignal }): Promise<void>;\n}\n\nexport interface PageDbInfo {\n /** The app the Db belongs to, as configured (`appId`). */\n appId: string | null;\n status: SyncStatus;\n}\n\n/** `window.__jazz`. Version 1 promises the shape below and nothing more. */\nexport interface JazzPageHandle {\n readonly version: 1;\n /**\n * The sync status of the page's Db (see `db.getSyncStatus()`), or null\n * while none is open. With several open, the one opened last.\n */\n status(): SyncStatus | null;\n /** How many of this page's committed transactions the server hasn't accepted or rejected yet. */\n pending(): number;\n /** Every open Db, oldest first. */\n dbs(): PageDbInfo[];\n /**\n * Resolve once every open Db's writes so far are accepted by the server\n * (see `db.waitForSync()`): rejects with the first rejection, or a timeout.\n */\n waitForSync(options?: { timeoutMs?: number }): Promise<void>;\n}\n\n// Clearing and shutting down a page's persistent client storage, from\n// window-client-storage.ts, shares the same object.\nexport type WindowJazzStorageDb = {\n deleteClientStorage(): Promise<void>;\n shutdown(): Promise<void>;\n};\n\nexport type LiveStorageContext = {\n db: WindowJazzStorageDb;\n namespace: string;\n};\n\nexport interface WindowJazzClientApi {\n clearStorage(namespace?: string): Promise<void>;\n listLiveStorageNamespaces(): string[];\n /**\n * Shut down live Jazz client storage contexts and await full cleanup\n * (runtime teardown and pending IndexedDB persistence). Pass a namespace to target\n * one context; with no argument, shuts down every live context.\n *\n * Resolves once all targets have completed shutdown. Db.shutdown is\n * idempotent, so this is safe to call alongside framework-driven cleanup\n * (e.g. JazzProvider unmount).\n */\n shutdown(namespace?: string): Promise<void>;\n}\n\ndeclare global {\n interface Window {\n /** Present once a Jazz Db opened on the page. */\n __jazz?: WindowJazzClientApi & JazzPageHandle;\n __jazzWindowStorageContexts__?: Set<LiveStorageContext>;\n }\n}\n\nexport function getLiveStorageContexts(currentWindow: Window): Set<LiveStorageContext> {\n if (!currentWindow.__jazzWindowStorageContexts__) {\n currentWindow.__jazzWindowStorageContexts__ = new Set();\n }\n\n return currentWindow.__jazzWindowStorageContexts__;\n}\n\nfunction listLiveStorageNamespaces(currentWindow: Window): string[] {\n return [\n ...new Set([...getLiveStorageContexts(currentWindow)].map((entry) => entry.namespace)),\n ].sort();\n}\n\nfunction formatAvailableNamespaces(namespaces: readonly string[]): string {\n if (namespaces.length === 0) {\n return \"\";\n }\n\n return ` Available namespaces: ${namespaces.join(\", \")}.`;\n}\n\nfunction resolveStorageTarget(currentWindow: Window, namespace?: string): WindowJazzStorageDb {\n const liveContexts = [...getLiveStorageContexts(currentWindow)];\n const namespaces = listLiveStorageNamespaces(currentWindow);\n\n if (liveContexts.length === 0) {\n throw new Error(\"No live Jazz storage contexts are available on this page.\");\n }\n\n const trimmedNamespace = namespace?.trim();\n if (!trimmedNamespace) {\n if (namespaces.length === 1) {\n const [onlyNamespace] = namespaces;\n return liveContexts.find((entry) => entry.namespace === onlyNamespace)!.db;\n }\n\n throw new Error(\n `Multiple live Jazz storage contexts are available. Call window.__jazz.clearStorage(\"<namespace>\").${formatAvailableNamespaces(\n namespaces,\n )}`,\n );\n }\n\n const match = liveContexts.find((entry) => entry.namespace === trimmedNamespace);\n if (!match) {\n throw new Error(\n `No live Jazz storage context matches \"${trimmedNamespace}\".${formatAvailableNamespaces(\n namespaces,\n )}`,\n );\n }\n\n return match.db;\n}\n\nconst open = new Map<PageDb, string | null>();\n\nfunction handle(): JazzPageHandle {\n const latest = () => [...open.keys()].at(-1) ?? null;\n return {\n version: 1,\n status: () => latest()?.getSyncStatus() ?? null,\n pending: () => [...open.keys()].reduce((sum, db) => sum + db.getSyncStatus().pendingUploads, 0),\n dbs: () => [...open].map(([db, appId]) => ({ appId, status: db.getSyncStatus() })),\n waitForSync: async (options = {}) => {\n await Promise.all([...open.keys()].map((db) => db.waitForSync(options)));\n },\n };\n}\n\n/**\n * List `db` on `window.__jazz` until the returned function is called. Does\n * nothing outside a browser page (Node, workers, React Native).\n */\nexport function registerPageDb(db: PageDb, appId: string | null): () => void {\n const page = (globalThis as { window?: Window }).window;\n if (!page || typeof page.document === \"undefined\") return () => {};\n open.set(db, appId);\n ensureWindowJazz(page);\n return () => {\n open.delete(db);\n };\n}\n\n/**\n * Marks the `window.__jazz` Jazz installed, so a later install (another\n * client, another copy of jazz-tools on the page) extends it, and a value the\n * app put there is told apart. `Symbol.for`, so every copy agrees.\n */\nconst JAZZ_PAGE_HANDLE = Symbol.for(\"jazz-tools.window-jazz\");\n\n/**\n * `window.__jazz` is reserved for Jazz: it is set by the first Db opened on\n * the page. A value the app (or another library) put there first is refused\n * by name rather than overwritten, or extended (it may be sealed or frozen).\n */\nexport class WindowJazzConflictError extends Error {\n constructor(existing: unknown) {\n super(\n `window.__jazz is reserved for Jazz (its page handle: window.__jazz.status(), waitForSync(), clearStorage()), and this page already has a window.__jazz that Jazz didn't set (${\n existing === null ? \"null\" : typeof existing\n }). Rename your app's global: Jazz doesn't overwrite it.`,\n );\n this.name = \"WindowJazzConflictError\";\n }\n}\n\n/**\n * Throw {@link WindowJazzConflictError} if `page` has a `window.__jazz` Jazz\n * didn't set. A browser session checks this when it starts, so the conflict\n * shows there rather than when a Db first opens (on the thin client, which\n * doesn't install it, only at the upgrade to local-first).\n */\nexport function refuseWindowJazzConflict(page: Window): void {\n const existing = page.__jazz as unknown;\n if (existing === undefined) return;\n if (isJazzPageHandle(existing)) return;\n throw new WindowJazzConflictError(existing);\n}\n\n/**\n * Jazz's own `window.__jazz`: marked by this or a later copy of jazz-tools,\n * or, from a copy before the mark (alpha.60 and earlier), the version-1\n * handle shape, which it extends as before.\n */\nfunction isJazzPageHandle(value: unknown): value is Record<string | symbol, unknown> {\n if (!value || typeof value !== \"object\") return false;\n if (JAZZ_PAGE_HANDLE in value) return true;\n const legacy = value as { version?: unknown; status?: unknown };\n return legacy.version === 1 && typeof legacy.status === \"function\";\n}\n\n/** Install `window.__jazz` (storage and sync status), extending the one Jazz installed. */\nexport function ensureWindowJazz(page: Window): WindowJazzClientApi & JazzPageHandle {\n refuseWindowJazzConflict(page);\n const existing = page.__jazz as unknown;\n const host = (existing as Record<string | symbol, unknown> | undefined) ?? {};\n // An older copy's handle gets the mark too, for copies after this one.\n host[JAZZ_PAGE_HANDLE] = true;\n const api = Object.assign(host, handle(), {\n async clearStorage(namespace?: string): Promise<void> {\n await resolveStorageTarget(page, namespace).deleteClientStorage();\n },\n listLiveStorageNamespaces(): string[] {\n return listLiveStorageNamespaces(page);\n },\n async shutdown(namespace?: string): Promise<void> {\n const contexts = [...getLiveStorageContexts(page)];\n if (contexts.length === 0) return;\n const trimmed = namespace?.trim();\n const targets = trimmed ? contexts.filter((entry) => entry.namespace === trimmed) : contexts;\n await Promise.all(targets.map((entry) => entry.db.shutdown()));\n },\n }) as WindowJazzClientApi & JazzPageHandle;\n page.__jazz = api;\n return api;\n}\n"]}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * The framework providers used to open the Inspector overlay on their own in
3
+ * development, and took `autoAttachDevTools` to opt out. They no longer do:
4
+ * a page mounts the overlay itself with `mountInspector(db)` from
5
+ * `jazz-tools/inspector`. Refuse the old prop (plain JavaScript, a Vue
6
+ * template, a cast), so it can't slip through into the client config.
7
+ */
8
+ export declare function refuseAutoAttachDevTools(provider: string, props: object): void;
9
+ /** The prop type the providers declare, so TypeScript refuses it too. */
10
+ export interface NoAutoAttachDevTools {
11
+ /**
12
+ * Removed: providers no longer open the Inspector overlay. Call
13
+ * `mountInspector(db)` from `jazz-tools/inspector` in development instead.
14
+ */
15
+ autoAttachDevTools?: never;
16
+ }
17
+ //# sourceMappingURL=removed-provider-props.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"removed-provider-props.d.ts","sourceRoot":"","sources":["../../src/runtime/removed-provider-props.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAS9E;AAED,yEAAyE;AACzE,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,kBAAkB,CAAC,EAAE,KAAK,CAAC;CAC5B"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * The framework providers used to open the Inspector overlay on their own in
3
+ * development, and took `autoAttachDevTools` to opt out. They no longer do:
4
+ * a page mounts the overlay itself with `mountInspector(db)` from
5
+ * `jazz-tools/inspector`. Refuse the old prop (plain JavaScript, a Vue
6
+ * template, a cast), so it can't slip through into the client config.
7
+ */
8
+ export function refuseAutoAttachDevTools(provider, props) {
9
+ const given = props;
10
+ if (given.autoAttachDevTools === undefined && given["auto-attach-dev-tools"] === undefined)
11
+ return;
12
+ throw new Error(`${provider} takes no autoAttachDevTools: providers no longer open the Inspector overlay. ` +
13
+ 'Remove the prop. To show the overlay, call mountInspector(db) from "jazz-tools/inspector" ' +
14
+ "in development.");
15
+ }
16
+ //# sourceMappingURL=removed-provider-props.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"removed-provider-props.js","sourceRoot":"","sources":["../../src/runtime/removed-provider-props.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,UAAU,wBAAwB,CAAC,QAAgB,EAAE,KAAa;IACtE,MAAM,KAAK,GAAG,KAAgC,CAAC;IAC/C,IAAI,KAAK,CAAC,kBAAkB,KAAK,SAAS,IAAI,KAAK,CAAC,uBAAuB,CAAC,KAAK,SAAS;QACxF,OAAO;IACT,MAAM,IAAI,KAAK,CACb,GAAG,QAAQ,gFAAgF;QACzF,4FAA4F;QAC5F,iBAAiB,CACpB,CAAC;AACJ,CAAC","sourcesContent":["/**\n * The framework providers used to open the Inspector overlay on their own in\n * development, and took `autoAttachDevTools` to opt out. They no longer do:\n * a page mounts the overlay itself with `mountInspector(db)` from\n * `jazz-tools/inspector`. Refuse the old prop (plain JavaScript, a Vue\n * template, a cast), so it can't slip through into the client config.\n */\nexport function refuseAutoAttachDevTools(provider: string, props: object): void {\n const given = props as Record<string, unknown>;\n if (given.autoAttachDevTools === undefined && given[\"auto-attach-dev-tools\"] === undefined)\n return;\n throw new Error(\n `${provider} takes no autoAttachDevTools: providers no longer open the Inspector overlay. ` +\n 'Remove the prop. To show the overlay, call mountInspector(db) from \"jazz-tools/inspector\" ' +\n \"in development.\",\n );\n}\n\n/** The prop type the providers declare, so TypeScript refuses it too. */\nexport interface NoAutoAttachDevTools {\n /**\n * Removed: providers no longer open the Inspector overlay. Call\n * `mountInspector(db)` from `jazz-tools/inspector` in development instead.\n */\n autoAttachDevTools?: never;\n}\n"]}
@@ -64,7 +64,10 @@ export interface BrowserWorkerConnection {
64
64
  updateAuth(authJson: string, sessionClaims: Record<string, unknown>): Promise<void>;
65
65
  disconnect(): Promise<void>;
66
66
  reconnect(authJson: string, sessionClaims: Record<string, unknown>): Promise<void>;
67
- deleteStorage(): Promise<void>;
67
+ /** Delete the store; resolves with how many unconfirmed writes it took, when the worker says. */
68
+ deleteStorage(): Promise<{
69
+ pendingUploads?: number;
70
+ } | void>;
68
71
  flushLocal(): Promise<void>;
69
72
  waitForPendingWrites(): Promise<void>;
70
73
  openInspectorControlPort(signal?: AbortSignal): Promise<MessagePort>;
@@ -1 +1 @@
1
- {"version":3,"file":"runtime-source.d.ts","sourceRoot":"","sources":["../../src/runtime/runtime-source.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,oBAAoB,CAAC,aAAa,SAAS,QAAQ,GAAG,QA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ACrF,uBAAuB,KAAU,CAAC;IAElC,gFAAgF;IAChF,mBAAmB,CAAC,MAAc;QAChC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,gFAAgF;IAChF,WAAW,CAAC,OAAsB,IAAS,CAAC;IAK5C;0EACsE;IACtE,KAAK,CAAC,QAAQ,KAAmB,CAAC;IAExB,KAAK,CAAC,WAAW,CAAC,OAAsB;QAChD,OAAO,SAAS,CAAC;IACnB,CAAC;IAID;;;OAGG;IACH,KAAK,CAAC,0BAA0B,CAC9B,OAAsB;QAEtB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,iCAAiC,CAAC,OAAsB;QACtD,OAAO,OAAO,CAAC,MAAM,CACnB,IAAI,KAAK,CAAC,8DAA8D,CAAC,CAC1E,CAAC;IACJ,CAAC;IAED,6BAA6B,CAC3B,QAAuD;QAEvD,MAAM,IAAI,KAAK,CAAC,+DAA+D,CAAC,CAAC;IACnF,CAAC;IAED,+BAA+B,CAC7B,QAAyD;QAEzD,MAAM,IAAI,KAAK,CAAC,iEAAiE,CAAC,CAAC;IACrF,CAAC;IAED,gBAAgB,CACd,QAAgD;QAEhD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,0EAA0E;IAC1E,mBAAmB,CAAC,OAA4B;QAC9C,OAAO,2BAA2B,CAChC,OAAO,CAAC,MAAM,EACd,OAAO,CAAC,QAAQ,EAChB,OAAO,CAAC,UAAU,EAClB,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAC3B,CAAC;IACJ,CAAC;IAED,kBAAkB,CAAC,QAA6B;QAC9C,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;IACvE,CAAC;IAED,WAAW;QACT,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;IACzE,CAAC;CACF","sourcesContent":["import { mintLocalFirstTokenFromSeed } from \"./local-first-token.js\";\nimport type { ClientMigrations } from \"./client-migrations.js\";\nimport type { RemoteLinkState } from \"./remote-link-state.js\";\nimport type { LinkStatus } from \"./sync-status.js\";\nimport type { WasmSchema } from \"../drivers/types.js\";\nimport type { JazzClient } from \"./client.js\";\nimport type { DbConfig } from \"./db.js\";\nimport type { AuthFailureReason } from \"./auth-state.js\";\nimport type { TextAnchors } from \"./text-anchors.js\";\n\nexport interface RuntimeTokenOptions {\n secret: string;\n audience: string;\n ttlSeconds: number;\n nowSeconds: bigint;\n}\n\nexport interface RuntimeClientContext<RuntimeConfig extends DbConfig = DbConfig> {\n config: RuntimeConfig;\n schema: WasmSchema;\n /** The migrations the app defining `schema` ships (see {@link ClientMigrations}). */\n migrations?: ClientMigrations;\n onAuthFailure: (reason: AuthFailureReason) => void;\n /**\n * Browser-only identity leased by the durable SharedWorker before the\n * synchronous foreground client is constructed.\n */\n foregroundNodeLease?: ForegroundNodeLease;\n}\n\n/** Internal foreground TxId lease, never exposed as application API. */\nexport interface ForegroundNodeLease {\n readonly node: Uint8Array;\n readonly confirmedTxTime: bigint;\n /** Atomically persists runtime high-water and makes this node reusable. */\n returnWithHighWater(highWater: bigint): Promise<void>;\n /** Permanently retires this node when clean handoff is not certain. */\n retire(): Promise<void>;\n}\n\n/** Browser-only terminal cleanup; the durable retirement outcome remains unknown. */\nexport interface BrowserForegroundNodeLease extends ForegroundNodeLease {\n /** Ephemeral owner identity; a successor realm cannot acknowledge this port. */\n readonly workerRealmId?: string;\n /** The caller must first disable the foreground lifetime that can mint this node's TxIds. */\n abandonAfterWorkerFailure(error: Error): void;\n /** Locally releases an erased epoch after its worker-authored reset receipt; never writes a handoff. */\n releaseAfterStorageReset(reason: Error): void;\n /** Release a dead owner's port after quiescing; its node remains non-reusable. */\n releaseAfterWorkerReplacement?(reason: Error): void;\n}\n\nexport interface RuntimeTelemetryContext<RuntimeConfig extends DbConfig = DbConfig> {\n config: RuntimeConfig;\n collectorUrl: string;\n runtimeThread: \"main\" | \"worker\";\n}\n\nexport interface BrowserWorkerConnection {\n /** Only a rejected initial configuration admission permits a later API call to retry. */\n canRetryInitialConfigurationAdmission?(): boolean;\n /**\n * The worker refused this connection because another tab holds the store\n * under another sign-in to the same account: the tab tries again on its\n * own (see `BROWSER_STORE_HELD_BY_ANOTHER_SIGN_IN`).\n */\n waitsForAnotherSignIn?(): boolean;\n ready(): Promise<void>;\n getWorkerRealmId?(): string | undefined;\n waitForServerConnection(): Promise<void>;\n updateAuth(authJson: string, sessionClaims: Record<string, unknown>): Promise<void>;\n disconnect(): Promise<void>;\n reconnect(authJson: string, sessionClaims: Record<string, unknown>): Promise<void>;\n deleteStorage(): Promise<void>;\n flushLocal(): Promise<void>;\n waitForPendingWrites(): Promise<void>;\n openInspectorControlPort(signal?: AbortSignal): Promise<MessagePort>;\n shutdown(): Promise<void>;\n /** Present only after an authenticated Inspector control-port attachment. */\n getAuthenticatedInspectorAttachmentPhysicalDbName?(): string | null;\n}\n\nexport interface BrowserFollowerConnection {\n ready(): Promise<void>;\n flushLocal(): Promise<void>;\n waitForPendingWrites(): Promise<void>;\n waitForServerConnection(): Promise<void>;\n updateAuth(authJson: string, sessionClaims: Record<string, unknown>): void;\n detachForReconnect(): void;\n shutdown(): Promise<void>;\n}\n\nexport interface BrowserWorkerConnectionContext<RuntimeConfig extends DbConfig = DbConfig> {\n config: RuntimeConfig;\n schema: WasmSchema;\n client: JazzClient;\n onAuthFailure: (reason: AuthFailureReason) => void;\n onAuthRestored: () => void;\n /** The worker namespace's explicit offline state changed. */\n onExplicitOfflineChange?: (offline: boolean) => void;\n /** The worker's live upstream server reachability changed. */\n onRemoteLinkChange?: (state: RemoteLinkState, link?: LinkStatus) => void;\n onFailure: (error: unknown) => void;\n onStorageReset?: (resetId: number) => void;\n onStorageInvalidated?: () => void;\n}\n\nexport interface BrowserFollowerConnectionContext<RuntimeConfig extends DbConfig = DbConfig> {\n config: RuntimeConfig;\n client: JazzClient;\n port: MessagePort;\n onAuthFailure: (reason: AuthFailureReason) => void;\n onAuthRestored: () => void;\n /** The worker namespace's explicit offline state changed. */\n onExplicitOfflineChange?: (offline: boolean) => void;\n /** The worker's live upstream server reachability changed. */\n onRemoteLinkChange?: (state: RemoteLinkState, link?: LinkStatus) => void;\n onFailure: (error: unknown) => void;\n onStorageReset?: (resetId: number) => void;\n onStorageInvalidated?: () => void;\n}\n\n/**\n * Internal source for loading and wiring the native runtime.\n *\n * This keeps platform/source differences (WASM, NAPI, browser storage, React\n * Native support status) out of Db. The active database path is native-runtime backed:\n * implementations preload the runtime, then create JazzClient instances for\n * concrete schemas.\n */\nexport abstract class RuntimeSource<RuntimeConfig extends DbConfig = DbConfig> {\n /** Set to true when this source can host browser persistence in a dedicated worker. */\n readonly supportsBrowserWorker: boolean = false;\n /** Set to false when the runtime must receive schemas exactly as declared. */\n readonly supportsPolicyBypass: boolean = true;\n\n async load(config: RuntimeConfig): Promise<void> {\n await this.loadRuntime(config);\n }\n\n /** Native hosts own their transport before a schema client is materialized. */\n nativeConnection?: {\n configured(): boolean;\n disconnect(): void | Promise<void>;\n reconnect(): void | Promise<void>;\n /**\n * Native hosts that share one transport between several Db facades own\n * explicit-offline state at the host, rather than on an individual facade.\n */\n isExplicitlyOffline?(): boolean;\n waitForTransportTransition?(): Promise<void>;\n waitForReconnect?(signal?: AbortSignal): Promise<void>;\n onExplicitOfflineChange?(listener: (offline: boolean) => void, signal: AbortSignal): void;\n };\n\n /** Admission-bound native sources reject updates before any public state changes. */\n assertAuthUpdateAllowed(): void {}\n\n /** Return true when the native host renewed its own same-identity transport. */\n refreshAccountToken(_token: string): boolean {\n return false;\n }\n\n /** Apply source-specific admission after the shared auth config is resolved. */\n admitConfig(_config: RuntimeConfig): void {}\n\n /** Shared native hosts supply the pending-write barrier for all their facades. */\n waitForPendingWrites?(signal?: AbortSignal): Promise<void>;\n\n /** Release runtime admission after ordinary client shutdown, including a\n * prepared source whose lazy schema client was never materialized. */\n async shutdown(): Promise<void> {}\n\n protected async loadRuntime(_config: RuntimeConfig): Promise<unknown> {\n return undefined;\n }\n\n abstract createClient(context: RuntimeClientContext<RuntimeConfig>): JazzClient;\n\n /**\n * Optional pre-runtime foreground identity lease for non-browser hosts.\n * Browser persistence uses the dedicated SharedWorker variant below.\n */\n async acquireForegroundNodeLease(\n _config: RuntimeConfig,\n ): Promise<ForegroundNodeLease | undefined> {\n return undefined;\n }\n\n acquireBrowserForegroundNodeLease(_config: RuntimeConfig): Promise<BrowserForegroundNodeLease> {\n return Promise.reject(\n new Error(\"Db runtime source does not support browser foreground leases\"),\n );\n }\n\n createBrowserWorkerConnection(\n _context: BrowserWorkerConnectionContext<RuntimeConfig>,\n ): BrowserWorkerConnection {\n throw new Error(\"Db runtime source does not support browser worker connections\");\n }\n\n createBrowserFollowerConnection(\n _context: BrowserFollowerConnectionContext<RuntimeConfig>,\n ): BrowserFollowerConnection {\n throw new Error(\"Db runtime source does not support browser follower connections\");\n }\n\n installTelemetry(\n _context: RuntimeTelemetryContext<RuntimeConfig>,\n ): (() => void) | null | undefined {\n return null;\n }\n\n /** Same on every host: minted in TypeScript by `src/local-first-auth`. */\n mintLocalFirstToken(options: RuntimeTokenOptions): string {\n return mintLocalFirstTokenFromSeed(\n options.secret,\n options.audience,\n options.ttlSeconds,\n Number(options.nowSeconds),\n );\n }\n\n mintAnonymousToken(_options: RuntimeTokenOptions): string {\n throw new Error(\"Db runtime source does not support anonymous auth\");\n }\n\n textAnchors(): TextAnchors {\n throw new Error(\"Db runtime source does not support text anchors yet\");\n }\n}\n"]}
1
+ {"version":3,"file":"runtime-source.js","sourceRoot":"","sources":["../../src/runtime/runtime-source.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AA2HrE;;;;;;;GAOG;AACH,MAAM,OAAgB,aAAa;IACjC,uFAAuF;IAC9E,qBAAqB,GAAY,KAAK,CAAC;IAChD,8EAA8E;IACrE,oBAAoB,GAAY,IAAI,CAAC;IAE9C,KAAK,CAAC,IAAI,CAAC,MAAqB;QAC9B,MAAM,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC;IAED,+EAA+E;IAC/E,gBAAgB,CAYd;IAEF,qFAAqF;IACrF,uBAAuB,KAAU,CAAC;IAElC,gFAAgF;IAChF,mBAAmB,CAAC,MAAc;QAChC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,gFAAgF;IAChF,WAAW,CAAC,OAAsB,IAAS,CAAC;IAK5C;0EACsE;IACtE,KAAK,CAAC,QAAQ,KAAmB,CAAC;IAExB,KAAK,CAAC,WAAW,CAAC,OAAsB;QAChD,OAAO,SAAS,CAAC;IACnB,CAAC;IAID;;;OAGG;IACH,KAAK,CAAC,0BAA0B,CAC9B,OAAsB;QAEtB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,iCAAiC,CAAC,OAAsB;QACtD,OAAO,OAAO,CAAC,MAAM,CACnB,IAAI,KAAK,CAAC,8DAA8D,CAAC,CAC1E,CAAC;IACJ,CAAC;IAED,6BAA6B,CAC3B,QAAuD;QAEvD,MAAM,IAAI,KAAK,CAAC,+DAA+D,CAAC,CAAC;IACnF,CAAC;IAED,+BAA+B,CAC7B,QAAyD;QAEzD,MAAM,IAAI,KAAK,CAAC,iEAAiE,CAAC,CAAC;IACrF,CAAC;IAED,gBAAgB,CACd,QAAgD;QAEhD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,0EAA0E;IAC1E,mBAAmB,CAAC,OAA4B;QAC9C,OAAO,2BAA2B,CAChC,OAAO,CAAC,MAAM,EACd,OAAO,CAAC,QAAQ,EAChB,OAAO,CAAC,UAAU,EAClB,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAC3B,CAAC;IACJ,CAAC;IAED,kBAAkB,CAAC,QAA6B;QAC9C,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;IACvE,CAAC;IAED,WAAW;QACT,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;IACzE,CAAC;CACF","sourcesContent":["import { mintLocalFirstTokenFromSeed } from \"./local-first-token.js\";\nimport type { ClientMigrations } from \"./client-migrations.js\";\nimport type { RemoteLinkState } from \"./remote-link-state.js\";\nimport type { LinkStatus } from \"./sync-status.js\";\nimport type { WasmSchema } from \"../drivers/types.js\";\nimport type { JazzClient } from \"./client.js\";\nimport type { DbConfig } from \"./db.js\";\nimport type { AuthFailureReason } from \"./auth-state.js\";\nimport type { TextAnchors } from \"./text-anchors.js\";\n\nexport interface RuntimeTokenOptions {\n secret: string;\n audience: string;\n ttlSeconds: number;\n nowSeconds: bigint;\n}\n\nexport interface RuntimeClientContext<RuntimeConfig extends DbConfig = DbConfig> {\n config: RuntimeConfig;\n schema: WasmSchema;\n /** The migrations the app defining `schema` ships (see {@link ClientMigrations}). */\n migrations?: ClientMigrations;\n onAuthFailure: (reason: AuthFailureReason) => void;\n /**\n * Browser-only identity leased by the durable SharedWorker before the\n * synchronous foreground client is constructed.\n */\n foregroundNodeLease?: ForegroundNodeLease;\n}\n\n/** Internal foreground TxId lease, never exposed as application API. */\nexport interface ForegroundNodeLease {\n readonly node: Uint8Array;\n readonly confirmedTxTime: bigint;\n /** Atomically persists runtime high-water and makes this node reusable. */\n returnWithHighWater(highWater: bigint): Promise<void>;\n /** Permanently retires this node when clean handoff is not certain. */\n retire(): Promise<void>;\n}\n\n/** Browser-only terminal cleanup; the durable retirement outcome remains unknown. */\nexport interface BrowserForegroundNodeLease extends ForegroundNodeLease {\n /** Ephemeral owner identity; a successor realm cannot acknowledge this port. */\n readonly workerRealmId?: string;\n /** The caller must first disable the foreground lifetime that can mint this node's TxIds. */\n abandonAfterWorkerFailure(error: Error): void;\n /** Locally releases an erased epoch after its worker-authored reset receipt; never writes a handoff. */\n releaseAfterStorageReset(reason: Error): void;\n /** Release a dead owner's port after quiescing; its node remains non-reusable. */\n releaseAfterWorkerReplacement?(reason: Error): void;\n}\n\nexport interface RuntimeTelemetryContext<RuntimeConfig extends DbConfig = DbConfig> {\n config: RuntimeConfig;\n collectorUrl: string;\n runtimeThread: \"main\" | \"worker\";\n}\n\nexport interface BrowserWorkerConnection {\n /** Only a rejected initial configuration admission permits a later API call to retry. */\n canRetryInitialConfigurationAdmission?(): boolean;\n /**\n * The worker refused this connection because another tab holds the store\n * under another sign-in to the same account: the tab tries again on its\n * own (see `BROWSER_STORE_HELD_BY_ANOTHER_SIGN_IN`).\n */\n waitsForAnotherSignIn?(): boolean;\n ready(): Promise<void>;\n getWorkerRealmId?(): string | undefined;\n waitForServerConnection(): Promise<void>;\n updateAuth(authJson: string, sessionClaims: Record<string, unknown>): Promise<void>;\n disconnect(): Promise<void>;\n reconnect(authJson: string, sessionClaims: Record<string, unknown>): Promise<void>;\n /** Delete the store; resolves with how many unconfirmed writes it took, when the worker says. */\n deleteStorage(): Promise<{ pendingUploads?: number } | void>;\n flushLocal(): Promise<void>;\n waitForPendingWrites(): Promise<void>;\n openInspectorControlPort(signal?: AbortSignal): Promise<MessagePort>;\n shutdown(): Promise<void>;\n /** Present only after an authenticated Inspector control-port attachment. */\n getAuthenticatedInspectorAttachmentPhysicalDbName?(): string | null;\n}\n\nexport interface BrowserFollowerConnection {\n ready(): Promise<void>;\n flushLocal(): Promise<void>;\n waitForPendingWrites(): Promise<void>;\n waitForServerConnection(): Promise<void>;\n updateAuth(authJson: string, sessionClaims: Record<string, unknown>): void;\n detachForReconnect(): void;\n shutdown(): Promise<void>;\n}\n\nexport interface BrowserWorkerConnectionContext<RuntimeConfig extends DbConfig = DbConfig> {\n config: RuntimeConfig;\n schema: WasmSchema;\n client: JazzClient;\n onAuthFailure: (reason: AuthFailureReason) => void;\n onAuthRestored: () => void;\n /** The worker namespace's explicit offline state changed. */\n onExplicitOfflineChange?: (offline: boolean) => void;\n /** The worker's live upstream server reachability changed. */\n onRemoteLinkChange?: (state: RemoteLinkState, link?: LinkStatus) => void;\n onFailure: (error: unknown) => void;\n onStorageReset?: (resetId: number) => void;\n onStorageInvalidated?: () => void;\n}\n\nexport interface BrowserFollowerConnectionContext<RuntimeConfig extends DbConfig = DbConfig> {\n config: RuntimeConfig;\n client: JazzClient;\n port: MessagePort;\n onAuthFailure: (reason: AuthFailureReason) => void;\n onAuthRestored: () => void;\n /** The worker namespace's explicit offline state changed. */\n onExplicitOfflineChange?: (offline: boolean) => void;\n /** The worker's live upstream server reachability changed. */\n onRemoteLinkChange?: (state: RemoteLinkState, link?: LinkStatus) => void;\n onFailure: (error: unknown) => void;\n onStorageReset?: (resetId: number) => void;\n onStorageInvalidated?: () => void;\n}\n\n/**\n * Internal source for loading and wiring the native runtime.\n *\n * This keeps platform/source differences (WASM, NAPI, browser storage, React\n * Native support status) out of Db. The active database path is native-runtime backed:\n * implementations preload the runtime, then create JazzClient instances for\n * concrete schemas.\n */\nexport abstract class RuntimeSource<RuntimeConfig extends DbConfig = DbConfig> {\n /** Set to true when this source can host browser persistence in a dedicated worker. */\n readonly supportsBrowserWorker: boolean = false;\n /** Set to false when the runtime must receive schemas exactly as declared. */\n readonly supportsPolicyBypass: boolean = true;\n\n async load(config: RuntimeConfig): Promise<void> {\n await this.loadRuntime(config);\n }\n\n /** Native hosts own their transport before a schema client is materialized. */\n nativeConnection?: {\n configured(): boolean;\n disconnect(): void | Promise<void>;\n reconnect(): void | Promise<void>;\n /**\n * Native hosts that share one transport between several Db facades own\n * explicit-offline state at the host, rather than on an individual facade.\n */\n isExplicitlyOffline?(): boolean;\n waitForTransportTransition?(): Promise<void>;\n waitForReconnect?(signal?: AbortSignal): Promise<void>;\n onExplicitOfflineChange?(listener: (offline: boolean) => void, signal: AbortSignal): void;\n };\n\n /** Admission-bound native sources reject updates before any public state changes. */\n assertAuthUpdateAllowed(): void {}\n\n /** Return true when the native host renewed its own same-identity transport. */\n refreshAccountToken(_token: string): boolean {\n return false;\n }\n\n /** Apply source-specific admission after the shared auth config is resolved. */\n admitConfig(_config: RuntimeConfig): void {}\n\n /** Shared native hosts supply the pending-write barrier for all their facades. */\n waitForPendingWrites?(signal?: AbortSignal): Promise<void>;\n\n /** Release runtime admission after ordinary client shutdown, including a\n * prepared source whose lazy schema client was never materialized. */\n async shutdown(): Promise<void> {}\n\n protected async loadRuntime(_config: RuntimeConfig): Promise<unknown> {\n return undefined;\n }\n\n abstract createClient(context: RuntimeClientContext<RuntimeConfig>): JazzClient;\n\n /**\n * Optional pre-runtime foreground identity lease for non-browser hosts.\n * Browser persistence uses the dedicated SharedWorker variant below.\n */\n async acquireForegroundNodeLease(\n _config: RuntimeConfig,\n ): Promise<ForegroundNodeLease | undefined> {\n return undefined;\n }\n\n acquireBrowserForegroundNodeLease(_config: RuntimeConfig): Promise<BrowserForegroundNodeLease> {\n return Promise.reject(\n new Error(\"Db runtime source does not support browser foreground leases\"),\n );\n }\n\n createBrowserWorkerConnection(\n _context: BrowserWorkerConnectionContext<RuntimeConfig>,\n ): BrowserWorkerConnection {\n throw new Error(\"Db runtime source does not support browser worker connections\");\n }\n\n createBrowserFollowerConnection(\n _context: BrowserFollowerConnectionContext<RuntimeConfig>,\n ): BrowserFollowerConnection {\n throw new Error(\"Db runtime source does not support browser follower connections\");\n }\n\n installTelemetry(\n _context: RuntimeTelemetryContext<RuntimeConfig>,\n ): (() => void) | null | undefined {\n return null;\n }\n\n /** Same on every host: minted in TypeScript by `src/local-first-auth`. */\n mintLocalFirstToken(options: RuntimeTokenOptions): string {\n return mintLocalFirstTokenFromSeed(\n options.secret,\n options.audience,\n options.ttlSeconds,\n Number(options.nowSeconds),\n );\n }\n\n mintAnonymousToken(_options: RuntimeTokenOptions): string {\n throw new Error(\"Db runtime source does not support anonymous auth\");\n }\n\n textAnchors(): TextAnchors {\n throw new Error(\"Db runtime source does not support text anchors yet\");\n }\n}\n"]}
@@ -19,6 +19,17 @@ export declare const STORE_HELD_BY_ANOTHER_TAB_ERROR_CODE = "store_held_by_anoth
19
19
  * the other tab lets go. Writes made in the meantime stay in this tab's
20
20
  * memory until it joins: a reload before then loses them.
21
21
  *
22
+ * A wait or read that failed with this error stays failed: it doesn't
23
+ * resume when the tab joins. The writes behind a failed `wait()` are not
24
+ * lost; they go to the store once the tab joins. Call `wait()` (or the
25
+ * read) again once the sync status is no longer `held-by-another-tab`.
26
+ * Calling it while the store is still held fails at once with this error.
27
+ * Live queries that read only this tab's own data keep running throughout.
28
+ *
29
+ * `db.deleteClientStorage()` waits for the store the same way, and fails
30
+ * with this error past the same patience; called again once the other tab
31
+ * lets go, it deletes the store.
32
+ *
22
33
  * Detect it with {@link isStoreHeldByAnotherTabError}, which checks the
23
34
  * stable `code`.
24
35
  */
@@ -1 +1 @@
1
- {"version":3,"file":"store-held-by-another-tab-error.d.ts","sourceRoot":"","sources":["../../src/runtime/store-held-by-another-tab-error.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,eAAO,MAAM,oCAAoC,8BAA8B,CAAC;AAEhF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,0BAA2B,SAAQ,KAAK;IACnD,SAAkB,IAAI,gCAAgC;IACtD,QAAQ,CAAC,IAAI,+BAAwC;gBAGnD,OAAO,SAA2L,EAClM,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE;CAIhC;AAED,qFAAqF;AACrF,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,KAAK,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,oCAAoC,CAAA;CAAE,CAGjF"}
1
+ {"version":3,"file":"store-held-by-another-tab-error.d.ts","sourceRoot":"","sources":["../../src/runtime/store-held-by-another-tab-error.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,eAAO,MAAM,oCAAoC,8BAA8B,CAAC;AAEhF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,qBAAa,0BAA2B,SAAQ,KAAK;IACnD,SAAkB,IAAI,gCAAgC;IACtD,QAAQ,CAAC,IAAI,+BAAwC;gBAGnD,OAAO,SAA2L,EAClM,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE;CAIhC;AAED,qFAAqF;AACrF,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,KAAK,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,oCAAoC,CAAA;CAAE,CAGjF"}
@@ -19,6 +19,17 @@ export const STORE_HELD_BY_ANOTHER_TAB_ERROR_CODE = "store_held_by_another_tab";
19
19
  * the other tab lets go. Writes made in the meantime stay in this tab's
20
20
  * memory until it joins: a reload before then loses them.
21
21
  *
22
+ * A wait or read that failed with this error stays failed: it doesn't
23
+ * resume when the tab joins. The writes behind a failed `wait()` are not
24
+ * lost; they go to the store once the tab joins. Call `wait()` (or the
25
+ * read) again once the sync status is no longer `held-by-another-tab`.
26
+ * Calling it while the store is still held fails at once with this error.
27
+ * Live queries that read only this tab's own data keep running throughout.
28
+ *
29
+ * `db.deleteClientStorage()` waits for the store the same way, and fails
30
+ * with this error past the same patience; called again once the other tab
31
+ * lets go, it deletes the store.
32
+ *
22
33
  * Detect it with {@link isStoreHeldByAnotherTabError}, which checks the
23
34
  * stable `code`.
24
35
  */
@@ -1 +1 @@
1
- {"version":3,"file":"store-held-by-another-tab-error.js","sourceRoot":"","sources":["../../src/runtime/store-held-by-another-tab-error.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,MAAM,CAAC,MAAM,oCAAoC,GAAG,2BAA2B,CAAC;AAEhF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,OAAO,0BAA2B,SAAQ,KAAK;IACjC,IAAI,GAAG,4BAA4B,CAAC;IAC7C,IAAI,GAAG,oCAAoC,CAAC;IAErD,YACE,OAAO,GAAG,wLAAwL,EAClM,OAA6B;QAE7B,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC1B,CAAC;CACF;AAED,qFAAqF;AACrF,MAAM,UAAU,4BAA4B,CAC1C,KAAc;IAEd,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IACtD,OAAQ,KAA4B,CAAC,IAAI,KAAK,oCAAoC,CAAC;AACrF,CAAC","sourcesContent":["/** Stable `code` of a {@link StoreHeldByAnotherTabError}. */\nexport const STORE_HELD_BY_ANOTHER_TAB_ERROR_CODE = \"store_held_by_another_tab\";\n\n/**\n * Another tab of this browser holds this account's local store under\n * another sign-in, so this tab cannot open it yet.\n *\n * This happens when a guest signs up (or in) in one tab while another tab is\n * still the guest: the store is the same account's, and one store serves one\n * sign-in at a time. The other tab normally follows the sign-up within\n * moments, or closes, and this tab joins on its own. Until then its sync\n * status is `connecting`.\n *\n * If the other tab does not let go for a while (it is frozen in the\n * background, or runs an app build that does not follow sign-ups), the\n * status becomes `{ state: \"offline\", reason: \"held-by-another-tab\",\n * retrying: true }`, and reads and waits that were waiting for the store\n * fail with this error, so the app can ask the user to close or reload the\n * other tab. The tab keeps trying in the background and joins as soon as\n * the other tab lets go. Writes made in the meantime stay in this tab's\n * memory until it joins: a reload before then loses them.\n *\n * Detect it with {@link isStoreHeldByAnotherTabError}, which checks the\n * stable `code`.\n */\nexport class StoreHeldByAnotherTabError extends Error {\n override readonly name = \"StoreHeldByAnotherTabError\";\n readonly code = STORE_HELD_BY_ANOTHER_TAB_ERROR_CODE;\n\n constructor(\n message = \"Another tab holds this account's local store under another sign-in: close or reload that other tab. This tab joins once it lets go; reloading this tab first loses its unsynced writes\",\n options?: { cause?: unknown },\n ) {\n super(message, options);\n }\n}\n\n/** Whether `error` is a {@link StoreHeldByAnotherTabError}, by its stable `code`. */\nexport function isStoreHeldByAnotherTabError(\n error: unknown,\n): error is Error & { readonly code: typeof STORE_HELD_BY_ANOTHER_TAB_ERROR_CODE } {\n if (!error || typeof error !== \"object\") return false;\n return (error as { code?: unknown }).code === STORE_HELD_BY_ANOTHER_TAB_ERROR_CODE;\n}\n"]}
1
+ {"version":3,"file":"store-held-by-another-tab-error.js","sourceRoot":"","sources":["../../src/runtime/store-held-by-another-tab-error.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,MAAM,CAAC,MAAM,oCAAoC,GAAG,2BAA2B,CAAC;AAEhF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,MAAM,OAAO,0BAA2B,SAAQ,KAAK;IACjC,IAAI,GAAG,4BAA4B,CAAC;IAC7C,IAAI,GAAG,oCAAoC,CAAC;IAErD,YACE,OAAO,GAAG,wLAAwL,EAClM,OAA6B;QAE7B,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC1B,CAAC;CACF;AAED,qFAAqF;AACrF,MAAM,UAAU,4BAA4B,CAC1C,KAAc;IAEd,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IACtD,OAAQ,KAA4B,CAAC,IAAI,KAAK,oCAAoC,CAAC;AACrF,CAAC","sourcesContent":["/** Stable `code` of a {@link StoreHeldByAnotherTabError}. */\nexport const STORE_HELD_BY_ANOTHER_TAB_ERROR_CODE = \"store_held_by_another_tab\";\n\n/**\n * Another tab of this browser holds this account's local store under\n * another sign-in, so this tab cannot open it yet.\n *\n * This happens when a guest signs up (or in) in one tab while another tab is\n * still the guest: the store is the same account's, and one store serves one\n * sign-in at a time. The other tab normally follows the sign-up within\n * moments, or closes, and this tab joins on its own. Until then its sync\n * status is `connecting`.\n *\n * If the other tab does not let go for a while (it is frozen in the\n * background, or runs an app build that does not follow sign-ups), the\n * status becomes `{ state: \"offline\", reason: \"held-by-another-tab\",\n * retrying: true }`, and reads and waits that were waiting for the store\n * fail with this error, so the app can ask the user to close or reload the\n * other tab. The tab keeps trying in the background and joins as soon as\n * the other tab lets go. Writes made in the meantime stay in this tab's\n * memory until it joins: a reload before then loses them.\n *\n * A wait or read that failed with this error stays failed: it doesn't\n * resume when the tab joins. The writes behind a failed `wait()` are not\n * lost; they go to the store once the tab joins. Call `wait()` (or the\n * read) again once the sync status is no longer `held-by-another-tab`.\n * Calling it while the store is still held fails at once with this error.\n * Live queries that read only this tab's own data keep running throughout.\n *\n * `db.deleteClientStorage()` waits for the store the same way, and fails\n * with this error past the same patience; called again once the other tab\n * lets go, it deletes the store.\n *\n * Detect it with {@link isStoreHeldByAnotherTabError}, which checks the\n * stable `code`.\n */\nexport class StoreHeldByAnotherTabError extends Error {\n override readonly name = \"StoreHeldByAnotherTabError\";\n readonly code = STORE_HELD_BY_ANOTHER_TAB_ERROR_CODE;\n\n constructor(\n message = \"Another tab holds this account's local store under another sign-in: close or reload that other tab. This tab joins once it lets go; reloading this tab first loses its unsynced writes\",\n options?: { cause?: unknown },\n ) {\n super(message, options);\n }\n}\n\n/** Whether `error` is a {@link StoreHeldByAnotherTabError}, by its stable `code`. */\nexport function isStoreHeldByAnotherTabError(\n error: unknown,\n): error is Error & { readonly code: typeof STORE_HELD_BY_ANOTHER_TAB_ERROR_CODE } {\n if (!error || typeof error !== \"object\") return false;\n return (error as { code?: unknown }).code === STORE_HELD_BY_ANOTHER_TAB_ERROR_CODE;\n}\n"]}
@@ -52,12 +52,69 @@ export interface SyncStatus {
52
52
  * reported through `db.onMutationError`.
53
53
  */
54
54
  pendingUploads: number;
55
+ /**
56
+ * When the oldest of {@link pendingUploads} was committed, in Unix ms, or
57
+ * null when none waits. How long a write has been stuck is
58
+ * `Date.now() - oldestPendingAt`.
59
+ */
60
+ oldestPendingAt: number | null;
61
+ /**
62
+ * This client's transactions the server rejected since the Db opened.
63
+ * Each is also reported through `db.onMutationError`, or to the write
64
+ * whose `wait()` claimed it.
65
+ */
66
+ rejected: number;
67
+ /**
68
+ * The latest thing that went wrong with sync since the Db opened, and
69
+ * when: a rejected transaction, or the link failing. It stays after the
70
+ * link recovers (`link` says how things are now), so an agent or a
71
+ * debugging person can see what happened and when.
72
+ */
73
+ lastError: SyncError | null;
55
74
  /**
56
75
  * Nothing waits for upload and the link is connected, or no server is
57
76
  * configured.
58
77
  */
59
78
  synced: boolean;
60
79
  }
80
+ /** What went wrong, as {@link SyncStatus.lastError} reports it. */
81
+ export type SyncError = {
82
+ /** The server rejected a transaction this client committed. */
83
+ kind: "rejected";
84
+ /** The public error code, such as `permission_denied`. */
85
+ code: string;
86
+ message: string;
87
+ /** When the rejection arrived, in Unix ms. */
88
+ at: number;
89
+ } | LinkFailure;
90
+ /** The link failing, as {@link SyncError} reports it. */
91
+ export interface LinkFailure {
92
+ /** Why, as an offline {@link LinkStatus} names it. */
93
+ kind: Exclude<OfflineReason, "disconnected">;
94
+ message: string;
95
+ /** When the link failed this way, in Unix ms. */
96
+ at: number;
97
+ }
98
+ /** @internal A client's uploads, as the core reports them. */
99
+ export interface UploadStatus {
100
+ pending: number;
101
+ oldestPendingAt: number | null;
102
+ rejected: number;
103
+ lastRejection: {
104
+ code: string;
105
+ message: string;
106
+ at: number;
107
+ } | null;
108
+ }
109
+ /** @internal The upload status of a client that has uploaded nothing. */
110
+ export declare const NO_UPLOADS: UploadStatus;
111
+ /** @internal The upload status from a count alone (a host without the full status). */
112
+ export declare function uploadStatusFromCount(pending: number): UploadStatus;
113
+ /** @internal The later of a rejection and a link failure. */
114
+ export declare function latestSyncError(uploads: UploadStatus, link: LinkFailure | null): SyncError | null;
115
+ /** @internal The failure an offline link reports, or null for a link that is not failing. */
116
+ export declare function linkFailureOf(link: LinkStatus, message: string | undefined): LinkFailure | null;
117
+ export declare function sameSyncError(a: SyncError | null, b: SyncError | null): boolean;
61
118
  /** @internal The upstream link machine's status, as the core reports it to its host. */
62
119
  export interface UpstreamLinkStatus {
63
120
  phase: "noServer" | "offline" | "connecting" | "live" | "backoff" | "awaitingCredential" | "stopped";
@@ -76,8 +133,10 @@ export declare function offlineLink(reason: OfflineReason, retrying?: boolean):
76
133
  export declare function linkStatusFromUpstream(status: UpstreamLinkStatus | null): LinkStatus;
77
134
  export declare function sameLinkStatus(a: LinkStatus, b: LinkStatus): boolean;
78
135
  /** @internal Assemble a {@link SyncStatus}. */
79
- export declare function syncStatus(link: LinkStatus, pendingUploads: number): SyncStatus;
136
+ export declare function syncStatus(link: LinkStatus, uploads?: UploadStatus, linkFailure?: LinkFailure | null): SyncStatus;
80
137
  export declare function sameSyncStatus(a: SyncStatus, b: SyncStatus): boolean;
138
+ /** @internal Whether two upload statuses report the same. */
139
+ export declare function sameUploadStatus(a: UploadStatus, b: UploadStatus): boolean;
81
140
  /**
82
141
  * @internal Listener set that publishes a derived value only when it changed.
83
142
  * Publication is deferred to a microtask so that intermediate values inside
@@ -1 +1 @@
1
- {"version":3,"file":"sync-status.d.ts","sourceRoot":"","sources":["../../src/runtime/sync-status.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,MAAM,MAAM,aAAa,GACrB,cAAc,GACd,SAAS,GACT,MAAM,GACN,SAAS,GACT,mBAAmB,GACnB,qBAAqB,CAAC;AAE1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,MAAM,UAAU,GAClB;IAAE,KAAK,EAAE,YAAY,CAAA;CAAE,GACvB;IAAE,KAAK,EAAE,YAAY,CAAA;CAAE,GACvB;IAAE,KAAK,EAAE,WAAW,CAAA;CAAE,GACtB;IACE,KAAK,EAAE,SAAS,CAAC;IACjB,MAAM,EAAE,aAAa,CAAC;IACtB,QAAQ,EAAE,OAAO,CAAC;CACnB,CAAC;AAEN,6FAA6F;AAC7F,MAAM,WAAW,UAAU;IACzB,+BAA+B;IAC/B,IAAI,EAAE,UAAU,CAAC;IACjB;;;;;;OAMG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,wFAAwF;AACxF,MAAM,WAAW,kBAAkB;IACjC,KAAK,EACD,UAAU,GACV,SAAS,GACT,YAAY,GACZ,MAAM,GACN,SAAS,GACT,oBAAoB,GACpB,SAAS,CAAC;IACd,eAAe,EAAE,OAAO,CAAC;CAC1B;AAED,eAAO,MAAM,UAAU,EAAE,UAAmD,CAAC;AAC7E,eAAO,MAAM,UAAU,EAAE,UAAmD,CAAC;AAC7E,eAAO,MAAM,SAAS,EAAE,UAAkD,CAAC;AAE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UAAU,EAChB,OAAO,GAAE,YAAyB,EAClC,WAAW,GAAE,WAAW,GAAG,IAAW,GACrC,UAAU,CASZ;AAED,wBAAgB,cAAc,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU,GAAG,OAAO,CAQpE;AAED,6DAA6D;AAC7D,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,YAAY,GAAG,OAAO,CAQ1E;AAED;;;;GAIG;AACH,qBAAa,qBAAqB,CAAC,CAAC;IAMhC,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,IAAI;IANvB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAiC;IAC3D,OAAO,CAAC,SAAS,CAAgB;IACjC,OAAO,CAAC,SAAS,CAAS;gBAGP,IAAI,EAAE,MAAM,CAAC,EACb,IAAI,GAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,OAAmB;IAG5D,SAAS,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,EAAE,MAAM,EAAE,WAAW,GAAG,IAAI;IAUlE,IAAI,YAAY,IAAI,OAAO,CAE1B;IAED,8DAA8D;IAC9D,OAAO,IAAI,IAAI;CAWhB"}
@@ -1,3 +1,48 @@
1
+ /** @internal The upload status of a client that has uploaded nothing. */
2
+ export const NO_UPLOADS = Object.freeze({
3
+ pending: 0,
4
+ oldestPendingAt: null,
5
+ rejected: 0,
6
+ lastRejection: null,
7
+ });
8
+ /** @internal The upload status from a count alone (a host without the full status). */
9
+ export function uploadStatusFromCount(pending) {
10
+ return { ...NO_UPLOADS, pending };
11
+ }
12
+ /** @internal The later of a rejection and a link failure. */
13
+ export function latestSyncError(uploads, link) {
14
+ const rejection = uploads.lastRejection
15
+ ? { kind: "rejected", ...uploads.lastRejection }
16
+ : null;
17
+ if (!rejection)
18
+ return link;
19
+ if (!link)
20
+ return rejection;
21
+ return link.at > rejection.at ? link : rejection;
22
+ }
23
+ /** @internal The failure an offline link reports, or null for a link that is not failing. */
24
+ export function linkFailureOf(link, message) {
25
+ if (link.state !== "offline" || link.reason === "disconnected")
26
+ return null;
27
+ const said = {
28
+ network: "The server is unreachable; retrying.",
29
+ auth: "The server refused this client's credential.",
30
+ stopped: "The link stopped for good; only db.reconnect() tries again.",
31
+ "authority-changed": "The server serves another history than this client's local store.",
32
+ "held-by-another-tab": "Another tab holds this account's local store under another sign-in.",
33
+ }[link.reason];
34
+ return { kind: link.reason, message: message || said, at: Date.now() };
35
+ }
36
+ export function sameSyncError(a, b) {
37
+ if (a === b)
38
+ return true;
39
+ if (!a || !b)
40
+ return false;
41
+ return (a.kind === b.kind &&
42
+ a.at === b.at &&
43
+ a.message === b.message &&
44
+ (a.kind !== "rejected" || (b.kind === "rejected" && a.code === b.code)));
45
+ }
1
46
  export const LOCAL_ONLY = Object.freeze({ state: "local-only" });
2
47
  export const CONNECTING = Object.freeze({ state: "connecting" });
3
48
  export const CONNECTED = Object.freeze({ state: "connected" });
@@ -35,15 +80,30 @@ export function sameLinkStatus(a, b) {
35
80
  return a.reason === b.reason && a.retrying === b.retrying;
36
81
  }
37
82
  /** @internal Assemble a {@link SyncStatus}. */
38
- export function syncStatus(link, pendingUploads) {
83
+ export function syncStatus(link, uploads = NO_UPLOADS, linkFailure = null) {
39
84
  return {
40
85
  link,
41
- pendingUploads,
42
- synced: pendingUploads === 0 && (link.state === "connected" || link.state === "local-only"),
86
+ pendingUploads: uploads.pending,
87
+ oldestPendingAt: uploads.pending === 0 ? null : uploads.oldestPendingAt,
88
+ rejected: uploads.rejected,
89
+ lastError: latestSyncError(uploads, linkFailure),
90
+ synced: uploads.pending === 0 && (link.state === "connected" || link.state === "local-only"),
43
91
  };
44
92
  }
45
93
  export function sameSyncStatus(a, b) {
46
- return a.pendingUploads === b.pendingUploads && sameLinkStatus(a.link, b.link);
94
+ return (a.pendingUploads === b.pendingUploads &&
95
+ a.oldestPendingAt === b.oldestPendingAt &&
96
+ a.rejected === b.rejected &&
97
+ sameSyncError(a.lastError, b.lastError) &&
98
+ sameLinkStatus(a.link, b.link));
99
+ }
100
+ /** @internal Whether two upload statuses report the same. */
101
+ export function sameUploadStatus(a, b) {
102
+ return (a.pending === b.pending &&
103
+ a.oldestPendingAt === b.oldestPendingAt &&
104
+ a.rejected === b.rejected &&
105
+ a.lastRejection?.at === b.lastRejection?.at &&
106
+ a.lastRejection?.code === b.lastRejection?.code);
47
107
  }
48
108
  /**
49
109
  * @internal Listener set that publishes a derived value only when it changed.
@@ -1 +1 @@
1
- {"version":3,"file":"sync-status.js","sourceRoot":"","sources":["../../src/runtime/sync-status.ts"],"names":[],"mappings":"AAgFA,MAAM,CAAC,MAAM,UAAU,GAAe,MAAM,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC,CAAC;AAC7E,MAAM,CAAC,MAAM,UAAU,GAAe,MAAM,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC,CAAC;AAC7E,MAAM,CAAC,MAAM,SAAS,GAAe,MAAM,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC,CAAC;AAE3E,0DAA0D;AAC1D,MAAM,UAAU,WAAW,CAAC,MAAqB,EAAE,QAAQ,GAAG,MAAM,KAAK,SAAS;IAChF,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;AAChD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CAAC,MAAiC;IACtE,QAAQ,MAAM,EAAE,KAAK,IAAI,UAAU,EAAE,CAAC;QACpC,KAAK,UAAU;YACb,OAAO,UAAU,CAAC;QACpB,KAAK,SAAS;YACZ,OAAO,WAAW,CAAC,cAAc,CAAC,CAAC;QACrC,KAAK,MAAM;YACT,OAAO,SAAS,CAAC;QACnB,KAAK,YAAY,CAAC;QAClB,KAAK,SAAS;YACZ,OAAO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=\n | \"disconnected\"\n | \"network\"\n | \"auth\"\n | \"stopped\"\n | \"authority-changed\"\n | \"held-by-another-tab\";\n\n/**\n * The upstream connection as an app should show it.\n *\n * - `local-only`: no server is configured; nothing is ever uploaded.\n * - `connecting`: the first connection attempt, or a reconnect after a short\n * drop that has not been reported as an outage yet.\n * - `connected`: the server admitted this client.\n * - `offline`: not connected, with the reason:\n * - `disconnected`: the app called `db.disconnect()`.\n * - `network`: the server has been unreachable for a while; the client\n * keeps retrying (`retrying: true`).\n * - `auth`: the server refused the credential. The client waits for a new\n * one (`db.updateAuthToken(...)`, or a fresh sign-in through the app's\n * backend).\n * - `stopped`: a failure retrying cannot fix (a protocol error or an\n * incompatible server); only `db.reconnect()` tries again.\n * - `authority-changed`: the server serves another history than this\n * client's local store (its store was recreated, or it is another app's\n * server), so nothing syncs with it. Waits for the server fail with an\n * `AuthorityChangedError`, which says how to recover: reset the local\n * store (`db.deleteClientStorage()` in the browser). Nothing is reset\n * automatically, so unsynced writes are never discarded behind the\n * app's back.\n * - `held-by-another-tab` (browser): another tab holds this account's\n * local store under another sign-in (it was still the guest when this\n * tab signed up) and has not let go for a while. The tab keeps trying\n * (`retrying: true`) and joins once the other tab follows or closes;\n * waits fail meanwhile with a `StoreHeldByAnotherTabError`.\n */\nexport type LinkStatus =\n | { state: \"local-only\" }\n | { state: \"connecting\" }\n | { state: \"connected\" }\n | {\n state: \"offline\";\n reason: OfflineReason;\n retrying: boolean;\n };\n\n/** Whether this client's data has reached the server, as `db.getSyncStatus()` reports it. */\nexport interface SyncStatus {\n /** The upstream connection. */\n link: LinkStatus;\n /**\n * Transactions this client committed that the server has neither accepted\n * nor rejected yet. In Node and React Native this includes ones recovered\n * from local storage after a restart; a browser tab counts only its own\n * commits, since the shared worker uploads recovered ones. Rejections are\n * reported through `db.onMutationError`.\n */\n pendingUploads: number;\n /**\n * Nothing waits for upload and the link is connected, or no server is\n * configured.\n */\n synced: boolean;\n}\n\n/** @internal The upstream link machine's status, as the core reports it to its host. */\nexport interface UpstreamLinkStatus {\n phase:\n | \"noServer\"\n | \"offline\"\n | \"connecting\"\n | \"live\"\n | \"backoff\"\n | \"awaitingCredential\"\n | \"stopped\";\n outagePublished: boolean;\n}\n\nexport const LOCAL_ONLY: LinkStatus = Object.freeze({ state: \"local-only\" });\nexport const CONNECTING: LinkStatus = Object.freeze({ state: \"connecting\" });\nexport const CONNECTED: LinkStatus = Object.freeze({ state: \"connected\" });\n\n/** @internal The app-facing status of an offline link. */\nexport function offlineLink(reason: OfflineReason, retrying = reason === \"network\"): LinkStatus {\n return { state: \"offline\", reason, retrying };\n}\n\n/**\n * @internal Map the core link machine's status to {@link LinkStatus}. A\n * dropped link that is retrying reads as `connecting` until the machine\n * publishes an outage, so a short blip never shows as offline.\n */\nexport function linkStatusFromUpstream(status: UpstreamLinkStatus | null): LinkStatus {\n switch (status?.phase ?? \"noServer\") {\n case \"noServer\":\n return LOCAL_ONLY;\n case \"offline\":\n return offlineLink(\"disconnected\");\n case \"live\":\n return CONNECTED;\n case \"connecting\":\n case \"backoff\":\n return status!.outagePublished ? offlineLink(\"network\") : CONNECTING;\n case \"awaitingCredential\":\n return offlineLink(\"auth\");\n case \"stopped\":\n return offlineLink(\"stopped\");\n }\n}\n\nexport function sameLinkStatus(a: LinkStatus, b: LinkStatus): boolean {\n if (a.state !== b.state) return false;\n if (a.state !== \"offline\" || b.state !== \"offline\") return true;\n return a.reason === b.reason && a.retrying === b.retrying;\n}\n\n/** @internal Assemble a {@link SyncStatus}. */\nexport function syncStatus(link: LinkStatus, pendingUploads: number): SyncStatus {\n return {\n link,\n pendingUploads,\n synced: pendingUploads === 0 && (link.state === \"connected\" || link.state === \"local-only\"),\n };\n}\n\nexport function sameSyncStatus(a: SyncStatus, b: SyncStatus): boolean {\n return a.pendingUploads === b.pendingUploads && sameLinkStatus(a.link, b.link);\n}\n\n/**\n * @internal Listener set that publishes a derived value only when it changed.\n * Publication is deferred to a microtask so that intermediate values inside\n * one synchronous transition are never observed.\n */\nexport class DerivedStatePublisher<T> {\n private readonly listeners = new Set<(value: T) => void>();\n private published: T | undefined;\n private scheduled = false;\n\n constructor(\n private readonly read: () => T,\n private readonly same: (a: T, b: T) => boolean = Object.is,\n ) {}\n\n subscribe(listener: (value: T) => void, signal: AbortSignal): void {\n if (signal.aborted) return;\n // Changes are not tracked while nobody listens; resynchronize first.\n if (this.listeners.size === 0) this.published = this.read();\n this.listeners.add(listener);\n signal.addEventListener(\"abort\", () => this.listeners.delete(listener), {\n once: true,\n });\n }\n\n get hasListeners(): boolean {\n return this.listeners.size > 0;\n }\n\n /** Schedule a comparison against the last published value. */\n changed(): void {\n if (this.scheduled || this.listeners.size === 0) return;\n this.scheduled = true;\n queueMicrotask(() => {\n this.scheduled = false;\n const value = this.read();\n if (this.published !== undefined && this.same(value, this.published)) return;\n this.published = value;\n for (const listener of [...this.listeners]) listener(value);\n });\n }\n}\n"]}
1
+ {"version":3,"file":"sync-status.js","sourceRoot":"","sources":["../../src/runtime/sync-status.ts"],"names":[],"mappings":"AAoHA,yEAAyE;AACzE,MAAM,CAAC,MAAM,UAAU,GAAiB,MAAM,CAAC,MAAM,CAAC;IACpD,OAAO,EAAE,CAAC;IACV,eAAe,EAAE,IAAI;IACrB,QAAQ,EAAE,CAAC;IACX,aAAa,EAAE,IAAI;CACpB,CAAC,CAAC;AAEH,uFAAuF;AACvF,MAAM,UAAU,qBAAqB,CAAC,OAAe;IACnD,OAAO,EAAE,GAAG,UAAU,EAAE,OAAO,EAAE,CAAC;AACpC,CAAC;AAED,6DAA6D;AAC7D,MAAM,UAAU,eAAe,CAAC,OAAqB,EAAE,IAAwB;IAC7E,MAAM,SAAS,GAAG,OAAO,CAAC,aAAa;QACrC,CAAC,CAAE,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,aAAa,EAAY;QAC3D,CAAC,CAAC,IAAI,CAAC;IACT,IAAI,CAAC,SAAS;QAAE,OAAO,IAAI,CAAC;IAC5B,IAAI,C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AS,KAAK,SAAS,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC;gBAAE,OAAO;YAC7E,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;YACvB,KAAK,MAAM,QAAQ,IAAI,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC;gBAAE,QAAQ,CAAC,KAAK,CAAC,CAAC;QAC9D,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["/** Why a {@link LinkStatus} is `offline`. */\nexport type OfflineReason =\n | \"disconnected\"\n | \"network\"\n | \"auth\"\n | \"stopped\"\n | \"authority-changed\"\n | \"held-by-another-tab\";\n\n/**\n * The upstream connection as an app should show it.\n *\n * - `local-only`: no server is configured; nothing is ever uploaded.\n * - `connecting`: the first connection attempt, or a reconnect after a short\n * drop that has not been reported as an outage yet.\n * - `connected`: the server admitted this client.\n * - `offline`: not connected, with the reason:\n * - `disconnected`: the app called `db.disconnect()`.\n * - `network`: the server has been unreachable for a while; the client\n * keeps retrying (`retrying: true`).\n * - `auth`: the server refused the credential. The client waits for a new\n * one (`db.updateAuthToken(...)`, or a fresh sign-in through the app's\n * backend).\n * - `stopped`: a failure retrying cannot fix (a protocol error or an\n * incompatible server); only `db.reconnect()` tries again.\n * - `authority-changed`: the server serves another history than this\n * client's local store (its store was recreated, or it is another app's\n * server), so nothing syncs with it. Waits for the server fail with an\n * `AuthorityChangedError`, which says how to recover: reset the local\n * store (`db.deleteClientStorage()` in the browser). Nothing is reset\n * automatically, so unsynced writes are never discarded behind the\n * app's back.\n * - `held-by-another-tab` (browser): another tab holds this account's\n * local store under another sign-in (it was still the guest when this\n * tab signed up) and has not let go for a while. The tab keeps trying\n * (`retrying: true`) and joins once the other tab follows or closes;\n * waits fail meanwhile with a `StoreHeldByAnotherTabError`.\n */\nexport type LinkStatus =\n | { state: \"local-only\" }\n | { state: \"connecting\" }\n | { state: \"connected\" }\n | {\n state: \"offline\";\n reason: OfflineReason;\n retrying: boolean;\n };\n\n/** Whether this client's data has reached the server, as `db.getSyncStatus()` reports it. */\nexport interface SyncStatus {\n /** The upstream connection. */\n link: LinkStatus;\n /**\n * Transactions this client committed that the server has neither accepted\n * nor rejected yet. In Node and React Native this includes ones recovered\n * from local storage after a restart; a browser tab counts only its own\n * commits, since the shared worker uploads recovered ones. Rejections are\n * reported through `db.onMutationError`.\n */\n pendingUploads: number;\n /**\n * When the oldest of {@link pendingUploads} was committed, in Unix ms, or\n * null when none waits. How long a write has been stuck is\n * `Date.now() - oldestPendingAt`.\n */\n oldestPendingAt: number | null;\n /**\n * This client's transactions the server rejected since the Db opened.\n * Each is also reported through `db.onMutationError`, or to the write\n * whose `wait()` claimed it.\n */\n rejected: number;\n /**\n * The latest thing that went wrong with sync since the Db opened, and\n * when: a rejected transaction, or the link failing. It stays after the\n * link recovers (`link` says how things are now), so an agent or a\n * debugging person can see what happened and when.\n */\n lastError: SyncError | null;\n /**\n * Nothing waits for upload and the link is connected, or no server is\n * configured.\n */\n synced: boolean;\n}\n\n/** What went wrong, as {@link SyncStatus.lastError} reports it. */\nexport type SyncError =\n | {\n /** The server rejected a transaction this client committed. */\n kind: \"rejected\";\n /** The public error code, such as `permission_denied`. */\n code: string;\n message: string;\n /** When the rejection arrived, in Unix ms. */\n at: number;\n }\n | LinkFailure;\n\n/** The link failing, as {@link SyncError} reports it. */\nexport interface LinkFailure {\n /** Why, as an offline {@link LinkStatus} names it. */\n kind: Exclude<OfflineReason, \"disconnected\">;\n message: string;\n /** When the link failed this way, in Unix ms. */\n at: number;\n}\n\n/** @internal A client's uploads, as the core reports them. */\nexport interface UploadStatus {\n pending: number;\n oldestPendingAt: number | null;\n rejected: number;\n lastRejection: { code: string; message: string; at: number } | null;\n}\n\n/** @internal The upload status of a client that has uploaded nothing. */\nexport const NO_UPLOADS: UploadStatus = Object.freeze({\n pending: 0,\n oldestPendingAt: null,\n rejected: 0,\n lastRejection: null,\n});\n\n/** @internal The upload status from a count alone (a host without the full status). */\nexport function uploadStatusFromCount(pending: number): UploadStatus {\n return { ...NO_UPLOADS, pending };\n}\n\n/** @internal The later of a rejection and a link failure. */\nexport function latestSyncError(uploads: UploadStatus, link: LinkFailure | null): SyncError | null {\n const rejection = uploads.lastRejection\n ? ({ kind: \"rejected\", ...uploads.lastRejection } as const)\n : null;\n if (!rejection) return link;\n if (!link) return rejection;\n return link.at > rejection.at ? link : rejection;\n}\n\n/** @internal The failure an offline link reports, or null for a link that is not failing. */\nexport function linkFailureOf(link: LinkStatus, message: string | undefined): LinkFailure | null {\n if (link.state !== \"offline\" || link.reason === \"disconnected\") return null;\n const said = {\n network: \"The server is unreachable; retrying.\",\n auth: \"The server refused this client's credential.\",\n stopped: \"The link stopped for good; only db.reconnect() tries again.\",\n \"authority-changed\": \"The server serves another history than this client's local store.\",\n \"held-by-another-tab\": \"Another tab holds this account's local store under another sign-in.\",\n }[link.reason];\n return { kind: link.reason, message: message || said, at: Date.now() };\n}\n\nexport function sameSyncError(a: SyncError | null, b: SyncError | null): boolean {\n if (a === b) return true;\n if (!a || !b) return false;\n return (\n a.kind === b.kind &&\n a.at === b.at &&\n a.message === b.message &&\n (a.kind !== \"rejected\" || (b.kind === \"rejected\" && a.code === b.code))\n );\n}\n\n/** @internal The upstream link machine's status, as the core reports it to its host. */\nexport interface UpstreamLinkStatus {\n phase:\n | \"noServer\"\n | \"offline\"\n | \"connecting\"\n | \"live\"\n | \"backoff\"\n | \"awaitingCredential\"\n | \"stopped\";\n outagePublished: boolean;\n}\n\nexport const LOCAL_ONLY: LinkStatus = Object.freeze({ state: \"local-only\" });\nexport const CONNECTING: LinkStatus = Object.freeze({ state: \"connecting\" });\nexport const CONNECTED: LinkStatus = Object.freeze({ state: \"connected\" });\n\n/** @internal The app-facing status of an offline link. */\nexport function offlineLink(reason: OfflineReason, retrying = reason === \"network\"): LinkStatus {\n return { state: \"offline\", reason, retrying };\n}\n\n/**\n * @internal Map the core link machine's status to {@link LinkStatus}. A\n * dropped link that is retrying reads as `connecting` until the machine\n * publishes an outage, so a short blip never shows as offline.\n */\nexport function linkStatusFromUpstream(status: UpstreamLinkStatus | null): LinkStatus {\n switch (status?.phase ?? \"noServer\") {\n case \"noServer\":\n return LOCAL_ONLY;\n case \"offline\":\n return offlineLink(\"disconnected\");\n case \"live\":\n return CONNECTED;\n case \"connecting\":\n case \"backoff\":\n return status!.outagePublished ? offlineLink(\"network\") : CONNECTING;\n case \"awaitingCredential\":\n return offlineLink(\"auth\");\n case \"stopped\":\n return offlineLink(\"stopped\");\n }\n}\n\nexport function sameLinkStatus(a: LinkStatus, b: LinkStatus): boolean {\n if (a.state !== b.state) return false;\n if (a.state !== \"offline\" || b.state !== \"offline\") return true;\n return a.reason === b.reason && a.retrying === b.retrying;\n}\n\n/** @internal Assemble a {@link SyncStatus}. */\nexport function syncStatus(\n link: LinkStatus,\n uploads: UploadStatus = NO_UPLOADS,\n linkFailure: LinkFailure | null = null,\n): SyncStatus {\n return {\n link,\n pendingUploads: uploads.pending,\n oldestPendingAt: uploads.pending === 0 ? null : uploads.oldestPendingAt,\n rejected: uploads.rejected,\n lastError: latestSyncError(uploads, linkFailure),\n synced: uploads.pending === 0 && (link.state === \"connected\" || link.state === \"local-only\"),\n };\n}\n\nexport function sameSyncStatus(a: SyncStatus, b: SyncStatus): boolean {\n return (\n a.pendingUploads === b.pendingUploads &&\n a.oldestPendingAt === b.oldestPendingAt &&\n a.rejected === b.rejected &&\n sameSyncError(a.lastError, b.lastError) &&\n sameLinkStatus(a.link, b.link)\n );\n}\n\n/** @internal Whether two upload statuses report the same. */\nexport function sameUploadStatus(a: UploadStatus, b: UploadStatus): boolean {\n return (\n a.pending === b.pending &&\n a.oldestPendingAt === b.oldestPendingAt &&\n a.rejected === b.rejected &&\n a.lastRejection?.at === b.lastRejection?.at &&\n a.lastRejection?.code === b.lastRejection?.code\n );\n}\n\n/**\n * @internal Listener set that publishes a derived value only when it changed.\n * Publication is deferred to a microtask so that intermediate values inside\n * one synchronous transition are never observed.\n */\nexport class DerivedStatePublisher<T> {\n private readonly listeners = new Set<(value: T) => void>();\n private published: T | undefined;\n private scheduled = false;\n\n constructor(\n private readonly read: () => T,\n private readonly same: (a: T, b: T) => boolean = Object.is,\n ) {}\n\n subscribe(listener: (value: T) => void, signal: AbortSignal): void {\n if (signal.aborted) return;\n // Changes are not tracked while nobody listens; resynchronize first.\n if (this.listeners.size === 0) this.published = this.read();\n this.listeners.add(listener);\n signal.addEventListener(\"abort\", () => this.listeners.delete(listener), {\n once: true,\n });\n }\n\n get hasListeners(): boolean {\n return this.listeners.size > 0;\n }\n\n /** Schedule a comparison against the last published value. */\n changed(): void {\n if (this.scheduled || this.listeners.size === 0) return;\n this.scheduled = true;\n queueMicrotask(() => {\n this.scheduled = false;\n const value = this.read();\n if (this.published !== undefined && this.same(value, this.published)) return;\n this.published = value;\n for (const listener of [...this.listeners]) listener(value);\n });\n }\n}\n"]}
@@ -1,5 +1,7 @@
1
- import type { AccountIdentity } from "../accounts/state.js";
2
- import { type JazzSession } from "./state.js";
1
+ import type { AccountHandle, AccountIdentity } from "../accounts/state.js";
2
+ import { type SessionCore } from "./state.js";
3
+ /** What an app's `onSignedOut` hook decides (see `watchBackendUser`). */
4
+ export type SignedOutDecision = "sign-out" | "keep";
3
5
  export interface BackendWatchEvents {
4
6
  /** Call `check` when the page or app comes back to the foreground. */
5
7
  onFocus(check: () => void): () => void;
@@ -10,6 +12,15 @@ export interface BackendWatchEvents {
10
12
  };
11
13
  /** Whether the page or app is in the foreground now (its cookies are fresh). */
12
14
  isVisible?(): boolean;
15
+ /**
16
+ * Run `probe` so that the windows of one browser ask the backend one at a
17
+ * time, never at once. Several windows asking at once (on focus after a
18
+ * laptop wakes) each carry the session cookie, and auth middleware on the
19
+ * route may refresh it once per request: with single-use refresh tokens,
20
+ * all but one refresh fail. Asked one after another, each request carries
21
+ * the cookie the one before it refreshed. Each window still asks itself.
22
+ */
23
+ singleFlight?<T>(probe: () => Promise<T>): Promise<T>;
13
24
  }
14
25
  /**
15
26
  * Who the backend says is signed in. `hasAccount: false` means the core holds
@@ -92,27 +103,25 @@ export interface BackendWatch {
92
103
  * again, once, which gives them a new account; reconnecting would only be
93
104
  * refused again.
94
105
  *
95
- * A sync server refusing the sign-in (`authRefused`) asks the backend too, but
96
- * only to reconnect, with backoff, while it still names the same user. It
97
- * never signs anyone out: a background tab's cookie may just be stale, so a
98
- * sign-out waits for a check after focus returns (or for the app to call
99
- * `reauthenticate`). A probe that reports there is no backend (404) is asked
106
+ * A sync server refusing the sign-in (`authRefused`, say after
107
+ * `jazz.revokeUser`) asks the backend too. While it still names the same
108
+ * user, the client reconnects, with backoff. When it says no one is signed
109
+ * in and the page is visible (its cookies are fresh), that answer counts as
110
+ * the first of the two a sign-out needs: a second one `confirmMs` later
111
+ * signs the user out (after `onSignedOut`), so a revoked user's open tab
112
+ * doesn't stay signed in and unsynced for long. A background tab's cookie
113
+ * may just be stale, so there a sign-out waits for a check after focus
114
+ * returns (or for the app to call `reauthenticate`). A probe that reports there is no backend (404) is asked
100
115
  * again with backoff, since a deploy or a proxy may answer 404 for a moment;
101
116
  * only 404s that keep coming for a while (`notFoundRetryMs`, three answers)
102
117
  * stop the watch. A stopped watch rejects every later `reauthenticate`.
103
118
  */
104
- export declare function watchBackendUser<Client>(session: JazzSession<Client>, probe: () => Promise<BackendUser | null>, events: BackendWatchEvents, options?: {
119
+ export declare function watchBackendUser<Client>(session: SessionCore<Client>, probe: () => Promise<BackendUser | null>, events: BackendWatchEvents, options?: {
105
120
  confirmMs?: number;
106
121
  /** Reconnect the current client, once the backend says its user is still signed in. */
107
122
  reconnect?: () => void;
108
123
  /** The first wait before reconnecting after a refusal; it doubles up to a minute. */
109
124
  reconnectBackoffMs?: number;
110
- /**
111
- * After a refusal the backend agrees with (no one signed in) while the
112
- * page is visible, wait this long and check again as on focus, so a
113
- * revoked user in a tab that stays focused is signed out. Default 30s.
114
- */
115
- refusedConfirmMs?: number;
116
125
  /**
117
126
  * Link a local-first guest to a signed-in user who has no account yet
118
127
  * (default true). Off, the watch leaves that guest as it is: the app
@@ -132,7 +141,37 @@ export declare function watchBackendUser<Client>(session: JazzSession<Client>, p
132
141
  * to a minute. Default 2s.
133
142
  */
134
143
  retryMs?: number;
144
+ /**
145
+ * Whether this device forgot a guest's account: another tab linked it
146
+ * to a user (their sign-up) under `clearOnSignOut`, so it is theirs now.
147
+ * Such a guest signs out when the backend says no one is signed in, as
148
+ * that user does. Left out, a guest never signs out on its own.
149
+ */
150
+ forgotten?: (account: AccountHandle) => Promise<boolean>;
151
+ /**
152
+ * Called when your backend says no one is signed in any more (confirmed
153
+ * by a second answer a moment later), before the session signs the
154
+ * user out. Return `"keep"` to stay signed in for now (your app refreshed
155
+ * its session itself, or redirects to sign-in first): the session asks
156
+ * your backend again on the next focus, refusal or `refresh()`.
157
+ * Return `"sign-out"` (or nothing) to sign out. A hook that throws signs
158
+ * out.
159
+ */
160
+ onSignedOut?: () => SignedOutDecision | void | Promise<SignedOutDecision | void>;
135
161
  }): BackendWatch;
136
162
  /** Focus, visibility and BroadcastChannel events for a browser page. */
137
163
  export declare function browserBackendWatchEvents(channelName: string): BackendWatchEvents;
164
+ /**
165
+ * The longest one window holds the turn: a window whose request hangs (its
166
+ * page is frozen, its network stalled) lets the others ask after this long.
167
+ */
168
+ export declare const SINGLE_FLIGHT_TURN_MS = 5000;
169
+ /**
170
+ * {@link BackendWatchEvents.singleFlight} for the windows of one browser: a
171
+ * Web Lock takes turns, held until the probe settles or for
172
+ * {@link SINGLE_FLIGHT_TURN_MS}, whichever is first. Each window's probe asks
173
+ * the backend itself; no answer is shared or stored. Without Web Locks,
174
+ * every probe runs on its own.
175
+ */
176
+ export declare function browserSingleFlight(name: string): (<T>(probe: () => Promise<T>) => Promise<T>) | undefined;
138
177
  //# sourceMappingURL=backend-watch.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"backend-watch.d.ts","sourceRoot":"","sources":["../../src/session/backend-watch.ts"],"names":[],"mappings":"AAAA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