@vuetify/one 2.3.1 → 2.5.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/dist/auth-fh7sX38H.js +518 -0
- package/dist/index.d.ts +15 -16
- package/dist/index.js +1854 -2381
- package/dist/{index.css → one.css} +1 -1
- package/dist/stores/auth.d.ts +65 -0
- package/dist/stores/auth.js +7 -0
- package/package.json +27 -30
|
@@ -0,0 +1,518 @@
|
|
|
1
|
+
import { defineStore as k } from "pinia";
|
|
2
|
+
import { ref as E, reactive as z, watch as A, toRefs as V, computed as f, shallowRef as U, nextTick as M } from "vue";
|
|
3
|
+
import { merge as F } from "lodash-es";
|
|
4
|
+
import { useRoute as X, useRouter as H } from "vue-router";
|
|
5
|
+
const _ = k("queue", () => {
|
|
6
|
+
const e = E([]);
|
|
7
|
+
function s(o) {
|
|
8
|
+
const u = typeof o == "string" ? { text: o } : o;
|
|
9
|
+
e.value.push(u);
|
|
10
|
+
}
|
|
11
|
+
function t(o) {
|
|
12
|
+
s({
|
|
13
|
+
color: "error",
|
|
14
|
+
text: o,
|
|
15
|
+
location: "top end",
|
|
16
|
+
timeout: -1
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
queue: e,
|
|
21
|
+
show: s,
|
|
22
|
+
showError: t
|
|
23
|
+
};
|
|
24
|
+
}), C = k("http", {
|
|
25
|
+
state: () => ({
|
|
26
|
+
url: ""
|
|
27
|
+
}),
|
|
28
|
+
actions: {
|
|
29
|
+
async fetch(e, s = {}) {
|
|
30
|
+
const t = await fetch(`${this.url}${e}`, {
|
|
31
|
+
credentials: "include",
|
|
32
|
+
...s
|
|
33
|
+
});
|
|
34
|
+
if (!t.ok)
|
|
35
|
+
throw new Error(await t.text());
|
|
36
|
+
return t.status === 204 ? {} : t.json();
|
|
37
|
+
},
|
|
38
|
+
async post(e, s, t = {}) {
|
|
39
|
+
return this.fetch(e, {
|
|
40
|
+
method: "POST",
|
|
41
|
+
headers: {
|
|
42
|
+
"Content-Type": "application/json"
|
|
43
|
+
},
|
|
44
|
+
body: JSON.stringify(s),
|
|
45
|
+
...t
|
|
46
|
+
});
|
|
47
|
+
},
|
|
48
|
+
async form(e, s, t = {}) {
|
|
49
|
+
return this.fetch(e, {
|
|
50
|
+
method: "POST",
|
|
51
|
+
body: s,
|
|
52
|
+
...t
|
|
53
|
+
});
|
|
54
|
+
},
|
|
55
|
+
async get(e, s = {}) {
|
|
56
|
+
return this.fetch(e, s);
|
|
57
|
+
},
|
|
58
|
+
async delete(e, s = {}) {
|
|
59
|
+
return this.fetch(e, {
|
|
60
|
+
method: "DELETE",
|
|
61
|
+
...s
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}), Y = [
|
|
66
|
+
(e) => (e.v || (e.pwaRefresh = !0, typeof e.api == "boolean" && (e.api = e.api ? "inline" : "link-only"), typeof e.rtl == "boolean" && (e.direction = e.rtl ? "rtl" : "ltr", delete e.rtl), typeof e.theme == "object" && (e.mixedTheme = e.theme.mixed, e.theme = e.theme.system ? "system" : e.theme.dark ? "dark" : "light"), Array.isArray(e.notifications) && (e.notifications = { read: e.notifications }), typeof e.last == "object" && (e.notifications = e.notifications || {}, e.notifications.last = e.last, delete e.last), e.v = 1), e),
|
|
67
|
+
(e) => (e.v === 1 && (Array.isArray(e.composition) && (e.composition = "composition"), Array.isArray(e.notifications?.last?.banner) || (e.notifications = e.notifications || {}, e.notifications.last = e.notifications.last || {}, e.notifications.last.banner = []), e.v = 2), e),
|
|
68
|
+
(e) => (e.v === 2 && (e.syncSettings = !0, e.disableAds = !1, e.v = 3), e),
|
|
69
|
+
(e) => (e.v === 3 && (e.quickbar = !1, e.v = 4), e),
|
|
70
|
+
(e) => (e.v === 4 && (e.suits = { show: !1, elements: ["app-bar"], suit: "" }, e.notifications = e.notifications || {}, e.notifications.banners = !0, e.v = 5), e)
|
|
71
|
+
];
|
|
72
|
+
function G(e) {
|
|
73
|
+
return {
|
|
74
|
+
version: 6,
|
|
75
|
+
ecosystem: {
|
|
76
|
+
bin: {
|
|
77
|
+
wordWrap: !1
|
|
78
|
+
},
|
|
79
|
+
play: {
|
|
80
|
+
showErrors: !0,
|
|
81
|
+
wordWrap: !1
|
|
82
|
+
},
|
|
83
|
+
docs: {
|
|
84
|
+
api: e.api || "link-only",
|
|
85
|
+
composition: e.composition || "composition",
|
|
86
|
+
pins: {
|
|
87
|
+
enabled: e.pins || !1,
|
|
88
|
+
pinned: Array.isArray(e.pinned) ? e.pinned.map((s) => s.name || s).filter(Boolean) : []
|
|
89
|
+
},
|
|
90
|
+
mixedTheme: e.mixedTheme ?? !0,
|
|
91
|
+
favorites: [],
|
|
92
|
+
slashSearch: e.slashSearch || !1,
|
|
93
|
+
railDrawer: e.railDrawer || !1
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
one: {
|
|
97
|
+
avatar: e.avatar || "",
|
|
98
|
+
ads: {
|
|
99
|
+
enabled: !e.disableAds,
|
|
100
|
+
house: e.showHouseAds || !1
|
|
101
|
+
},
|
|
102
|
+
command: {},
|
|
103
|
+
theme: e.theme || "system",
|
|
104
|
+
direction: e.direction || "ltr",
|
|
105
|
+
colors: {
|
|
106
|
+
primary: e.colors?.one || "surface-light"
|
|
107
|
+
},
|
|
108
|
+
suits: {
|
|
109
|
+
enabled: e.suits?.show || !1,
|
|
110
|
+
elements: e.suits?.elements || ["app-bar"],
|
|
111
|
+
suit: e.suits?.suit || ""
|
|
112
|
+
},
|
|
113
|
+
notifications: {
|
|
114
|
+
enabled: e.notifications?.show ?? !0,
|
|
115
|
+
read: e.notifications?.read || [],
|
|
116
|
+
last: ""
|
|
117
|
+
},
|
|
118
|
+
banners: {
|
|
119
|
+
enabled: e.notifications?.banners ?? !0,
|
|
120
|
+
read: e.notifications?.last?.banner || [],
|
|
121
|
+
last: ""
|
|
122
|
+
},
|
|
123
|
+
quicklinks: e.quickbar || !1,
|
|
124
|
+
sync: e.syncSettings ?? !0,
|
|
125
|
+
devmode: e.dev || !1
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
function K(e) {
|
|
130
|
+
const s = Y.reduce((t, o) => o(t), e);
|
|
131
|
+
return G(s);
|
|
132
|
+
}
|
|
133
|
+
const W = typeof window < "u", P = {
|
|
134
|
+
version: 6,
|
|
135
|
+
ecosystem: {
|
|
136
|
+
bin: {
|
|
137
|
+
wordWrap: !1
|
|
138
|
+
},
|
|
139
|
+
play: {
|
|
140
|
+
showErrors: !0,
|
|
141
|
+
wordWrap: !1
|
|
142
|
+
},
|
|
143
|
+
docs: {
|
|
144
|
+
api: "link-only",
|
|
145
|
+
composition: "composition",
|
|
146
|
+
pins: {
|
|
147
|
+
enabled: !1,
|
|
148
|
+
pinned: []
|
|
149
|
+
},
|
|
150
|
+
mixedTheme: !0,
|
|
151
|
+
favorites: [],
|
|
152
|
+
slashSearch: !1,
|
|
153
|
+
railDrawer: !1
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
one: {
|
|
157
|
+
avatar: "",
|
|
158
|
+
ads: {
|
|
159
|
+
enabled: !0,
|
|
160
|
+
house: !1
|
|
161
|
+
},
|
|
162
|
+
command: {},
|
|
163
|
+
theme: "system",
|
|
164
|
+
direction: "ltr",
|
|
165
|
+
colors: {
|
|
166
|
+
primary: "surface-light"
|
|
167
|
+
},
|
|
168
|
+
suits: {
|
|
169
|
+
enabled: !1,
|
|
170
|
+
elements: ["app-bar"],
|
|
171
|
+
suit: ""
|
|
172
|
+
},
|
|
173
|
+
notifications: {
|
|
174
|
+
enabled: !0,
|
|
175
|
+
read: [],
|
|
176
|
+
last: ""
|
|
177
|
+
},
|
|
178
|
+
banners: {
|
|
179
|
+
enabled: !0,
|
|
180
|
+
read: [],
|
|
181
|
+
last: ""
|
|
182
|
+
},
|
|
183
|
+
quicklinks: !1,
|
|
184
|
+
sync: !0,
|
|
185
|
+
devmode: !1
|
|
186
|
+
}
|
|
187
|
+
}, Z = k("user", () => {
|
|
188
|
+
const e = z(structuredClone(P));
|
|
189
|
+
A(e, t, { deep: !0 });
|
|
190
|
+
function s() {
|
|
191
|
+
if (!W)
|
|
192
|
+
return;
|
|
193
|
+
const u = localStorage.getItem("vuetify@user");
|
|
194
|
+
if (u)
|
|
195
|
+
try {
|
|
196
|
+
const n = JSON.parse(u);
|
|
197
|
+
if (n.version >= 6) {
|
|
198
|
+
const c = {
|
|
199
|
+
version: 6,
|
|
200
|
+
ecosystem: F(P.ecosystem, n.ecosystem || {}),
|
|
201
|
+
one: F(P.one, n.one || {})
|
|
202
|
+
};
|
|
203
|
+
Object.assign(e, c);
|
|
204
|
+
} else {
|
|
205
|
+
const c = K(n);
|
|
206
|
+
Object.assign(e, c);
|
|
207
|
+
}
|
|
208
|
+
t();
|
|
209
|
+
} catch (n) {
|
|
210
|
+
console.error("Failed to load user settings:", n);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
function t() {
|
|
214
|
+
W && localStorage.setItem("vuetify@user", JSON.stringify(e, null, 2));
|
|
215
|
+
}
|
|
216
|
+
function o() {
|
|
217
|
+
W && (Object.assign(e, structuredClone(P)), t());
|
|
218
|
+
}
|
|
219
|
+
return s(), {
|
|
220
|
+
...V(e),
|
|
221
|
+
load: s,
|
|
222
|
+
save: t,
|
|
223
|
+
reset: o
|
|
224
|
+
};
|
|
225
|
+
});
|
|
226
|
+
function J() {
|
|
227
|
+
const e = X();
|
|
228
|
+
return f(
|
|
229
|
+
() => e.query
|
|
230
|
+
);
|
|
231
|
+
}
|
|
232
|
+
const Q = k("one", () => {
|
|
233
|
+
const e = J(), s = H(), t = B(), o = C(), u = _(), n = U(!1), c = U(!1), d = E(), y = E([]), g = f(() => e.value.session_id), T = f(() => d.value?.items[0].plan.interval), p = f(() => d.value?.items[0].plan.type), I = E([]), h = f(() => t.user?.sponsorships.find((r) => r.platform === "stripe" && r.tierName.startsWith("sub_"))), q = f(() => !!h.value?.tierName), a = f(() => t.user?.sponsorships.reduce((r, m) => {
|
|
234
|
+
if (!m.isActive || m.interval === "once")
|
|
235
|
+
return r;
|
|
236
|
+
const b = m.interval === "month" ? m.amount : m.amount / 12;
|
|
237
|
+
return r + b / 100;
|
|
238
|
+
}, 0) ?? 0), i = f(() => t.user?.sponsorships.find((r) => r.tierName.startsWith("sub_") && r.isActive)), l = f(() => t.user?.sponsorships.find((r) => r.platform === "github" && r.isActive)), v = f(() => t.user?.sponsorships.find((r) => r.platform === "discord" && r.isActive)), L = f(() => t.user?.identities.find((r) => r.provider === "shopify")), N = f(() => !o.url || t.user?.isAdmin || h.value?.isActive || I.value.some((r) => ["one", "one/team"].includes(r)));
|
|
239
|
+
A(c, w), A(g, async (r) => {
|
|
240
|
+
r && await O();
|
|
241
|
+
}, { immediate: !0 }), A(e, (r) => {
|
|
242
|
+
if (r.one !== "subscribe" || t.user)
|
|
243
|
+
return;
|
|
244
|
+
t.dialog = !0;
|
|
245
|
+
const m = A(() => t.user, (b) => {
|
|
246
|
+
b && (t.dialog = !1, m());
|
|
247
|
+
});
|
|
248
|
+
}, { immediate: !0 });
|
|
249
|
+
async function O() {
|
|
250
|
+
try {
|
|
251
|
+
n.value = !0, await o.post("/one/activate", { sessionId: g.value }), await t.verify(!0), await $();
|
|
252
|
+
const r = new URL(window.location.href), m = r.searchParams;
|
|
253
|
+
m.delete("session_id"), m.delete("team"), history.pushState(null, "", r.toString());
|
|
254
|
+
} catch (r) {
|
|
255
|
+
u.showError(r?.message ?? "Error activating subscription, Please contact support");
|
|
256
|
+
} finally {
|
|
257
|
+
n.value = !1;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
async function S() {
|
|
261
|
+
window.open(`${o.url}/one/manage`, "_blank");
|
|
262
|
+
}
|
|
263
|
+
async function R(r, m) {
|
|
264
|
+
n.value = !0;
|
|
265
|
+
const b = new URL("/one/subscribe", o.url);
|
|
266
|
+
b.searchParams.set("interval", r), b.searchParams.set("type", m), window.location.href = b.toString();
|
|
267
|
+
}
|
|
268
|
+
async function j() {
|
|
269
|
+
if (h.value)
|
|
270
|
+
try {
|
|
271
|
+
n.value = !0, await o.post(
|
|
272
|
+
`/one/cancel?subscriptionId=${h.value?.tierName}`
|
|
273
|
+
), await t.verify(!0);
|
|
274
|
+
} catch (r) {
|
|
275
|
+
u.showError(r?.message ?? "Error cancelling subscription, Please contact support");
|
|
276
|
+
} finally {
|
|
277
|
+
n.value = !1;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
async function x(r, m) {
|
|
281
|
+
if (h.value)
|
|
282
|
+
try {
|
|
283
|
+
n.value = !0, await o.post("/one/modify", {
|
|
284
|
+
subscriptionId: h.value.tierName,
|
|
285
|
+
interval: r,
|
|
286
|
+
type: m
|
|
287
|
+
}), await t.verify(!0);
|
|
288
|
+
} catch (b) {
|
|
289
|
+
u.showError(b?.message ?? "Error modifying subscription");
|
|
290
|
+
} finally {
|
|
291
|
+
n.value = !1;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
async function $() {
|
|
295
|
+
try {
|
|
296
|
+
n.value = !0;
|
|
297
|
+
const r = await o.get("/one/info");
|
|
298
|
+
return d.value = r.subscription, y.value = r.invoices, r;
|
|
299
|
+
} catch (r) {
|
|
300
|
+
u.showError(r?.message ?? "Error fetching subscription info");
|
|
301
|
+
} finally {
|
|
302
|
+
n.value = !1;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
function w() {
|
|
306
|
+
s.push({
|
|
307
|
+
query: {
|
|
308
|
+
...e.value,
|
|
309
|
+
one: void 0
|
|
310
|
+
}
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
return {
|
|
314
|
+
info: d,
|
|
315
|
+
interval: T,
|
|
316
|
+
subscriptionType: p,
|
|
317
|
+
access: I,
|
|
318
|
+
invoices: y,
|
|
319
|
+
sessionId: g,
|
|
320
|
+
subscription: h,
|
|
321
|
+
monthlyTotal: a,
|
|
322
|
+
hasBilling: q,
|
|
323
|
+
isLoading: n,
|
|
324
|
+
isOpen: c,
|
|
325
|
+
isSubscriber: N,
|
|
326
|
+
github: l,
|
|
327
|
+
discord: v,
|
|
328
|
+
shopify: L,
|
|
329
|
+
one: i,
|
|
330
|
+
activate: O,
|
|
331
|
+
cancel: j,
|
|
332
|
+
manage: S,
|
|
333
|
+
modify: x,
|
|
334
|
+
resetQuery: w,
|
|
335
|
+
subscribe: R,
|
|
336
|
+
subscriptionInfo: $
|
|
337
|
+
};
|
|
338
|
+
}), D = k("team", () => {
|
|
339
|
+
const e = J(), s = B(), t = Q(), o = C(), u = _(), n = U(!1), c = E(null), d = E(!1), y = f(() => e.value.invite), g = f(
|
|
340
|
+
() => c.value ? t.access?.some((a) => ["one/team", "snips/team"].includes(a)) : !1
|
|
341
|
+
);
|
|
342
|
+
A(y, async () => {
|
|
343
|
+
if (y.value) {
|
|
344
|
+
s.user || (s.dialog = !0);
|
|
345
|
+
try {
|
|
346
|
+
n.value = !0;
|
|
347
|
+
const a = await o.get(`/one/team/${y.value}`);
|
|
348
|
+
c.value = a.team, d.value = !0;
|
|
349
|
+
} catch (a) {
|
|
350
|
+
h(), u.showError(a.message);
|
|
351
|
+
} finally {
|
|
352
|
+
n.value = !1;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
}, { immediate: !0 });
|
|
356
|
+
async function T(a) {
|
|
357
|
+
try {
|
|
358
|
+
if (n.value = !0, !c.value)
|
|
359
|
+
return;
|
|
360
|
+
await o.post("/one/team/remove", { userId: a }), c.value.members = c.value.members.filter((i) => i.id !== a);
|
|
361
|
+
} catch (i) {
|
|
362
|
+
u.showError(i?.message ?? "Error removing user from team");
|
|
363
|
+
} finally {
|
|
364
|
+
n.value = !1;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
async function p() {
|
|
368
|
+
try {
|
|
369
|
+
n.value = !0, await o.post("/one/team/leave", { teamId: c.value?.id }), await s.verify(!0);
|
|
370
|
+
} catch (a) {
|
|
371
|
+
u.showError(a?.message ?? "Error leaving team");
|
|
372
|
+
} finally {
|
|
373
|
+
n.value = !1;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
async function I() {
|
|
377
|
+
try {
|
|
378
|
+
n.value = !0, await o.post("/one/team/join", { inviteCode: y.value }), await s.verify(!0), h();
|
|
379
|
+
} catch (a) {
|
|
380
|
+
u.showError(a?.message ?? "Error joining team");
|
|
381
|
+
} finally {
|
|
382
|
+
n.value = !1;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
function h() {
|
|
386
|
+
d.value = !1;
|
|
387
|
+
const a = new URL(window.location.href);
|
|
388
|
+
a.searchParams.delete("invite"), window.history.replaceState({}, "", a.toString());
|
|
389
|
+
}
|
|
390
|
+
const q = f(() => s.user?.id === s.user?.team?.owner.id);
|
|
391
|
+
return {
|
|
392
|
+
team: c,
|
|
393
|
+
teamInviteDialog: d,
|
|
394
|
+
teamInviteCode: y,
|
|
395
|
+
hasTeamAccess: g,
|
|
396
|
+
isTeamOwner: q,
|
|
397
|
+
isLoading: n,
|
|
398
|
+
removeFromTeam: T,
|
|
399
|
+
leaveTeam: p,
|
|
400
|
+
joinTeam: I,
|
|
401
|
+
clearTeamQuery: h
|
|
402
|
+
};
|
|
403
|
+
}), B = k("auth", () => {
|
|
404
|
+
const e = E(!1), s = E(null), t = C(), o = Z(), u = H(), n = U(!1), c = Q(), d = D(), y = _();
|
|
405
|
+
let g = !!a();
|
|
406
|
+
A(s, (i) => {
|
|
407
|
+
if (!i?.settings)
|
|
408
|
+
return;
|
|
409
|
+
const l = localStorage.getItem("vuetify@user") || "{}";
|
|
410
|
+
JSON.stringify(i.settings, null, 2) !== l && (g = !0, Object.assign(o, i.settings));
|
|
411
|
+
}), o.$subscribe(() => {
|
|
412
|
+
g || T(), g = !1;
|
|
413
|
+
});
|
|
414
|
+
async function T() {
|
|
415
|
+
if (await M(), !(!s.value || !o.one.sync))
|
|
416
|
+
try {
|
|
417
|
+
await t.post("/user/settings", { settings: o.$state }), await p(!0);
|
|
418
|
+
} catch (i) {
|
|
419
|
+
y.showError(i?.message ?? "Error syncing settings");
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
async function p(i = !1) {
|
|
423
|
+
if (p.promise)
|
|
424
|
+
return p.promise;
|
|
425
|
+
if (!i && !document.cookie.includes("sx=1") && location.hostname.match(/([^.]+\.[^.]+)$/)?.[1] === new URL(t.url).hostname.match(/([^.]+\.[^.]+)$/)?.[1]) {
|
|
426
|
+
s.value = null;
|
|
427
|
+
return;
|
|
428
|
+
}
|
|
429
|
+
n.value = !0, p.promise = fetch(`${t.url}/auth/verify`, {
|
|
430
|
+
credentials: "include",
|
|
431
|
+
cache: i ? "reload" : void 0
|
|
432
|
+
}).then(
|
|
433
|
+
async (l) => {
|
|
434
|
+
if (l.ok || l.status === 401) {
|
|
435
|
+
const v = await l.json();
|
|
436
|
+
s.value = v.user, c.access = v.access, d.team = v.user?.team;
|
|
437
|
+
} else
|
|
438
|
+
console.error(l.statusText);
|
|
439
|
+
},
|
|
440
|
+
() => {
|
|
441
|
+
}
|
|
442
|
+
).finally(() => {
|
|
443
|
+
n.value = !1, p.promise = null;
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
p.promise = null;
|
|
447
|
+
async function I(i = "github") {
|
|
448
|
+
n.value = !0;
|
|
449
|
+
const l = `${t.url}/auth/${i}/redirect`;
|
|
450
|
+
if (i === "shopify") {
|
|
451
|
+
window.location.assign(l + "?next=" + encodeURIComponent(window.location.href));
|
|
452
|
+
return;
|
|
453
|
+
}
|
|
454
|
+
const v = 400, L = 600, N = window.screenX + (window.innerWidth - v) / 2, O = window.screenY + (window.innerHeight - L) / 2, S = window.open(
|
|
455
|
+
"",
|
|
456
|
+
"vuetify:authorize:popup",
|
|
457
|
+
`popup,left=${N},top=${O},width=${v},height=${L},resizable`
|
|
458
|
+
);
|
|
459
|
+
if (!S) {
|
|
460
|
+
console.error("Failed to open popup");
|
|
461
|
+
return;
|
|
462
|
+
}
|
|
463
|
+
S.location.href = l;
|
|
464
|
+
let R = -1, j = -1;
|
|
465
|
+
function x(w) {
|
|
466
|
+
w.origin === t.url && w.data?.type === "auth-response" && (w.data.status === "success" ? (s.value || localStorage.setItem("vuetify@lastLoginProvider", i), s.value = w.data.body.user, c.access = w.data.body.access, d.team = w.data.body.user?.team, T()) : console.error(w.data.message), $());
|
|
467
|
+
}
|
|
468
|
+
function $() {
|
|
469
|
+
window.removeEventListener("message", x), window.clearInterval(R), window.clearTimeout(j), S?.close(), n.value = !1;
|
|
470
|
+
}
|
|
471
|
+
window.addEventListener("message", x), R = window.setInterval(() => {
|
|
472
|
+
!S || S.closed ? (console.error("Auth popup closed"), $()) : S.postMessage({ type: "auth-request" }, "*");
|
|
473
|
+
}, 1e3), j = window.setTimeout(() => {
|
|
474
|
+
$(), console.error("Auth timed out");
|
|
475
|
+
}, 120 * 1e3);
|
|
476
|
+
}
|
|
477
|
+
async function h(i) {
|
|
478
|
+
n.value = !0;
|
|
479
|
+
const l = i ? `/auth/${i}/logout` : "/auth/logout";
|
|
480
|
+
try {
|
|
481
|
+
await t.post(l), await p(!0), s.value = null;
|
|
482
|
+
} catch (v) {
|
|
483
|
+
y.showError(v?.message ?? "Error logging out");
|
|
484
|
+
} finally {
|
|
485
|
+
u.push({
|
|
486
|
+
path: "/",
|
|
487
|
+
query: u.currentRoute.value.query
|
|
488
|
+
}), n.value = !1;
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
function q(i) {
|
|
492
|
+
return s.value?.identities.find((l) => l.provider === i);
|
|
493
|
+
}
|
|
494
|
+
function a() {
|
|
495
|
+
return localStorage.getItem("vuetify@lastLoginProvider");
|
|
496
|
+
}
|
|
497
|
+
return p(), {
|
|
498
|
+
user: s,
|
|
499
|
+
url: t.url,
|
|
500
|
+
dialog: e,
|
|
501
|
+
isLoading: n,
|
|
502
|
+
verify: p,
|
|
503
|
+
findIdentity: q,
|
|
504
|
+
login: I,
|
|
505
|
+
logout: h,
|
|
506
|
+
lastLoginProvider: a,
|
|
507
|
+
sync: T
|
|
508
|
+
};
|
|
509
|
+
});
|
|
510
|
+
export {
|
|
511
|
+
B as a,
|
|
512
|
+
C as b,
|
|
513
|
+
Z as c,
|
|
514
|
+
Q as d,
|
|
515
|
+
J as e,
|
|
516
|
+
D as f,
|
|
517
|
+
_ as u
|
|
518
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as vue from 'vue';
|
|
2
1
|
import { Ref, ComputedRef, ShallowRef, App } from 'vue';
|
|
3
2
|
import * as pinia from 'pinia';
|
|
4
3
|
import { PiniaPluginContext } from 'pinia';
|
|
@@ -54,7 +53,7 @@ declare const useTeamStore: pinia.StoreDefinition<"team", Pick<{
|
|
|
54
53
|
teamInviteCode: ComputedRef<string>;
|
|
55
54
|
hasTeamAccess: ComputedRef<boolean>;
|
|
56
55
|
isTeamOwner: ComputedRef<boolean>;
|
|
57
|
-
isLoading: ShallowRef<boolean
|
|
56
|
+
isLoading: ShallowRef<boolean>;
|
|
58
57
|
removeFromTeam: (id: string) => Promise<void>;
|
|
59
58
|
leaveTeam: () => Promise<void>;
|
|
60
59
|
joinTeam: () => Promise<void>;
|
|
@@ -93,7 +92,7 @@ declare const useTeamStore: pinia.StoreDefinition<"team", Pick<{
|
|
|
93
92
|
teamInviteCode: ComputedRef<string>;
|
|
94
93
|
hasTeamAccess: ComputedRef<boolean>;
|
|
95
94
|
isTeamOwner: ComputedRef<boolean>;
|
|
96
|
-
isLoading: ShallowRef<boolean
|
|
95
|
+
isLoading: ShallowRef<boolean>;
|
|
97
96
|
removeFromTeam: (id: string) => Promise<void>;
|
|
98
97
|
leaveTeam: () => Promise<void>;
|
|
99
98
|
joinTeam: () => Promise<void>;
|
|
@@ -132,7 +131,7 @@ declare const useTeamStore: pinia.StoreDefinition<"team", Pick<{
|
|
|
132
131
|
teamInviteCode: ComputedRef<string>;
|
|
133
132
|
hasTeamAccess: ComputedRef<boolean>;
|
|
134
133
|
isTeamOwner: ComputedRef<boolean>;
|
|
135
|
-
isLoading: ShallowRef<boolean
|
|
134
|
+
isLoading: ShallowRef<boolean>;
|
|
136
135
|
removeFromTeam: (id: string) => Promise<void>;
|
|
137
136
|
leaveTeam: () => Promise<void>;
|
|
138
137
|
joinTeam: () => Promise<void>;
|
|
@@ -160,6 +159,7 @@ interface VOneIdentity {
|
|
|
160
159
|
interface VOneUser {
|
|
161
160
|
id: string;
|
|
162
161
|
isAdmin: boolean;
|
|
162
|
+
role: 'super' | 'admin' | 'editor' | 'user';
|
|
163
163
|
name: string;
|
|
164
164
|
picture: string;
|
|
165
165
|
settings: Record<string, any> | null;
|
|
@@ -180,7 +180,7 @@ interface AuthState {
|
|
|
180
180
|
lastLoginProvider: () => string | null;
|
|
181
181
|
sync: () => Promise<void>;
|
|
182
182
|
}
|
|
183
|
-
declare const useAuthStore: pinia.StoreDefinition<"auth", Pick<AuthState, "isLoading" | "user" | "url" | "dialog">, Pick<AuthState, never>, Pick<AuthState, "
|
|
183
|
+
declare const useAuthStore: pinia.StoreDefinition<"auth", Pick<AuthState, "isLoading" | "user" | "url" | "dialog">, Pick<AuthState, never>, Pick<AuthState, "sync" | "verify" | "findIdentity" | "login" | "logout" | "lastLoginProvider">>;
|
|
184
184
|
|
|
185
185
|
interface VOneBanner {
|
|
186
186
|
id: string;
|
|
@@ -281,7 +281,7 @@ declare const useDownloadsStore: pinia.StoreDefinition<"downloads", Pick<{
|
|
|
281
281
|
created_at: string;
|
|
282
282
|
download_url: string;
|
|
283
283
|
}[]>;
|
|
284
|
-
isLoading: ShallowRef<boolean
|
|
284
|
+
isLoading: ShallowRef<boolean>;
|
|
285
285
|
index: () => Promise<{
|
|
286
286
|
id: number;
|
|
287
287
|
download_items: {
|
|
@@ -321,7 +321,7 @@ declare const useDownloadsStore: pinia.StoreDefinition<"downloads", Pick<{
|
|
|
321
321
|
created_at: string;
|
|
322
322
|
download_url: string;
|
|
323
323
|
}[]>;
|
|
324
|
-
isLoading: ShallowRef<boolean
|
|
324
|
+
isLoading: ShallowRef<boolean>;
|
|
325
325
|
index: () => Promise<{
|
|
326
326
|
id: number;
|
|
327
327
|
download_items: {
|
|
@@ -361,7 +361,7 @@ declare const useDownloadsStore: pinia.StoreDefinition<"downloads", Pick<{
|
|
|
361
361
|
created_at: string;
|
|
362
362
|
download_url: string;
|
|
363
363
|
}[]>;
|
|
364
|
-
isLoading: ShallowRef<boolean
|
|
364
|
+
isLoading: ShallowRef<boolean>;
|
|
365
365
|
index: () => Promise<{
|
|
366
366
|
id: number;
|
|
367
367
|
download_items: {
|
|
@@ -467,9 +467,8 @@ interface OneState {
|
|
|
467
467
|
resetQuery: () => void;
|
|
468
468
|
subscribe: (interval: SubscriptionItemPlan['interval'], type: SubscriptionItemPlan['type']) => Promise<void>;
|
|
469
469
|
subscriptionInfo: () => Promise<any>;
|
|
470
|
-
verify: () => Promise<void>;
|
|
471
470
|
}
|
|
472
|
-
declare const useOneStore: pinia.StoreDefinition<"one", Pick<OneState, "info" | "access" | "invoices" | "isLoading" | "isOpen">, Pick<OneState, "one" | "interval" | "subscriptionType" | "sessionId" | "subscription" | "monthlyTotal" | "hasBilling" | "isSubscriber" | "github" | "discord" | "shopify">, Pick<OneState, "activate" | "cancel" | "manage" | "modify" | "resetQuery" | "subscribe" | "subscriptionInfo"
|
|
471
|
+
declare const useOneStore: pinia.StoreDefinition<"one", Pick<OneState, "info" | "access" | "invoices" | "isLoading" | "isOpen">, Pick<OneState, "one" | "interval" | "subscriptionType" | "sessionId" | "subscription" | "monthlyTotal" | "hasBilling" | "isSubscriber" | "github" | "discord" | "shopify">, Pick<OneState, "activate" | "cancel" | "manage" | "modify" | "resetQuery" | "subscribe" | "subscriptionInfo">>;
|
|
473
472
|
|
|
474
473
|
interface ShopifyProduct {
|
|
475
474
|
id: string;
|
|
@@ -587,8 +586,8 @@ declare const usePromotionsStore: pinia.StoreDefinition<"promotions", Pick<{
|
|
|
587
586
|
type: "theme" | "video" | "book" | "course" | "website" | "job" | "merch" | "digital" | "services" | "documentation";
|
|
588
587
|
};
|
|
589
588
|
}[]>;
|
|
590
|
-
isLoading:
|
|
591
|
-
hasLoaded:
|
|
589
|
+
isLoading: globalThis.ShallowRef<boolean>;
|
|
590
|
+
hasLoaded: globalThis.ShallowRef<boolean>;
|
|
592
591
|
discoverable: globalThis.ComputedRef<{
|
|
593
592
|
id: string;
|
|
594
593
|
slug: string;
|
|
@@ -730,8 +729,8 @@ declare const usePromotionsStore: pinia.StoreDefinition<"promotions", Pick<{
|
|
|
730
729
|
type: "theme" | "video" | "book" | "course" | "website" | "job" | "merch" | "digital" | "services" | "documentation";
|
|
731
730
|
};
|
|
732
731
|
}[]>;
|
|
733
|
-
isLoading:
|
|
734
|
-
hasLoaded:
|
|
732
|
+
isLoading: globalThis.ShallowRef<boolean>;
|
|
733
|
+
hasLoaded: globalThis.ShallowRef<boolean>;
|
|
735
734
|
discoverable: globalThis.ComputedRef<{
|
|
736
735
|
id: string;
|
|
737
736
|
slug: string;
|
|
@@ -873,8 +872,8 @@ declare const usePromotionsStore: pinia.StoreDefinition<"promotions", Pick<{
|
|
|
873
872
|
type: "theme" | "video" | "book" | "course" | "website" | "job" | "merch" | "digital" | "services" | "documentation";
|
|
874
873
|
};
|
|
875
874
|
}[]>;
|
|
876
|
-
isLoading:
|
|
877
|
-
hasLoaded:
|
|
875
|
+
isLoading: globalThis.ShallowRef<boolean>;
|
|
876
|
+
hasLoaded: globalThis.ShallowRef<boolean>;
|
|
878
877
|
discoverable: globalThis.ComputedRef<{
|
|
879
878
|
id: string;
|
|
880
879
|
slug: string;
|