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