jazz-vue 0.8.11 → 0.8.12

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # jazz-react
2
2
 
3
+ ## 0.8.12
4
+
5
+ ### Patch Changes
6
+
7
+ - a734530: fix useCoState reactivity
8
+ - Updated dependencies [f6bc8af]
9
+ - jazz-browser@0.8.22
10
+
3
11
  ## 0.8.11
4
12
 
5
13
  ### Patch Changes
@@ -1,5 +1,5 @@
1
1
  import { Account, AnonymousJazzAgent, CoValue, CoValueClass, DeeplyLoaded, DepthsIn, ID } from 'jazz-tools';
2
- import { Component, ComputedRef, Ref } from 'vue';
2
+ import { Component, ComputedRef, MaybeRef, Ref } from 'vue';
3
3
  export declare const logoutHandler: Ref<(() => void) | undefined, (() => void) | undefined>;
4
4
  export interface JazzVueApp<Acc extends Account> {
5
5
  JazzProvider: Component;
@@ -17,7 +17,7 @@ export interface JazzVueApp<Acc extends Account> {
17
17
  useAccountOrGuest<D extends DepthsIn<Acc>>(depth: D): {
18
18
  me: ComputedRef<DeeplyLoaded<Acc, D> | undefined | AnonymousJazzAgent>;
19
19
  };
20
- useCoState<V extends CoValue, D>(Schema: CoValueClass<V>, id: ID<V> | undefined, depth?: D & DepthsIn<V>): Ref<DeeplyLoaded<V, D> | undefined>;
20
+ useCoState<V extends CoValue, D>(Schema: CoValueClass<V>, id: MaybeRef<ID<V> | undefined>, depth?: D & DepthsIn<V>): Ref<DeeplyLoaded<V, D> | undefined>;
21
21
  useAcceptInvite<V extends CoValue>(args: {
22
22
  invitedObjectSchema: CoValueClass<V>;
23
23
  onAccept: (projectID: ID<V>) => void;
package/dist/index.js CHANGED
@@ -1,11 +1,11 @@
1
- import { createJazzBrowserContext as D, consumeInviteLinkFromWindowLocation as _, BrowserDemoAuth as B } from "jazz-browser";
2
- import { Account as j, subscribeToCoValue as T } from "jazz-tools";
3
- import { ref as y, defineComponent as R, provide as V, onMounted as P, watch as A, onUnmounted as I, computed as v, toRaw as b, shallowRef as M, inject as N, reactive as $, openBlock as g, createElementBlock as f, normalizeStyle as w, Fragment as k, createElementVNode as x, toDisplayString as C, renderList as E, withModifiers as F, withDirectives as G, vModelText as W, createCommentVNode as L, toRef as q, renderSlot as H, unref as J } from "vue";
4
- const S = y(), O = Symbol("JazzContext");
1
+ import { createJazzBrowserContext as D, consumeInviteLinkFromWindowLocation as M, BrowserDemoAuth as _ } from "jazz-browser";
2
+ import { Account as B, subscribeToCoValue as V } from "jazz-tools";
3
+ import { ref as z, defineComponent as R, provide as j, onMounted as P, watch as I, onUnmounted as k, computed as v, toRaw as w, shallowRef as T, unref as S, inject as N, reactive as $, openBlock as g, createElementBlock as f, normalizeStyle as y, Fragment as C, createElementVNode as x, toDisplayString as J, renderList as E, withModifiers as F, withDirectives as G, vModelText as W, createCommentVNode as L, toRef as q, renderSlot as H } from "vue";
4
+ const A = z(), O = Symbol("JazzContext");
5
5
  function te({
6
- AccountSchema: p = j
6
+ AccountSchema: p = B
7
7
  } = {}) {
8
- const i = R({
8
+ const u = R({
9
9
  name: "JazzProvider",
10
10
  props: {
11
11
  auth: {
@@ -21,28 +21,28 @@ function te({
21
21
  default: void 0
22
22
  }
23
23
  },
24
- setup(r, { slots: o }) {
25
- const t = y(
24
+ setup(t, { slots: o }) {
25
+ const r = z(
26
26
  void 0
27
- ), n = y(0);
28
- V(O, t);
29
- const s = async () => {
30
- var e, u;
31
- t.value && ((u = (e = t.value).done) == null || u.call(e), t.value = void 0);
27
+ ), a = z(0);
28
+ j(O, r);
29
+ const n = async () => {
30
+ var e, s;
31
+ r.value && ((s = (e = r.value).done) == null || s.call(e), r.value = void 0);
32
32
  try {
33
33
  const m = await D(
34
- r.auth === "guest" ? { peer: r.peer, storage: r.storage } : {
34
+ t.auth === "guest" ? { peer: t.peer, storage: t.storage } : {
35
35
  AccountSchema: p,
36
- auth: r.auth,
37
- peer: r.peer,
38
- storage: r.storage
36
+ auth: t.auth,
37
+ peer: t.peer,
38
+ storage: t.storage
39
39
  }
40
40
  );
41
- t.value = {
41
+ r.value = {
42
42
  ...m,
43
43
  logOut: () => {
44
- var z;
45
- (z = S.value) == null || z.call(S), n.value += 1;
44
+ var b;
45
+ (b = A.value) == null || b.call(A), a.value += 1;
46
46
  }
47
47
  };
48
48
  } catch (m) {
@@ -50,28 +50,29 @@ function te({
50
50
  }
51
51
  };
52
52
  return P(() => {
53
- s();
54
- }), A(
55
- () => n.value,
53
+ n();
54
+ }), I(
55
+ () => a.value,
56
56
  async () => {
57
- await s();
57
+ await n();
58
58
  }
59
- ), I(() => {
60
- var e, u;
61
- t.value && ((u = (e = t.value).done) == null || u.call(e));
59
+ ), k(() => {
60
+ var e, s;
61
+ r.value && ((s = (e = r.value).done) == null || s.call(e));
62
62
  }), () => {
63
63
  var e;
64
- return t.value ? (e = o.default) == null ? void 0 : e.call(o) : null;
64
+ return r.value ? (e = o.default) == null ? void 0 : e.call(o) : null;
65
65
  };
66
66
  }
67
67
  });
68
68
  function l() {
69
- const r = N(O);
70
- if (!r)
69
+ const t = N(O);
70
+ if (!t)
71
71
  throw new Error("useJazzContext must be used within a JazzProvider");
72
- return r;
72
+ return t;
73
73
  }
74
- function a(r) {
74
+ function i(t) {
75
+ var n, e;
75
76
  const o = l();
76
77
  if (!o.value)
77
78
  throw new Error("useAccount must be used within a JazzProvider");
@@ -79,136 +80,143 @@ function te({
79
80
  throw new Error(
80
81
  "useAccount can't be used in a JazzProvider with auth === 'guest' - consider using useAccountOrGuest()"
81
82
  );
82
- const t = d(
83
- o.value.me.constructor,
84
- o.value.me.id,
85
- r
83
+ const r = v(
84
+ () => "me" in o.value ? o.value.me : void 0
85
+ ), a = d(
86
+ (n = r.value) == null ? void 0 : n.constructor,
87
+ (e = r.value) == null ? void 0 : e.id,
88
+ t
86
89
  );
87
90
  return {
88
91
  me: v(() => {
89
- const n = r === void 0 ? t.value || b(o.value.me) : t.value;
90
- return n && b(n);
92
+ const s = t === void 0 ? a.value || w(o.value.me) : a.value;
93
+ return s && w(s);
91
94
  }),
92
95
  logOut: o.value.logOut
93
96
  };
94
97
  }
95
- function c(r) {
98
+ function c(t) {
99
+ var n, e;
96
100
  const o = l();
97
101
  if (!o.value)
98
102
  throw new Error("useAccountOrGuest must be used within a JazzProvider");
99
- const t = "me" in o.value ? o.value.me : void 0, n = d(
100
- t == null ? void 0 : t.constructor,
101
- t == null ? void 0 : t.id,
102
- r
103
+ const r = v(
104
+ () => "me" in o.value ? o.value.me : void 0
105
+ ), a = d(
106
+ (n = r.value) == null ? void 0 : n.constructor,
107
+ (e = r.value) == null ? void 0 : e.id,
108
+ t
103
109
  );
104
110
  return "me" in o.value ? {
105
111
  me: v(
106
- () => r === void 0 ? n.value || b(o.value.me) : n.value
112
+ () => t === void 0 ? a.value || w(o.value.me) : a.value
107
113
  )
108
114
  } : {
109
- me: v(() => b(o.value.guest))
115
+ me: v(() => w(o.value.guest))
110
116
  };
111
117
  }
112
- function d(r, o, t = []) {
113
- const n = M(void 0), s = l();
114
- if (!s.value)
118
+ function d(t, o, r = []) {
119
+ const a = T(void 0), n = l();
120
+ if (!n.value)
115
121
  throw new Error("useCoState must be used within a JazzProvider");
116
122
  let e;
117
- return A(
118
- [() => o, () => s, () => r, () => t],
123
+ return I(
124
+ [() => S(o), () => n, () => t, () => r],
119
125
  () => {
120
- e && e(), o && (e = T(
121
- r,
122
- o,
123
- "me" in s.value ? b(s.value.me) : b(s.value.guest),
126
+ e && e();
127
+ const m = S(o);
128
+ m && (e = V(
124
129
  t,
125
- (m) => {
126
- n.value = m;
130
+ m,
131
+ "me" in n.value ? w(n.value.me) : w(n.value.guest),
132
+ r,
133
+ (b) => {
134
+ a.value = b;
127
135
  }
128
136
  ));
129
137
  },
130
- { immediate: !0 }
131
- ), I(() => {
138
+ { deep: !0, immediate: !0 }
139
+ ), k(() => {
132
140
  e && e();
133
- }), v(() => n.value);
141
+ }), v(() => a.value);
134
142
  }
135
143
  function h({
136
- invitedObjectSchema: r,
144
+ invitedObjectSchema: t,
137
145
  onAccept: o,
138
- forValueHint: t
146
+ forValueHint: r
139
147
  }) {
140
- const n = l();
141
- if (!n.value)
148
+ const a = l();
149
+ if (!a.value)
142
150
  throw new Error("useAcceptInvite must be used within a JazzProvider");
143
- if (!("me" in n.value))
151
+ if (!("me" in a.value))
144
152
  throw new Error(
145
153
  "useAcceptInvite can't be used in a JazzProvider with auth === 'guest'."
146
154
  );
147
- const s = () => {
148
- _({
149
- as: b(n.value.me),
150
- invitedObjectSchema: r,
151
- forValueHint: t
152
- }).then((u) => u && o(u.valueID)).catch((u) => {
153
- console.error("Failed to accept invite", u);
155
+ const n = () => {
156
+ M({
157
+ as: w(a.value.me),
158
+ invitedObjectSchema: t,
159
+ forValueHint: r
160
+ }).then((s) => s && o(s.valueID)).catch((s) => {
161
+ console.error("Failed to accept invite", s);
154
162
  });
155
163
  };
156
164
  P(() => {
157
- s();
158
- }), A(
165
+ n();
166
+ }), I(
159
167
  () => o,
160
- (e, u) => {
161
- e !== u && s();
168
+ (e, s) => {
169
+ e !== s && n();
162
170
  }
163
171
  );
164
172
  }
165
173
  return {
166
- JazzProvider: i,
167
- useAccount: a,
174
+ JazzProvider: u,
175
+ useAccount: i,
168
176
  useAccountOrGuest: c,
169
177
  useCoState: d,
170
178
  useAcceptInvite: h
171
179
  };
172
180
  }
173
- function re({
181
+ function oe({
174
182
  seedAccounts: p
175
183
  } = {}) {
176
- const i = $({
184
+ const u = $({
177
185
  state: "loading",
178
186
  errors: []
179
- }), l = y(
180
- new B(
187
+ }), l = z(
188
+ new _(
181
189
  {
182
- onReady: ({ signUp: a, existingUsers: c, logInAs: d }) => {
183
- i.state = "ready", i.signUp = a, i.existingUsers = c, i.logInAs = d, i.errors = [];
190
+ onReady: ({ signUp: i, existingUsers: c, logInAs: d }) => {
191
+ u.state = "ready", u.signUp = i, u.existingUsers = c, u.logInAs = d, u.errors = [];
184
192
  },
185
- onSignedIn: ({ logOut: a }) => {
186
- i.state = "signedIn", i.logOut = () => {
187
- a(), i.state = "ready", i.errors = [];
188
- }, i.errors = [], S.value = i.logOut;
193
+ onSignedIn: ({ logOut: i }) => {
194
+ u.state = "signedIn", u.logOut = () => {
195
+ i(), u.state = "ready", u.errors = [];
196
+ }, u.errors = [], A.value = u.logOut;
189
197
  },
190
- onError: (a) => {
191
- i.errors.push(a.toString());
198
+ onError: (i) => {
199
+ u.errors.push(i.toString());
192
200
  }
193
201
  },
194
202
  p
195
203
  )
196
204
  );
197
- return I(() => {
198
- i.state === "signedIn" && (S.value = void 0);
199
- }), { authMethod: l, state: i };
205
+ return k(() => {
206
+ u.state === "signedIn" && (A.value = void 0);
207
+ }), { authMethod: l, state: u };
200
208
  }
201
209
  const K = { key: 0 }, Q = {
202
210
  key: 0,
203
211
  style: { display: "flex", "flex-direction": "column", gap: "0.5rem" }
204
- }, X = ["onClick", "aria-label"], oe = /* @__PURE__ */ R({
212
+ }, X = ["onClick", "aria-label"], re = /* @__PURE__ */ R({
205
213
  __name: "DemoAuthBasicUI",
206
214
  props: {
207
215
  appName: {},
208
216
  state: {}
209
217
  },
210
218
  setup(p) {
211
- const i = p, l = y(""), a = v(
219
+ const u = p, l = z(""), i = v(
212
220
  () => window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches
213
221
  ), c = v(() => ({
214
222
  minHeight: "100vh",
@@ -221,77 +229,77 @@ const K = { key: 0 }, Q = {
221
229
  maxWidth: "100vw",
222
230
  gap: "2rem",
223
231
  margin: "0",
224
- ...a.value ? { background: "#000" } : {}
232
+ ...i.value ? { background: "#000" } : {}
225
233
  })), d = v(() => ({
226
- border: a.value ? "2px solid #444" : "2px solid #ddd",
234
+ border: i.value ? "2px solid #444" : "2px solid #ddd",
227
235
  padding: "11px 8px",
228
236
  borderRadius: "6px",
229
- background: a.value ? "#000" : "#fff",
230
- color: a.value ? "#fff" : "#000"
237
+ background: i.value ? "#000" : "#fff",
238
+ color: i.value ? "#fff" : "#000"
231
239
  })), h = v(() => ({
232
240
  padding: "13px 5px",
233
241
  border: "none",
234
242
  borderRadius: "6px",
235
243
  cursor: "pointer",
236
- background: a.value ? "#444" : "#ddd",
237
- color: a.value ? "#fff" : "#000"
238
- })), r = v(() => ({
239
- background: a.value ? "#0d0d0d" : "#eee",
240
- color: a.value ? "#fff" : "#000",
244
+ background: i.value ? "#444" : "#ddd",
245
+ color: i.value ? "#fff" : "#000"
246
+ })), t = v(() => ({
247
+ background: i.value ? "#0d0d0d" : "#eee",
248
+ color: i.value ? "#fff" : "#000",
241
249
  padding: "0.5rem",
242
250
  border: "none",
243
251
  borderRadius: "6px"
244
252
  })), o = () => {
245
- i.state.signUp(l.value), l.value = "";
246
- }, t = (n) => {
247
- i.state.logInAs(n);
253
+ u.state.signUp(l.value), l.value = "";
254
+ }, r = (a) => {
255
+ u.state.logInAs(a);
248
256
  };
249
- return (n, s) => (g(), f("div", {
250
- style: w(c.value)
257
+ return (a, n) => (g(), f("div", {
258
+ style: y(c.value)
251
259
  }, [
252
- n.state.state === "loading" ? (g(), f("div", K, "Loading...")) : n.state.state === "ready" ? (g(), f(k, { key: 1 }, [
260
+ a.state.state === "loading" ? (g(), f("div", K, "Loading...")) : a.state.state === "ready" ? (g(), f(C, { key: 1 }, [
253
261
  x("h1", {
254
- style: w({ color: a.value ? "#fff" : "#000", textAlign: "center" })
255
- }, C(n.appName), 5),
256
- (g(!0), f(k, null, E(n.state.errors, (e) => (g(), f("div", {
262
+ style: y({ color: i.value ? "#fff" : "#000", textAlign: "center" })
263
+ }, J(a.appName), 5),
264
+ (g(!0), f(C, null, E(a.state.errors, (e) => (g(), f("div", {
257
265
  key: e,
258
266
  style: { color: "red" }
259
- }, C(e), 1))), 128)),
267
+ }, J(e), 1))), 128)),
260
268
  x("form", {
261
269
  onSubmit: F(o, ["prevent"]),
262
270
  style: { display: "flex", "flex-direction": "column", gap: "0.5rem" }
263
271
  }, [
264
272
  G(x("input", {
265
- "onUpdate:modelValue": s[0] || (s[0] = (e) => l.value = e),
273
+ "onUpdate:modelValue": n[0] || (n[0] = (e) => l.value = e),
266
274
  placeholder: "Display name",
267
275
  autoComplete: "webauthn",
268
- style: w(d.value)
276
+ style: y(d.value)
269
277
  }, null, 4), [
270
278
  [W, l.value]
271
279
  ]),
272
280
  x("input", {
273
281
  type: "submit",
274
282
  value: "Sign up",
275
- style: w(h.value)
283
+ style: y(h.value)
276
284
  }, null, 4)
277
285
  ], 32),
278
- n.state.existingUsers.length > 0 ? (g(), f("div", Q, [
286
+ a.state.existingUsers.length > 0 ? (g(), f("div", Q, [
279
287
  x("p", {
280
- style: w({
281
- color: a.value ? "#e2e2e2" : "#000",
288
+ style: y({
289
+ color: i.value ? "#e2e2e2" : "#000",
282
290
  textAlign: "center",
283
291
  paddingTop: "0.5rem",
284
292
  borderTop: "1px solid",
285
- borderColor: a.value ? "#111" : "#e2e2e2"
293
+ borderColor: i.value ? "#111" : "#e2e2e2"
286
294
  })
287
295
  }, " Log in as ", 4),
288
- (g(!0), f(k, null, E(n.state.existingUsers, (e) => (g(), f("button", {
296
+ (g(!0), f(C, null, E(a.state.existingUsers, (e) => (g(), f("button", {
289
297
  key: e,
290
- onClick: (u) => t(e),
298
+ onClick: (s) => r(e),
291
299
  type: "button",
292
300
  "aria-label": `Log in as ${e}`,
293
- style: w(r.value)
294
- }, C(e), 13, X))), 128))
301
+ style: y(t.value)
302
+ }, J(e), 13, X))), 128))
295
303
  ])) : L("", !0)
296
304
  ], 64)) : L("", !0)
297
305
  ], 4));
@@ -303,59 +311,59 @@ const K = { key: 0 }, Q = {
303
311
  maxWidth: {}
304
312
  },
305
313
  setup(p) {
306
- function i(c, d) {
307
- const h = y({});
308
- let r;
309
- const o = A(
314
+ function u(c, d) {
315
+ const h = z({});
316
+ let t;
317
+ const o = I(
310
318
  () => {
311
- var t;
312
- return [(t = c.value) == null ? void 0 : t.id, d];
319
+ var r;
320
+ return [(r = c.value) == null ? void 0 : r.id, d];
313
321
  },
314
322
  () => {
315
- let t;
316
- return c.value ? c.value.subscribe({}, (s) => {
317
- var u, m;
318
- const e = s == null ? void 0 : s.highestResAvailable({ maxWidth: d });
323
+ let r;
324
+ return c.value ? c.value.subscribe({}, (n) => {
325
+ var s, m;
326
+ const e = n == null ? void 0 : n.highestResAvailable({ maxWidth: d });
319
327
  if (e) {
320
- if (e.res !== t) {
321
- t = e.res;
322
- const z = e.stream.toBlob();
323
- if (z) {
324
- const U = URL.createObjectURL(z);
328
+ if (e.res !== r) {
329
+ r = e.res;
330
+ const b = e.stream.toBlob();
331
+ if (b) {
332
+ const U = URL.createObjectURL(b);
325
333
  h.value = {
326
334
  src: U,
327
335
  res: e.res,
328
- originalSize: (u = c.value) == null ? void 0 : u.originalSize
329
- }, r && r(), r = () => {
336
+ originalSize: (s = c.value) == null ? void 0 : s.originalSize
337
+ }, t && t(), t = () => {
330
338
  setTimeout(() => URL.revokeObjectURL(U), 200);
331
339
  };
332
340
  }
333
341
  }
334
342
  } else
335
343
  h.value = {
336
- src: s == null ? void 0 : s.placeholderDataURL,
344
+ src: n == null ? void 0 : n.placeholderDataURL,
337
345
  res: "placeholder",
338
346
  originalSize: (m = c.value) == null ? void 0 : m.originalSize
339
347
  };
340
348
  }) : void 0;
341
349
  }
342
350
  );
343
- return I(() => {
344
- o(), r && r();
351
+ return k(() => {
352
+ o(), t && t();
345
353
  }), h;
346
354
  }
347
- const l = p, a = i(q(l, "image"), l.maxWidth);
355
+ const l = p, i = u(q(l, "image"), l.maxWidth);
348
356
  return (c, d) => H(c.$slots, "default", {
349
- src: J(a).src,
350
- res: J(a).res,
351
- originalSize: J(a).originalSize
357
+ src: S(i).src,
358
+ res: S(i).res,
359
+ originalSize: S(i).originalSize
352
360
  });
353
361
  }
354
362
  });
355
363
  export {
356
- oe as DemoAuthBasicUI,
364
+ re as DemoAuthBasicUI,
357
365
  ne as ProgressiveImg,
358
366
  te as createJazzVueApp,
359
- S as logoutHandler,
360
- re as useDemoAuth
367
+ A as logoutHandler,
368
+ oe as useDemoAuth
361
369
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jazz-vue",
3
- "version": "0.8.11",
3
+ "version": "0.8.12",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "src/index.ts",
@@ -8,7 +8,7 @@
8
8
  "dependencies": {
9
9
  "@scure/bip39": "^1.3.0",
10
10
  "cojson": "0.8.21",
11
- "jazz-browser": "0.8.21",
11
+ "jazz-browser": "0.8.22",
12
12
  "jazz-tools": "0.8.21"
13
13
  },
14
14
  "devDependencies": {
@@ -19,6 +19,7 @@ import {
19
19
  import {
20
20
  Component,
21
21
  ComputedRef,
22
+ MaybeRef,
22
23
  PropType,
23
24
  Ref,
24
25
  ShallowRef,
@@ -31,6 +32,7 @@ import {
31
32
  ref,
32
33
  shallowRef,
33
34
  toRaw,
35
+ unref,
34
36
  watch,
35
37
  } from "vue";
36
38
 
@@ -56,7 +58,7 @@ export interface JazzVueApp<Acc extends Account> {
56
58
 
57
59
  useCoState<V extends CoValue, D>(
58
60
  Schema: CoValueClass<V>,
59
- id: ID<V> | undefined,
61
+ id: MaybeRef<ID<V> | undefined>,
60
62
  depth?: D & DepthsIn<V>,
61
63
  ): Ref<DeeplyLoaded<V, D> | undefined>;
62
64
 
@@ -181,9 +183,13 @@ export function createJazzVueApp<Acc extends Account>({
181
183
  );
182
184
  }
183
185
 
186
+ const contextMe = computed(() =>
187
+ "me" in context.value ? context.value.me : undefined,
188
+ );
189
+
184
190
  const me = useCoState<Acc, D>(
185
- context.value.me.constructor as CoValueClass<Acc>,
186
- context.value.me.id,
191
+ contextMe.value?.constructor as CoValueClass<Acc>,
192
+ contextMe.value?.id,
187
193
  depth,
188
194
  );
189
195
 
@@ -219,11 +225,13 @@ export function createJazzVueApp<Acc extends Account>({
219
225
  throw new Error("useAccountOrGuest must be used within a JazzProvider");
220
226
  }
221
227
 
222
- const contextMe = "me" in context.value ? context.value.me : undefined;
228
+ const contextMe = computed(() =>
229
+ "me" in context.value ? context.value.me : undefined,
230
+ );
223
231
 
224
232
  const me = useCoState<Acc, D>(
225
- contextMe?.constructor as CoValueClass<Acc>,
226
- contextMe?.id,
233
+ contextMe.value?.constructor as CoValueClass<Acc>,
234
+ contextMe.value?.id,
227
235
  depth,
228
236
  );
229
237
 
@@ -244,7 +252,7 @@ export function createJazzVueApp<Acc extends Account>({
244
252
 
245
253
  function useCoState<V extends CoValue, D>(
246
254
  Schema: CoValueClass<V>,
247
- id: ID<V> | undefined,
255
+ id: MaybeRef<ID<V> | undefined>,
248
256
  depth: D & DepthsIn<V> = [] as D & DepthsIn<V>,
249
257
  ): Ref<DeeplyLoaded<V, D> | undefined> {
250
258
  const state: ShallowRef<DeeplyLoaded<V, D> | undefined> =
@@ -258,15 +266,16 @@ export function createJazzVueApp<Acc extends Account>({
258
266
  let unsubscribe: (() => void) | undefined;
259
267
 
260
268
  watch(
261
- [() => id, () => context, () => Schema, () => depth],
269
+ [() => unref(id), () => context, () => Schema, () => depth],
262
270
  () => {
263
271
  if (unsubscribe) unsubscribe();
264
272
 
265
- if (!id) return;
273
+ const idValue = unref(id);
274
+ if (!idValue) return;
266
275
 
267
276
  unsubscribe = subscribeToCoValue(
268
277
  Schema,
269
- id,
278
+ idValue,
270
279
  "me" in context.value
271
280
  ? toRaw(context.value.me)
272
281
  : toRaw(context.value.guest),
@@ -276,7 +285,7 @@ export function createJazzVueApp<Acc extends Account>({
276
285
  },
277
286
  );
278
287
  },
279
- { immediate: true },
288
+ { deep: true, immediate: true },
280
289
  );
281
290
 
282
291
  onUnmounted(() => {