jazz-tools 2.0.0-alpha.70 → 2.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (238) hide show
  1. package/README.md +2 -3
  2. package/bin/jazz-tools.js +0 -3
  3. package/dist/accounts/account-manager-core.d.ts +54 -1
  4. package/dist/accounts/account-manager-core.d.ts.map +1 -1
  5. package/dist/accounts/account-manager-core.js +2 -2
  6. package/dist/accounts/account-manager-core.js.map +1 -1
  7. package/dist/accounts/context.js +1 -1
  8. package/dist/accounts/context.js.map +1 -1
  9. package/dist/backend/api.d.ts +1 -2
  10. package/dist/backend/api.d.ts.map +1 -1
  11. package/dist/backend/api.js +0 -2
  12. package/dist/backend/api.js.map +1 -1
  13. package/dist/backend/create-jazz.d.ts +0 -6
  14. package/dist/backend/create-jazz.d.ts.map +1 -1
  15. package/dist/backend/create-jazz.js +1 -1
  16. package/dist/backend/create-jazz.js.map +1 -1
  17. package/dist/backend/inspector-ui/11.js +2 -2
  18. package/dist/backend/inspector-ui/12.js +2 -2
  19. package/dist/backend/inspector-ui/13.js +2 -2
  20. package/dist/backend/inspector-ui/14.js +2 -2
  21. package/dist/backend/inspector-ui/20.js +1 -1
  22. package/dist/backend/inspector-ui-files.js +4 -4
  23. package/dist/backend/no-account-error.d.ts +1 -1
  24. package/dist/backend/no-account-error.js +1 -1
  25. package/dist/backend/no-account-error.js.map +1 -1
  26. package/dist/cli.d.ts +0 -1
  27. package/dist/cli.d.ts.map +1 -1
  28. package/dist/cli.js +8 -22
  29. package/dist/cli.js.map +1 -1
  30. package/dist/client/index.d.ts +0 -1
  31. package/dist/client/index.d.ts.map +1 -1
  32. package/dist/client/index.js +0 -2
  33. package/dist/client/index.js.map +1 -1
  34. package/dist/dev/app-files.js +1 -1
  35. package/dist/dev/app-files.js.map +1 -1
  36. package/dist/dev/catalogue-api.d.ts.map +1 -1
  37. package/dist/dev/catalogue-api.js +3 -6
  38. package/dist/dev/catalogue-api.js.map +1 -1
  39. package/dist/dev/inspector-overlay/embedded/assets/{index-D3RK8wNj.js → index-DUKUt96e.js} +3 -3
  40. package/dist/dev/inspector-overlay/embedded/assets/{jazz-broker-worker-EyaWhBtz.js → jazz-broker-worker-C_mr9Omd.js} +2 -2
  41. package/dist/dev/inspector-overlay/embedded/assets/{jazz_wasm-O10pptvY.js → jazz_wasm-BOvbCHn3.js} +1 -1
  42. package/dist/dev/inspector-overlay/embedded/assets/{jazz_wasm_bg-wI43fvvq.wasm → jazz_wasm_bg-BG8gazqt.wasm} +0 -0
  43. package/dist/dev/inspector-overlay/embedded/embedded.html +1 -1
  44. package/dist/dev/project.js +1 -1
  45. package/dist/dev/project.js.map +1 -1
  46. package/dist/dev/ts-project.d.ts.map +1 -1
  47. package/dist/dev/ts-project.js +3 -2
  48. package/dist/dev/ts-project.js.map +1 -1
  49. package/dist/expo/create-account-manager.d.ts +1 -1
  50. package/dist/expo/create-account-manager.js.map +1 -1
  51. package/dist/expo/index.d.ts +1 -2
  52. package/dist/expo/index.d.ts.map +1 -1
  53. package/dist/expo/index.js +1 -3
  54. package/dist/expo/index.js.map +1 -1
  55. package/dist/index.d.ts +0 -2
  56. package/dist/index.d.ts.map +1 -1
  57. package/dist/index.js +0 -4
  58. package/dist/index.js.map +1 -1
  59. package/dist/printer/index.d.ts +2 -2
  60. package/dist/printer/index.d.ts.map +1 -1
  61. package/dist/printer/index.js +4 -1
  62. package/dist/printer/index.js.map +1 -1
  63. package/dist/react/index.d.ts +1 -2
  64. package/dist/react/index.d.ts.map +1 -1
  65. package/dist/react/index.js +1 -3
  66. package/dist/react/index.js.map +1 -1
  67. package/dist/react/provider.d.ts +0 -2
  68. package/dist/react/provider.d.ts.map +1 -1
  69. package/dist/react/provider.js +1 -2
  70. package/dist/react/provider.js.map +1 -1
  71. package/dist/react-core/index.d.ts +1 -2
  72. package/dist/react-core/index.d.ts.map +1 -1
  73. package/dist/react-core/index.js +3 -5
  74. package/dist/react-core/index.js.map +1 -1
  75. package/dist/react-core/provider.d.ts +0 -8
  76. package/dist/react-core/provider.d.ts.map +1 -1
  77. package/dist/react-core/provider.js +0 -13
  78. package/dist/react-core/provider.js.map +1 -1
  79. package/dist/react-native/create-account-manager.d.ts +1 -1
  80. package/dist/react-native/create-account-manager.js.map +1 -1
  81. package/dist/react-native/index.d.ts +1 -3
  82. package/dist/react-native/index.d.ts.map +1 -1
  83. package/dist/react-native/index.js +1 -5
  84. package/dist/react-native/index.js.map +1 -1
  85. package/dist/react-native/provider.d.ts +0 -2
  86. package/dist/react-native/provider.d.ts.map +1 -1
  87. package/dist/react-native/provider.js +1 -2
  88. package/dist/react-native/provider.js.map +1 -1
  89. package/dist/runtime/db.d.ts +0 -5
  90. package/dist/runtime/db.d.ts.map +1 -1
  91. package/dist/runtime/db.js +0 -5
  92. package/dist/runtime/db.js.map +1 -1
  93. package/dist/runtime/native-artifact-fingerprint-napi.d.ts +1 -1
  94. package/dist/runtime/native-artifact-fingerprint-napi.js +1 -1
  95. package/dist/runtime/native-artifact-fingerprint-napi.js.map +1 -1
  96. package/dist/runtime/native-artifact-fingerprint-wasm.d.ts +1 -1
  97. package/dist/runtime/native-artifact-fingerprint-wasm.js +1 -1
  98. package/dist/runtime/native-artifact-fingerprint-wasm.js.map +1 -1
  99. package/dist/runtime/native-artifact-fingerprints.d.ts +2 -2
  100. package/dist/schema-builders.d.ts +0 -7
  101. package/dist/schema-builders.d.ts.map +1 -1
  102. package/dist/schema-builders.js +0 -7
  103. package/dist/schema-builders.js.map +1 -1
  104. package/dist/session/create-jazz-session.d.ts +1 -1
  105. package/dist/session/create-jazz-session.d.ts.map +1 -1
  106. package/dist/session/create-jazz-session.js.map +1 -1
  107. package/dist/solid/index.d.ts +1 -2
  108. package/dist/solid/index.d.ts.map +1 -1
  109. package/dist/solid/index.js +7 -8
  110. package/dist/solid/index.ssr.js +2 -3
  111. package/dist/solid/provider.d.ts +1 -12
  112. package/dist/solid/provider.d.ts.map +1 -1
  113. package/dist/solid/provider.js +12 -18
  114. package/dist/solid/provider.js.map +1 -1
  115. package/dist/solid/provider.ssr.js +1 -11
  116. package/dist/solid/provider.ssr.js.map +1 -1
  117. package/dist/svelte/context.svelte.d.ts +1 -12
  118. package/dist/svelte/context.svelte.d.ts.map +1 -1
  119. package/dist/svelte/context.svelte.js +2 -20
  120. package/dist/svelte/index.d.ts +1 -2
  121. package/dist/svelte/index.d.ts.map +1 -1
  122. package/dist/svelte/index.js +1 -3
  123. package/dist/thin/index.d.ts +0 -1
  124. package/dist/thin/index.d.ts.map +1 -1
  125. package/dist/thin/index.js +0 -2
  126. package/dist/thin/index.js.map +1 -1
  127. package/dist/typed-app.d.ts +1 -1
  128. package/dist/typed-app.js.map +1 -1
  129. package/dist/vue/index.d.ts +1 -2
  130. package/dist/vue/index.d.ts.map +1 -1
  131. package/dist/vue/index.js +1 -3
  132. package/dist/vue/index.js.map +1 -1
  133. package/dist/vue/provider.d.ts +2 -35
  134. package/dist/vue/provider.d.ts.map +1 -1
  135. package/dist/vue/provider.js +1 -135
  136. package/dist/vue/provider.js.map +1 -1
  137. package/dist/web/lazy-local-first.d.ts +0 -3
  138. package/dist/web/lazy-local-first.d.ts.map +1 -1
  139. package/dist/web/lazy-local-first.js +1 -6
  140. package/dist/web/lazy-local-first.js.map +1 -1
  141. package/dist/worker/jazz-broker-worker.js +2 -2
  142. package/dist/worker/jazz_wasm_bg.wasm +0 -0
  143. package/package.json +4 -8
  144. package/dist/accounts/create-account-manager.d.ts +0 -57
  145. package/dist/accounts/create-account-manager.d.ts.map +0 -1
  146. package/dist/accounts/create-account-manager.js +0 -17
  147. package/dist/accounts/create-account-manager.js.map +0 -1
  148. package/dist/permissions/index.d.ts +0 -5
  149. package/dist/permissions/index.d.ts.map +0 -1
  150. package/dist/permissions/index.js +0 -11
  151. package/dist/permissions/index.js.map +0 -1
  152. package/dist/removed-api.d.ts +0 -87
  153. package/dist/removed-api.d.ts.map +0 -1
  154. package/dist/removed-api.js +0 -95
  155. package/dist/removed-api.js.map +0 -1
  156. package/dist/removed-schema-api.d.ts +0 -80
  157. package/dist/removed-schema-api.d.ts.map +0 -1
  158. package/dist/removed-schema-api.js +0 -128
  159. package/dist/removed-schema-api.js.map +0 -1
  160. package/dist/session/deprecated-session-hook.d.ts +0 -8
  161. package/dist/session/deprecated-session-hook.d.ts.map +0 -1
  162. package/dist/session/deprecated-session-hook.js +0 -28
  163. package/dist/session/deprecated-session-hook.js.map +0 -1
  164. package/dist/svelte/JazzSvelteProvider.svelte +0 -181
  165. package/dist/svelte/JazzSvelteProvider.svelte.d.ts +0 -14
  166. package/dist/svelte/JazzSvelteProvider.svelte.d.ts.map +0 -1
  167. package/dist/upgrade/aliases.d.ts +0 -25
  168. package/dist/upgrade/aliases.d.ts.map +0 -1
  169. package/dist/upgrade/aliases.js +0 -80
  170. package/dist/upgrade/aliases.js.map +0 -1
  171. package/dist/upgrade/app-json.d.ts +0 -32
  172. package/dist/upgrade/app-json.d.ts.map +0 -1
  173. package/dist/upgrade/app-json.js +0 -145
  174. package/dist/upgrade/app-json.js.map +0 -1
  175. package/dist/upgrade/constants.d.ts +0 -25
  176. package/dist/upgrade/constants.d.ts.map +0 -1
  177. package/dist/upgrade/constants.js +0 -136
  178. package/dist/upgrade/constants.js.map +0 -1
  179. package/dist/upgrade/edits.d.ts +0 -10
  180. package/dist/upgrade/edits.d.ts.map +0 -1
  181. package/dist/upgrade/edits.js +0 -21
  182. package/dist/upgrade/edits.js.map +0 -1
  183. package/dist/upgrade/errors.d.ts +0 -12
  184. package/dist/upgrade/errors.d.ts.map +0 -1
  185. package/dist/upgrade/errors.js +0 -18
  186. package/dist/upgrade/errors.js.map +0 -1
  187. package/dist/upgrade/extras.d.ts +0 -42
  188. package/dist/upgrade/extras.d.ts.map +0 -1
  189. package/dist/upgrade/extras.js +0 -487
  190. package/dist/upgrade/extras.js.map +0 -1
  191. package/dist/upgrade/fresh.d.ts +0 -36
  192. package/dist/upgrade/fresh.d.ts.map +0 -1
  193. package/dist/upgrade/fresh.js +0 -154
  194. package/dist/upgrade/fresh.js.map +0 -1
  195. package/dist/upgrade/index.d.ts +0 -79
  196. package/dist/upgrade/index.d.ts.map +0 -1
  197. package/dist/upgrade/index.js +0 -806
  198. package/dist/upgrade/index.js.map +0 -1
  199. package/dist/upgrade/json-only.d.ts +0 -24
  200. package/dist/upgrade/json-only.d.ts.map +0 -1
  201. package/dist/upgrade/json-only.js +0 -124
  202. package/dist/upgrade/json-only.js.map +0 -1
  203. package/dist/upgrade/names.d.ts +0 -29
  204. package/dist/upgrade/names.d.ts.map +0 -1
  205. package/dist/upgrade/names.js +0 -105
  206. package/dist/upgrade/names.js.map +0 -1
  207. package/dist/upgrade/payload-enums.d.ts +0 -18
  208. package/dist/upgrade/payload-enums.d.ts.map +0 -1
  209. package/dist/upgrade/payload-enums.js +0 -52
  210. package/dist/upgrade/payload-enums.js.map +0 -1
  211. package/dist/upgrade/permissions-check.d.ts +0 -10
  212. package/dist/upgrade/permissions-check.d.ts.map +0 -1
  213. package/dist/upgrade/permissions-check.js +0 -85
  214. package/dist/upgrade/permissions-check.js.map +0 -1
  215. package/dist/upgrade/program.d.ts +0 -18
  216. package/dist/upgrade/program.d.ts.map +0 -1
  217. package/dist/upgrade/program.js +0 -56
  218. package/dist/upgrade/program.js.map +0 -1
  219. package/dist/upgrade/project.d.ts +0 -56
  220. package/dist/upgrade/project.d.ts.map +0 -1
  221. package/dist/upgrade/project.js +0 -254
  222. package/dist/upgrade/project.js.map +0 -1
  223. package/dist/upgrade/rewrite.d.ts +0 -34
  224. package/dist/upgrade/rewrite.d.ts.map +0 -1
  225. package/dist/upgrade/rewrite.js +0 -500
  226. package/dist/upgrade/rewrite.js.map +0 -1
  227. package/dist/upgrade/schema-ts.d.ts +0 -59
  228. package/dist/upgrade/schema-ts.d.ts.map +0 -1
  229. package/dist/upgrade/schema-ts.js +0 -582
  230. package/dist/upgrade/schema-ts.js.map +0 -1
  231. package/dist/upgrade/snapshot.d.ts +0 -11
  232. package/dist/upgrade/snapshot.d.ts.map +0 -1
  233. package/dist/upgrade/snapshot.js +0 -90
  234. package/dist/upgrade/snapshot.js.map +0 -1
  235. package/dist/upgrade/upgrade-test-helpers.d.ts +0 -12
  236. package/dist/upgrade/upgrade-test-helpers.d.ts.map +0 -1
  237. package/dist/upgrade/upgrade-test-helpers.js +0 -72
  238. package/dist/upgrade/upgrade-test-helpers.js.map +0 -1
