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

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 (719) 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 +13 -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 +38 -2
  19. package/dist/accounts/persistence.d.ts.map +1 -1
  20. package/dist/accounts/persistence.js +123 -6
  21. package/dist/accounts/persistence.js.map +1 -1
  22. package/dist/accounts/registry-client.d.ts +29 -0
  23. package/dist/accounts/registry-client.d.ts.map +1 -1
  24. package/dist/accounts/registry-client.js +45 -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-context.d.ts +7 -0
  30. package/dist/backend/create-jazz-context.d.ts.map +1 -1
  31. package/dist/backend/create-jazz-context.js +115 -18
  32. package/dist/backend/create-jazz-context.js.map +1 -1
  33. package/dist/backend/create-jazz-session.d.ts +9 -7
  34. package/dist/backend/create-jazz-session.d.ts.map +1 -1
  35. package/dist/backend/create-jazz-session.js +55 -17
  36. package/dist/backend/create-jazz-session.js.map +1 -1
  37. package/dist/backend/create-jazz.d.ts +196 -38
  38. package/dist/backend/create-jazz.d.ts.map +1 -1
  39. package/dist/backend/create-jazz.js +935 -147
  40. package/dist/backend/create-jazz.js.map +1 -1
  41. package/dist/backend/early-db.d.ts.map +1 -1
  42. package/dist/backend/early-db.js +1 -0
  43. package/dist/backend/early-db.js.map +1 -1
  44. package/dist/backend/external-jwt.d.ts.map +1 -1
  45. package/dist/backend/external-jwt.js +34 -10
  46. package/dist/backend/external-jwt.js.map +1 -1
  47. package/dist/backend/from-jwt.d.ts +6 -4
  48. package/dist/backend/from-jwt.d.ts.map +1 -1
  49. package/dist/backend/from-jwt.js +11 -3
  50. package/dist/backend/from-jwt.js.map +1 -1
  51. package/dist/backend/index.d.ts +2 -1
  52. package/dist/backend/index.d.ts.map +1 -1
  53. package/dist/backend/index.js +3 -1
  54. package/dist/backend/index.js.map +1 -1
  55. package/dist/backend/inspect-ui.d.ts +14 -0
  56. package/dist/backend/inspect-ui.d.ts.map +1 -0
  57. package/dist/backend/inspect-ui.js +156 -0
  58. package/dist/backend/inspect-ui.js.map +1 -0
  59. package/dist/backend/inspect.d.ts +133 -0
  60. package/dist/backend/inspect.d.ts.map +1 -0
  61. package/dist/backend/inspect.js +983 -0
  62. package/dist/backend/inspect.js.map +1 -0
  63. package/dist/backend/inspector-ui/0.js +2 -0
  64. package/dist/backend/inspector-ui/1.js +2 -0
  65. package/dist/backend/inspector-ui/10.js +2 -0
  66. package/dist/backend/inspector-ui/11.js +2 -0
  67. package/dist/backend/inspector-ui/12.js +2 -0
  68. package/dist/backend/inspector-ui/13.js +2 -0
  69. package/dist/backend/inspector-ui/14.js +2 -0
  70. package/dist/backend/inspector-ui/15.js +2 -0
  71. package/dist/backend/inspector-ui/16.js +2 -0
  72. package/dist/backend/inspector-ui/17.js +2 -0
  73. package/dist/backend/inspector-ui/18.js +2 -0
  74. package/dist/backend/inspector-ui/19.js +2 -0
  75. package/dist/backend/inspector-ui/2.js +2 -0
  76. package/dist/backend/inspector-ui/20.js +2 -0
  77. package/dist/backend/inspector-ui/3.js +2 -0
  78. package/dist/backend/inspector-ui/4.js +2 -0
  79. package/dist/backend/inspector-ui/5.js +2 -0
  80. package/dist/backend/inspector-ui/6.js +2 -0
  81. package/dist/backend/inspector-ui/7.js +2 -0
  82. package/dist/backend/inspector-ui/8.js +2 -0
  83. package/dist/backend/inspector-ui/9.js +2 -0
  84. package/dist/backend/inspector-ui-files.d.ts +4 -0
  85. package/dist/backend/inspector-ui-files.d.ts.map +1 -0
  86. package/dist/backend/inspector-ui-files.js +25 -0
  87. package/dist/backend/request-auth.d.ts +11 -0
  88. package/dist/backend/request-auth.d.ts.map +1 -1
  89. package/dist/backend/request-auth.js +14 -0
  90. package/dist/backend/request-auth.js.map +1 -1
  91. package/dist/backend/session-expiry.d.ts +61 -0
  92. package/dist/backend/session-expiry.d.ts.map +1 -0
  93. package/dist/backend/session-expiry.js +102 -0
  94. package/dist/backend/session-expiry.js.map +1 -0
  95. package/dist/backend/signing-key.d.ts +10 -0
  96. package/dist/backend/signing-key.d.ts.map +1 -0
  97. package/dist/backend/signing-key.js +15 -0
  98. package/dist/backend/signing-key.js.map +1 -0
  99. package/dist/backend/store-log.d.ts +3 -0
  100. package/dist/backend/store-log.d.ts.map +1 -0
  101. package/dist/backend/store-log.js +16 -0
  102. package/dist/backend/store-log.js.map +1 -0
  103. package/dist/backend/upgrade-status.d.ts +19 -0
  104. package/dist/backend/upgrade-status.d.ts.map +1 -0
  105. package/dist/backend/upgrade-status.js +55 -0
  106. package/dist/backend/upgrade-status.js.map +1 -0
  107. package/dist/backend/vercel-store.d.ts +88 -12
  108. package/dist/backend/vercel-store.d.ts.map +1 -1
  109. package/dist/backend/vercel-store.js +303 -44
  110. package/dist/backend/vercel-store.js.map +1 -1
  111. package/dist/backend/ws-peer.d.ts +32 -0
  112. package/dist/backend/ws-peer.d.ts.map +1 -0
  113. package/dist/backend/ws-peer.js +40 -0
  114. package/dist/backend/ws-peer.js.map +1 -0
  115. package/dist/better-auth-adapter/fixtures/issuer-upgrade-schema.d.ts +134 -0
  116. package/dist/better-auth-adapter/fixtures/issuer-upgrade-schema.d.ts.map +1 -0
  117. package/dist/better-auth-adapter/fixtures/issuer-upgrade-schema.js +121 -0
  118. package/dist/better-auth-adapter/fixtures/issuer-upgrade-schema.js.map +1 -0
  119. package/dist/better-auth-adapter/fixtures/schema.d.ts +2 -1
  120. package/dist/better-auth-adapter/fixtures/schema.d.ts.map +1 -1
  121. package/dist/better-auth-adapter/fixtures/schema.js +2 -1
  122. package/dist/better-auth-adapter/fixtures/schema.js.map +1 -1
  123. package/dist/better-auth-adapter/index.d.ts.map +1 -1
  124. package/dist/better-auth-adapter/index.js +47 -0
  125. package/dist/better-auth-adapter/index.js.map +1 -1
  126. package/dist/classic-api.d.ts.map +1 -1
  127. package/dist/classic-api.js +36 -0
  128. package/dist/classic-api.js.map +1 -1
  129. package/dist/cli.d.ts.map +1 -1
  130. package/dist/cli.js +54 -11
  131. package/dist/cli.js.map +1 -1
  132. package/dist/client/index.d.ts +2 -6
  133. package/dist/client/index.d.ts.map +1 -1
  134. package/dist/client/index.js +2 -3
  135. package/dist/client/index.js.map +1 -1
  136. package/dist/cloud/credentials.d.ts +1 -1
  137. package/dist/cloud/credentials.d.ts.map +1 -1
  138. package/dist/cloud/credentials.js.map +1 -1
  139. package/dist/dev/catalogue-project.d.ts +12 -3
  140. package/dist/dev/catalogue-project.d.ts.map +1 -1
  141. package/dist/dev/catalogue-project.js +29 -4
  142. package/dist/dev/catalogue-project.js.map +1 -1
  143. package/dist/dev/catalogue.d.ts +12 -0
  144. package/dist/dev/catalogue.d.ts.map +1 -1
  145. package/dist/dev/catalogue.js +94 -15
  146. package/dist/dev/catalogue.js.map +1 -1
  147. package/dist/dev/dev-server.d.ts +4 -1
  148. package/dist/dev/dev-server.d.ts.map +1 -1
  149. package/dist/dev/dev-server.js +41 -3
  150. package/dist/dev/dev-server.js.map +1 -1
  151. package/dist/dev/inspector-overlay/embedded/assets/backend-C6JfNAB2.js +1 -0
  152. package/dist/dev/inspector-overlay/embedded/assets/backend-DHeT1LCS.css +1 -0
  153. package/dist/dev/inspector-overlay/embedded/assets/{create-legacy-browser-delegate-X_T_QKCN.js → create-legacy-browser-delegate-Bf58kV5i.js} +1 -1
  154. package/dist/dev/inspector-overlay/embedded/assets/{esm-aRzpnC3u.js → esm-B8Fn7-qJ.js} +1 -1
  155. package/dist/dev/inspector-overlay/embedded/assets/{esm-ezD5H765.js → esm-C3BWHq-S.js} +1 -1
  156. package/dist/dev/inspector-overlay/embedded/assets/esm-DC_mAoiW.js +1 -0
  157. package/dist/dev/inspector-overlay/embedded/assets/{esm-7mP3GQX4.js → esm-D_R-EGgt.js} +1 -1
  158. package/dist/dev/inspector-overlay/embedded/assets/{esm-BX6IY2Mv.js → esm-WihpI9g6.js} +1 -1
  159. package/dist/dev/inspector-overlay/embedded/assets/index-C_pcvEcg.js +1 -0
  160. package/dist/dev/inspector-overlay/embedded/assets/{jazz-broker-worker-XRRxJUcx.js → jazz-broker-worker-Cv6-V0tc.js} +787 -608
  161. package/dist/dev/inspector-overlay/embedded/assets/jazz-broker-worker-Db-pNME-.js +5 -0
  162. package/dist/dev/inspector-overlay/embedded/assets/jazz_wasm-CTwPHZcZ.js +1 -0
  163. package/dist/dev/inspector-overlay/embedded/assets/{jazz_wasm_bg-KR7h3v27.wasm → jazz_wasm_bg-HpkRDlj-.wasm} +0 -0
  164. package/dist/dev/inspector-overlay/embedded/assets/src-B5UtjtXQ.js +22 -0
  165. package/dist/dev/inspector-overlay/embedded/assets/{index-C78Pprka.css → src-Cq8gSOLx.css} +1 -1
  166. package/dist/dev/inspector-overlay/embedded/assets/{trace-api-B5CaetI0.js → trace-api-BctnwbUf.js} +1 -1
  167. package/dist/dev/inspector-overlay/embedded/backend.html +16 -0
  168. package/dist/dev/inspector-overlay/embedded/embedded.html +3 -2
  169. package/dist/dev/inspector-overlay/host-bridge.d.ts.map +1 -1
  170. package/dist/dev/inspector-overlay/host-bridge.js +4 -1
  171. package/dist/dev/inspector-overlay/host-bridge.js.map +1 -1
  172. package/dist/dev/inspector-overlay/loader.d.ts +12 -1
  173. package/dist/dev/inspector-overlay/loader.d.ts.map +1 -1
  174. package/dist/dev/inspector-overlay/loader.js +31 -4
  175. package/dist/dev/inspector-overlay/loader.js.map +1 -1
  176. package/dist/dev/migrations.d.ts.map +1 -1
  177. package/dist/dev/migrations.js +53 -7
  178. package/dist/dev/migrations.js.map +1 -1
  179. package/dist/drivers/schema-wire.d.ts +6 -2
  180. package/dist/drivers/schema-wire.d.ts.map +1 -1
  181. package/dist/drivers/schema-wire.js +6 -2
  182. package/dist/drivers/schema-wire.js.map +1 -1
  183. package/dist/effect/jazz.d.ts +12 -5
  184. package/dist/effect/jazz.d.ts.map +1 -1
  185. package/dist/effect/jazz.js +28 -5
  186. package/dist/effect/jazz.js.map +1 -1
  187. package/dist/expo/create-account-manager.d.ts +1 -1
  188. package/dist/expo/create-account-manager.d.ts.map +1 -1
  189. package/dist/expo/create-jazz-session.d.ts +37 -17
  190. package/dist/expo/create-jazz-session.d.ts.map +1 -1
  191. package/dist/expo/create-jazz-session.js +53 -10
  192. package/dist/expo/create-jazz-session.js.map +1 -1
  193. package/dist/expo/index.d.ts +5 -8
  194. package/dist/expo/index.d.ts.map +1 -1
  195. package/dist/expo/index.js +5 -7
  196. package/dist/expo/index.js.map +1 -1
  197. package/dist/expo/metro.d.ts +20 -0
  198. package/dist/expo/metro.d.ts.map +1 -0
  199. package/dist/expo/metro.js +58 -0
  200. package/dist/expo/metro.js.map +1 -0
  201. package/dist/expo/provider.d.ts +6 -3
  202. package/dist/expo/provider.d.ts.map +1 -1
  203. package/dist/expo/provider.js +7 -6
  204. package/dist/expo/provider.js.map +1 -1
  205. package/dist/index.d.ts +3 -2
  206. package/dist/index.d.ts.map +1 -1
  207. package/dist/index.js +3 -1
  208. package/dist/index.js.map +1 -1
  209. package/dist/inspect/cli.d.ts +12 -0
  210. package/dist/inspect/cli.d.ts.map +1 -0
  211. package/dist/inspect/cli.js +320 -0
  212. package/dist/inspect/cli.js.map +1 -0
  213. package/dist/inspect/client.d.ts +67 -0
  214. package/dist/inspect/client.d.ts.map +1 -0
  215. package/dist/inspect/client.js +254 -0
  216. package/dist/inspect/client.js.map +1 -0
  217. package/dist/inspect/mcp.d.ts +28 -0
  218. package/dist/inspect/mcp.d.ts.map +1 -0
  219. package/dist/inspect/mcp.js +441 -0
  220. package/dist/inspect/mcp.js.map +1 -0
  221. package/dist/inspect/protocol.d.ts +317 -0
  222. package/dist/inspect/protocol.d.ts.map +1 -0
  223. package/dist/inspect/protocol.js +544 -0
  224. package/dist/inspect/protocol.js.map +1 -0
  225. package/dist/inspector/index.d.ts +10 -0
  226. package/dist/inspector/index.d.ts.map +1 -0
  227. package/dist/inspector/index.js +27 -0
  228. package/dist/inspector/index.js.map +1 -0
  229. package/dist/local-first/index.d.ts +2 -0
  230. package/dist/local-first/index.d.ts.map +1 -1
  231. package/dist/local-first/index.js +2 -0
  232. package/dist/local-first/index.js.map +1 -1
  233. package/dist/migrations.d.ts +23 -3
  234. package/dist/migrations.d.ts.map +1 -1
  235. package/dist/migrations.js +28 -6
  236. package/dist/migrations.js.map +1 -1
  237. package/dist/module-interop.d.ts +17 -0
  238. package/dist/module-interop.d.ts.map +1 -0
  239. package/dist/module-interop.js +32 -0
  240. package/dist/module-interop.js.map +1 -0
  241. package/dist/permissions/index.d.ts +1 -1
  242. package/dist/permissions/index.d.ts.map +1 -1
  243. package/dist/permissions/index.js +31 -10
  244. package/dist/permissions/index.js.map +1 -1
  245. package/dist/prosemirror/sync.d.ts.map +1 -1
  246. package/dist/prosemirror/sync.js +43 -21
  247. package/dist/prosemirror/sync.js.map +1 -1
  248. package/dist/react/index.d.ts +4 -9
  249. package/dist/react/index.d.ts.map +1 -1
  250. package/dist/react/index.js +4 -6
  251. package/dist/react/index.js.map +1 -1
  252. package/dist/react/provider-props.d.ts +7 -0
  253. package/dist/react/provider-props.d.ts.map +1 -0
  254. package/dist/react/provider-props.js +15 -0
  255. package/dist/react/provider-props.js.map +1 -0
  256. package/dist/react/provider.d.ts +9 -15
  257. package/dist/react/provider.d.ts.map +1 -1
  258. package/dist/react/provider.js +19 -38
  259. package/dist/react/provider.js.map +1 -1
  260. package/dist/react-core/index.d.ts +3 -4
  261. package/dist/react-core/index.d.ts.map +1 -1
  262. package/dist/react-core/index.js +8 -4
  263. package/dist/react-core/index.js.map +1 -1
  264. package/dist/react-core/provider.d.ts +6 -6
  265. package/dist/react-core/provider.d.ts.map +1 -1
  266. package/dist/react-core/provider.js +5 -6
  267. package/dist/react-core/provider.js.map +1 -1
  268. package/dist/react-core/session.d.ts +41 -33
  269. package/dist/react-core/session.d.ts.map +1 -1
  270. package/dist/react-core/session.js +42 -90
  271. package/dist/react-core/session.js.map +1 -1
  272. package/dist/react-native/account-session.js +1 -1
  273. package/dist/react-native/account-session.js.map +1 -1
  274. package/dist/react-native/create-account-manager.d.ts +1 -1
  275. package/dist/react-native/create-account-manager.d.ts.map +1 -1
  276. package/dist/react-native/create-jazz-session.d.ts +37 -17
  277. package/dist/react-native/create-jazz-session.d.ts.map +1 -1
  278. package/dist/react-native/create-jazz-session.js +53 -10
  279. package/dist/react-native/create-jazz-session.js.map +1 -1
  280. package/dist/react-native/index.d.ts +5 -10
  281. package/dist/react-native/index.d.ts.map +1 -1
  282. package/dist/react-native/index.js +5 -7
  283. package/dist/react-native/index.js.map +1 -1
  284. package/dist/react-native/native-foreground-db.d.ts +21 -0
  285. package/dist/react-native/native-foreground-db.d.ts.map +1 -1
  286. package/dist/react-native/native-foreground-db.js +47 -1
  287. package/dist/react-native/native-foreground-db.js.map +1 -1
  288. package/dist/react-native/provider.d.ts +14 -19
  289. package/dist/react-native/provider.d.ts.map +1 -1
  290. package/dist/react-native/provider.js +19 -18
  291. package/dist/react-native/provider.js.map +1 -1
  292. package/dist/react-native/runtime-source.d.ts +22 -0
  293. package/dist/react-native/runtime-source.d.ts.map +1 -1
  294. package/dist/react-native/runtime-source.js +68 -5
  295. package/dist/react-native/runtime-source.js.map +1 -1
  296. package/dist/removed-api.d.ts +87 -0
  297. package/dist/removed-api.d.ts.map +1 -0
  298. package/dist/removed-api.js +95 -0
  299. package/dist/removed-api.js.map +1 -0
  300. package/dist/runtime/auth-secret-store.d.ts +0 -44
  301. package/dist/runtime/auth-secret-store.d.ts.map +1 -1
  302. package/dist/runtime/auth-secret-store.js +1 -103
  303. package/dist/runtime/auth-secret-store.js.map +1 -1
  304. package/dist/runtime/authority-changed-error.d.ts +5 -3
  305. package/dist/runtime/authority-changed-error.d.ts.map +1 -1
  306. package/dist/runtime/authority-changed-error.js +5 -3
  307. package/dist/runtime/authority-changed-error.js.map +1 -1
  308. package/dist/runtime/browser-worker-assets.d.ts +19 -1
  309. package/dist/runtime/browser-worker-assets.d.ts.map +1 -1
  310. package/dist/runtime/browser-worker-assets.js +23 -1
  311. package/dist/runtime/browser-worker-assets.js.map +1 -1
  312. package/dist/runtime/browser-worker-assets.metro.d.ts +28 -0
  313. package/dist/runtime/browser-worker-assets.metro.d.ts.map +1 -0
  314. package/dist/runtime/browser-worker-assets.metro.js +52 -0
  315. package/dist/runtime/browser-worker-assets.metro.js.map +1 -0
  316. package/dist/runtime/browser-worker-assets.native.d.ts +2 -0
  317. package/dist/runtime/browser-worker-assets.native.d.ts.map +1 -1
  318. package/dist/runtime/browser-worker-assets.native.js +2 -0
  319. package/dist/runtime/browser-worker-assets.native.js.map +1 -1
  320. package/dist/runtime/browser-worker-config.d.ts +23 -0
  321. package/dist/runtime/browser-worker-config.d.ts.map +1 -1
  322. package/dist/runtime/browser-worker-config.js +72 -4
  323. package/dist/runtime/browser-worker-config.js.map +1 -1
  324. package/dist/runtime/client-migrations.d.ts +6 -4
  325. package/dist/runtime/client-migrations.d.ts.map +1 -1
  326. package/dist/runtime/client-migrations.js +20 -2
  327. package/dist/runtime/client-migrations.js.map +1 -1
  328. package/dist/runtime/client.d.ts +46 -6
  329. package/dist/runtime/client.d.ts.map +1 -1
  330. package/dist/runtime/client.js +65 -13
  331. package/dist/runtime/client.js.map +1 -1
  332. package/dist/runtime/connection-manager/browser-connection-manager.d.ts +5 -1
  333. package/dist/runtime/connection-manager/browser-connection-manager.d.ts.map +1 -1
  334. package/dist/runtime/connection-manager/browser-connection-manager.js +38 -2
  335. package/dist/runtime/connection-manager/browser-connection-manager.js.map +1 -1
  336. package/dist/runtime/connection-manager/direct-connection-manager.d.ts +3 -1
  337. package/dist/runtime/connection-manager/direct-connection-manager.d.ts.map +1 -1
  338. package/dist/runtime/connection-manager/direct-connection-manager.js +7 -3
  339. package/dist/runtime/connection-manager/direct-connection-manager.js.map +1 -1
  340. package/dist/runtime/connection-manager/types.d.ts +23 -2
  341. package/dist/runtime/connection-manager/types.d.ts.map +1 -1
  342. package/dist/runtime/connection-manager/types.js +49 -6
  343. package/dist/runtime/connection-manager/types.js.map +1 -1
  344. package/dist/runtime/context.d.ts +5 -1
  345. package/dist/runtime/context.d.ts.map +1 -1
  346. package/dist/runtime/context.js.map +1 -1
  347. package/dist/runtime/core-tick-failed-error.d.ts +31 -0
  348. package/dist/runtime/core-tick-failed-error.d.ts.map +1 -0
  349. package/dist/runtime/core-tick-failed-error.js +45 -0
  350. package/dist/runtime/core-tick-failed-error.js.map +1 -0
  351. package/dist/runtime/credentialed-transport.d.ts +18 -3
  352. package/dist/runtime/credentialed-transport.d.ts.map +1 -1
  353. package/dist/runtime/credentialed-transport.js +34 -11
  354. package/dist/runtime/credentialed-transport.js.map +1 -1
  355. package/dist/runtime/db-replaced-error.d.ts +3 -1
  356. package/dist/runtime/db-replaced-error.d.ts.map +1 -1
  357. package/dist/runtime/db-replaced-error.js +4 -2
  358. package/dist/runtime/db-replaced-error.js.map +1 -1
  359. package/dist/runtime/db.d.ts +40 -8
  360. package/dist/runtime/db.d.ts.map +1 -1
  361. package/dist/runtime/db.js +76 -9
  362. package/dist/runtime/db.js.map +1 -1
  363. package/dist/runtime/default-runtime-source.d.ts.map +1 -1
  364. package/dist/runtime/default-runtime-source.js +6 -1
  365. package/dist/runtime/default-runtime-source.js.map +1 -1
  366. package/dist/runtime/delete-local-first-store.d.ts +12 -0
  367. package/dist/runtime/delete-local-first-store.d.ts.map +1 -0
  368. package/dist/runtime/delete-local-first-store.js +12 -0
  369. package/dist/runtime/delete-local-first-store.js.map +1 -0
  370. package/dist/runtime/index.d.ts +4 -4
  371. package/dist/runtime/index.d.ts.map +1 -1
  372. package/dist/runtime/index.js +2 -2
  373. package/dist/runtime/index.js.map +1 -1
  374. package/dist/runtime/local-first-upgrade.d.ts +9 -0
  375. package/dist/runtime/local-first-upgrade.d.ts.map +1 -1
  376. package/dist/runtime/local-first-upgrade.js.map +1 -1
  377. package/dist/runtime/metro-setup-error.d.ts +20 -0
  378. package/dist/runtime/metro-setup-error.d.ts.map +1 -0
  379. package/dist/runtime/metro-setup-error.js +22 -0
  380. package/dist/runtime/metro-setup-error.js.map +1 -0
  381. package/dist/runtime/native-artifact-fingerprint-napi.d.ts +1 -1
  382. package/dist/runtime/native-artifact-fingerprint-napi.js +1 -1
  383. package/dist/runtime/native-artifact-fingerprint-napi.js.map +1 -1
  384. package/dist/runtime/native-artifact-fingerprint-wasm.d.ts +1 -1
  385. package/dist/runtime/native-artifact-fingerprint-wasm.js +1 -1
  386. package/dist/runtime/native-artifact-fingerprint-wasm.js.map +1 -1
  387. package/dist/runtime/native-artifact-fingerprints.d.ts +2 -2
  388. package/dist/runtime/native-runtime/attached-browser-worker-connection.d.ts +4 -1
  389. package/dist/runtime/native-runtime/attached-browser-worker-connection.d.ts.map +1 -1
  390. package/dist/runtime/native-runtime/attached-browser-worker-connection.js +3 -0
  391. package/dist/runtime/native-runtime/attached-browser-worker-connection.js.map +1 -1
  392. package/dist/runtime/native-runtime/broker-worker-load-failure.d.ts +34 -0
  393. package/dist/runtime/native-runtime/broker-worker-load-failure.d.ts.map +1 -0
  394. package/dist/runtime/native-runtime/broker-worker-load-failure.js +61 -0
  395. package/dist/runtime/native-runtime/broker-worker-load-failure.js.map +1 -0
  396. package/dist/runtime/native-runtime/browser-follower-connection.d.ts +6 -1
  397. package/dist/runtime/native-runtime/browser-follower-connection.d.ts.map +1 -1
  398. package/dist/runtime/native-runtime/browser-follower-connection.js +9 -3
  399. package/dist/runtime/native-runtime/browser-follower-connection.js.map +1 -1
  400. package/dist/runtime/native-runtime/browser-shared-worker-connection.d.ts +12 -1
  401. package/dist/runtime/native-runtime/browser-shared-worker-connection.d.ts.map +1 -1
  402. package/dist/runtime/native-runtime/browser-shared-worker-connection.js +140 -7
  403. package/dist/runtime/native-runtime/browser-shared-worker-connection.js.map +1 -1
  404. package/dist/runtime/native-runtime/browser-worker-protocol.d.ts +29 -1
  405. package/dist/runtime/native-runtime/browser-worker-protocol.d.ts.map +1 -1
  406. package/dist/runtime/native-runtime/browser-worker-protocol.js.map +1 -1
  407. package/dist/runtime/native-runtime/http-stream-socket.d.ts +25 -7
  408. package/dist/runtime/native-runtime/http-stream-socket.d.ts.map +1 -1
  409. package/dist/runtime/native-runtime/http-stream-socket.js +148 -44
  410. package/dist/runtime/native-runtime/http-stream-socket.js.map +1 -1
  411. package/dist/runtime/native-runtime/native-error-code.d.ts +1 -1
  412. package/dist/runtime/native-runtime/native-error-code.d.ts.map +1 -1
  413. package/dist/runtime/native-runtime/native-error-code.js +1 -0
  414. package/dist/runtime/native-runtime/native-error-code.js.map +1 -1
  415. package/dist/runtime/native-runtime/native-runtime-adapter.d.ts +105 -7
  416. package/dist/runtime/native-runtime/native-runtime-adapter.d.ts.map +1 -1
  417. package/dist/runtime/native-runtime/native-runtime-adapter.js +306 -27
  418. package/dist/runtime/native-runtime/native-runtime-adapter.js.map +1 -1
  419. package/dist/runtime/native-runtime/session-renewal-wire.d.ts +48 -0
  420. package/dist/runtime/native-runtime/session-renewal-wire.d.ts.map +1 -0
  421. package/dist/runtime/native-runtime/session-renewal-wire.js +107 -0
  422. package/dist/runtime/native-runtime/session-renewal-wire.js.map +1 -0
  423. package/dist/runtime/native-runtime/stream-endpoint-memory.d.ts +22 -0
  424. package/dist/runtime/native-runtime/stream-endpoint-memory.d.ts.map +1 -0
  425. package/dist/runtime/native-runtime/stream-endpoint-memory.js +69 -0
  426. package/dist/runtime/native-runtime/stream-endpoint-memory.js.map +1 -0
  427. package/dist/runtime/native-runtime/websocket.d.ts +51 -1
  428. package/dist/runtime/native-runtime/websocket.d.ts.map +1 -1
  429. package/dist/runtime/native-runtime/websocket.js +187 -7
  430. package/dist/runtime/native-runtime/websocket.js.map +1 -1
  431. package/dist/runtime/page-handle.d.ts +83 -0
  432. package/dist/runtime/page-handle.d.ts.map +1 -0
  433. package/dist/runtime/page-handle.js +151 -0
  434. package/dist/runtime/page-handle.js.map +1 -0
  435. package/dist/runtime/removed-provider-props.d.ts +17 -0
  436. package/dist/runtime/removed-provider-props.d.ts.map +1 -0
  437. package/dist/runtime/removed-provider-props.js +16 -0
  438. package/dist/runtime/removed-provider-props.js.map +1 -0
  439. package/dist/runtime/row-transformer.d.ts.map +1 -1
  440. package/dist/runtime/row-transformer.js +20 -0
  441. package/dist/runtime/row-transformer.js.map +1 -1
  442. package/dist/runtime/runtime-config.d.ts +5 -1
  443. package/dist/runtime/runtime-config.d.ts.map +1 -1
  444. package/dist/runtime/runtime-config.js +5 -1
  445. package/dist/runtime/runtime-config.js.map +1 -1
  446. package/dist/runtime/runtime-source.d.ts +6 -1
  447. package/dist/runtime/runtime-source.d.ts.map +1 -1
  448. package/dist/runtime/runtime-source.js.map +1 -1
  449. package/dist/runtime/schema-metadata.d.ts +17 -0
  450. package/dist/runtime/schema-metadata.d.ts.map +1 -1
  451. package/dist/runtime/schema-metadata.js +28 -0
  452. package/dist/runtime/schema-metadata.js.map +1 -1
  453. package/dist/runtime/store-held-by-another-tab-error.d.ts +11 -0
  454. package/dist/runtime/store-held-by-another-tab-error.d.ts.map +1 -1
  455. package/dist/runtime/store-held-by-another-tab-error.js +11 -0
  456. package/dist/runtime/store-held-by-another-tab-error.js.map +1 -1
  457. package/dist/runtime/sync-status.d.ts +60 -1
  458. package/dist/runtime/sync-status.d.ts.map +1 -1
  459. package/dist/runtime/sync-status.js +64 -4
  460. package/dist/runtime/sync-status.js.map +1 -1
  461. package/dist/runtime/wasm-loader.d.ts.map +1 -1
  462. package/dist/runtime/wasm-loader.js +8 -1
  463. package/dist/runtime/wasm-loader.js.map +1 -1
  464. package/dist/schema-loader.d.ts +2 -0
  465. package/dist/schema-loader.d.ts.map +1 -1
  466. package/dist/schema-loader.js +7 -2
  467. package/dist/schema-loader.js.map +1 -1
  468. package/dist/schema-permissions.d.ts.map +1 -1
  469. package/dist/schema-permissions.js +19 -0
  470. package/dist/schema-permissions.js.map +1 -1
  471. package/dist/schema-source.d.ts.map +1 -1
  472. package/dist/schema-source.js +14 -0
  473. package/dist/schema-source.js.map +1 -1
  474. package/dist/session/backend-watch.d.ts +56 -15
  475. package/dist/session/backend-watch.d.ts.map +1 -1
  476. package/dist/session/backend-watch.js +127 -31
  477. package/dist/session/backend-watch.js.map +1 -1
  478. package/dist/session/config-options.d.ts +15 -0
  479. package/dist/session/config-options.d.ts.map +1 -0
  480. package/dist/session/config-options.js +55 -0
  481. package/dist/session/config-options.js.map +1 -0
  482. package/dist/session/consumer.d.ts +1 -1
  483. package/dist/session/consumer.js +1 -1
  484. package/dist/session/consumer.js.map +1 -1
  485. package/dist/session/create-jazz-session.d.ts +55 -21
  486. package/dist/session/create-jazz-session.d.ts.map +1 -1
  487. package/dist/session/create-jazz-session.js +215 -166
  488. package/dist/session/create-jazz-session.js.map +1 -1
  489. package/dist/session/follow-user.d.ts +30 -11
  490. package/dist/session/follow-user.d.ts.map +1 -1
  491. package/dist/session/follow-user.js +49 -9
  492. package/dist/session/follow-user.js.map +1 -1
  493. package/dist/session/jazz-session.d.ts +182 -0
  494. package/dist/session/jazz-session.d.ts.map +1 -0
  495. package/dist/session/jazz-session.js +459 -0
  496. package/dist/session/jazz-session.js.map +1 -0
  497. package/dist/session/no-kept-device-account-error.d.ts +6 -0
  498. package/dist/session/no-kept-device-account-error.d.ts.map +1 -0
  499. package/dist/session/no-kept-device-account-error.js +8 -0
  500. package/dist/session/no-kept-device-account-error.js.map +1 -0
  501. package/dist/session/replica-ledger.d.ts +164 -0
  502. package/dist/session/replica-ledger.d.ts.map +1 -0
  503. package/dist/session/replica-ledger.js +450 -0
  504. package/dist/session/replica-ledger.js.map +1 -0
  505. package/dist/session/state.d.ts +50 -13
  506. package/dist/session/state.d.ts.map +1 -1
  507. package/dist/session/state.js +158 -29
  508. package/dist/session/state.js.map +1 -1
  509. package/dist/solid/index.d.ts +3 -9
  510. package/dist/solid/index.d.ts.map +1 -1
  511. package/dist/solid/index.js +8 -11
  512. package/dist/solid/index.ssr.js +3 -6
  513. package/dist/solid/provider.d.ts +3 -3
  514. package/dist/solid/provider.d.ts.map +1 -1
  515. package/dist/solid/provider.js +23 -39
  516. package/dist/solid/provider.js.map +1 -1
  517. package/dist/solid/provider.ssr.js +6 -23
  518. package/dist/solid/provider.ssr.js.map +1 -1
  519. package/dist/solid/session.d.ts +42 -12
  520. package/dist/solid/session.d.ts.map +1 -1
  521. package/dist/solid/session.js +82 -35
  522. package/dist/solid/session.js.map +1 -1
  523. package/dist/solid/session.ssr.js +86 -23
  524. package/dist/solid/session.ssr.js.map +1 -1
  525. package/dist/svelte/JazzProvider.svelte +54 -20
  526. package/dist/svelte/JazzProvider.svelte.d.ts +14 -4
  527. package/dist/svelte/JazzProvider.svelte.d.ts.map +1 -1
  528. package/dist/svelte/JazzSvelteClientProvider.svelte +1 -7
  529. package/dist/svelte/JazzSvelteClientProvider.svelte.d.ts +0 -1
  530. package/dist/svelte/JazzSvelteClientProvider.svelte.d.ts.map +1 -1
  531. package/dist/svelte/JazzSvelteProvider.svelte +5 -4
  532. package/dist/svelte/JazzSvelteProvider.svelte.d.ts +2 -2
  533. package/dist/svelte/JazzSvelteProvider.svelte.d.ts.map +1 -1
  534. package/dist/svelte/index.d.ts +4 -12
  535. package/dist/svelte/index.d.ts.map +1 -1
  536. package/dist/svelte/index.js +4 -8
  537. package/dist/svelte/session-state.d.ts +14 -4
  538. package/dist/svelte/session-state.d.ts.map +1 -1
  539. package/dist/svelte/session-state.js +10 -4
  540. package/dist/testing/client-migrations.d.ts +8 -1
  541. package/dist/testing/client-migrations.d.ts.map +1 -1
  542. package/dist/testing/client-migrations.js +11 -0
  543. package/dist/testing/client-migrations.js.map +1 -1
  544. package/dist/testing/policy-test-app.d.ts.map +1 -1
  545. package/dist/testing/policy-test-app.js +5 -4
  546. package/dist/testing/policy-test-app.js.map +1 -1
  547. package/dist/testing/test-jazz.d.ts +2 -2
  548. package/dist/testing/test-jazz.d.ts.map +1 -1
  549. package/dist/testing/test-jazz.js +6 -3
  550. package/dist/testing/test-jazz.js.map +1 -1
  551. package/dist/thin/index.d.ts +7 -10
  552. package/dist/thin/index.d.ts.map +1 -1
  553. package/dist/thin/index.js +28 -11
  554. package/dist/thin/index.js.map +1 -1
  555. package/dist/thin/thin-runtime.d.ts +53 -3
  556. package/dist/thin/thin-runtime.d.ts.map +1 -1
  557. package/dist/thin/thin-runtime.js +256 -33
  558. package/dist/thin/thin-runtime.js.map +1 -1
  559. package/dist/typed-app.d.ts +10 -4
  560. package/dist/typed-app.d.ts.map +1 -1
  561. package/dist/typed-app.js +44 -18
  562. package/dist/typed-app.js.map +1 -1
  563. package/dist/vue/index.d.ts +3 -8
  564. package/dist/vue/index.d.ts.map +1 -1
  565. package/dist/vue/index.js +3 -5
  566. package/dist/vue/index.js.map +1 -1
  567. package/dist/vue/provider.d.ts +6 -27
  568. package/dist/vue/provider.d.ts.map +1 -1
  569. package/dist/vue/provider.js +10 -19
  570. package/dist/vue/provider.js.map +1 -1
  571. package/dist/vue/session.d.ts +29 -28
  572. package/dist/vue/session.d.ts.map +1 -1
  573. package/dist/vue/session.js +80 -23
  574. package/dist/vue/session.js.map +1 -1
  575. package/dist/web/create-jazz-client.d.ts +5 -1
  576. package/dist/web/create-jazz-client.d.ts.map +1 -1
  577. package/dist/web/create-jazz-client.js +30 -3
  578. package/dist/web/create-jazz-client.js.map +1 -1
  579. package/dist/window-client-storage.d.ts +4 -30
  580. package/dist/window-client-storage.d.ts.map +1 -1
  581. package/dist/window-client-storage.js +2 -63
  582. package/dist/window-client-storage.js.map +1 -1
  583. package/dist/worker/jazz-broker-worker-core.d.ts.map +1 -1
  584. package/dist/worker/jazz-broker-worker-core.js +118 -20
  585. package/dist/worker/jazz-broker-worker-core.js.map +1 -1
  586. package/dist/worker/jazz-broker-worker.js +787 -608
  587. package/dist/worker/jazz_wasm_bg.wasm +0 -0
  588. package/dist/worker/runtime-admission.d.ts +19 -0
  589. package/dist/worker/runtime-admission.d.ts.map +1 -0
  590. package/dist/worker/runtime-admission.js +34 -0
  591. package/dist/worker/runtime-admission.js.map +1 -0
  592. package/dist/worker/vite-dev-broker.d.ts +2 -0
  593. package/dist/worker/vite-dev-broker.d.ts.map +1 -0
  594. package/dist/worker/vite-dev-broker.js +8 -0
  595. package/dist/worker/vite-dev-broker.js.map +1 -0
  596. package/package.json +30 -10
  597. package/dist/backend/session-recheck.d.ts +0 -18
  598. package/dist/backend/session-recheck.d.ts.map +0 -1
  599. package/dist/backend/session-recheck.js +0 -57
  600. package/dist/backend/session-recheck.js.map +0 -1
  601. package/dist/dev/inspector-overlay/embedded/assets/esm-k3rsq4Gn.js +0 -1
  602. package/dist/dev/inspector-overlay/embedded/assets/index-C-btvLcw.js +0 -20
  603. package/dist/dev/inspector-overlay/embedded/assets/jazz-broker-worker-CAMcDeUa.js +0 -3
  604. package/dist/dev/inspector-overlay/embedded/assets/jazz_wasm-Cc71x_6y.js +0 -1
  605. package/dist/dev/inspector-overlay/serve.d.ts +0 -46
  606. package/dist/dev/inspector-overlay/serve.d.ts.map +0 -1
  607. package/dist/dev/inspector-overlay/serve.js +0 -131
  608. package/dist/dev/inspector-overlay/serve.js.map +0 -1
  609. package/dist/dev-tools/auto-attach.d.ts +0 -11
  610. package/dist/dev-tools/auto-attach.d.ts.map +0 -1
  611. package/dist/dev-tools/auto-attach.js +0 -26
  612. package/dist/dev-tools/auto-attach.js.map +0 -1
  613. package/dist/expo/auth-secret-store.d.ts +0 -37
  614. package/dist/expo/auth-secret-store.d.ts.map +0 -1
  615. package/dist/expo/auth-secret-store.js +0 -139
  616. package/dist/expo/auth-secret-store.js.map +0 -1
  617. package/dist/expo/session.d.ts +0 -10
  618. package/dist/expo/session.d.ts.map +0 -1
  619. package/dist/expo/session.js +0 -5
  620. package/dist/expo/session.js.map +0 -1
  621. package/dist/expo/use-local-first-auth.d.ts +0 -12
  622. package/dist/expo/use-local-first-auth.d.ts.map +0 -1
  623. package/dist/expo/use-local-first-auth.js +0 -13
  624. package/dist/expo/use-local-first-auth.js.map +0 -1
  625. package/dist/react/devtools-auto-attach.d.ts +0 -2
  626. package/dist/react/devtools-auto-attach.d.ts.map +0 -1
  627. package/dist/react/devtools-auto-attach.js +0 -11
  628. package/dist/react/devtools-auto-attach.js.map +0 -1
  629. package/dist/react/session.d.ts +0 -18
  630. package/dist/react/session.d.ts.map +0 -1
  631. package/dist/react/session.js +0 -28
  632. package/dist/react/session.js.map +0 -1
  633. package/dist/react/use-local-first-auth.d.ts +0 -11
  634. package/dist/react/use-local-first-auth.d.ts.map +0 -1
  635. package/dist/react/use-local-first-auth.js +0 -13
  636. package/dist/react/use-local-first-auth.js.map +0 -1
  637. package/dist/react-core/app.d.ts +0 -31
  638. package/dist/react-core/app.d.ts.map +0 -1
  639. package/dist/react-core/app.js +0 -65
  640. package/dist/react-core/app.js.map +0 -1
  641. package/dist/react-core/use-account-state.d.ts +0 -4
  642. package/dist/react-core/use-account-state.d.ts.map +0 -1
  643. package/dist/react-core/use-account-state.js +0 -6
  644. package/dist/react-core/use-account-state.js.map +0 -1
  645. package/dist/react-core/use-local-first-auth.d.ts +0 -12
  646. package/dist/react-core/use-local-first-auth.d.ts.map +0 -1
  647. package/dist/react-core/use-local-first-auth.js +0 -14
  648. package/dist/react-core/use-local-first-auth.js.map +0 -1
  649. package/dist/react-native/session.d.ts +0 -10
  650. package/dist/react-native/session.d.ts.map +0 -1
  651. package/dist/react-native/session.js +0 -5
  652. package/dist/react-native/session.js.map +0 -1
  653. package/dist/react-native/use-local-first-auth.d.ts +0 -15
  654. package/dist/react-native/use-local-first-auth.d.ts.map +0 -1
  655. package/dist/react-native/use-local-first-auth.js +0 -14
  656. package/dist/react-native/use-local-first-auth.js.map +0 -1
  657. package/dist/runtime/local-first-auth-controller.d.ts +0 -29
  658. package/dist/runtime/local-first-auth-controller.d.ts.map +0 -1
  659. package/dist/runtime/local-first-auth-controller.js +0 -101
  660. package/dist/runtime/local-first-auth-controller.js.map +0 -1
  661. package/dist/session/app.d.ts +0 -58
  662. package/dist/session/app.d.ts.map +0 -1
  663. package/dist/session/app.js +0 -325
  664. package/dist/session/app.js.map +0 -1
  665. package/dist/session/create-jazz-app.d.ts +0 -11
  666. package/dist/session/create-jazz-app.d.ts.map +0 -1
  667. package/dist/session/create-jazz-app.js +0 -11
  668. package/dist/session/create-jazz-app.js.map +0 -1
  669. package/dist/session/left-behind-replicas.d.ts +0 -62
  670. package/dist/session/left-behind-replicas.d.ts.map +0 -1
  671. package/dist/session/left-behind-replicas.js +0 -146
  672. package/dist/session/left-behind-replicas.js.map +0 -1
  673. package/dist/solid/app.d.ts +0 -30
  674. package/dist/solid/app.d.ts.map +0 -1
  675. package/dist/solid/app.js +0 -95
  676. package/dist/solid/app.js.map +0 -1
  677. package/dist/solid/app.ssr.js +0 -109
  678. package/dist/solid/app.ssr.js.map +0 -1
  679. package/dist/solid/create-account-state.d.ts +0 -4
  680. package/dist/solid/create-account-state.d.ts.map +0 -1
  681. package/dist/solid/create-account-state.js +0 -10
  682. package/dist/solid/create-account-state.js.map +0 -1
  683. package/dist/solid/create-account-state.ssr.js +0 -12
  684. package/dist/solid/create-account-state.ssr.js.map +0 -1
  685. package/dist/solid/use-local-first-auth.d.ts +0 -11
  686. package/dist/solid/use-local-first-auth.d.ts.map +0 -1
  687. package/dist/solid/use-local-first-auth.js +0 -30
  688. package/dist/solid/use-local-first-auth.js.map +0 -1
  689. package/dist/solid/use-local-first-auth.ssr.js +0 -31
  690. package/dist/solid/use-local-first-auth.ssr.js.map +0 -1
  691. package/dist/svelte/JazzSessionClientProvider.svelte +0 -42
  692. package/dist/svelte/JazzSessionClientProvider.svelte.d.ts +0 -13
  693. package/dist/svelte/JazzSessionClientProvider.svelte.d.ts.map +0 -1
  694. package/dist/svelte/JazzSessionProvider.svelte +0 -68
  695. package/dist/svelte/JazzSessionProvider.svelte.d.ts +0 -19
  696. package/dist/svelte/JazzSessionProvider.svelte.d.ts.map +0 -1
  697. package/dist/svelte/account-state.d.ts +0 -5
  698. package/dist/svelte/account-state.d.ts.map +0 -1
  699. package/dist/svelte/account-state.js +0 -9
  700. package/dist/svelte/auth-state.d.ts +0 -23
  701. package/dist/svelte/auth-state.d.ts.map +0 -1
  702. package/dist/svelte/auth-state.js +0 -16
  703. package/dist/svelte/local-first-auth.svelte.d.ts +0 -50
  704. package/dist/svelte/local-first-auth.svelte.d.ts.map +0 -1
  705. package/dist/svelte/local-first-auth.svelte.js +0 -58
  706. package/dist/vue/app.d.ts +0 -76
  707. package/dist/vue/app.d.ts.map +0 -1
  708. package/dist/vue/app.js +0 -100
  709. package/dist/vue/app.js.map +0 -1
  710. package/dist/vue/use-account-state.d.ts +0 -5
  711. package/dist/vue/use-account-state.d.ts.map +0 -1
  712. package/dist/vue/use-account-state.js +0 -10
  713. package/dist/vue/use-account-state.js.map +0 -1
  714. package/dist/vue/use-local-first-auth.d.ts +0 -53
  715. package/dist/vue/use-local-first-auth.d.ts.map +0 -1
  716. package/dist/vue/use-local-first-auth.js +0 -67
  717. package/dist/vue/use-local-first-auth.js.map +0 -1
  718. /package/dist/dev/inspector-overlay/embedded/assets/{esm-CH5eVyQQ.js → esm-xNe3wI_B.js} +0 -0
  719. /package/dist/dev/inspector-overlay/embedded/assets/{node-foreground-node-lease.browser-Bm3gYjlT.js → node-foreground-node-lease.browser-CH8w-D6S.js} +0 -0