@@ -3,7 +3,6 @@ import { isPendingSolidJazzClientReady } from "./create-solid-jazz-client.ssr.js
3
3
  import { JazzProvider } from "./session.ssr.js";
4
4
  import { Show, createContext, useContext } from "solid-js";
5
5
  import { createComponent } from "solid-js/web";
6
- import { warnSessionHookDeprecated } from "../session/deprecated-session-hook.js";
7
6
  import { refuseAutoAttachDevTools } from "../runtime/removed-provider-props.js";
8
7
  // src/solid/provider.tsx
9
8
  var JazzClientContext = createContext(void 0);
@@ -40,19 +39,10 @@ function useDb() {
40
39
  const client = useJazzClient();
41
40
  return () => client.db;
42
41
  }
43
- /**
44
- * @deprecated Use `useJazzSession().snapshot().user`: the same user, with
45
- * `user` as `accountId`. Warns once in development; removed in a later alpha.
46
- */
47
- function useSession() {
48
- warnSessionHookDeprecated("useSession()", "useJazzSession().snapshot().user");
49
- const client = useJazzClient();
50
- return () => client.session;
51
- }
52
42
  function useAuthState() {
53
43
  const client = useJazzClient();
54
44
  return () => client.authState;
55
45
  }
56
- export { JazzClientContext, JazzClientProvider, JazzProvider, useAuthState, useDb, useJazzClient, useSession };
46
+ export { JazzClientContext, JazzClientProvider, JazzProvider, useAuthState, useDb, useJazzClient };
57
47
 
58
48
  //# sourceMappingURL=provider.ssr.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"provider.ssr.js","names":["warnSessionHookDeprecated","SessionContext","createContext","useContext","Show","isPendingSolidJazzClientReady","refuseAutoAttachDevTools","JazzClientContext","undefined","client","fallback","children","JazzClientProvider","props","clientReady","_$createComponent","when","keyed","Provider","value","useJazzClient","ctx","Error","useDb","db","useSession","session","useAuthState","authState"],"sources":["../../src/solid/provider.tsx"],"sourcesContent":["import { warnSessionHookDeprecated } from \"../session/deprecated-session-hook.js\";\nimport { SessionContext } from \"./session-context.js\";\nimport { createContext, useContext, type JSX, type Accessor, Show } from \"solid-js\";\nimport type { PublicSession } from \"../runtime/context.js\";\nimport {\n createSolidJazzClient,\n isPendingSolidJazzClientReady,\n type SolidJazzClient,\n type PendingSolidJazzClient,\n} from \"./create-solid-jazz-client.js\";\nimport type { Db } from \"../runtime/db.js\";\nimport type { AccountDbConfig as DbConfig } from \"../accounts/context.js\";\nimport {\n refuseAutoAttachDevTools,\n type NoAutoAttachDevTools,\n} from \"../runtime/removed-provider-props.js\";\n\ntype JazzClientContextValue = SolidJazzClient;\n\nexport const JazzClientContext = createContext<JazzClientContextValue | undefined>(undefined);\n\nexport type JazzClientProviderProps = NoAutoAttachDevTools & {\n client: PendingSolidJazzClient;\n fallback?: JSX.Element;\n children: JSX.Element;\n};\n\nexport function JazzClientProvider(props: JazzClientProviderProps) {\n refuseAutoAttachDevTools(\"JazzClientProvider\", props);\n const clientReady = () =>\n isPendingSolidJazzClientReady(props.client) ? props.client : undefined;\n\n return (\n <Show when={clientReady()} keyed fallback={props.fallback ?? null}>\n {(client) => (\n // Its children read this client, not an enclosing <JazzProvider>'s session.\n <SessionContext.Provider value={undefined}>\n <JazzClientContext.Provider value={client}>{props.children}</JazzClientContext.Provider>\n </SessionContext.Provider>\n )}\n </Show>\n );\n}\n\nexport type LegacyJazzProviderProps = Omit<JazzClientProviderProps, \"client\"> & {\n config: DbConfig;\n};\n\nexport function LegacyJazzProvider(props: LegacyJazzProviderProps) {\n const client = createSolidJazzClient(() => props.config);\n\n return (\n <JazzClientProvider client={client} fallback={props.fallback}>\n {props.children}\n </JazzClientProvider>\n );\n}\n\nexport function useJazzClient(): JazzClientContextValue {\n const ctx = useContext(JazzClientContext);\n if (!ctx) {\n throw new Error(\"useJazzClient must be used inside JazzProvider or JazzClientProvider.\");\n }\n return ctx;\n}\n\nexport function useDb<TDb = Db>(): Accessor<TDb> {\n const client = useJazzClient();\n return () => client.db as TDb;\n}\n\n/**\n * @deprecated Use `useJazzSession().snapshot().user`: the same user, with\n * `user` as `accountId`. Warns once in development; removed in a later alpha.\n */\nexport function useSession(): Accessor<PublicSession | null> {\n warnSessionHookDeprecated(\"useSession()\", \"useJazzSession().snapshot().user\");\n const client = useJazzClient();\n return () => client.session;\n}\n\nexport function useAuthState() {\n const client = useJazzClient();\n return () => client.authState;\n}\n\nexport { JazzProvider, type JazzProviderProps } from \"./session.js\";\n"],"mappings":";;;;;;;;AAmBA,IAAaO,oBAAoBL,cAAkDM,KAAAA,CAAS;AAQ5F,SAAgBI,mBAAmBC,OAAgC;CACjEP,yBAAyB,sBAAsBO,KAAK;CACpD,MAAMC,oBACJT,8BAA8BQ,MAAMJ,MAAM,IAAII,MAAMJ,SAASD,KAAAA;CAE/D,OAAAO,gBACGX,MAAI;EAAA,IAACY,OAAI;GAAA,OAAEF,YAAY;EAAC;EAAEG,OAAK;EAAA,IAACP,WAAQ;GAAA,OAAEG,MAAMH,YAAY;EAAI;EAAAC,WAC7DF,WACAM,gBACCd,eAAeiB,UAAQ;GAACC,OAAOX,KAAAA;GAAS,IAAAG,WAAA;IAAA,OAAAI,gBACtCR,kBAAkBW,UAAQ;KAACC,OAAOV;KAAM,IAAAE,WAAA;MAAA,OAAGE,MAAMF;KAAQ;IAAA,CAAA;GAAA;EAAA,CAAA;CAE7D,CAAA;AAGP;AAgBA,SAAgBS,gBAAwC;CACtD,MAAMC,MAAMlB,WAAWI,iBAAiB;CACxC,IAAI,CAACc,KACH,MAAM,IAAIC,MAAM,uEAAuE;CAEzF,OAAOD;AACT;AAEA,SAAgBE,QAAiC;CAC/C,MAAMd,SAASW,cAAc;CAC7B,aAAaX,OAAOe;AACtB;;;;;AAMA,SAAgBC,aAA6C;CAC3DzB,0BAA0B,gBAAgB,kCAAkC;CAC5E,MAAMS,SAASW,cAAc;CAC7B,aAAaX,OAAOiB;AACtB;AAEA,SAAgBC,eAAe;CAC7B,MAAMlB,SAASW,cAAc;CAC7B,aAAaX,OAAOmB;AACtB"}