@@ -926,7 +926,7 @@ function __wbg_get_imports() {
926
926
  return ret;
927
927
  },
928
928
  __wbindgen_cast_0000000000000002: function(arg0, arg1) {
929
- const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h62288b7949ffd3ae);
929
+ const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h674c3a97310f6b6c);
930
930
  return ret;
931
931
  },
932
932
  __wbindgen_cast_0000000000000003: function(arg0, arg1) {
@@ -934,7 +934,7 @@ function __wbg_get_imports() {
934
934
  return ret;
935
935
  },
936
936
  __wbindgen_cast_0000000000000004: function(arg0, arg1) {
937
- const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h05f77cffdc1766b5);
937
+ const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h621b350062601bb0);
938
938
  return ret;
939
939
  },
940
940
  __wbindgen_cast_0000000000000005: function(arg0, arg1) {
@@ -985,8 +985,8 @@ function wasm_bindgen__convert__closures_____invoke__h492b14c1fd17d971(arg0, arg
985
985
  function wasm_bindgen__convert__closures_____invoke__hf83e1094fac4ab4c(arg0, arg1, arg2) {
986
986
  wasm.wasm_bindgen__convert__closures_____invoke__hf83e1094fac4ab4c(arg0, arg1, arg2);
987
987
  }
988
- function wasm_bindgen__convert__closures_____invoke__h62288b7949ffd3ae(arg0, arg1, arg2) {
989
- const ret = wasm.wasm_bindgen__convert__closures_____invoke__h62288b7949ffd3ae(arg0, arg1, arg2);
988
+ function wasm_bindgen__convert__closures_____invoke__h674c3a97310f6b6c(arg0, arg1, arg2) {
989
+ const ret = wasm.wasm_bindgen__convert__closures_____invoke__h674c3a97310f6b6c(arg0, arg1, arg2);
990
990
  return ret;
991
991
  }
992
992
  function wasm_bindgen__convert__closures_____invoke__hf2d3ca0c7acb67d9(arg0, arg1, arg2) {
@@ -995,8 +995,8 @@ function wasm_bindgen__convert__closures_____invoke__hf2d3ca0c7acb67d9(arg0, arg
995
995
  throw takeFromExternrefTable0(ret[0]);
996
996
  }
997
997
  }
998
- function wasm_bindgen__convert__closures_____invoke__h05f77cffdc1766b5(arg0, arg1, arg2) {
999
- const ret = wasm.wasm_bindgen__convert__closures_____invoke__h05f77cffdc1766b5(arg0, arg1, arg2);
998
+ function wasm_bindgen__convert__closures_____invoke__h621b350062601bb0(arg0, arg1, arg2) {
999
+ const ret = wasm.wasm_bindgen__convert__closures_____invoke__h621b350062601bb0(arg0, arg1, arg2);
1000
1000
  if (ret[1]) {
1001
1001
  throw takeFromExternrefTable0(ret[0]);
1002
1002
  }
@@ -1695,8 +1695,8 @@ var init_jazz_wasm = __esm({
1695
1695
  * @param {string} database
1696
1696
  * @returns {Promise<void>}
1697
1697
  */
1698
- static destroyBrowserStorage(storage, database) {
1699
- const ptr0 = passStringToWasm0(database, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1698
+ static destroyBrowserStorage(storage, database2) {
1699
+ const ptr0 = passStringToWasm0(database2, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1700
1700
  const len0 = WASM_VECTOR_LEN;
1701
1701
  const ret = wasm.wasmdb_destroyBrowserStorage(storage, ptr0, len0);
1702
1702
  return ret;
@@ -1820,12 +1820,12 @@ var init_jazz_wasm = __esm({
1820
1820
  * @param {string} database
1821
1821
  * @returns {Promise<WasmDb>}
1822
1822
  */
1823
- static openBrowser(storage, schema, config, database) {
1823
+ static openBrowser(storage, schema, config, database2) {
1824
1824
  const ptr0 = passArray8ToWasm0(schema, wasm.__wbindgen_malloc);
1825
1825
  const len0 = WASM_VECTOR_LEN;
1826
1826
  const ptr1 = passArray8ToWasm0(config, wasm.__wbindgen_malloc);
1827
1827
  const len1 = WASM_VECTOR_LEN;
1828
- const ptr2 = passStringToWasm0(database, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1828
+ const ptr2 = passStringToWasm0(database2, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1829
1829
  const len2 = WASM_VECTOR_LEN;
1830
1830
  const ret = wasm.wasmdb_openBrowser(storage, ptr0, len0, ptr1, len1, ptr2, len2);
1831
1831
  return ret;
@@ -1840,7 +1840,7 @@ var init_jazz_wasm = __esm({
1840
1840
  * @param {string} database
1841
1841
  * @returns {Promise<WasmDb>}
1842
1842
  */
1843
- static openBrowserWithSelfSignedProof(storage, schema, config, token, app_id, claimed_author, database) {
1843
+ static openBrowserWithSelfSignedProof(storage, schema, config, token, app_id, claimed_author, database2) {
1844
1844
  const ptr0 = passArray8ToWasm0(schema, wasm.__wbindgen_malloc);
1845
1845
  const len0 = WASM_VECTOR_LEN;
1846
1846
  const ptr1 = passArray8ToWasm0(config, wasm.__wbindgen_malloc);
@@ -1851,7 +1851,7 @@ var init_jazz_wasm = __esm({
1851
1851
  const len3 = WASM_VECTOR_LEN;
1852
1852
  const ptr4 = passStringToWasm0(claimed_author, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1853
1853
  const len4 = WASM_VECTOR_LEN;
1854
- const ptr5 = passStringToWasm0(database, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1854
+ const ptr5 = passStringToWasm0(database2, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1855
1855
  const len5 = WASM_VECTOR_LEN;
1856
1856
  const ret = wasm.wasmdb_openBrowserWithSelfSignedProof(storage, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, ptr5, len5);
1857
1857
  return ret;
@@ -1919,17 +1919,6 @@ var init_jazz_wasm = __esm({
1919
1919
  }
1920
1920
  return _WasmDb.__wrap(ret[0]);
1921
1921
  }
1922
- /**
1923
- * How many local commits still wait for the server's verdict.
1924
- * @returns {number}
1925
- */
1926
- pendingUploadCount() {
1927
- const ret = wasm.wasmdb_pendingUploadCount(this.__wbg_ptr);
1928
- if (ret[2]) {
1929
- throw takeFromExternrefTable0(ret[1]);
1930
- }
1931
- return ret[0] >>> 0;
1932
- }
1933
1922
  /**
1934
1923
  * Register a typed schema view backed by this same runtime owner, of
1935
1924
  * an app shipping `migrations` (its bundle as JSON).
@@ -2287,6 +2276,19 @@ var init_jazz_wasm = __esm({
2287
2276
  throw takeFromExternrefTable0(ret[0]);
2288
2277
  }
2289
2278
  }
2279
+ /**
2280
+ * This store's uploads: how many still wait for the server's verdict
2281
+ * and since when, and what the server refused since it opened
2282
+ * (`{ pending, oldestPendingAt, rejected, lastRejection }`).
2283
+ * @returns {any}
2284
+ */
2285
+ uploadStatus() {
2286
+ const ret = wasm.wasmdb_uploadStatus(this.__wbg_ptr);
2287
+ if (ret[2]) {
2288
+ throw takeFromExternrefTable0(ret[1]);
2289
+ }
2290
+ return takeFromExternrefTable0(ret[0]);
2291
+ }
2290
2292
  /**
2291
2293
  * @param {string} table
2292
2294
  * @param {Uint8Array} row_id
@@ -8676,10 +8678,11 @@ function sortSchemaTables(schema) {
8676
8678
  Object.keys(schema).sort().map((tableName) => [tableName, schema[tableName]])
8677
8679
  );
8678
8680
  }
8679
- function serializeSchemaSource(schema) {
8681
+ function serializeSchemaSource(schema, migrations) {
8680
8682
  return JSON.stringify(
8681
8683
  {
8682
- tables: sortSchemaTables(schema)
8684
+ tables: sortSchemaTables(schema),
8685
+ ...migrations ? { migrations } : {}
8683
8686
  },
8684
8687
  runtimeSchemaJsonReplacer
8685
8688
  );
@@ -8911,384 +8914,12 @@ function mapAuthReason(reason) {
8911
8914
  return "invalid";
8912
8915
  }
8913
8916
 
8914
- // ../../node_modules/.pnpm/@noble+hashes@2.0.1/node_modules/@noble/hashes/utils.js
8915
- function isBytes(a) {
8916
- return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
8917
- }
8918
- function abytes(value, length, title = "") {
8919
- const bytes = isBytes(value);
8920
- const len = value?.length;
8921
- const needsLen = length !== void 0;
8922
- if (!bytes || needsLen && len !== length) {
8923
- const prefix = title && `"${title}" `;
8924
- const ofLen = needsLen ? ` of length ${length}` : "";
8925
- const got = bytes ? `length=${len}` : `type=${typeof value}`;
8926
- throw new Error(prefix + "expected Uint8Array" + ofLen + ", got " + got);
8927
- }
8928
- return value;
8929
- }
8930
- function aexists(instance, checkFinished = true) {
8931
- if (instance.destroyed)
8932
- throw new Error("Hash instance has been destroyed");
8933
- if (checkFinished && instance.finished)
8934
- throw new Error("Hash#digest() has already been called");
8935
- }
8936
- function aoutput(out, instance) {
8937
- abytes(out, void 0, "digestInto() output");
8938
- const min = instance.outputLen;
8939
- if (out.length < min) {
8940
- throw new Error('"digestInto() output" expected to be of length >=' + min);
8941
- }
8942
- }
8943
- function clean(...arrays) {
8944
- for (let i = 0; i < arrays.length; i++) {
8945
- arrays[i].fill(0);
8946
- }
8947
- }
8948
- function createView(arr) {
8949
- return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
8950
- }
8951
- function rotr(word, shift) {
8952
- return word << 32 - shift | word >>> shift;
8953
- }
8954
- function createHasher(hashCons, info = {}) {
8955
- const hashC = (msg, opts) => hashCons(opts).update(msg).digest();
8956
- const tmp = hashCons(void 0);
8957
- hashC.outputLen = tmp.outputLen;
8958
- hashC.blockLen = tmp.blockLen;
8959
- hashC.create = (opts) => hashCons(opts);
8960
- Object.assign(hashC, info);
8961
- return Object.freeze(hashC);
8962
- }
8963
- var oidNist = (suffix) => ({
8964
- oid: Uint8Array.from([6, 9, 96, 134, 72, 1, 101, 3, 4, 2, suffix])
8965
- });
8966
-
8967
- // ../../node_modules/.pnpm/@noble+hashes@2.0.1/node_modules/@noble/hashes/_md.js
8968
- function Chi(a, b, c) {
8969
- return a & b ^ ~a & c;
8970
- }
8971
- function Maj(a, b, c) {
8972
- return a & b ^ a & c ^ b & c;
8973
- }
8974
- var HashMD = class {
8975
- blockLen;
8976
- outputLen;
8977
- padOffset;
8978
- isLE;
8979
- // For partial updates less than block size
8980
- buffer;
8981
- view;
8982
- finished = false;
8983
- length = 0;
8984
- pos = 0;
8985
- destroyed = false;
8986
- constructor(blockLen, outputLen, padOffset, isLE) {
8987
- this.blockLen = blockLen;
8988
- this.outputLen = outputLen;
8989
- this.padOffset = padOffset;
8990
- this.isLE = isLE;
8991
- this.buffer = new Uint8Array(blockLen);
8992
- this.view = createView(this.buffer);
8993
- }
8994
- update(data) {
8995
- aexists(this);
8996
- abytes(data);
8997
- const { view, buffer, blockLen } = this;
8998
- const len = data.length;
8999
- for (let pos = 0; pos < len; ) {
9000
- const take = Math.min(blockLen - this.pos, len - pos);
9001
- if (take === blockLen) {
9002
- const dataView = createView(data);
9003
- for (; blockLen <= len - pos; pos += blockLen)
9004
- this.process(dataView, pos);
9005
- continue;
9006
- }
9007
- buffer.set(data.subarray(pos, pos + take), this.pos);
9008
- this.pos += take;
9009
- pos += take;
9010
- if (this.pos === blockLen) {
9011
- this.process(view, 0);
9012
- this.pos = 0;
9013
- }
9014
- }
9015
- this.length += data.length;
9016
- this.roundClean();
9017
- return this;
9018
- }
9019
- digestInto(out) {
9020
- aexists(this);
9021
- aoutput(out, this);
9022
- this.finished = true;
9023
- const { buffer, view, blockLen, isLE } = this;
9024
- let { pos } = this;
9025
- buffer[pos++] = 128;
9026
- clean(this.buffer.subarray(pos));
9027
- if (this.padOffset > blockLen - pos) {
9028
- this.process(view, 0);
9029
- pos = 0;
9030
- }
9031
- for (let i = pos; i < blockLen; i++)
9032
- buffer[i] = 0;
9033
- view.setBigUint64(blockLen - 8, BigInt(this.length * 8), isLE);
9034
- this.process(view, 0);
9035
- const oview = createView(out);
9036
- const len = this.outputLen;
9037
- if (len % 4)
9038
- throw new Error("_sha2: outputLen must be aligned to 32bit");
9039
- const outLen = len / 4;
9040
- const state = this.get();
9041
- if (outLen > state.length)
9042
- throw new Error("_sha2: outputLen bigger than state");
9043
- for (let i = 0; i < outLen; i++)
9044
- oview.setUint32(4 * i, state[i], isLE);
9045
- }
9046
- digest() {
9047
- const { buffer, outputLen } = this;
9048
- this.digestInto(buffer);
9049
- const res = buffer.slice(0, outputLen);
9050
- this.destroy();
9051
- return res;
9052
- }
9053
- _cloneInto(to) {
9054
- to ||= new this.constructor();
9055
- to.set(...this.get());
9056
- const { blockLen, buffer, length, finished, destroyed, pos } = this;
9057
- to.destroyed = destroyed;
9058
- to.finished = finished;
9059
- to.length = length;
9060
- to.pos = pos;
9061
- if (length % blockLen)
9062
- to.buffer.set(buffer);
9063
- return to;
9064
- }
9065
- clone() {
9066
- return this._cloneInto();
9067
- }
9068
- };
9069
- var SHA256_IV = /* @__PURE__ */ Uint32Array.from([
9070
- 1779033703,
9071
- 3144134277,
9072
- 1013904242,
9073
- 2773480762,
9074
- 1359893119,
9075
- 2600822924,
9076
- 528734635,
9077
- 1541459225
9078
- ]);
9079
-
9080
- // ../../node_modules/.pnpm/@noble+hashes@2.0.1/node_modules/@noble/hashes/sha2.js
9081
- var SHA256_K = /* @__PURE__ */ Uint32Array.from([
9082
- 1116352408,
9083
- 1899447441,
9084
- 3049323471,
9085
- 3921009573,
9086
- 961987163,
9087
- 1508970993,
9088
- 2453635748,
9089
- 2870763221,
9090
- 3624381080,
9091
- 310598401,
9092
- 607225278,
9093
- 1426881987,
9094
- 1925078388,
9095
- 2162078206,
9096
- 2614888103,
9097
- 3248222580,
9098
- 3835390401,
9099
- 4022224774,
9100
- 264347078,
9101
- 604807628,
9102
- 770255983,
9103
- 1249150122,
9104
- 1555081692,
9105
- 1996064986,
9106
- 2554220882,
9107
- 2821834349,
9108
- 2952996808,
9109
- 3210313671,
9110
- 3336571891,
9111
- 3584528711,
9112
- 113926993,
9113
- 338241895,
9114
- 666307205,
9115
- 773529912,
9116
- 1294757372,
9117
- 1396182291,
9118
- 1695183700,
9119
- 1986661051,
9120
- 2177026350,
9121
- 2456956037,
9122
- 2730485921,
9123
- 2820302411,
9124
- 3259730800,
9125
- 3345764771,
9126
- 3516065817,
9127
- 3600352804,
9128
- 4094571909,
9129
- 275423344,
9130
- 430227734,
9131
- 506948616,
9132
- 659060556,
9133
- 883997877,
9134
- 958139571,
9135
- 1322822218,
9136
- 1537002063,
9137
- 1747873779,
9138
- 1955562222,
9139
- 2024104815,
9140
- 2227730452,
9141
- 2361852424,
9142
- 2428436474,
9143
- 2756734187,
9144
- 3204031479,
9145
- 3329325298
9146
- ]);
9147
- var SHA256_W = /* @__PURE__ */ new Uint32Array(64);
9148
- var SHA2_32B = class extends HashMD {
9149
- constructor(outputLen) {
9150
- super(64, outputLen, 8, false);
9151
- }
9152
- get() {
9153
- const { A, B, C, D, E, F, G, H } = this;
9154
- return [A, B, C, D, E, F, G, H];
9155
- }
9156
- // prettier-ignore
9157
- set(A, B, C, D, E, F, G, H) {
9158
- this.A = A | 0;
9159
- this.B = B | 0;
9160
- this.C = C | 0;
9161
- this.D = D | 0;
9162
- this.E = E | 0;
9163
- this.F = F | 0;
9164
- this.G = G | 0;
9165
- this.H = H | 0;
9166
- }
9167
- process(view, offset) {
9168
- for (let i = 0; i < 16; i++, offset += 4)
9169
- SHA256_W[i] = view.getUint32(offset, false);
9170
- for (let i = 16; i < 64; i++) {
9171
- const W15 = SHA256_W[i - 15];
9172
- const W2 = SHA256_W[i - 2];
9173
- const s0 = rotr(W15, 7) ^ rotr(W15, 18) ^ W15 >>> 3;
9174
- const s1 = rotr(W2, 17) ^ rotr(W2, 19) ^ W2 >>> 10;
9175
- SHA256_W[i] = s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16] | 0;
9176
- }
9177
- let { A, B, C, D, E, F, G, H } = this;
9178
- for (let i = 0; i < 64; i++) {
9179
- const sigma1 = rotr(E, 6) ^ rotr(E, 11) ^ rotr(E, 25);
9180
- const T1 = H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i] | 0;
9181
- const sigma0 = rotr(A, 2) ^ rotr(A, 13) ^ rotr(A, 22);
9182
- const T2 = sigma0 + Maj(A, B, C) | 0;
9183
- H = G;
9184
- G = F;
9185
- F = E;
9186
- E = D + T1 | 0;
9187
- D = C;
9188
- C = B;
9189
- B = A;
9190
- A = T1 + T2 | 0;
9191
- }
9192
- A = A + this.A | 0;
9193
- B = B + this.B | 0;
9194
- C = C + this.C | 0;
9195
- D = D + this.D | 0;
9196
- E = E + this.E | 0;
9197
- F = F + this.F | 0;
9198
- G = G + this.G | 0;
9199
- H = H + this.H | 0;
9200
- this.set(A, B, C, D, E, F, G, H);
9201
- }
9202
- roundClean() {
9203
- clean(SHA256_W);
9204
- }
9205
- destroy() {
9206
- this.set(0, 0, 0, 0, 0, 0, 0, 0);
9207
- clean(this.buffer);
9208
- }
9209
- };
9210
- var _SHA256 = class extends SHA2_32B {
9211
- // We cannot use array here since array allows indexing by variable
9212
- // which means optimizer/compiler cannot use registers.
9213
- A = SHA256_IV[0] | 0;
9214
- B = SHA256_IV[1] | 0;
9215
- C = SHA256_IV[2] | 0;
9216
- D = SHA256_IV[3] | 0;
9217
- E = SHA256_IV[4] | 0;
9218
- F = SHA256_IV[5] | 0;
9219
- G = SHA256_IV[6] | 0;
9220
- H = SHA256_IV[7] | 0;
9221
- constructor() {
9222
- super(32);
9223
- }
9224
- };
9225
- var sha256 = /* @__PURE__ */ createHasher(
9226
- () => new _SHA256(),
9227
- /* @__PURE__ */ oidNist(1)
9228
- );
9229
-
9230
8917
  // src/local-first-auth/encoding.ts
9231
8918
  var encoder = new TextEncoder();
9232
8919
  var decoder = new TextDecoder("utf-8", { fatal: true });
9233
8920
  function utf8(text) {
9234
8921
  return encoder.encode(text);
9235
8922
  }
9236
- function base64urlEncode(bytes) {
9237
- let binary = "";
9238
- for (const byte of bytes) binary += String.fromCharCode(byte);
9239
- return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
9240
- }
9241
- function base64urlDecode(text, allowNonCanonical = false) {
9242
- if (!/^[A-Za-z0-9_-]*$/.test(text) || text.length % 4 === 1) {
9243
- throw new Error("invalid base64url");
9244
- }
9245
- const padding = "=".repeat((4 - text.length % 4) % 4);
9246
- const binary = atob(text.replace(/-/g, "+").replace(/_/g, "/") + padding);
9247
- const bytes = Uint8Array.from(binary, (char) => char.charCodeAt(0));
9248
- if (!allowNonCanonical && base64urlEncode(bytes) !== text)
9249
- throw new Error("non-canonical base64url");
9250
- return bytes;
9251
- }
9252
-
9253
- // src/local-first-auth/secret.ts
9254
- var SECRET_PREFIX = "jazz-auth-v1:";
9255
- var SECRET_BYTES = 32;
9256
- var SECRET_PAYLOAD = /^[A-Za-z0-9_-]{43}$/;
9257
- var SecretFormatError = class extends Error {
9258
- constructor(message) {
9259
- super(message);
9260
- this.name = "SecretFormatError";
9261
- }
9262
- };
9263
- function formatSecret(bytes) {
9264
- if (bytes.byteLength !== SECRET_BYTES) {
9265
- throw new SecretFormatError(`A local-first secret must contain exactly ${SECRET_BYTES} bytes`);
9266
- }
9267
- return `${SECRET_PREFIX}${base64urlEncode(bytes)}`;
9268
- }
9269
- function parseSecret(secret) {
9270
- if (typeof secret !== "string" || !secret.startsWith(SECRET_PREFIX)) {
9271
- throw new SecretFormatError(`A local-first secret must start with ${SECRET_PREFIX}`);
9272
- }
9273
- const payload = secret.slice(SECRET_PREFIX.length);
9274
- if (!SECRET_PAYLOAD.test(payload)) {
9275
- throw new SecretFormatError("A local-first secret must use 43 unpadded base64url characters");
9276
- }
9277
- let bytes;
9278
- try {
9279
- bytes = base64urlDecode(payload, true);
9280
- } catch {
9281
- throw new SecretFormatError("A local-first secret is not valid base64url");
9282
- }
9283
- if (bytes.byteLength !== SECRET_BYTES || formatSecret(bytes) !== secret) {
9284
- throw new SecretFormatError("A local-first secret is not canonical");
9285
- }
9286
- return bytes;
9287
- }
9288
- function secretStorageKey(scope, profile = null) {
9289
- const material = JSON.stringify({ appId: scope, profile });
9290
- return `jazz-auth-store-v1-${base64urlEncode(sha256(utf8(material)))}`;
9291
- }
9292
8923
 
9293
8924
  // src/local-first-auth/identity.ts
9294
8925
  var SUBJECT_NAMESPACE = utf8("jazz-auth-key-v1");
@@ -9311,119 +8942,6 @@ var DNS_NAMESPACE = Uint8Array.from([
9311
8942
  200
9312
8943
  ]);
9313
8944
 
9314
- // src/runtime/auth-secret-codec.ts
9315
- var formatAuthSecret = formatSecret;
9316
- var parseAuthSecret = parseSecret;
9317
- function scopePart(value, name) {
9318
- if (value === null || value === void 0) return null;
9319
- if (typeof value !== "string") {
9320
- throw new SecretFormatError(`Jazz auth secret scope ${name} must be a string or null`);
9321
- }
9322
- return value;
9323
- }
9324
- function authSecretStorageKey(scope = {}) {
9325
- return secretStorageKey(scopePart(scope.appId, "appId"), scopePart(scope.profile, "profile"));
9326
- }
9327
-
9328
- // src/runtime/auth-secret-store.ts
9329
- function generateAuthSecret() {
9330
- const bytes = new Uint8Array(32);
9331
- crypto.getRandomValues(bytes);
9332
- return formatAuthSecret(bytes);
9333
- }
9334
- function resolveBrowserAuthSecretKey(options = {}) {
9335
- if (options.key) {
9336
- return options.key;
9337
- }
9338
- return authSecretStorageKey(options);
9339
- }
9340
- var BrowserAuthSecretStore = class _BrowserAuthSecretStore {
9341
- static globalInstances = /* @__PURE__ */ new Map();
9342
- static storageScopedInstances = /* @__PURE__ */ new WeakMap();
9343
- key;
9344
- explicitStorage;
9345
- cachedPromise = null;
9346
- constructor(options = {}) {
9347
- this.key = resolveBrowserAuthSecretKey(options);
9348
- this.explicitStorage = options.storage;
9349
- }
9350
- requireStorage() {
9351
- const storage = this.explicitStorage ?? globalThis.localStorage;
9352
- if (!storage) {
9353
- throw new Error(
9354
- "BrowserAuthSecretStore requires a browser environment. Defer reads to a client-only context, or pass `options.storage`."
9355
- );
9356
- }
9357
- return storage;
9358
- }
9359
- static getDefault(options = {}) {
9360
- const storage = options.storage;
9361
- const key = resolveBrowserAuthSecretKey(options);
9362
- if (storage) {
9363
- let instances = _BrowserAuthSecretStore.storageScopedInstances.get(storage);
9364
- if (!instances) {
9365
- instances = /* @__PURE__ */ new Map();
9366
- _BrowserAuthSecretStore.storageScopedInstances.set(storage, instances);
9367
- }
9368
- let instance2 = instances.get(key);
9369
- if (!instance2) {
9370
- instance2 = new _BrowserAuthSecretStore(options);
9371
- instances.set(key, instance2);
9372
- }
9373
- return instance2;
9374
- }
9375
- let instance = _BrowserAuthSecretStore.globalInstances.get(key);
9376
- if (!instance) {
9377
- instance = new _BrowserAuthSecretStore(options);
9378
- _BrowserAuthSecretStore.globalInstances.set(key, instance);
9379
- }
9380
- return instance;
9381
- }
9382
- async loadSecret() {
9383
- const secret = this.requireStorage().getItem(this.key);
9384
- if (secret === null) return null;
9385
- parseAuthSecret(secret);
9386
- return secret;
9387
- }
9388
- async saveSecret(secret) {
9389
- parseAuthSecret(secret);
9390
- this.requireStorage().setItem(this.key, secret);
9391
- this.cachedPromise = Promise.resolve(secret);
9392
- }
9393
- async clearSecret() {
9394
- this.requireStorage().removeItem(this.key);
9395
- this.cachedPromise = null;
9396
- }
9397
- getOrCreateSecret() {
9398
- if (!this.cachedPromise) {
9399
- const storage = this.requireStorage();
9400
- const existing = storage.getItem(this.key);
9401
- if (existing !== null) {
9402
- parseAuthSecret(existing);
9403
- this.cachedPromise = Promise.resolve(existing);
9404
- } else {
9405
- const secret = generateAuthSecret();
9406
- storage.setItem(this.key, secret);
9407
- this.cachedPromise = Promise.resolve(secret);
9408
- }
9409
- }
9410
- return this.cachedPromise;
9411
- }
9412
- static loadSecret(options = {}) {
9413
- return _BrowserAuthSecretStore.getDefault(options).loadSecret();
9414
- }
9415
- static saveSecret(secret, options = {}) {
9416
- return _BrowserAuthSecretStore.getDefault(options).saveSecret(secret);
9417
- }
9418
- static clearSecret(options = {}) {
9419
- return _BrowserAuthSecretStore.getDefault(options).clearSecret();
9420
- }
9421
- static getOrCreateSecret(options = {}) {
9422
- return _BrowserAuthSecretStore.getDefault(options).getOrCreateSecret();
9423
- }
9424
- };
9425
- var browserAuthSecretStore = BrowserAuthSecretStore.getDefault();
9426
-
9427
8945
  // src/runtime/hex.ts
9428
8946
  var BYTE_HEX = Array.from(
9429
8947
  { length: 256 },
@@ -9465,6 +8983,9 @@ function transportFor(url) {
9465
8983
  return void 0;
9466
8984
  }
9467
8985
  }
8986
+ function fetchFor(url) {
8987
+ return transportFor(url)?.fetch ?? globalThis.fetch;
8988
+ }
9468
8989
  function inProcessWebSocketFor(url) {
9469
8990
  return transportFor(url)?.WebSocket;
9470
8991
  }
@@ -9556,14 +9077,18 @@ function resolveRuntimeConfigWasmUrl(runtimeModuleUrl, locationHref, runtime) {
9556
9077
  return versionRuntimeAssetUrl(new URL("jazz_wasm_bg.wasm", baseUrl).href, runtime);
9557
9078
  }
9558
9079
  }
9559
- return resolveDerivedWasmUrl(runtimeModuleUrl, locationHref, false);
9080
+ return resolveDerivedWasmUrl(
9081
+ typeof runtimeModuleUrl === "function" ? runtimeModuleUrl() : runtimeModuleUrl,
9082
+ locationHref,
9083
+ false
9084
+ );
9560
9085
  }
9561
9086
 
9562
9087
  // src/runtime/native-artifact-fingerprint-napi.ts
9563
- var EXPECTED_NAPI_ARTIFACT_FINGERPRINT = "546c99fe8d26ce6442b4e3c98b839e9a0a014a31c8c3987b1079591e2e050f10";
9088
+ var EXPECTED_NAPI_ARTIFACT_FINGERPRINT = "4aacda475cb433caa9b257e56f8cb3ff2c7068b62d582ecb208e89ddfaba0877";
9564
9089
 
9565
9090
  // src/runtime/native-artifact-fingerprint-wasm.ts
9566
- var EXPECTED_WASM_ARTIFACT_FINGERPRINT = "6ec417edefd95de7cd81f91b9862d9075dcccb3c667d7c3d039f76ba5e7be5d4";
9091
+ var EXPECTED_WASM_ARTIFACT_FINGERPRINT = "7bd27c821a6352a44ddcd86301c7c138c0dd465b6a7723805dabf0c3be557bc4";
9567
9092
 
9568
9093
  // src/runtime/native-artifact-fingerprints.ts
9569
9094
  var EXPECTED_NATIVE_ARTIFACT_FINGERPRINTS = {
@@ -12477,6 +12002,20 @@ function installJsonSchemaValidator(wasmModule2) {
12477
12002
  wasmModule2.setJsonSchemaValidator(compileJsonSchemaText);
12478
12003
  }
12479
12004
 
12005
+ // src/runtime/browser-worker-assets.ts
12006
+ function browserRuntimeModuleUrl() {
12007
+ return import.meta.url;
12008
+ }
12009
+ function bundledWasmUrl() {
12010
+ return null;
12011
+ }
12012
+
12013
+ // src/runtime/metro-setup-error.ts
12014
+ var METRO_SETUP_ERROR = "Jazz's local-first client needs its Metro setup on Expo web: wrap your Metro config in withJazz from jazz-tools/expo/metro (module.exports = withJazz(getDefaultConfig(__dirname))) and restart Metro with --clear.";
12015
+ function isMetroBundle() {
12016
+ return "__METRO_GLOBAL_PREFIX__" in globalThis;
12017
+ }
12018
+
12480
12019
  // src/runtime/wasm-loader.ts
12481
12020
  async function tryLoadNodePackagedWasmBinary() {
12482
12021
  const moduleBuiltin = process.getBuiltinModule?.("module");
@@ -12527,8 +12066,9 @@ async function initializeWasmModule(runtime) {
12527
12066
  }
12528
12067
  }
12529
12068
  if (!nodeInitDone && typeof wasmModule2.default === "function") {
12530
- const wasmUrl = typeof location !== "undefined" ? resolveRuntimeConfigWasmUrl(import.meta.url, location.href, runtime) : null;
12069
+ const wasmUrl = typeof location !== "undefined" ? resolveRuntimeConfigWasmUrl(browserRuntimeModuleUrl, location.href, runtime) ?? bundledWasmUrl() : null;
12531
12070
  if (wasmUrl) await initializeWasmFromUrl(wasmModule2, wasmUrl);
12071
+ else if (typeof location !== "undefined" && isMetroBundle()) throw new Error(METRO_SETUP_ERROR);
12532
12072
  else await wasmModule2.default();
12533
12073
  }
12534
12074
  return readyWasmModule(wasmModule2);
@@ -16056,6 +15596,28 @@ function upstreamRefusalError(refusal) {
16056
15596
  return error;
16057
15597
  }
16058
15598
 
15599
+ // src/runtime/core-tick-failed-error.ts
15600
+ var CORE_TICK_FAILED_ERROR_CODE = "core_tick_failed";
15601
+ var CoreTickFailedError = class extends Error {
15602
+ name = "CoreTickFailedError";
15603
+ code = CORE_TICK_FAILED_ERROR_CODE;
15604
+ constructor(cause) {
15605
+ super(`core tick failed: ${causeMessage(cause)}`, { cause });
15606
+ }
15607
+ };
15608
+ function isCoreTickFailedError(error) {
15609
+ if (!error || typeof error !== "object") return false;
15610
+ return error.code === CORE_TICK_FAILED_ERROR_CODE;
15611
+ }
15612
+ function causeMessage(cause) {
15613
+ if (cause instanceof Error) return cause.message;
15614
+ if (cause && typeof cause === "object") {
15615
+ const message = cause.message;
15616
+ if (typeof message === "string") return message;
15617
+ }
15618
+ return String(cause);
15619
+ }
15620
+
16059
15621
  // src/runtime/query-column-name.ts
16060
15622
  function stripColumnQualifier(column) {
16061
15623
  if (column.startsWith("$")) return column;
@@ -16149,6 +15711,23 @@ function writeRow(table, id, columns, values) {
16149
15711
  }
16150
15712
 
16151
15713
  // src/runtime/sync-status.ts
15714
+ var NO_UPLOADS = Object.freeze({
15715
+ pending: 0,
15716
+ oldestPendingAt: null,
15717
+ rejected: 0,
15718
+ lastRejection: null
15719
+ });
15720
+ function linkFailureOf(link, message) {
15721
+ if (link.state !== "offline" || link.reason === "disconnected") return null;
15722
+ const said = {
15723
+ network: "The server is unreachable; retrying.",
15724
+ auth: "The server refused this client's credential.",
15725
+ stopped: "The link stopped for good; only db.reconnect() tries again.",
15726
+ "authority-changed": "The server serves another history than this client's local store.",
15727
+ "held-by-another-tab": "Another tab holds this account's local store under another sign-in."
15728
+ }[link.reason];
15729
+ return { kind: link.reason, message: message || said, at: Date.now() };
15730
+ }
16152
15731
  var LOCAL_ONLY = Object.freeze({ state: "local-only" });
16153
15732
  var CONNECTING = Object.freeze({ state: "connecting" });
16154
15733
  var CONNECTED = Object.freeze({ state: "connected" });
@@ -16177,6 +15756,9 @@ function sameLinkStatus(a, b) {
16177
15756
  if (a.state !== "offline" || b.state !== "offline") return true;
16178
15757
  return a.reason === b.reason && a.retrying === b.retrying;
16179
15758
  }
15759
+ function sameUploadStatus(a, b) {
15760
+ return a.pending === b.pending && a.oldestPendingAt === b.oldestPendingAt && a.rejected === b.rejected && a.lastRejection?.at === b.lastRejection?.at && a.lastRejection?.code === b.lastRejection?.code;
15761
+ }
16180
15762
  var DerivedStatePublisher = class {
16181
15763
  constructor(read, same = Object.is) {
16182
15764
  this.read = read;
@@ -16254,7 +15836,8 @@ var NATIVE_CORE_ERROR_CODES = /* @__PURE__ */ new Set([
16254
15836
  "not_observed",
16255
15837
  "historical_read_requires_server",
16256
15838
  "unsupported_storage_codecs",
16257
- "authority_changed"
15839
+ "authority_changed",
15840
+ "store_opened_without_migrations"
16258
15841
  ]);
16259
15842
  function nativeCoreErrorCode(error) {
16260
15843
  const code = nativeErrorCode(error);
@@ -16280,6 +15863,62 @@ function nativeCoreErrorReason(error) {
16280
15863
  return typeof reason === "string" && NATIVE_CORE_ERROR_REASONS.has(reason) ? reason : void 0;
16281
15864
  }
16282
15865
 
15866
+ // src/runtime/native-runtime/stream-endpoint-memory.ts
15867
+ var STREAM_ENDPOINT_MEMORY_MS = 60 * 60 * 1e3;
15868
+ var RECALL_TIMEOUT_MS = 500;
15869
+ var DB_NAME = "jazz-http-stream-endpoints";
15870
+ var STORE = "endpoints";
15871
+ function streamEndpointMemoryAvailable() {
15872
+ return globalThis.indexedDB !== void 0;
15873
+ }
15874
+ function database() {
15875
+ const factory = globalThis.indexedDB;
15876
+ if (!factory) return void 0;
15877
+ return new Promise((resolve, reject) => {
15878
+ const open = factory.open(DB_NAME, 1);
15879
+ open.onupgradeneeded = () => open.result.createObjectStore(STORE);
15880
+ open.onsuccess = () => resolve(open.result);
15881
+ open.onerror = () => reject(open.error);
15882
+ open.onblocked = () => reject(new Error("blocked"));
15883
+ });
15884
+ }
15885
+ async function withStore(mode, use) {
15886
+ const opened = database();
15887
+ if (!opened) return void 0;
15888
+ const db = await opened;
15889
+ try {
15890
+ return await new Promise((resolve, reject) => {
15891
+ const request = use(db.transaction(STORE, mode).objectStore(STORE));
15892
+ request.onsuccess = () => resolve(request.result);
15893
+ request.onerror = () => reject(request.error);
15894
+ });
15895
+ } finally {
15896
+ db.close();
15897
+ }
15898
+ }
15899
+ async function recallStreamEndpoint(url, now = Date.now()) {
15900
+ let timer;
15901
+ const until = await Promise.race([
15902
+ withStore("readonly", (store) => store.get(url)).catch(() => void 0),
15903
+ new Promise((resolve) => {
15904
+ timer = setTimeout(() => resolve(void 0), RECALL_TIMEOUT_MS);
15905
+ })
15906
+ ]).finally(() => clearTimeout(timer));
15907
+ return typeof until === "number" && until > now;
15908
+ }
15909
+ function rememberStreamEndpoint(url, now = Date.now()) {
15910
+ return withStore("readwrite", (store) => store.put(now + STREAM_ENDPOINT_MEMORY_MS, url)).then(
15911
+ () => void 0,
15912
+ () => void 0
15913
+ );
15914
+ }
15915
+ function forgetStreamEndpoint(url) {
15916
+ return withStore("readwrite", (store) => store.delete(url)).then(
15917
+ () => void 0,
15918
+ () => void 0
15919
+ );
15920
+ }
15921
+
16283
15922
  // src/runtime/native-runtime/http-stream-socket.ts
16284
15923
  var STREAM_RECORD_SESSION = 0;
16285
15924
  var STREAM_KEY_HEADER = "x-jazz-stream-key";
@@ -16347,7 +15986,14 @@ var SocketEvents = class {
16347
15986
  }
16348
15987
  };
16349
15988
  var MAX_SEND_BYTES = 4 * 1024 * 1024;
15989
+ var globalFetch = (input, init2) => fetch(input, init2);
16350
15990
  var HttpStreamSocket = class extends SocketEvents {
15991
+ constructor(url, request = globalFetch) {
15992
+ super();
15993
+ this.request = request;
15994
+ this.streamUrl = streamUrlForSocketUrl(url);
15995
+ void this.run();
15996
+ }
16351
15997
  binaryType = "arraybuffer";
16352
15998
  readyState = 0;
16353
15999
  streamUrl;
@@ -16355,11 +16001,6 @@ var HttpStreamSocket = class extends SocketEvents {
16355
16001
  session;
16356
16002
  queued = [];
16357
16003
  sending = false;
16358
- constructor(url) {
16359
- super();
16360
- this.streamUrl = streamUrlForSocketUrl(url);
16361
- void this.run();
16362
- }
16363
16004
  send(data) {
16364
16005
  if (this.readyState !== 1) throw new Error("HTTP stream session is not open");
16365
16006
  const bytes = typeof data === "string" ? textEncoder2.encode(data) : data;
@@ -16369,18 +16010,18 @@ var HttpStreamSocket = class extends SocketEvents {
16369
16010
  close() {
16370
16011
  if (this.readyState >= 2) return;
16371
16012
  const session = this.session;
16372
- this.finish(1e3, "client closed");
16373
- if (session) {
16374
- void fetch(`${this.streamUrl}/${encodeURIComponent(session.id)}`, {
16375
- method: "DELETE",
16376
- credentials: "same-origin",
16377
- headers: { [STREAM_KEY_HEADER]: session.key }
16378
- }).catch(() => void 0);
16379
- }
16013
+ if (!session) return this.finish(1e3, "client closed");
16014
+ this.finish(1e3, "client closed", false);
16015
+ void this.request(`${this.streamUrl}/${encodeURIComponent(session.id)}`, {
16016
+ method: "DELETE",
16017
+ credentials: "same-origin",
16018
+ headers: { [STREAM_KEY_HEADER]: session.key },
16019
+ signal: AbortSignal.timeout?.(SOCKET_OPEN_DEADLINE_MS)
16020
+ }).catch(() => void 0).finally(() => this.abort.abort());
16380
16021
  }
16381
16022
  async run() {
16382
16023
  try {
16383
- const response = await fetch(this.streamUrl, {
16024
+ const response = await this.request(this.streamUrl, {
16384
16025
  method: "POST",
16385
16026
  credentials: "same-origin",
16386
16027
  signal: this.abort.signal
@@ -16394,8 +16035,8 @@ var HttpStreamSocket = class extends SocketEvents {
16394
16035
  const { done, value } = await reader.read();
16395
16036
  if (done) break;
16396
16037
  for (const record of records.push(value)) {
16397
- this.receive(record.kind, record.payload);
16398
16038
  if (this.readyState >= 2) return;
16039
+ this.receive(record.kind, record.payload);
16399
16040
  }
16400
16041
  }
16401
16042
  this.fail(1006, "HTTP stream ended");
@@ -16433,15 +16074,18 @@ var HttpStreamSocket = class extends SocketEvents {
16433
16074
  take += 1;
16434
16075
  }
16435
16076
  const body = concatBytes2(this.queued.splice(0, take));
16436
- const response = await fetch(`${this.streamUrl}/${encodeURIComponent(this.session.id)}`, {
16437
- method: "POST",
16438
- credentials: "same-origin",
16439
- headers: {
16440
- "Content-Type": "application/octet-stream",
16441
- [STREAM_KEY_HEADER]: this.session.key
16442
- },
16443
- body
16444
- });
16077
+ const response = await this.request(
16078
+ `${this.streamUrl}/${encodeURIComponent(this.session.id)}`,
16079
+ {
16080
+ method: "POST",
16081
+ credentials: "same-origin",
16082
+ headers: {
16083
+ "Content-Type": "application/octet-stream",
16084
+ [STREAM_KEY_HEADER]: this.session.key
16085
+ },
16086
+ body
16087
+ }
16088
+ );
16445
16089
  if (!response.ok) throw new Error(`HTTP stream send refused (${response.status})`);
16446
16090
  }
16447
16091
  } catch (error) {
@@ -16454,10 +16098,10 @@ var HttpStreamSocket = class extends SocketEvents {
16454
16098
  fail(code, reason) {
16455
16099
  this.finish(code, reason);
16456
16100
  }
16457
- finish(code, reason) {
16101
+ finish(code, reason, abort = true) {
16458
16102
  if (this.readyState >= 2) return;
16459
16103
  this.readyState = 3;
16460
- this.abort.abort();
16104
+ if (abort) this.abort.abort();
16461
16105
  this.emit("close", { code, reason });
16462
16106
  }
16463
16107
  };
@@ -16469,26 +16113,38 @@ var UPGRADE_HANGS_BEFORE_STREAM = 2;
16469
16113
  var hungUpgrades = /* @__PURE__ */ new Map();
16470
16114
  var STREAM_AVAILABLE_HEADER = "x-jazz-stream";
16471
16115
  var refusedOrigins = /* @__PURE__ */ new Set();
16472
- async function probeSocketPath(url) {
16116
+ var STORE_ERROR_HEADER = "x-jazz-store-error";
16117
+ var reportedStoreErrors = /* @__PURE__ */ new Set();
16118
+ async function probeSocketPath(url, request) {
16473
16119
  try {
16474
- const response = await fetch(url.replace(/^ws/, "http"), {
16120
+ const response = await request(url.replace(/^ws/, "http"), {
16475
16121
  method: "POST",
16476
16122
  credentials: "same-origin",
16477
16123
  // A stall that holds plain requests too must not keep the socket
16478
16124
  // connecting: a probe that gets no answer says nothing.
16479
16125
  signal: AbortSignal.timeout?.(SOCKET_OPEN_DEADLINE_MS)
16480
16126
  });
16127
+ if (response.status === 503 && response.headers.get(STORE_ERROR_HEADER) === "1") {
16128
+ const why = await response.text().catch(() => "");
16129
+ if (why && !reportedStoreErrors.has(`${url}
16130
+ ${why}`)) {
16131
+ reportedStoreErrors.add(`${url}
16132
+ ${why}`);
16133
+ console.error(`jazz: the backend at ${url} can't serve: ${why}`);
16134
+ }
16135
+ return "other";
16136
+ }
16481
16137
  void response.body?.cancel().catch(() => void 0);
16482
16138
  if (response.status === 403) return "refused";
16483
- if (response.status !== 426) return "unknown";
16139
+ if (response.status !== 426) return "other";
16484
16140
  return response.headers.get(STREAM_AVAILABLE_HEADER) === "1" ? "stream" : "upgrades";
16485
16141
  } catch {
16486
- return "unknown";
16142
+ return "silent";
16487
16143
  }
16488
16144
  }
16489
- async function servesStreamInstead(url, hung = false) {
16490
- const answer = await probeSocketPath(url);
16491
- if (answer === "stream") return true;
16145
+ async function servesStreamInstead(url, hung, request) {
16146
+ const answer = await probeSocketPath(url, request);
16147
+ if (answer === "stream") return answer;
16492
16148
  if (answer !== "upgrades") {
16493
16149
  failedUpgrades.delete(url);
16494
16150
  hungUpgrades.delete(url);
@@ -16498,7 +16154,7 @@ async function servesStreamInstead(url, hung = false) {
16498
16154
  `jazz: the backend at ${url} refuses this page's origin (403). If a proxy rewrites the Host header, set the backend's publicUrl or allowedOrigins.`
16499
16155
  );
16500
16156
  }
16501
- return false;
16157
+ return answer;
16502
16158
  }
16503
16159
  const failures = (failedUpgrades.get(url) ?? 0) + 1;
16504
16160
  failedUpgrades.set(url, failures);
@@ -16506,47 +16162,92 @@ async function servesStreamInstead(url, hung = false) {
16506
16162
  if (hung) hungUpgrades.set(url, hangs);
16507
16163
  else hungUpgrades.delete(url);
16508
16164
  const hangsSwitch = hangs >= UPGRADE_HANGS_BEFORE_STREAM;
16509
- if (failures < UPGRADE_FAILURES_BEFORE_STREAM && !hangsSwitch) return false;
16165
+ if (failures < UPGRADE_FAILURES_BEFORE_STREAM && !hangsSwitch) return answer;
16510
16166
  failedUpgrades.delete(url);
16511
16167
  hungUpgrades.delete(url);
16512
16168
  if (hangsSwitch) {
16513
16169
  console.warn(
16514
- `jazz: ${hangs} WebSockets in a row to ${url} got no answer in ${SOCKET_OPEN_DEADLINE_MS / 1e3} s, although the backend answers and upgrades them: something in between (a proxy or dev server) doesn't pass WebSocket upgrades on. Syncing over the HTTP stream instead, for as long as this page is open.`
16170
+ `jazz: ${hangs} WebSockets in a row to ${url} got no answer in ${SOCKET_OPEN_DEADLINE_MS / 1e3} s, although the backend answers and upgrades them: something in between (a proxy or dev server) doesn't pass WebSocket upgrades on. Syncing over the HTTP stream instead, for as long as this client runs.`
16515
16171
  );
16516
- return true;
16172
+ return "stream-in-between";
16517
16173
  }
16518
16174
  console.warn(
16519
- `jazz: ${failures} WebSockets in a row to ${url} failed, although the backend answers and upgrades them: something in between (a proxy or dev server) doesn't pass WebSocket upgrades on. Syncing over the HTTP stream instead, for as long as this page is open.`
16175
+ `jazz: ${failures} WebSockets in a row to ${url} failed, although the backend answers and upgrades them: something in between (a proxy or dev server) doesn't pass WebSocket upgrades on. Syncing over the HTTP stream instead, for as long as this client runs.`
16520
16176
  );
16521
- return true;
16177
+ return "stream-in-between";
16522
16178
  }
16523
- function sameOriginWebSocketConstructor(native) {
16524
- return class SameOriginSocket extends SocketEvents {
16179
+ function httpStreamFallbackWebSocket(native, options = {}) {
16180
+ const request = options.fetch ?? globalFetch;
16181
+ const describeFailedUpgrade = options.describeFailedUpgrade;
16182
+ return class StreamFallbackSocket extends SocketEvents {
16525
16183
  constructor(url) {
16526
16184
  super();
16527
16185
  this.url = url;
16528
- const stream = streamEndpoints.has(url);
16529
- this.inner = stream ? new HttpStreamSocket(url) : this.openNative();
16530
- if (stream) this.forward(this.inner);
16186
+ if (streamEndpoints.has(url)) {
16187
+ this.openStream();
16188
+ return;
16189
+ }
16190
+ if (!streamEndpointMemoryAvailable()) {
16191
+ this.inner = this.openNative();
16192
+ return;
16193
+ }
16194
+ void recallStreamEndpoint(url).then((stream) => {
16195
+ if (this.closedEarly) return;
16196
+ if (stream) {
16197
+ streamEndpoints.add(url);
16198
+ this.openStream();
16199
+ } else {
16200
+ this.inner = this.openNative();
16201
+ }
16202
+ });
16531
16203
  }
16532
16204
  binaryType = "arraybuffer";
16205
+ /** Unset while looking up whether the backend serves the stream instead. */
16533
16206
  inner;
16207
+ /** Closed before the lookup decided what to open. */
16208
+ closedEarly = false;
16209
+ /** The client closed this socket (a refused stream is not its doing). */
16210
+ closedByClient = false;
16534
16211
  settled = false;
16535
16212
  /** The native socket failed and we're asking whether to use the stream. */
16536
16213
  probing = false;
16537
16214
  /** Ends a socket that stays connecting (see {@link SOCKET_OPEN_DEADLINE_MS}). */
16538
16215
  openDeadline;
16216
+ /** Cancels `describeFailedUpgrade` when the socket is closed. */
16217
+ abort = new AbortController();
16539
16218
  get readyState() {
16219
+ if (!this.inner) return this.closedEarly ? 3 : 0;
16540
16220
  return this.probing ? 0 : this.inner.readyState;
16541
16221
  }
16542
16222
  send(data) {
16223
+ if (!this.inner) throw new Error("WebSocket is not open");
16543
16224
  this.inner.send(data);
16544
16225
  }
16545
16226
  close() {
16227
+ this.closedByClient = true;
16546
16228
  this.settled = true;
16547
16229
  this.probing = false;
16548
16230
  clearTimeout(this.openDeadline);
16549
- this.inner.close();
16231
+ this.abort.abort();
16232
+ if (this.inner) return this.inner.close();
16233
+ if (this.closedEarly) return;
16234
+ this.closedEarly = true;
16235
+ queueMicrotask(() => this.emit("close", { code: 1e3, reason: "" }));
16236
+ }
16237
+ openStream() {
16238
+ const stream = new HttpStreamSocket(this.url, request);
16239
+ let opened = false;
16240
+ stream.addEventListener("open", () => {
16241
+ opened = true;
16242
+ });
16243
+ stream.addEventListener("close", () => {
16244
+ if (!opened && !this.closedByClient) {
16245
+ streamEndpoints.delete(this.url);
16246
+ void forgetStreamEndpoint(this.url);
16247
+ }
16248
+ });
16249
+ this.inner = stream;
16250
+ this.forward(stream);
16550
16251
  }
16551
16252
  openNative() {
16552
16253
  const socket = new native(this.url);
@@ -16562,14 +16263,22 @@ function sameOriginWebSocketConstructor(native) {
16562
16263
  }
16563
16264
  failure = { [kind]: event };
16564
16265
  this.probing = true;
16565
- void servesStreamInstead(this.url, hung).then((stream) => {
16266
+ void servesStreamInstead(this.url, hung, request).then(async (answer) => {
16267
+ const stream = answer === "stream" || answer === "stream-in-between";
16268
+ const answered = !hung && (answer === "upgrades" || answer === "other");
16269
+ const why = !answered || this.settled ? void 0 : await describeFailedUpgrade?.(this.url, this.abort.signal).catch(() => void 0);
16566
16270
  this.probing = false;
16567
16271
  if (this.settled) return;
16568
16272
  this.settled = true;
16569
16273
  if (stream) {
16570
16274
  streamEndpoints.add(this.url);
16571
- this.inner = new HttpStreamSocket(this.url);
16572
- this.forward(this.inner);
16275
+ if (answer === "stream") void rememberStreamEndpoint(this.url);
16276
+ this.openStream();
16277
+ return;
16278
+ }
16279
+ if (why) {
16280
+ this.emit("error", new Error(why));
16281
+ this.emit("close", { code: 1006, reason: why });
16573
16282
  return;
16574
16283
  }
16575
16284
  if (failure?.error !== void 0) this.emit("error", failure.error);
@@ -16615,6 +16324,52 @@ function sameOriginWebSocketConstructor(native) {
16615
16324
  };
16616
16325
  }
16617
16326
 
16327
+ // src/runtime/native-runtime/session-renewal-wire.ts
16328
+ var SESSION_RENEWAL_PRELUDE_FIELD = "jazz_renewal";
16329
+ var SESSION_RENEWAL_HEADER = "X-Jazz-Renew";
16330
+ var WIRE_FRAME_RENEW_SOON = 64;
16331
+ var WIRE_FRAME_RENEW = 65;
16332
+ var MAX_RENEWAL_STRING = 2048;
16333
+ function decodeRenewSoonFrame(frame) {
16334
+ const reader = new PostcardReader(frame);
16335
+ if (reader.u64() !== WIRE_FRAME_RENEW_SOON) throw new Error("not a renew-soon frame");
16336
+ const session = reader.string();
16337
+ const renewInMs = reader.u64();
16338
+ if (!reader.done() || !session || session.length > MAX_RENEWAL_STRING) {
16339
+ throw new Error("malformed renew-soon frame");
16340
+ }
16341
+ return { session, renewInMs };
16342
+ }
16343
+ function encodeRenewFrame(ticket) {
16344
+ const writer = new PostcardWriter();
16345
+ writer.u64(WIRE_FRAME_RENEW);
16346
+ writer.string(ticket);
16347
+ return writer.finish();
16348
+ }
16349
+ function isRenewSoonFrame(frame) {
16350
+ return frame[0] === WIRE_FRAME_RENEW_SOON;
16351
+ }
16352
+ function renewalUrlFor(socketUrl) {
16353
+ try {
16354
+ const url = new URL(socketUrl);
16355
+ if (!/\/ws\/?$/.test(url.pathname)) return null;
16356
+ url.protocol = url.protocol === "wss:" ? "https:" : url.protocol === "ws:" ? "http:" : url.protocol;
16357
+ url.pathname = url.pathname.replace(/\/ws\/?$/, "/accounts/backend-user");
16358
+ url.search = "";
16359
+ url.hash = "";
16360
+ return url.toString();
16361
+ } catch {
16362
+ return null;
16363
+ }
16364
+ }
16365
+ function sessionRefreshLockName(url) {
16366
+ try {
16367
+ return `jazz-session-refresh:${new URL(url.replace(/^ws/, "http")).origin}`;
16368
+ } catch {
16369
+ return `jazz-session-refresh:${url}`;
16370
+ }
16371
+ }
16372
+
16618
16373
  // src/runtime/native-runtime/websocket.ts
16619
16374
  var PreHelloWireError = class extends Error {
16620
16375
  wireError;
@@ -16627,6 +16382,10 @@ var PreHelloWireError = class extends Error {
16627
16382
  function isReconnectLaterWireError(error) {
16628
16383
  return error.retry === "later" && (error.code === "not_ready" || error.code === "backpressure");
16629
16384
  }
16385
+ var REAUTHENTICATE_WIRE_MESSAGE_PREFIX = "reauthenticate:";
16386
+ function isReauthenticateWireError(error) {
16387
+ return error.code === "auth_failed" && error.retry === "after_resume" && error.message.startsWith(REAUTHENTICATE_WIRE_MESSAGE_PREFIX);
16388
+ }
16630
16389
  function isSocketDropWireError(error) {
16631
16390
  return error.retry === "later" && (error.code === "websocket_closed" || error.code === "websocket_error" || error.code === "websocket_silent");
16632
16391
  }
@@ -16638,6 +16397,7 @@ var FEATURE_AUTHORIZATION_SCOPE_VIEWS = 1 << 7;
16638
16397
  var FEATURE_AUXILIARY_CHUNKS = 1 << 8;
16639
16398
  var FEATURE_HEARTBEAT = 1 << 11;
16640
16399
  var HEARTBEAT_SILENCE_MS = 12e4;
16400
+ var HANDSHAKE_TIMEOUT_MS = 1e4;
16641
16401
  var HEARTBEAT_CONFIRM_MS = 1e3;
16642
16402
  var WIRE_FRAME_HEARTBEAT = 7;
16643
16403
  var CLIENT_WIRE_FEATURES = FEATURE_PAYLOAD_ZSTD | FEATURE_AUTHORIZATION_SCOPE_VIEWS | FEATURE_AUXILIARY_CHUNKS;
@@ -16750,6 +16510,10 @@ var WebSocketCarrier = class {
16750
16510
  terminated = false;
16751
16511
  lastInbound = performance.now();
16752
16512
  silenceTimer;
16513
+ handshakeTimer;
16514
+ /** Where to renew this session in place, when it rides on the app's cookie. */
16515
+ renewalUrl;
16516
+ renewalTimer;
16753
16517
  constructor(options) {
16754
16518
  this.url = options.endpointUrl;
16755
16519
  const WebSocketCtor = options.WebSocket ?? inProcessWebSocketFor(this.url) ?? defaultWebSocketConstructor(this.url);
@@ -16757,9 +16521,11 @@ var WebSocketCarrier = class {
16757
16521
  this.onError = options.onError;
16758
16522
  this.onTerminal = options.onTerminal;
16759
16523
  this.localFeatures = (options.features ?? CLIENT_WIRE_FEATURES) | FEATURE_HEARTBEAT;
16524
+ this.renewalUrl = isCookieSessionAuth(options.authJson) ? renewalUrlFor(this.url) : null;
16760
16525
  assertWireFeatures(this.localFeatures, "client wire features");
16761
16526
  this.socket = new WebSocketCtor(this.url);
16762
16527
  this.socket.binaryType = "arraybuffer";
16528
+ this.watchHandshake(options.handshakeTimeoutMs ?? HANDSHAKE_TIMEOUT_MS);
16763
16529
  this.opened = new Promise((resolve, reject) => {
16764
16530
  this.resolveNegotiation = resolve;
16765
16531
  this.rejectNegotiation = reject;
@@ -16771,7 +16537,8 @@ var WebSocketCarrier = class {
16771
16537
  encodeWebSocketPrelude(
16772
16538
  options.authJson ?? "{}",
16773
16539
  options.peerIdentity,
16774
- options.requestedLink
16540
+ options.requestedLink,
16541
+ this.renewalUrl !== null
16775
16542
  )
16776
16543
  );
16777
16544
  this.socket.send(encodeWebSocketFrameBatch([encodeWireClientHello(this.localFeatures)]));
@@ -16800,11 +16567,13 @@ var WebSocketCarrier = class {
16800
16567
  this.close();
16801
16568
  });
16802
16569
  });
16803
- this.socket.addEventListener("error", () => {
16570
+ this.socket.addEventListener("error", (event) => {
16804
16571
  this.reportTerminal({
16805
16572
  code: "websocket_error",
16806
16573
  retry: "later",
16807
- message: "websocket transport error"
16574
+ // A native socket's error event says nothing; the HTTP stream and a
16575
+ // backend client's failed upgrade hand an Error that does.
16576
+ message: event instanceof Error ? event.message : "websocket transport error"
16808
16577
  });
16809
16578
  });
16810
16579
  this.socket.addEventListener("close", (event) => {
@@ -16847,6 +16616,8 @@ var WebSocketCarrier = class {
16847
16616
  if (this.closing) return;
16848
16617
  this.closing = true;
16849
16618
  clearTimeout(this.silenceTimer);
16619
+ clearTimeout(this.handshakeTimer);
16620
+ clearTimeout(this.renewalTimer);
16850
16621
  this.reportTerminal(
16851
16622
  {
16852
16623
  code: "websocket_closed",
@@ -16866,10 +16637,56 @@ var WebSocketCarrier = class {
16866
16637
  if (this.terminated) return;
16867
16638
  this.terminated = true;
16868
16639
  clearTimeout(this.silenceTimer);
16640
+ clearTimeout(this.handshakeTimer);
16641
+ clearTimeout(this.renewalTimer);
16869
16642
  this.rejectNegotiation(negotiationError);
16870
16643
  if (notifyError) this.onError?.(error);
16871
16644
  if (notifyTerminal) this.onTerminal?.(error);
16872
16645
  }
16646
+ /**
16647
+ * Give the attempt up when the server has not said hello within
16648
+ * `timeoutMs`, as a dropped socket (`websocket_silent`), so the link
16649
+ * retries and, past its reporting window, publishes the outage. The
16650
+ * timeout is confirmed a moment later, so a hello that a frozen page held
16651
+ * back is delivered before it counts.
16652
+ */
16653
+ watchHandshake(timeoutMs) {
16654
+ this.handshakeTimer = setTimeout(() => {
16655
+ this.handshakeTimer = setTimeout(() => {
16656
+ if (this.negotiated || this.terminated) return;
16657
+ this.reportTerminal({
16658
+ code: "websocket_silent",
16659
+ retry: "later",
16660
+ message: `the server did not answer the connection within ${Math.round(timeoutMs / 1e3)} s`
16661
+ });
16662
+ this.close();
16663
+ }, HEARTBEAT_CONFIRM_MS);
16664
+ }, timeoutMs);
16665
+ }
16666
+ /**
16667
+ * Renew this session in place at the time the backend named: one ordinary
16668
+ * request to the backend (where its auth may refresh the cookie), whose
16669
+ * answer carries a ticket sent back over this socket. A renewal that
16670
+ * fails does nothing: the backend then ends the session at its expiry
16671
+ * and this client connects again, as without renewal.
16672
+ */
16673
+ scheduleRenewal({ session, renewInMs }) {
16674
+ clearTimeout(this.renewalTimer);
16675
+ const url = this.renewalUrl;
16676
+ if (!url) return;
16677
+ this.renewalTimer = setTimeout(
16678
+ () => {
16679
+ this.renewalTimer = void 0;
16680
+ if (this.closing || this.terminated) return;
16681
+ void requestSessionRenewal(url, session).then((ticket) => {
16682
+ if (!ticket || this.closing || this.terminated) return;
16683
+ return this.send(encodeRenewFrame(ticket));
16684
+ }).catch(() => {
16685
+ });
16686
+ },
16687
+ Math.min(renewInMs, 2 ** 31 - 1)
16688
+ );
16689
+ }
16873
16690
  /** Give the link up once the server has sent nothing, not even a
16874
16691
  * heartbeat, for {@link HEARTBEAT_SILENCE_MS}. Checked against the time
16875
16692
  * of the last message, so a timer the browser throttled judges the
@@ -16900,6 +16717,7 @@ var WebSocketCarrier = class {
16900
16717
  if (isWireHello(frame)) {
16901
16718
  if (this.negotiated) continue;
16902
16719
  this.negotiated = true;
16720
+ clearTimeout(this.handshakeTimer);
16903
16721
  const negotiation = decodeServerHello(frame, this.localFeatures);
16904
16722
  if ((negotiation.features & FEATURE_HEARTBEAT) !== 0) this.watchSilence();
16905
16723
  this.resolveNegotiation({
@@ -16911,6 +16729,10 @@ var WebSocketCarrier = class {
16911
16729
  if (this.negotiated && frame.byteLength === 1 && frame[0] === WIRE_FRAME_HEARTBEAT) {
16912
16730
  continue;
16913
16731
  }
16732
+ if (this.negotiated && this.renewalUrl && isRenewSoonFrame(frame)) {
16733
+ this.scheduleRenewal(decodeRenewSoonFrame(frame));
16734
+ continue;
16735
+ }
16914
16736
  if (!this.negotiated) {
16915
16737
  if (isWireError(frame)) {
16916
16738
  const error = decodeWireError(frame);
@@ -17003,7 +16825,7 @@ function websocketCloseDetails(event) {
17003
16825
  reason: typeof close.reason === "string" ? close.reason : void 0
17004
16826
  };
17005
16827
  }
17006
- function encodeWebSocketPrelude(authJson, peerIdentity, requestedLink) {
16828
+ function encodeWebSocketPrelude(authJson, peerIdentity, requestedLink, renewal = false) {
17007
16829
  const auth = JSON.parse(authJson);
17008
16830
  const peerAuthor = new Utf8Decoder().decode(peerIdentity);
17009
16831
  const sub = authSub(auth) ?? canonicalAuthorSubjectPart(peerAuthor) ?? peerAuthor;
@@ -17012,9 +16834,59 @@ function encodeWebSocketPrelude(authJson, peerIdentity, requestedLink) {
17012
16834
  ...auth,
17013
16835
  auth: { ...auth, sub },
17014
16836
  sub,
17015
- ...requestedLink ? { requested_link: requestedLink } : {}
16837
+ ...requestedLink ? { requested_link: requestedLink } : {},
16838
+ // A core ignores unknown top-level fields; an app backend that renews
16839
+ // sessions in place takes this out before the core sees the prelude.
16840
+ ...renewal ? { [SESSION_RENEWAL_PRELUDE_FIELD]: 1 } : {}
17016
16841
  });
17017
16842
  }
16843
+ function isCookieSessionAuth(authJson) {
16844
+ if (!authJson) return false;
16845
+ try {
16846
+ const auth = JSON.parse(authJson);
16847
+ return auth.backend_session != null && auth.jwt_token == null && auth.admin_secret == null && auth.backend_secret == null;
16848
+ } catch {
16849
+ return false;
16850
+ }
16851
+ }
16852
+ var SESSION_RENEWAL_TURN_MS = 3e4;
16853
+ async function requestSessionRenewal(url, session) {
16854
+ return oneWindowAtATime(sessionRefreshLockName(url), () => renewalRequest(url, session));
16855
+ }
16856
+ async function oneWindowAtATime(name, request) {
16857
+ const locks = globalThis.navigator?.locks;
16858
+ if (!locks) return request();
16859
+ let started;
16860
+ const run = () => started ??= request();
16861
+ try {
16862
+ await locks.request(name, () => {
16863
+ let turn;
16864
+ return Promise.race([
16865
+ run().catch(() => void 0),
16866
+ new Promise((done) => {
16867
+ turn = setTimeout(done, SESSION_RENEWAL_TURN_MS);
16868
+ })
16869
+ ]).finally(() => clearTimeout(turn));
16870
+ });
16871
+ } catch {
16872
+ }
16873
+ return run();
16874
+ }
16875
+ async function renewalRequest(url, session) {
16876
+ try {
16877
+ const response = await fetchFor(url)(url, {
16878
+ method: "POST",
16879
+ credentials: "same-origin",
16880
+ redirect: "error",
16881
+ headers: { [SESSION_RENEWAL_HEADER]: session }
16882
+ });
16883
+ if (!response.ok) return null;
16884
+ const answer = await response.json();
16885
+ return typeof answer.renewal === "string" ? answer.renewal : null;
16886
+ } catch {
16887
+ return null;
16888
+ }
16889
+ }
17018
16890
  function policyClaimsForAdmittedWebSocket(authJson) {
17019
16891
  const auth = JSON.parse(authJson);
17020
16892
  if (auth.admin_secret) return {};
@@ -17065,6 +16937,10 @@ function hasUsableBackendSession(auth) {
17065
16937
  const session = auth.backend_session;
17066
16938
  return session !== null && typeof session === "object" && !Array.isArray(session) && typeof session.issuer === "string" && typeof session.user_id === "string" && isUsableSubject(session.issuer) && isUsableSubject(session.user_id);
17067
16939
  }
16940
+ function webSocketAuthNamesPrincipal(authJson) {
16941
+ const auth = JSON.parse(authJson);
16942
+ return typeof auth.admin_secret === "string" || typeof auth.backend_secret === "string" || canonicalAuthorForWebSocketAuth(auth) !== null;
16943
+ }
17068
16944
  function canonicalAuthorForWebSocketAuth(auth) {
17069
16945
  if (typeof auth.admin_secret === "string") return null;
17070
16946
  if (typeof auth.backend_secret === "string" && hasUsableBackendSession(auth)) {
@@ -17096,7 +16972,7 @@ async function bytesFromWebSocketMessage(data) {
17096
16972
  }
17097
16973
  function defaultWebSocketConstructor(url) {
17098
16974
  const native = browserWebSocketConstructor();
17099
- return isSameOriginEndpoint(url) ? sameOriginWebSocketConstructor(native) : native;
16975
+ return isSameOriginEndpoint(url) ? httpStreamFallbackWebSocket(native) : native;
17100
16976
  }
17101
16977
  function isSameOriginEndpoint(url) {
17102
16978
  const location2 = globalThis.location;
@@ -17224,9 +17100,11 @@ function isPendingNativePermissionAdvice(value) {
17224
17100
  }
17225
17101
  function upstreamLinkFailure(error, negotiated) {
17226
17102
  const message = error.message;
17103
+ if (isReauthenticateWireError(error)) return { kind: "reauthenticate", message };
17227
17104
  if (wireAuthFailureReason(error)) return { kind: "authRejected", message };
17228
17105
  if (isReconnectLaterWireError(error)) {
17229
- return { kind: negotiated ? "network" : "serverNotReady", message };
17106
+ if (negotiated) return { kind: "network", message };
17107
+ return { kind: error.code === "backpressure" ? "refused" : "serverNotReady", message };
17230
17108
  }
17231
17109
  if (isSocketDropWireError(error)) {
17232
17110
  return { kind: "network", message };
@@ -17319,6 +17197,10 @@ function openMemoryDb(Runtime, schema, config, selfSignedClientProof, backendMod
17319
17197
  selfSignedClientProof.claimedAuthor
17320
17198
  );
17321
17199
  }
17200
+ function slowQuerySummary(line) {
17201
+ const plan = line.indexOf(". Plan: ");
17202
+ return plan === -1 ? line : line.slice(0, plan);
17203
+ }
17322
17204
  var NativeRuntimeAdapter = class _NativeRuntimeAdapter {
17323
17205
  constructor(Runtime, schema, node, author, _sourceId, historyComplete, opts) {
17324
17206
  this.schema = schema;
@@ -17379,6 +17261,7 @@ var NativeRuntimeAdapter = class _NativeRuntimeAdapter {
17379
17261
  }
17380
17262
  if (opts?.owner) return;
17381
17263
  this.slowQueryApp = opts?.slowQueryLog?.appId;
17264
+ this.slowQueryConsoleDetail = opts?.slowQueryLog?.consoleDetail;
17382
17265
  const threshold = opts?.slowQueryLog?.thresholdMs;
17383
17266
  if (threshold !== void 0) {
17384
17267
  if (!Number.isFinite(threshold) || threshold < 0) {
@@ -17400,8 +17283,9 @@ var NativeRuntimeAdapter = class _NativeRuntimeAdapter {
17400
17283
  this.nativeAuthRefusalRenewable = false;
17401
17284
  return this.clearRemoteServerTransportError();
17402
17285
  }
17286
+ const error = failure.code ? upstreamRefusalError({ code: failure.code, message: failure.reason }) : new Error(failure.reason);
17403
17287
  this.handleServerTransportError(
17404
- new Error(failure.reason),
17288
+ error,
17405
17289
  this.serverConnectionGeneration,
17406
17290
  failure.retrying || this.nativeAuthRefusalRenewable
17407
17291
  );
@@ -17414,6 +17298,8 @@ var NativeRuntimeAdapter = class _NativeRuntimeAdapter {
17414
17298
  schemaBytes;
17415
17299
  configBytes;
17416
17300
  peerIdentity;
17301
+ /** The principal of the first admitted credential naming one; see `assertCredentialKeepsPrincipal`. */
17302
+ upstreamPrincipal = null;
17417
17303
  selfSignedClientProof;
17418
17304
  scopeIsolatedRelay;
17419
17305
  schemaHash;
@@ -17437,6 +17323,7 @@ var NativeRuntimeAdapter = class _NativeRuntimeAdapter {
17437
17323
  ownerRuntime;
17438
17324
  /** The app named in slow-query reports (owner runtime only). */
17439
17325
  slowQueryApp;
17326
+ slowQueryConsoleDetail;
17440
17327
  get preparationOwner() {
17441
17328
  return this.ownerRuntime;
17442
17329
  }
@@ -17450,6 +17337,11 @@ var NativeRuntimeAdapter = class _NativeRuntimeAdapter {
17450
17337
  }
17451
17338
  readAuthorizationHost;
17452
17339
  subscriptions = /* @__PURE__ */ new Map();
17340
+ /** Pooled native subscriptions, by pool id: one native call reads them all. */
17341
+ subscriptionPool;
17342
+ pooledSubscriptions = /* @__PURE__ */ new Map();
17343
+ drainingSubscriptionPool = false;
17344
+ subscriptionPoolDirty = false;
17453
17345
  authFailureCallback = null;
17454
17346
  mutationErrorCallback = null;
17455
17347
  serverTransportErrorCallback = null;
@@ -17507,8 +17399,11 @@ var NativeRuntimeAdapter = class _NativeRuntimeAdapter {
17507
17399
  );
17508
17400
  syncStatusPublisher = new DerivedStatePublisher(
17509
17401
  () => this.readSyncStatus(),
17510
- (a, b) => a.pendingUploads === b.pendingUploads && sameLinkStatus(a.link, b.link)
17402
+ (a, b) => sameUploadStatus(a.uploads, b.uploads) && sameLinkStatus(a.link, b.link)
17511
17403
  );
17404
+ /** The latest link failure, and the failing state it was recorded for. */
17405
+ lastFailure = null;
17406
+ failingAs = null;
17512
17407
  pendingInboundServerFrames = [];
17513
17408
  serverInboundRouting = Promise.resolve();
17514
17409
  serverInboundProcessed = false;
@@ -17854,6 +17749,7 @@ var NativeRuntimeAdapter = class _NativeRuntimeAdapter {
17854
17749
  return this.syncStatusPublisher.hasListeners || this.linkStatusPublisher.hasListeners || this.firstLoadWaitSeen && this.remoteLink.hasListeners;
17855
17750
  }
17856
17751
  linkChanged() {
17752
+ if (this === this.ownerRuntime) this.noteLinkFailure();
17857
17753
  this.remoteLink.changed();
17858
17754
  this.linkStatusPublisher.changed();
17859
17755
  this.syncStatusPublisher.changed();
@@ -17869,7 +17765,8 @@ var NativeRuntimeAdapter = class _NativeRuntimeAdapter {
17869
17765
  if (nativeStatus.authRejected) return offlineLink("auth");
17870
17766
  if (nativeStatus.connected) return CONNECTED;
17871
17767
  if (this.serverTransportError) {
17872
- return this.serverTransportErrorRetrying ? offlineLink("network") : offlineLink("stopped");
17768
+ if (this.serverTransportErrorRetrying) return offlineLink("network");
17769
+ return isAuthorityChangedError(this.serverTransportError) ? offlineLink("authority-changed", false) : offlineLink("stopped");
17873
17770
  }
17874
17771
  return CONNECTING;
17875
17772
  }
@@ -17878,11 +17775,44 @@ var NativeRuntimeAdapter = class _NativeRuntimeAdapter {
17878
17775
  }
17879
17776
  return linkStatusFromUpstream(this.linkStatus);
17880
17777
  }
17881
- /** How many local commits still wait for the server's verdict. */
17882
- pendingUploadCount() {
17883
- if (this !== this.ownerRuntime) return this.ownerRuntime.pendingUploadCount();
17884
- if (this.closed) return 0;
17885
- return this.db?.pendingUploadCount?.() ?? 0;
17778
+ /**
17779
+ * Delete this runtime's local store, where its native host can (React
17780
+ * Native's relay): `deleteClientStorage()`. The runtime is closed with it;
17781
+ * the account stays, and the next client opens a fresh store.
17782
+ */
17783
+ canClearClientStorage() {
17784
+ if (this !== this.ownerRuntime) return this.ownerRuntime.canClearClientStorage();
17785
+ return typeof this.db?.deleteNativeStore === "function";
17786
+ }
17787
+ async clearClientStorage() {
17788
+ if (this !== this.ownerRuntime) return this.ownerRuntime.clearClientStorage();
17789
+ if (!this.db?.deleteNativeStore) {
17790
+ throw new Error("Runtime does not support client storage reset.");
17791
+ }
17792
+ const deleted = this.db.deleteNativeStore();
17793
+ this.closed = true;
17794
+ return deleted;
17795
+ }
17796
+ /** This client's uploads: pending, since when, and the server's refusals. */
17797
+ uploadStatus() {
17798
+ if (this !== this.ownerRuntime) return this.ownerRuntime.uploadStatus();
17799
+ if (this.closed) return NO_UPLOADS;
17800
+ return this.db?.uploadStatus?.() ?? NO_UPLOADS;
17801
+ }
17802
+ /** The latest time the link failed, and how; it stays after the link recovers. */
17803
+ lastLinkFailure() {
17804
+ if (this !== this.ownerRuntime) return this.ownerRuntime.lastLinkFailure();
17805
+ this.noteLinkFailure();
17806
+ return this.lastFailure;
17807
+ }
17808
+ /** Record a failure the first time the link is seen failing that way. */
17809
+ noteLinkFailure() {
17810
+ const link = this.upstreamLinkStatus();
17811
+ const failing = link.state === "offline" ? link.reason : null;
17812
+ if (failing === this.failingAs) return;
17813
+ this.failingAs = failing;
17814
+ const failure = linkFailureOf(link, (this.linkFailure ?? this.serverTransportError)?.message);
17815
+ if (failure) this.lastFailure = failure;
17886
17816
  }
17887
17817
  /** Observe changes of {@link upstreamLinkStatus} alone. */
17888
17818
  onUpstreamLinkStatusChange(listener, signal) {
@@ -17893,7 +17823,7 @@ var NativeRuntimeAdapter = class _NativeRuntimeAdapter {
17893
17823
  this.linkStatusPublisher.subscribe(listener, signal);
17894
17824
  this.startNativeLinkPoll();
17895
17825
  }
17896
- /** Observe changes of {@link upstreamLinkStatus} and {@link pendingUploadCount}. */
17826
+ /** Observe changes of {@link upstreamLinkStatus} and {@link uploadStatus}. */
17897
17827
  onSyncStatusChange(listener, signal) {
17898
17828
  if (this !== this.ownerRuntime) {
17899
17829
  this.ownerRuntime.onSyncStatusChange(listener, signal);
@@ -17903,7 +17833,7 @@ var NativeRuntimeAdapter = class _NativeRuntimeAdapter {
17903
17833
  this.startNativeLinkPoll();
17904
17834
  }
17905
17835
  readSyncStatus() {
17906
- return { link: this.upstreamLinkStatus(), pendingUploads: this.pendingUploadCount() };
17836
+ return { link: this.upstreamLinkStatus(), uploads: this.uploadStatus() };
17907
17837
  }
17908
17838
  readRemoteLinkState() {
17909
17839
  if (this.closed) return "unavailable";
@@ -18454,6 +18384,19 @@ var NativeRuntimeAdapter = class _NativeRuntimeAdapter {
18454
18384
  return null;
18455
18385
  }
18456
18386
  }
18387
+ /**
18388
+ * The Inspector's `explain`: for each of `rows` of `table`, which clauses
18389
+ * of its read policy (the arms of its top-level `Or`) hold for `session`.
18390
+ * Backend only.
18391
+ */
18392
+ explainReadClauses(table, rows, session) {
18393
+ if (!this.trustedBackend) throw new Error("explain runs only on a trusted backend");
18394
+ const explain = this.db.explainReadClauses;
18395
+ if (!explain) throw new Error("explain is not supported yet by this runtime");
18396
+ const native = readSession(JSON.stringify(session));
18397
+ if (!native?.identity) throw new Error("explain needs a user to explain for");
18398
+ return explain.call(this.db, table, rows, native.identity, native.claims);
18399
+ }
18457
18400
  requestInsertPermissionAdvice(table, values, session) {
18458
18401
  if (this.isScopedPermissionAdvice(session) && !this.trustedBackend)
18459
18402
  return Promise.resolve("unknown");
@@ -18778,6 +18721,7 @@ var NativeRuntimeAdapter = class _NativeRuntimeAdapter {
18778
18721
  return;
18779
18722
  }
18780
18723
  const normalizedAuthJson = normalizeBackendWebSocketAuth(authJson);
18724
+ this.assertCredentialKeepsPrincipal(normalizedAuthJson);
18781
18725
  this.nativeWireFeatures();
18782
18726
  this.link ??= this.createUpstreamLink();
18783
18727
  this.serverEndpointUrl = url;
@@ -19068,6 +19012,7 @@ var NativeRuntimeAdapter = class _NativeRuntimeAdapter {
19068
19012
  const firstPump = this.pumpServerTransport();
19069
19013
  firstPump.catch((error) => this.handleServerTransportError(error, generation));
19070
19014
  this.pumpSubscriptions();
19015
+ this.pinUpstreamPrincipal(normalizedAuthJson);
19071
19016
  this.stepLink({ type: "admitted", attempt: id });
19072
19017
  await Promise.race([
19073
19018
  firstPump.catch(() => void 0),
@@ -19145,10 +19090,45 @@ var NativeRuntimeAdapter = class _NativeRuntimeAdapter {
19145
19090
  if (this !== this.ownerRuntime) return this.ownerRuntime.updateAuth(authJson);
19146
19091
  this.nativeAuthRefusalRenewable = false;
19147
19092
  if (this.db?.rejectAuthUpdate) return this.db.rejectAuthUpdate();
19093
+ const normalizedAuthJson = normalizeBackendWebSocketAuth(authJson);
19094
+ this.assertCredentialKeepsPrincipal(normalizedAuthJson);
19148
19095
  if (!this.serverEndpointUrl) return;
19149
- this.serverAuthJson = normalizeBackendWebSocketAuth(authJson);
19096
+ this.serverAuthJson = normalizedAuthJson;
19150
19097
  this.stepLink({ type: "credentialUpdated" });
19151
19098
  }
19099
+ /**
19100
+ * The upstream principal is fixed once the server admits a credential that
19101
+ * names one. A later credential, from a refresh or a reconnect, that names
19102
+ * another principal is refused (`identity_mismatch`): the store, and in a
19103
+ * browser worker every tab it serves, syncs as that principal, so a
19104
+ * credential for someone else would link its replica upstream as them
19105
+ * (#4476). A renewed credential for the same principal passes, and so does
19106
+ * one that names no principal (signing out to `{}`). A credential the
19107
+ * server refuses pins nothing.
19108
+ */
19109
+ assertCredentialKeepsPrincipal(authJson) {
19110
+ if (this !== this.ownerRuntime)
19111
+ return this.ownerRuntime.assertCredentialKeepsPrincipal(authJson);
19112
+ if (!this.upstreamPrincipal) return;
19113
+ const normalizedAuthJson = normalizeBackendWebSocketAuth(authJson);
19114
+ if (!webSocketAuthNamesPrincipal(normalizedAuthJson)) return;
19115
+ let identity2;
19116
+ try {
19117
+ identity2 = peerIdentityForWebSocketAuth(normalizedAuthJson, this.peerIdentity);
19118
+ } catch {
19119
+ identity2 = null;
19120
+ }
19121
+ if (!identity2 || !sameBytes(identity2, this.upstreamPrincipal)) {
19122
+ throw identityMismatchError(
19123
+ "a credential refresh must keep the principal this store connects upstream as"
19124
+ );
19125
+ }
19126
+ }
19127
+ /** Pin the principal of a credential the server just admitted. */
19128
+ pinUpstreamPrincipal(normalizedAuthJson) {
19129
+ if (this.upstreamPrincipal || !webSocketAuthNamesPrincipal(normalizedAuthJson)) return;
19130
+ this.upstreamPrincipal = peerIdentityForWebSocketAuth(normalizedAuthJson, this.peerIdentity);
19131
+ }
19152
19132
  onAuthFailure(callback) {
19153
19133
  if (this !== this.ownerRuntime) return this.ownerRuntime.onAuthFailure(callback);
19154
19134
  this.authFailureCallback = callback;
@@ -19675,10 +19655,71 @@ var NativeRuntimeAdapter = class _NativeRuntimeAdapter {
19675
19655
  }
19676
19656
  }
19677
19657
  pumpSubscriptions() {
19658
+ this.drainSubscriptionPool();
19678
19659
  for (const [handle, subscription] of this.subscriptions) {
19660
+ if (subscription.poolId !== void 0) continue;
19679
19661
  this.startSubscriptionReader(handle, subscription);
19680
19662
  }
19681
19663
  }
19664
+ nativeSubscriptionPool() {
19665
+ if (this.subscriptionPool === void 0) {
19666
+ this.subscriptionPool = this.db.createSubscriptionPool?.() ?? null;
19667
+ }
19668
+ return this.subscriptionPool;
19669
+ }
19670
+ /**
19671
+ * Read every pooled subscription in one native call. Events are applied in
19672
+ * order per subscription; a drain requested while one is applying events
19673
+ * (a callback that writes) runs after it, so no subscription sees a later
19674
+ * batch before an earlier one finishes.
19675
+ */
19676
+ drainSubscriptionPool() {
19677
+ const pool = this.subscriptionPool;
19678
+ if (!pool || this.pooledSubscriptions.size === 0) return;
19679
+ if (this.drainingSubscriptionPool) {
19680
+ this.subscriptionPoolDirty = true;
19681
+ return;
19682
+ }
19683
+ this.drainingSubscriptionPool = true;
19684
+ try {
19685
+ do {
19686
+ this.subscriptionPoolDirty = false;
19687
+ for (const batch of pool.drain()) this.applyPooledBatch(batch);
19688
+ } while (this.subscriptionPoolDirty && !this.closed);
19689
+ } finally {
19690
+ this.drainingSubscriptionPool = false;
19691
+ }
19692
+ }
19693
+ applyPooledBatch(batch) {
19694
+ const handle = this.pooledSubscriptions.get(batch.id);
19695
+ if (handle === void 0) return;
19696
+ const subscription = this.subscriptions.get(handle);
19697
+ const isActive = () => subscription !== void 0 && !subscription.cancelled && this.subscriptions.get(handle) === subscription;
19698
+ if (!subscription || !isActive()) {
19699
+ this.pooledSubscriptions.delete(batch.id);
19700
+ return;
19701
+ }
19702
+ for (const event of batch.events) {
19703
+ if (!isActive()) break;
19704
+ try {
19705
+ this.applySubscriptionChunk(handle, subscription, event);
19706
+ } catch (error) {
19707
+ this.failSubscription(
19708
+ subscription,
19709
+ error instanceof Error ? error : new Error(String(error))
19710
+ );
19711
+ }
19712
+ }
19713
+ if (batch.error) {
19714
+ this.pooledSubscriptions.delete(batch.id);
19715
+ if (!this.closed && isActive()) {
19716
+ const error = new Error(batch.error.message);
19717
+ error.code = batch.error.code;
19718
+ this.failSubscription(subscription, error);
19719
+ }
19720
+ }
19721
+ if (!isActive()) this.pooledSubscriptions.delete(batch.id);
19722
+ }
19682
19723
  withPermissionAdviceTimeout(start) {
19683
19724
  if (this !== this.ownerRuntime) return this.ownerRuntime.withPermissionAdviceTimeout(start);
19684
19725
  if (this.closed || (!this.serverTransport || !this.serverCarrier) && !this.nativeUpstreamConfigured()) {
@@ -19773,6 +19814,11 @@ var NativeRuntimeAdapter = class _NativeRuntimeAdapter {
19773
19814
  this.coreTickScheduled = true;
19774
19815
  queueMicrotask(() => {
19775
19816
  this.coreTickScheduled = false;
19817
+ if (!this.coreProgressAllowed()) return;
19818
+ if (this.coreOperation) {
19819
+ this.coreTickAgain = true;
19820
+ return;
19821
+ }
19776
19822
  void this.runCoreTick().catch((error) => {
19777
19823
  try {
19778
19824
  if (this.db.isNativeForegroundClosed?.()) return;
@@ -19780,7 +19826,11 @@ var NativeRuntimeAdapter = class _NativeRuntimeAdapter {
19780
19826
  reportAsyncRuntimeError(livenessError);
19781
19827
  return;
19782
19828
  }
19783
- reportAsyncRuntimeError(error);
19829
+ if (this.serverTransport !== null || this.serverEndpointUrl !== null) {
19830
+ this.handleServerTransportError(error);
19831
+ } else {
19832
+ reportAsyncRuntimeError(error);
19833
+ }
19784
19834
  });
19785
19835
  });
19786
19836
  }
@@ -19804,11 +19854,23 @@ var NativeRuntimeAdapter = class _NativeRuntimeAdapter {
19804
19854
  /**
19805
19855
  * Write the slow-query report due now with `console.warn`: each line is a
19806
19856
  * query shape that held the database for at least the threshold, with its
19807
- * plan and the index that would likely make it fast.
19857
+ * plan and the index that would likely make it fast. With the `"summary"`
19858
+ * console detail, the plan and SQL go to `console.debug` instead.
19808
19859
  */
19809
19860
  reportSlowQueries() {
19810
- for (const line of this.db.takeSlowQueryReport?.(this.ownerRuntime.slowQueryApp) ?? []) {
19811
- console.warn(`[jazz] ${line}`);
19861
+ const owner = this.ownerRuntime;
19862
+ for (const line of this.db.takeSlowQueryReport?.(owner.slowQueryApp) ?? []) {
19863
+ if (owner.slowQueryConsoleDetail !== "summary") {
19864
+ console.warn(`[jazz] ${line}`);
19865
+ continue;
19866
+ }
19867
+ const summary = slowQuerySummary(line);
19868
+ if (summary === line) {
19869
+ console.warn(`[jazz] ${line}`);
19870
+ continue;
19871
+ }
19872
+ console.warn(`[jazz] ${summary}. Plan and SQL are logged at the debug ("Verbose") level.`);
19873
+ console.debug(`[jazz] ${line}`);
19812
19874
  }
19813
19875
  }
19814
19876
  async driveCoreTicks() {
@@ -19816,7 +19878,11 @@ var NativeRuntimeAdapter = class _NativeRuntimeAdapter {
19816
19878
  try {
19817
19879
  for (let round = 0; ; round += 1) {
19818
19880
  this.coreTickAgain = false;
19819
- await this.db.tick();
19881
+ try {
19882
+ await this.db.tick();
19883
+ } catch (error) {
19884
+ throw new CoreTickFailedError(error);
19885
+ }
19820
19886
  this.syncStatusPublisher.changed();
19821
19887
  this.reportSlowQueries();
19822
19888
  this.pumpSubscriptions();
@@ -19851,6 +19917,18 @@ var NativeRuntimeAdapter = class _NativeRuntimeAdapter {
19851
19917
  startSubscriptionReader(handle, subscription) {
19852
19918
  const source = subscription.source;
19853
19919
  if (subscription.cancelled || subscription.reading || !subscription.callback || !source) return;
19920
+ if (subscription.poolId !== void 0) {
19921
+ this.drainSubscriptionPool();
19922
+ return;
19923
+ }
19924
+ const pool = source.joinPool ? this.nativeSubscriptionPool() : null;
19925
+ if (pool && source.joinPool) {
19926
+ const id = source.joinPool(pool);
19927
+ subscription.poolId = id;
19928
+ this.pooledSubscriptions.set(id, handle);
19929
+ this.drainSubscriptionPool();
19930
+ return;
19931
+ }
19854
19932
  subscription.reading = true;
19855
19933
  this.readSubscription(handle, subscription, source);
19856
19934
  }
@@ -20121,7 +20199,8 @@ var NativeRuntimeAdapter = class _NativeRuntimeAdapter {
20121
20199
  this.serverTransportErrorAwaitsAuth = false;
20122
20200
  }
20123
20201
  handleServerTransportError(error, generation = this.serverConnectionGeneration, reconnecting = false) {
20124
- if (generation !== this.serverConnectionGeneration) return;
20202
+ if (generation !== this.serverConnectionGeneration && (this.closed || !isCoreTickFailedError(error)))
20203
+ return;
20125
20204
  const message = errorMessage(error);
20126
20205
  if (this.serverTransportError && message === "websocket closed") {
20127
20206
  if (reconnecting || !this.serverTransportErrorRetrying) return;
@@ -20218,6 +20297,7 @@ var NativeRuntimeAdapter = class _NativeRuntimeAdapter {
20218
20297
  retireSubscriptionResources(subscription) {
20219
20298
  if (subscription.cancelled) return;
20220
20299
  subscription.cancelled = true;
20300
+ if (subscription.poolId !== void 0) this.pooledSubscriptions.delete(subscription.poolId);
20221
20301
  subscription.openingAbort?.abort();
20222
20302
  const source = subscription.source;
20223
20303
  subscription.source = void 0;
@@ -20463,7 +20543,7 @@ function updatedAtMsFromWriteContext(writeContext) {
20463
20543
  return parsed.updated_at;
20464
20544
  }
20465
20545
  function effectiveUpdatedAtMs(writeContext) {
20466
- return updatedAtMsFromWriteContext(writeContext) ?? Date.now();
20546
+ return updatedAtMsFromWriteContext(writeContext) ?? null;
20467
20547
  }
20468
20548
  function txStateMessage(openTransactionId, completedBatches) {
20469
20549
  const completed = completedBatches.get(openTransactionId);
@@ -20922,11 +21002,11 @@ function errorMessage(error) {
20922
21002
  }
20923
21003
  return String(error);
20924
21004
  }
20925
- function identityMismatchError() {
20926
- return Object.assign(
20927
- new Error("a store configured as one user serves only its own identity's peers"),
20928
- { code: "protocol", reason: "identity_mismatch" }
20929
- );
21005
+ function identityMismatchError(message = "a store configured as one user serves only its own identity's peers") {
21006
+ return Object.assign(new Error(message), {
21007
+ code: "protocol",
21008
+ reason: "identity_mismatch"
21009
+ });
20930
21010
  }
20931
21011
  function contextualError(context2, error) {
20932
21012
  const cause = error instanceof Error ? error : new Error(errorMessage(error));
@@ -22205,7 +22285,7 @@ function normalizeSubscriptionRejectionReason(reason) {
22205
22285
  }
22206
22286
  const failure = record.code ?? record.detail;
22207
22287
  if (record.type === "ServerFailure" && typeof failure === "string") {
22208
- return { type: "ServerFailure", code: failure };
22288
+ return typeof record.errorCode === "string" ? { type: "ServerFailure", code: failure, errorCode: record.errorCode } : { type: "ServerFailure", code: failure };
22209
22289
  }
22210
22290
  if (record.type === "InvalidAuthoritySourceClosure" && typeof record.transition === "string") {
22211
22291
  return {
@@ -22217,7 +22297,10 @@ function normalizeSubscriptionRejectionReason(reason) {
22217
22297
  }
22218
22298
  function subscriptionRejectionError(reason) {
22219
22299
  const detail = reason.type === "UnsupportedShapeCapability" ? reason.detail : reason.type === "ServerFailure" ? reason.code : reason.type === "InvalidAuthoritySourceClosure" ? reason.transition : "catalogue admission pending";
22220
- return new Error(`Subscription rejected: ${reason.type}: ${detail}`);
22300
+ const message = `Subscription rejected: ${reason.type}: ${detail}`;
22301
+ const code = reason.type === "ServerFailure" ? reason.errorCode : void 0;
22302
+ if (code === void 0) return new Error(message);
22303
+ return upstreamRefusalError({ code, message }) ?? new Error(message);
22221
22304
  }
22222
22305
  function subscriptionSource(subscription) {
22223
22306
  const maybeReadable = subscription;
@@ -22239,6 +22322,7 @@ function subscriptionSource(subscription) {
22239
22322
  }
22240
22323
  const native = subscription;
22241
22324
  return {
22325
+ joinPool: native.joinPool ? (pool) => native.joinPool(pool) : void 0,
22242
22326
  pull() {
22243
22327
  const batch = native.readAll();
22244
22328
  return Array.isArray(batch) ? { type: "batch", events: batch } : { type: "pending", retryAfterMs: batch.retryAfterMs?.() ?? 0 };
@@ -22348,6 +22432,29 @@ function deliverMutationErrorToAttachedPeers(peers, event, deliver) {
22348
22432
  for (const peer of peers) deliver(peer, event);
22349
22433
  }
22350
22434
 
22435
+ // src/worker/runtime-admission.ts
22436
+ function compareRuntimeAdmission(open, requested, requestedSchema) {
22437
+ if (open === requested) return "admit";
22438
+ try {
22439
+ const {
22440
+ authClass: openAuth,
22441
+ schemaHash: openSchema,
22442
+ ...openRest
22443
+ } = JSON.parse(open);
22444
+ const {
22445
+ authClass: requestedAuth,
22446
+ schemaHash: requestedSchemaHash,
22447
+ ...requestedRest
22448
+ } = JSON.parse(requested);
22449
+ if (JSON.stringify(openRest) !== JSON.stringify(requestedRest)) return "incompatible";
22450
+ const schemaless = Object.keys(requestedSchema).length === 0;
22451
+ if (openSchema !== requestedSchemaHash && !schemaless) return "incompatible";
22452
+ return openAuth === requestedAuth ? "admit" : "held-by-another-sign-in";
22453
+ } catch {
22454
+ return "incompatible";
22455
+ }
22456
+ }
22457
+
22351
22458
  // src/worker/jazz-broker-worker-core.ts
22352
22459
  Error.stackTraceLimit = 50;
22353
22460
  var DEFAULT_WASM_LOG_LEVEL = "warn";
@@ -22567,6 +22674,11 @@ function attachBootstrapPort(port, scope) {
22567
22674
  if (workerTerminationScheduled) {
22568
22675
  if (message?.type === "connect-runtime") {
22569
22676
  post(port, { type: "worker-closing" });
22677
+ } else if (message?.type === "delete-store") {
22678
+ post(port, {
22679
+ type: "delete-store-result",
22680
+ outcome: "held"
22681
+ });
22570
22682
  } else if (message?.type === "probe-foreground-node-lease-worker" || message?.type === "acquire-foreground-node-lease") {
22571
22683
  post(port, {
22572
22684
  type: "foreground-node-lease-worker-closing",
@@ -22589,6 +22701,26 @@ function attachBootstrapPort(port, scope) {
22589
22701
  closeBootstrapPort();
22590
22702
  return;
22591
22703
  }
22704
+ if (message?.type === "delete-store") {
22705
+ if (scope) {
22706
+ closeBootstrapPort();
22707
+ return;
22708
+ }
22709
+ operationStarted = true;
22710
+ clearTimeout(idleTimer);
22711
+ recordWorkerLifecycle("delete-store", message.dbName, null);
22712
+ void deleteStoreWithoutTabs(message.dbName, message.runtimeSources).then(
22713
+ (outcome) => post(port, {
22714
+ type: "delete-store-result",
22715
+ outcome
22716
+ }),
22717
+ (error) => post(port, {
22718
+ type: "delete-store-error",
22719
+ error: serializeBrowserRelayError(toError(error))
22720
+ })
22721
+ ).finally(closeBootstrapPort);
22722
+ return;
22723
+ }
22592
22724
  if (message?.type !== "connect-runtime" && message?.type !== "acquire-foreground-node-lease") {
22593
22725
  return;
22594
22726
  }
@@ -22636,6 +22768,37 @@ function attachBootstrapPort(port, scope) {
22636
22768
  if (!operationStarted) closeBootstrapPort();
22637
22769
  };
22638
22770
  }
22771
+ async function deleteStoreWithoutTabs(dbName, runtimeSources) {
22772
+ for (const context2 of [...contexts.values()]) {
22773
+ if (context2.options.dbName !== dbName) continue;
22774
+ if (context2.peers.size !== 0 || context2.pendingAdmissionTasks !== 0) return "held";
22775
+ await releaseIdleContext(context2);
22776
+ }
22777
+ const leaseOwner = foregroundLeaseOwners.get(dbName);
22778
+ if ([...contexts.values()].some((context2) => context2.options.dbName === dbName) || physicalDatabaseOwnerAdmissions.has(dbName) || leaseOwner && (leaseOwner.pendingLeaseAllocations > 0 || leaseOwner.pendingLeaseFinalizations > 0))
22779
+ return "held";
22780
+ pendingRuntimeOwnerRetirements.delete(dbName);
22781
+ await releasePhysicalDatabaseOwner(dbName).catch(() => void 0);
22782
+ if (leaseOwner) {
22783
+ foregroundLeaseOwners.delete(dbName);
22784
+ leaseOwner.pageStore.close();
22785
+ }
22786
+ let epoch;
22787
+ try {
22788
+ epoch = await acquireBrowserPhysicalDatabaseEpoch(dbName);
22789
+ } catch (error) {
22790
+ if (error instanceof BrowserPhysicalDatabaseBusyError) return "held";
22791
+ throw error;
22792
+ }
22793
+ try {
22794
+ await IndexedDbPageStore.destroy(dbName);
22795
+ const wasmModule2 = await loadWorkerWasmModule(runtimeSources);
22796
+ await wasmModule2.WasmDb.destroyBrowserStorage(void 0, dbName);
22797
+ } finally {
22798
+ await epoch.release();
22799
+ }
22800
+ return "deleted";
22801
+ }
22639
22802
  async function acquireForegroundNodeLease(port, request, parentLifetime) {
22640
22803
  const testHooks = foregroundLeaseTestHooks;
22641
22804
  let owner = null;
@@ -22931,9 +23094,10 @@ async function connectTab(port, message, signal, finishBootstrap) {
22931
23094
  if (context2 && !workerTelemetryCompatible(context2.options, message.options)) {
22932
23095
  throw new Error("incompatible persistent browser telemetry configuration");
22933
23096
  }
22934
- if (context2 && context2.fingerprint !== message.fingerprint) {
23097
+ const admission = context2 ? compareRuntimeAdmission(context2.fingerprint, message.fingerprint, message.options.schema) : "admit";
23098
+ if (admission !== "admit") {
22935
23099
  throw new Error(
22936
- differsOnlyInSignIn(context2.fingerprint, message.fingerprint) ? BROWSER_STORE_HELD_BY_ANOTHER_SIGN_IN : "incompatible persistent browser configuration"
23100
+ admission === "held-by-another-sign-in" ? BROWSER_STORE_HELD_BY_ANOTHER_SIGN_IN : "incompatible persistent browser configuration"
22937
23101
  );
22938
23102
  }
22939
23103
  if (context2?.idleReleaseTimer) {
@@ -23068,7 +23232,12 @@ async function initialize(context2) {
23068
23232
  {
23069
23233
  selfSignedClientProof: proof,
23070
23234
  scopeIsolatedRelay: true,
23071
- slowQueryLog: { appId: options.appId, thresholdMs: options.slowQueryThresholdMs }
23235
+ slowQueryLog: {
23236
+ appId: options.appId,
23237
+ thresholdMs: options.slowQueryThresholdMs,
23238
+ // End users see a browser's console: plan and SQL go to debug.
23239
+ consoleDetail: "summary"
23240
+ }
23072
23241
  }
23073
23242
  );
23074
23243
  context2.runtime = runtime;
@@ -23192,6 +23361,7 @@ async function configureServer(context2, options) {
23192
23361
  const requestedUrl = options.serverUrl ?? null;
23193
23362
  if (context2.serverUrl === requestedUrl) {
23194
23363
  if (!carriesCredential(options.authJson) && carriesCredential(context2.serverAuthJson)) return;
23364
+ context2.runtime?.assertCredentialKeepsPrincipal(options.authJson);
23195
23365
  context2.serverAuthJson = options.authJson;
23196
23366
  if (context2.serverConnectionStarted) await requireRuntime(context2).updateAuth(options.authJson);
23197
23367
  return;
@@ -23383,9 +23553,25 @@ async function handleTabMessage(peer, message) {
23383
23553
  result(peer, message.id);
23384
23554
  return;
23385
23555
  }
23556
+ if (message.type === "store-pending-uploads") {
23557
+ let pendingUploads;
23558
+ try {
23559
+ pendingUploads = peer.context.runtime?.uploadStatus().pending;
23560
+ } catch {
23561
+ pendingUploads = void 0;
23562
+ }
23563
+ result(peer, message.id, void 0, { pendingUploads });
23564
+ return;
23565
+ }
23386
23566
  if (message.type === "prepare-storage-reset") {
23387
23567
  peer.context.intentionalStorageReset = true;
23388
- result(peer, message.id);
23568
+ let pendingUploads;
23569
+ try {
23570
+ pendingUploads = peer.context.runtime?.uploadStatus().pending;
23571
+ } catch {
23572
+ pendingUploads = void 0;
23573
+ }
23574
+ result(peer, message.id, void 0, { pendingUploads });
23389
23575
  return;
23390
23576
  }
23391
23577
  if (message.type === "abort-storage-reset") {
@@ -23551,6 +23737,7 @@ async function handleTabMessage(peer, message) {
23551
23737
  if (!peer.subscriber) throw new Error("Browser tab is not initialized");
23552
23738
  let authenticationRejected = false;
23553
23739
  await enqueueTransportTransition(peer.context, async () => {
23740
+ activeRuntime.assertCredentialKeepsPrincipal(message.authJson);
23554
23741
  const authFailureEpoch = peer.context.authFailureEpoch;
23555
23742
  try {
23556
23743
  if (!peer.context.explicitlyDisconnected) {
@@ -23618,6 +23805,7 @@ async function handleTabMessage(peer, message) {
23618
23805
  await enqueueTransportTransition(peer.context, async () => {
23619
23806
  const own = carriesCredential(message.authJson) || !carriesCredential(peer.context.serverAuthJson);
23620
23807
  const authJson = own ? message.authJson : peer.context.serverAuthJson;
23808
+ activeRuntime.assertCredentialKeepsPrincipal(authJson);
23621
23809
  const dial = carriesCredential(authJson);
23622
23810
  if (dial) {
23623
23811
  activeRuntime.connect(serverUrl, authJson);
@@ -23977,15 +24165,6 @@ function workerTelemetryCompatible(current, next) {
23977
24165
  }
23978
24166
  return (current.logLevel ?? DEFAULT_WASM_LOG_LEVEL) === (next.logLevel ?? DEFAULT_WASM_LOG_LEVEL);
23979
24167
  }
23980
- function differsOnlyInSignIn(open, requested) {
23981
- try {
23982
- const { authClass: openAuth, ...openRest } = JSON.parse(open);
23983
- const { authClass: requestedAuth, ...requestedRest } = JSON.parse(requested);
23984
- return openAuth !== requestedAuth && JSON.stringify(openRest) === JSON.stringify(requestedRest);
23985
- } catch {
23986
- return false;
23987
- }
23988
- }
23989
24168
  function runtimeKey(options) {
23990
24169
  return options.dbName;
23991
24170
  }