1
+ {"version":3,"file":"provider.ssr.js","names":["SessionContext","createContext","useContext","Show","isPendingSolidJazzClientReady","refuseAutoAttachDevTools","JazzClientContext","undefined","client","fallback","children","JazzClientProvider","props","clientReady","_$createComponent","when","keyed","Provider","value","useJazzClient","ctx","Error","useDb","db","useAuthState","authState"],"sources":["../../src/solid/provider.tsx"],"sourcesContent":["import { SessionContext } from \"./session-context.js\";\nimport { createContext, useContext, type JSX, type Accessor, Show } from \"solid-js\";\nimport {\n isPendingSolidJazzClientReady,\n type SolidJazzClient,\n type PendingSolidJazzClient,\n} from \"./create-solid-jazz-client.js\";\nimport type { Db } from \"../runtime/db.js\";\nimport {\n refuseAutoAttachDevTools,\n type NoAutoAttachDevTools,\n} from \"../runtime/removed-provider-props.js\";\n\ntype JazzClientContextValue = SolidJazzClient;\n\nexport const JazzClientContext = createContext<JazzClientContextValue | undefined>(undefined);\n\nexport type JazzClientProviderProps = NoAutoAttachDevTools & {\n client: PendingSolidJazzClient;\n fallback?: JSX.Element;\n children: JSX.Element;\n};\n\nexport function JazzClientProvider(props: JazzClientProviderProps) {\n refuseAutoAttachDevTools(\"JazzClientProvider\", props);\n const clientReady = () =>\n isPendingSolidJazzClientReady(props.client) ? props.client : undefined;\n\n return (\n <Show when={clientReady()} keyed fallback={props.fallback ?? null}>\n {(client) => (\n // Its children read this client, not an enclosing <JazzProvider>'s session.\n <SessionContext.Provider value={undefined}>\n <JazzClientContext.Provider value={client}>{props.children}</JazzClientContext.Provider>\n </SessionContext.Provider>\n )}\n </Show>\n );\n}\n\nexport function useJazzClient(): JazzClientContextValue {\n const ctx = useContext(JazzClientContext);\n if (!ctx) {\n throw new Error(\"useJazzClient must be used inside JazzProvider or JazzClientProvider.\");\n }\n return ctx;\n}\n\nexport function useDb<TDb = Db>(): Accessor<TDb> {\n const client = useJazzClient();\n return () => client.db as TDb;\n}\n\nexport function useAuthState() {\n const client = useJazzClient();\n return () => client.authState;\n}\n\nexport { JazzProvider, type JazzProviderProps } from \"./session.js\";\n"],"mappings":";;;;;;;AAeA,IAAaM,oBAAoBL,cAAkDM,KAAAA,CAAS;AAQ5F,SAAgBI,mBAAmBC,OAAgC;CACjEP,yBAAyB,sBAAsBO,KAAK;CACpD,MAAMC,oBACJT,8BAA8BQ,MAAMJ,MAAM,IAAII,MAAMJ,SAASD,KAAAA;CAE/D,OAAAO,gBACGX,MAAI;EAAA,IAACY,OAAI;GAAA,OAAEF,YAAY;EAAC;EAAEG,OAAK;EAAA,IAACP,WAAQ;GAAA,OAAEG,MAAMH,YAAY;EAAI;EAAAC,WAC7DF,WACAM,gBACCd,eAAeiB,UAAQ;GAACC,OAAOX,KAAAA;GAAS,IAAAG,WAAA;IAAA,OAAAI,gBACtCR,kBAAkBW,UAAQ;KAACC,OAAOV;KAAM,IAAAE,WAAA;MAAA,OAAGE,MAAMF;KAAQ;IAAA,CAAA;GAAA;EAAA,CAAA;CAE7D,CAAA;AAGP;AAEA,SAAgBS,gBAAwC;CACtD,MAAMC,MAAMlB,WAAWI,iBAAiB;CACxC,IAAI,CAACc,KACH,MAAM,IAAIC,MAAM,uEAAuE;CAEzF,OAAOD;AACT;AAEA,SAAgBE,QAAiC;CAC/C,MAAMd,SAASW,cAAc;CAC7B,aAAaX,OAAOe;AACtB;AAEA,SAAgBC,eAAe;CAC7B,MAAMhB,SAASW,cAAc;CAC7B,aAAaX,OAAOiB;AACtB"}
@@ -11,7 +11,7 @@ export interface JazzContext {
11
11
  }
12
12
  /**
13
13
  * Initialize the Jazz context for descendant Svelte components.
14
- * Called internally by {@link JazzSvelteProvider} and {@link JazzSvelteClientProvider}.
14
+ * Called internally by `JazzProvider` and `JazzSvelteClientProvider`.
15
15
  */
16
16
  export declare function initJazzContext(): JazzContext;
17
17
  /**
@@ -24,15 +24,4 @@ export declare function getOptionalJazzContext(): JazzContext | undefined;
24
24
  * Get a Jazz {@link Db} instance that can be used to read and write data.
25
25
  */
26
26
  export declare function getDb(): Db;
27
- /**
28
- * Subscribe to the current Jazz {@link Session}.
29
- * The returned handle's `.current` property always reflects the latest session,
30
- * updating automatically as the user logs in or out.
31
- *
32
- * @deprecated Use `getJazzSession()` and read `$session.user`: the same user,
33
- * with `user` as `accountId`. Warns once in development; removed in a later alpha.
34
- */
35
- export declare function getSession(): {
36
- readonly current: PublicSession | null;
37
- };
38
27
  //# sourceMappingURL=context.svelte.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"context.svelte.d.ts","sourceRoot":"","sources":["../../src/svelte/context.svelte.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAI3E,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,EAAE,GAAG,IAAI,CAAC;IACd,OAAO,EAAE,aAAa,GAAG,IAAI,CAAC;IAC9B,sEAAsE;IACtE,MAAM,EAAE,OAAO,CAAC;IAChB,mFAAmF;IACnF,iBAAiB,EAAE,iBAAiB,GAAG,IAAI,CAAC;CAC7C;AAED;;;GAGG;AACH,wBAAgB,eAAe,IAAI,WAAW,CAS7C;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,WAAW,CAQ5C;AAED,4EAA4E;AAC5E,wBAAgB,sBAAsB,IAAI,WAAW,GAAG,SAAS,CAEhE;AAED;;GAEG;AACH,wBAAgB,KAAK,IAAI,EAAE,CAM1B;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,IAAI;IAAE,QAAQ,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,CAAA;CAAE,CAQvE"}
1
+ {"version":3,"file":"context.svelte.d.ts","sourceRoot":"","sources":["../../src/svelte/context.svelte.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAI3E,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,EAAE,GAAG,IAAI,CAAC;IACd,OAAO,EAAE,aAAa,GAAG,IAAI,CAAC;IAC9B,sEAAsE;IACtE,MAAM,EAAE,OAAO,CAAC;IAChB,mFAAmF;IACnF,iBAAiB,EAAE,iBAAiB,GAAG,IAAI,CAAC;CAC7C;AAED;;;GAGG;AACH,wBAAgB,eAAe,IAAI,WAAW,CAS7C;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,WAAW,CAM5C;AAED,4EAA4E;AAC5E,wBAAgB,sBAAsB,IAAI,WAAW,GAAG,SAAS,CAEhE;AAED;;GAEG;AACH,wBAAgB,KAAK,IAAI,EAAE,CAM1B"}
@@ -1,9 +1,8 @@
1
1
  import { getContext, setContext } from "svelte";
2
- import { warnSessionHookDeprecated } from "../session/deprecated-session-hook.js";
3
2
  const JAZZ_CTX_KEY = Symbol("jazz");
4
3
  /**
5
4
  * Initialize the Jazz context for descendant Svelte components.
6
- * Called internally by {@link JazzSvelteProvider} and {@link JazzSvelteClientProvider}.
5
+ * Called internally by `JazzProvider` and `JazzSvelteClientProvider`.
7
6
  */
8
7
  export function initJazzContext() {
9
8
  const ctx = $state({
@@ -21,7 +20,7 @@ export function initJazzContext() {
21
20
  export function getJazzContext() {
22
21
  const ctx = getContext(JAZZ_CTX_KEY);
23
22
  if (!ctx) {
24
- throw new Error("getDb/getSession must be used within <JazzSvelteProvider> or <JazzSvelteClientProvider>");
23
+ throw new Error("getDb must be used within <JazzProvider> or <JazzSvelteClientProvider>");
25
24
  }
26
25
  return ctx;
27
26
  }
@@ -39,20 +38,3 @@ export function getDb() {
39
38
  }
40
39
  return ctx.db;
41
40
  }
42
- /**
43
- * Subscribe to the current Jazz {@link Session}.
44
- * The returned handle's `.current` property always reflects the latest session,
45
- * updating automatically as the user logs in or out.
46
- *
47
- * @deprecated Use `getJazzSession()` and read `$session.user`: the same user,
48
- * with `user` as `accountId`. Warns once in development; removed in a later alpha.
49
- */
50
- export function getSession() {
51
- warnSessionHookDeprecated("getSession()", "getJazzSession() ($session.user)");
52
- const ctx = getJazzContext();
53
- return {
54
- get current() {
55
- return ctx.session;
56
- },
57
- };
58
- }
@@ -1,7 +1,7 @@
1
1
  export { CoState, AccountCoState, InviteListener, SyncConnectionStatus } from "../classic-api.js";
2
2
  export { default as JazzSvelteClientProvider } from "./JazzSvelteClientProvider.svelte";
3
3
  export type { JazzClient } from "./create-jazz-client.js";
4
- export { getDb, getSession, getJazzContext, type JazzContext } from "./context.svelte.js";
4
+ export { getDb, getJazzContext, type JazzContext } from "./context.svelte.js";
5
5
  export { QuerySubscription, QuerySubscriptionOne } from "./query-subscription.svelte.js";
6
6
  export type { DurabilityTier, QueryOptions, RuntimeSourcesConfig } from "../runtime/index.js";
7
7
  export { generateAuthSecret } from "../runtime/auth-secret-store.js";
@@ -12,5 +12,4 @@ export { createJazzClient, startJazzClient, type JazzClientConfig, } from "../se
12
12
  export type { JazzSession, JazzSessionSnapshot, JazzSessionErrorViewProps, JazzSessionOperation, JazzUser, } from "../session/jazz-session.js";
13
13
  export { default as JazzProvider } from "./JazzProvider.svelte";
14
14
  export { sessionState, getJazzSession, type JazzSessionState } from "./session-state.js";
15
- export { AccountManager, BrowserAuthSecretStore, JazzSessionProvider, JazzSvelteProvider, LocalFirstAuth, accountState, createAccountManager, exportLocalFirstSecret, useJazzAuth, } from "../removed-api.js";
16
15
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/svelte/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,oBAAoB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AClG,OAAO,EAAE,OAAO,IAAI,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AACxF,YAAY,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AACzF,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC9F,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAErE,cAAc,wBAAwB,CAAC;AAEvC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAExE,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,KAAK,gBAAgB,GACtB,MAAM,mCAAmC,CAAC;AAC3C,YAAY,EACV,WAAW,EACX,mBAAmB,EACnB,yBAAyB,EACzB,oBAAoB,EACpB,QAAQ,GACT,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,KAAK,gBAAgB,EAAE,MAAM,oBAAoB,CAAC"}
@@ -1,6 +1,6 @@
1
1
  export { CoState, AccountCoState, InviteListener, SyncConnectionStatus } from "../classic-api.js";
2
2
  export { default as JazzSvelteClientProvider } from "./JazzSvelteClientProvider.svelte";
3
- export { getDb, getSession, getJazzContext } from "./context.svelte.js";
3
+ export { getDb, getJazzContext } from "./context.svelte.js";
4
4
  export { QuerySubscription, QuerySubscriptionOne } from "./query-subscription.svelte.js";
5
5
  export { generateAuthSecret } from "../runtime/auth-secret-store.js";
6
6
  export * from "../accounts/exports.js";
@@ -8,5 +8,3 @@ export { syncStatus } from "./sync-status.js";
8
8
  export { createJazzClient, startJazzClient, } from "../session/create-jazz-session.js";
9
9
  export { default as JazzProvider } from "./JazzProvider.svelte";
10
10
  export { sessionState, getJazzSession } from "./session-state.js";
11
- // Removed in alpha.61: stubs that throw, naming the replacement (one release).
12
- export { AccountManager, BrowserAuthSecretStore, JazzSessionProvider, JazzSvelteProvider, LocalFirstAuth, accountState, createAccountManager, exportLocalFirstSecret, useJazzAuth, } from "../removed-api.js";
@@ -77,5 +77,4 @@ export declare function prefetchThinQueries(thin: Db, next: Db): Promise<void>;
77
77
  export declare function handOffThinWrites(thin: Db, next: Db): Promise<void>;
78
78
  /** @internal Sign a local-first token in JS, byte-identical to the WASM runtime. */
79
79
  export declare function mintLocalFirstTokenInJs(secret: string, audience: string): string;
80
- export { AccountManager, createAccountManager } from "../removed-api.js";
81
80
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/thin/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAoC,KAAK,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEhG,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAI3C,OAAO,EAAe,KAAK,kBAAkB,EAAmB,MAAM,mBAAmB,CAAC;AAI1F,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EACL,6BAA6B,EAC7B,uBAAuB,EACvB,uBAAuB,EACvB,wBAAwB,EACxB,eAAe,EACf,KAAK,kBAAkB,GACxB,MAAM,mBAAmB,CAAC;AAG3B,cAAc,wBAAwB,CAAC;AACvC,YAAY,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAC3C,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAE5F,MAAM,MAAM,YAAY,GAAG,eAAe,GAAG;IAAE,IAAI,CAAC,EAAE,kBAAkB,CAAA;CAAE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B,CAAC;AAC3C,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAE5F,MAAM,MAAM,YAAY,GAAG,eAAe,GAAG;IAAE,IAAI,CAAC,EAAE,kBAAkB,CAAA;CAAE,CAAC;AAE3E;;;;GAIG;AACH,wBAAsB,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,EAAE,CAAC,CAQpE;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,EAAE,CAAC,CAyBxF;AAID;;;;;;;GAOG;AACH,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAoB3E;AA4BD;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAWzE;AAiDD,oFAAoF;AACpF,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAOhF"}
@@ -216,6 +216,4 @@ export function mintLocalFirstTokenInJs(secret, audience) {
216
216
  nowSeconds: BigInt(Math.floor(Date.now() / 1000)),
217
217
  });
218
218
  }
219
- // Removed in alpha.61: stubs that throw, naming the replacement (one release).
220
- export { AccountManager, createAccountManager } from "../removed-api.js";
221
219
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/thin/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,gCAAgC,EAAwB,MAAM,wBAAwB,CAAC;AAChG,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAE3E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AAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,KAAK,IAAI,IAAI,CAAC,CAAC,OAAO,YAAY,WAAW,CAAC,CAAC,EAAE,CAAC;QAC/E,MAAM,IAAI,KAAK,CAAC,2DAA2D,CAAC,CAAC;IAC/E,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,oFAAoF;AACpF,MAAM,UAAU,uBAAuB,CAAC,MAAc,EAAE,QAAgB;IACtE,OAAO,mBAAmB,CAAC,kBAAkB,EAAE;QAC7C,MAAM,EAAE,wBAAwB,CAAC,MAAM,CAAC;QACxC,QAAQ;QACR,UAAU,EAAE,IAAI;QAChB,UAAU,EAAE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;KAClD,CAAC,CAAC;AACL,CAAC;AAED,+EAA+E;AAC/E,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC","sourcesContent":["/**\n * `jazz-tools/thin`: a browser client with no local engine (SPEC 8.14).\n *\n * The server evaluates every query under the signed-in session and sends\n * finished results; writes run on the server. The `Db` it returns has the\n * same query and write API as the local-first client's `Db`, without\n * WASM, workers or local storage.\n *\n * Transactions, branch and snapshot views and large-value streaming run on\n * the server too. Not supported yet: offline use and attributed writes.\n * Upgrade to the local-first client for offline use.\n */\nimport { createAccountDbWithRuntimeSource, type AccountDbConfig } from \"../accounts/context.js\";\nimport { authSecretSeedForMinting } from \"../runtime/auth-secret-codec.js\";\nimport type { Db } from \"../runtime/db.js\";\nimport { isThinDb, markThinDb } from \"../runtime/local-first-upgrade.js\";\nimport { LOCAL_FIRST_ISSUER, mintSelfSignedToken } from \"./self-signed-token.js\";\nimport { ThinRuntimeSource } from \"./thin-runtime-source.js\";\nimport { ThinRuntime, type ThinRuntimeOptions, type WrittenRow } from \"./thin-runtime.js\";\nimport { translateQuery } from \"../runtime/query-adapter.js\";\nimport type { WasmSchema } from \"../drivers/types.js\";\n\nexport { ThinRuntimeSource } from \"./thin-runtime-source.js\";\nexport {\n ThinCommitOutcomeUnknownError,\n ThinConnectionLostError,\n ThinRequestNotSentError,\n ThinTransactionLostError,\n ThinRemoteError,\n type ThinRuntimeOptions,\n} from \"./thin-runtime.js\";\n// Accounts are the session's (`createJazzClient`): only its error and the\n// storage a host may supply are public, as on the package root.\nexport * from \"../accounts/exports.js\";\nexport type { Db } from \"../runtime/db.js\";\nexport type { LocalFirstLoader, LocalFirstModule } from \"../runtime/local-first-upgrade.js\";\n\nexport type ThinDbConfig = AccountDbConfig & { thin?: ThinRuntimeOptions };\n\n/**\n * @internal The session opens its thin `Db` with this (`createJazzClient`);\n * apps can't call it, since it takes the session's own account handle.\n * `serverUrl` is required.\n */\nexport async function createClient(config: ThinDbConfig): Promise<Db> {\n const { thin, ...dbConfig } = config;\n const db = await createAccountDbWithRuntimeSource(\n { ...dbConfig, driver: { type: \"memory\" } },\n new ThinRuntimeSource(thin),\n );\n markThinDb(db);\n return db;\n}\n\n/**\n * Move an app from a thin `Db` to a local-first one, once it has loaded the\n * full client. `open` creates the local-first `Db` for the same account, for\n * example after `await import(\"jazz-tools\")`. The queries the app is\n * subscribed to are read into the new `Db` from the server first, so its live\n * queries answer from local data straight away. Queries subscribed during\n * that read are read too, for up to 3 rounds; one subscribed later opens on\n * the new `Db` with what it has locally. The thin `Db` then refuses new work\n * and closes once its writes are answered, in the background: the returned\n * `Db` doesn't wait for them, so a server that is down doesn't hold the\n * upgrade (those writes stay in the thin client's memory until it is back,\n * and are lost if the page closes first). Shutting the returned `Db` down\n * (a sign-out) stops that wait and closes the thin runtime, dropping what it\n * still holds. A read the app made on the thin `Db` that never reached the\n * server ends with `ThinRequestNotSentError`: read again on the returned\n * `Db`. The app swaps the returned `Db` in where it held the thin one.\n *\n * This is for a thin `Db` the app opened itself with {@link createClient}.\n * Under a Jazz provider or `createJazzClient`, call the `Db` method\n * `db.upgradeToLocalFirst(loader)` instead: it takes the loader, and the\n * session upgrades in place, so the app keeps the same `Db`.\n */\nexport async function upgradeToLocalFirst(thin: Db, open: () => Promise<Db>): Promise<Db> {\n const runtime = thinRuntimeOf(thin);\n const next = await open();\n try {\n await prefetchThinQueries(thin, next);\n await handOffThinWrites(thin, next);\n } catch (error) {\n await next.shutdown();\n throw error;\n }\n // The thin Db's last writes upload in the background, then it closes: with\n // the server down, waiting for them would hold the upgrade until it is\n // back. Shutting `next` down ends the wait, and the thin runtime closes.\n runtime?.endUnsentReads();\n // A stream still sending its value finishes first, unless `next` shuts down.\n const streams = thin.letStreamsFinish();\n next.onShutdown(() => {\n streams.abort();\n thin.abortGracefulShutdown();\n });\n void thin\n .shutdown({ waitForSync: true })\n .catch(() => thin.shutdown())\n .catch(() => {});\n return next;\n}\n\nconst PREFETCH_ROUNDS = 3;\n\n/**\n * @internal Read every query `thin` is subscribed to into `next` from the\n * server, until the thin link reports offline or a read fails. The\n * prefetch only spares the app's live queries a moment without rows: with\n * no server to read from (a first visit offline, an outage) it must not\n * hold the upgrade, or a guest's writes would stay in the thin client's\n * memory, never stored, until the server is back.\n */\nexport async function prefetchThinQueries(thin: Db, next: Db): Promise<void> {\n const runtime = thinRuntimeOf(thin);\n if (!runtime) return;\n const ended = { done: false };\n // Still connecting: wait to learn whether the server answers (an outage\n // reports as offline after a few seconds).\n let stop!: () => void;\n const offline = new Promise<void>((resolve) => {\n stop = thin.onSyncStatusChange(({ link }) => {\n if (link.state === \"offline\") resolve();\n });\n });\n try {\n if (thin.getSyncStatus().link.state === \"offline\") return;\n // A read that fails (the server went away) just ends the prefetch.\n await Promise.race([prefetchRounds(runtime, next, ended).catch(() => {}), offline]);\n } finally {\n ended.done = true;\n stop();\n }\n}\n\n/**\n * The prefetch's rounds, until `ended`. A read already sent when the\n * prefetch ends may still land in `next` later: rows from the server, as its\n * own sync would bring them, so that is harmless.\n */\nasync function prefetchRounds(\n runtime: ThinRuntime,\n next: Db,\n ended: { done: boolean },\n): Promise<void> {\n // Queries the app subscribes to while one round reads are read in the\n // next, so each live query opens on the local-first Db with its rows.\n // A few rounds: a component that keeps subscribing with new queries\n // must not hold the upgrade.\n const read = new Set<string>();\n for (let round = 0; round < PREFETCH_ROUNDS && !ended.done; round++) {\n const pending = runtime.liveQueryJsons().filter((query) => !read.has(query));\n if (pending.length === 0) return;\n await next.prefetchRuntimeQueries(runtime.schema, pending);\n for (const query of pending) read.add(query);\n }\n}\n\n/** How long one hand-off read may wait for the server. */\nconst HAND_OFF_READ_MS = 5_000;\n\n/**\n * @internal The rows `thin` wrote reach `next` too, so a local-first read\n * there shows them: those the server already confirmed now, later ones as\n * the server confirms them. Each read is best-effort, like the prefetch: it\n * ends when either link reports offline or after {@link HAND_OFF_READ_MS},\n * so neither the upgrade nor a write's wait hangs on a server that doesn't\n * answer; the rows then arrive with `next`'s own sync. It never throws.\n *\n * Not handed off, also left to sync: a delete (a read of a deleted row\n * brings nothing back, and only a local store that already held the row,\n * another tab's, can show it), a write that ended with its fate unknown (a\n * `ThinConnectionLostError`: it may have committed, but the server never\n * confirmed it, so a local-first read shows it only once `next` syncs it),\n * and writes older than the last 1,024 the thin runtime keeps.\n */\nexport async function handOffThinWrites(thin: Db, next: Db): Promise<void> {\n const runtime = thinRuntimeOf(thin);\n if (!runtime) return;\n const read = (rows: readonly WrittenRow[]) =>\n readWhileOnline([thin, next], () =>\n next.prefetchRuntimeQueries(runtime.schema, rowQueries(runtime.schema, rows)),\n );\n const committed = runtime.handOffWrittenRows(read);\n // A failed or superseded upgrade shuts `next` down: nothing to hand to.\n next.onShutdown(() => runtime.stopHandingOffWrittenRows(read));\n if (committed.length > 0) await read(committed);\n}\n\n/** Run `read` until it settles, one of `dbs` reports offline, or the time is up. */\nasync function readWhileOnline(dbs: readonly Db[], read: () => Promise<void>): Promise<void> {\n if (dbs.some((db) => db.getSyncStatus().link.state === \"offline\")) return;\n const stops: (() => void)[] = [];\n let timer: ReturnType<typeof setTimeout> | undefined;\n const ended = new Promise<void>((resolve) => {\n for (const db of dbs)\n stops.push(\n db.onSyncStatusChange(({ link }) => {\n if (link.state === \"offline\") resolve();\n }),\n );\n timer = setTimeout(resolve, HAND_OFF_READ_MS);\n });\n try {\n await Promise.race([read().catch(() => {}), ended]);\n } finally {\n clearTimeout(timer);\n for (const stop of stops) stop();\n }\n}\n\n/** One runtime query per table, for the rows of it in `rows`. */\nfunction rowQueries(schema: WasmSchema, rows: readonly WrittenRow[]): string[] {\n const ids = new Map<string, Set<string>>();\n for (const { table, id } of rows) {\n if (!schema[table]) continue;\n let set = ids.get(table);\n if (!set) ids.set(table, (set = new Set()));\n set.add(id);\n }\n return [...ids].map(([table, set]) =>\n translateQuery(\n JSON.stringify({ table, conditions: [{ column: \"id\", op: \"in\", value: [...set] }] }),\n schema,\n ),\n );\n}\n\nfunction thinRuntimeOf(thin: Db): ThinRuntime | null {\n const runtime = thin.currentRuntime();\n if (!isThinDb(thin) || (runtime !== null && !(runtime instanceof ThinRuntime))) {\n throw new Error(\"upgradeToLocalFirst takes a Db created by jazz-tools/thin\");\n }\n return runtime;\n}\n\n/** @internal Sign a local-first token in JS, byte-identical to the WASM runtime. */\nexport function mintLocalFirstTokenInJs(secret: string, audience: string): string {\n return mintSelfSignedToken(LOCAL_FIRST_ISSUER, {\n secret: authSecretSeedForMinting(secret),\n audience,\n ttlSeconds: 3600,\n nowSeconds: BigInt(Math.floor(Date.now() / 1000)),\n });\n}\n\n// Removed in alpha.61: stubs that throw, naming the replacement (one release).\nexport { AccountManager, createAccountManager } from \"../removed-api.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/thin/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,gCAAgC,EAAwB,MAAM,wBAAwB,CAAC;AAChG,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAE3E,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EA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AAC,OAAO,YAAY,WAAW,CAAC,CAAC,EAAE,CAAC;QAC/E,MAAM,IAAI,KAAK,CAAC,2DAA2D,CAAC,CAAC;IAC/E,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,oFAAoF;AACpF,MAAM,UAAU,uBAAuB,CAAC,MAAc,EAAE,QAAgB;IACtE,OAAO,mBAAmB,CAAC,kBAAkB,EAAE;QAC7C,MAAM,EAAE,wBAAwB,CAAC,MAAM,CAAC;QACxC,QAAQ;QACR,UAAU,EAAE,IAAI;QAChB,UAAU,EAAE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;KAClD,CAAC,CAAC;AACL,CAAC","sourcesContent":["/**\n * `jazz-tools/thin`: a browser client with no local engine (SPEC 8.14).\n *\n * The server evaluates every query under the signed-in session and sends\n * finished results; writes run on the server. The `Db` it returns has the\n * same query and write API as the local-first client's `Db`, without\n * WASM, workers or local storage.\n *\n * Transactions, branch and snapshot views and large-value streaming run on\n * the server too. Not supported yet: offline use and attributed writes.\n * Upgrade to the local-first client for offline use.\n */\nimport { createAccountDbWithRuntimeSource, type AccountDbConfig } from \"../accounts/context.js\";\nimport { authSecretSeedForMinting } from \"../runtime/auth-secret-codec.js\";\nimport type { Db } from \"../runtime/db.js\";\nimport { isThinDb, markThinDb } from \"../runtime/local-first-upgrade.js\";\nimport { LOCAL_FIRST_ISSUER, mintSelfSignedToken } from \"./self-signed-token.js\";\nimport { ThinRuntimeSource } from \"./thin-runtime-source.js\";\nimport { ThinRuntime, type ThinRuntimeOptions, type WrittenRow } from \"./thin-runtime.js\";\nimport { translateQuery } from \"../runtime/query-adapter.js\";\nimport type { WasmSchema } from \"../drivers/types.js\";\n\nexport { ThinRuntimeSource } from \"./thin-runtime-source.js\";\nexport {\n ThinCommitOutcomeUnknownError,\n ThinConnectionLostError,\n ThinRequestNotSentError,\n ThinTransactionLostError,\n ThinRemoteError,\n type ThinRuntimeOptions,\n} from \"./thin-runtime.js\";\n// Accounts are the session's (`createJazzClient`): only its error and the\n// storage a host may supply are public, as on the package root.\nexport * from \"../accounts/exports.js\";\nexport type { Db } from \"../runtime/db.js\";\nexport type { LocalFirstLoader, LocalFirstModule } from \"../runtime/local-first-upgrade.js\";\n\nexport type ThinDbConfig = AccountDbConfig & { thin?: ThinRuntimeOptions };\n\n/**\n * @internal The session opens its thin `Db` with this (`createJazzClient`);\n * apps can't call it, since it takes the session's own account handle.\n * `serverUrl` is required.\n */\nexport async function createClient(config: ThinDbConfig): Promise<Db> {\n const { thin, ...dbConfig } = config;\n const db = await createAccountDbWithRuntimeSource(\n { ...dbConfig, driver: { type: \"memory\" } },\n new ThinRuntimeSource(thin),\n );\n markThinDb(db);\n return db;\n}\n\n/**\n * Move an app from a thin `Db` to a local-first one, once it has loaded the\n * full client. `open` creates the local-first `Db` for the same account, for\n * example after `await import(\"jazz-tools\")`. The queries the app is\n * subscribed to are read into the new `Db` from the server first, so its live\n * queries answer from local data straight away. Queries subscribed during\n * that read are read too, for up to 3 rounds; one subscribed later opens on\n * the new `Db` with what it has locally. The thin `Db` then refuses new work\n * and closes once its writes are answered, in the background: the returned\n * `Db` doesn't wait for them, so a server that is down doesn't hold the\n * upgrade (those writes stay in the thin client's memory until it is back,\n * and are lost if the page closes first). Shutting the returned `Db` down\n * (a sign-out) stops that wait and closes the thin runtime, dropping what it\n * still holds. A read the app made on the thin `Db` that never reached the\n * server ends with `ThinRequestNotSentError`: read again on the returned\n * `Db`. The app swaps the returned `Db` in where it held the thin one.\n *\n * This is for a thin `Db` the app opened itself with {@link createClient}.\n * Under a Jazz provider or `createJazzClient`, call the `Db` method\n * `db.upgradeToLocalFirst(loader)` instead: it takes the loader, and the\n * session upgrades in place, so the app keeps the same `Db`.\n */\nexport async function upgradeToLocalFirst(thin: Db, open: () => Promise<Db>): Promise<Db> {\n const runtime = thinRuntimeOf(thin);\n const next = await open();\n try {\n await prefetchThinQueries(thin, next);\n await handOffThinWrites(thin, next);\n } catch (error) {\n await next.shutdown();\n throw error;\n }\n // The thin Db's last writes upload in the background, then it closes: with\n // the server down, waiting for them would hold the upgrade until it is\n // back. Shutting `next` down ends the wait, and the thin runtime closes.\n runtime?.endUnsentReads();\n // A stream still sending its value finishes first, unless `next` shuts down.\n const streams = thin.letStreamsFinish();\n next.onShutdown(() => {\n streams.abort();\n thin.abortGracefulShutdown();\n });\n void thin\n .shutdown({ waitForSync: true })\n .catch(() => thin.shutdown())\n .catch(() => {});\n return next;\n}\n\nconst PREFETCH_ROUNDS = 3;\n\n/**\n * @internal Read every query `thin` is subscribed to into `next` from the\n * server, until the thin link reports offline or a read fails. The\n * prefetch only spares the app's live queries a moment without rows: with\n * no server to read from (a first visit offline, an outage) it must not\n * hold the upgrade, or a guest's writes would stay in the thin client's\n * memory, never stored, until the server is back.\n */\nexport async function prefetchThinQueries(thin: Db, next: Db): Promise<void> {\n const runtime = thinRuntimeOf(thin);\n if (!runtime) return;\n const ended = { done: false };\n // Still connecting: wait to learn whether the server answers (an outage\n // reports as offline after a few seconds).\n let stop!: () => void;\n const offline = new Promise<void>((resolve) => {\n stop = thin.onSyncStatusChange(({ link }) => {\n if (link.state === \"offline\") resolve();\n });\n });\n try {\n if (thin.getSyncStatus().link.state === \"offline\") return;\n // A read that fails (the server went away) just ends the prefetch.\n await Promise.race([prefetchRounds(runtime, next, ended).catch(() => {}), offline]);\n } finally {\n ended.done = true;\n stop();\n }\n}\n\n/**\n * The prefetch's rounds, until `ended`. A read already sent when the\n * prefetch ends may still land in `next` later: rows from the server, as its\n * own sync would bring them, so that is harmless.\n */\nasync function prefetchRounds(\n runtime: ThinRuntime,\n next: Db,\n ended: { done: boolean },\n): Promise<void> {\n // Queries the app subscribes to while one round reads are read in the\n // next, so each live query opens on the local-first Db with its rows.\n // A few rounds: a component that keeps subscribing with new queries\n // must not hold the upgrade.\n const read = new Set<string>();\n for (let round = 0; round < PREFETCH_ROUNDS && !ended.done; round++) {\n const pending = runtime.liveQueryJsons().filter((query) => !read.has(query));\n if (pending.length === 0) return;\n await next.prefetchRuntimeQueries(runtime.schema, pending);\n for (const query of pending) read.add(query);\n }\n}\n\n/** How long one hand-off read may wait for the server. */\nconst HAND_OFF_READ_MS = 5_000;\n\n/**\n * @internal The rows `thin` wrote reach `next` too, so a local-first read\n * there shows them: those the server already confirmed now, later ones as\n * the server confirms them. Each read is best-effort, like the prefetch: it\n * ends when either link reports offline or after {@link HAND_OFF_READ_MS},\n * so neither the upgrade nor a write's wait hangs on a server that doesn't\n * answer; the rows then arrive with `next`'s own sync. It never throws.\n *\n * Not handed off, also left to sync: a delete (a read of a deleted row\n * brings nothing back, and only a local store that already held the row,\n * another tab's, can show it), a write that ended with its fate unknown (a\n * `ThinConnectionLostError`: it may have committed, but the server never\n * confirmed it, so a local-first read shows it only once `next` syncs it),\n * and writes older than the last 1,024 the thin runtime keeps.\n */\nexport async function handOffThinWrites(thin: Db, next: Db): Promise<void> {\n const runtime = thinRuntimeOf(thin);\n if (!runtime) return;\n const read = (rows: readonly WrittenRow[]) =>\n readWhileOnline([thin, next], () =>\n next.prefetchRuntimeQueries(runtime.schema, rowQueries(runtime.schema, rows)),\n );\n const committed = runtime.handOffWrittenRows(read);\n // A failed or superseded upgrade shuts `next` down: nothing to hand to.\n next.onShutdown(() => runtime.stopHandingOffWrittenRows(read));\n if (committed.length > 0) await read(committed);\n}\n\n/** Run `read` until it settles, one of `dbs` reports offline, or the time is up. */\nasync function readWhileOnline(dbs: readonly Db[], read: () => Promise<void>): Promise<void> {\n if (dbs.some((db) => db.getSyncStatus().link.state === \"offline\")) return;\n const stops: (() => void)[] = [];\n let timer: ReturnType<typeof setTimeout> | undefined;\n const ended = new Promise<void>((resolve) => {\n for (const db of dbs)\n stops.push(\n db.onSyncStatusChange(({ link }) => {\n if (link.state === \"offline\") resolve();\n }),\n );\n timer = setTimeout(resolve, HAND_OFF_READ_MS);\n });\n try {\n await Promise.race([read().catch(() => {}), ended]);\n } finally {\n clearTimeout(timer);\n for (const stop of stops) stop();\n }\n}\n\n/** One runtime query per table, for the rows of it in `rows`. */\nfunction rowQueries(schema: WasmSchema, rows: readonly WrittenRow[]): string[] {\n const ids = new Map<string, Set<string>>();\n for (const { table, id } of rows) {\n if (!schema[table]) continue;\n let set = ids.get(table);\n if (!set) ids.set(table, (set = new Set()));\n set.add(id);\n }\n return [...ids].map(([table, set]) =>\n translateQuery(\n JSON.stringify({ table, conditions: [{ column: \"id\", op: \"in\", value: [...set] }] }),\n schema,\n ),\n );\n}\n\nfunction thinRuntimeOf(thin: Db): ThinRuntime | null {\n const runtime = thin.currentRuntime();\n if (!isThinDb(thin) || (runtime !== null && !(runtime instanceof ThinRuntime))) {\n throw new Error(\"upgradeToLocalFirst takes a Db created by jazz-tools/thin\");\n }\n return runtime;\n}\n\n/** @internal Sign a local-first token in JS, byte-identical to the WASM runtime. */\nexport function mintLocalFirstTokenInJs(secret: string, audience: string): string {\n return mintSelfSignedToken(LOCAL_FIRST_ISSUER, {\n secret: authSecretSeedForMinting(secret),\n audience,\n ttlSeconds: 3600,\n nowSeconds: BigInt(Math.floor(Date.now() / 1000)),\n });\n}\n"]}
@@ -566,7 +566,7 @@ export type ComputedImpl<TTypes extends SchemaLike> = {
566
566
  * Null passes through: Jazz never calls a transform with null, so a null
567
567
  * branch is never reached. Either may still return null, so an alpha.64
568
568
  * transform on an optional column, which handled null itself and which
569
- * `jazz-tools upgrade` moves here unchanged, keeps typechecking.
569
+ * alpha.66's `jazz-tools upgrade` moved here unchanged, keeps typechecking.
570
570
  */
571
571
  /**
572
572
  * Whether every column stored through the transform `TName` is nullable: only