@vuetify/one 0.1.3 → 0.3.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/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import * as vue from 'vue';
2
2
  import { App } from 'vue';
3
3
  import * as pinia from 'pinia';
4
+ import { PiniaPluginContext } from 'pinia';
4
5
 
5
6
  declare const useAuthStore: pinia.StoreDefinition<"auth", pinia._UnwrapAll<Pick<{
6
7
  user: vue.Ref<{
@@ -90,7 +91,7 @@ declare const useAuthStore: pinia.StoreDefinition<"auth", pinia._UnwrapAll<Pick<
90
91
  };
91
92
  }[];
92
93
  } | null>;
93
- url: any;
94
+ url: string;
94
95
  isLoading: vue.ShallowRef<boolean>;
95
96
  verify: {
96
97
  (force?: boolean): Promise<void>;
@@ -188,7 +189,7 @@ declare const useAuthStore: pinia.StoreDefinition<"auth", pinia._UnwrapAll<Pick<
188
189
  };
189
190
  }[];
190
191
  } | null>;
191
- url: any;
192
+ url: string;
192
193
  isLoading: vue.ShallowRef<boolean>;
193
194
  verify: {
194
195
  (force?: boolean): Promise<void>;
@@ -198,7 +199,7 @@ declare const useAuthStore: pinia.StoreDefinition<"auth", pinia._UnwrapAll<Pick<
198
199
  logout: () => Promise<void>;
199
200
  isSubscriber: vue.ComputedRef<boolean | undefined>;
200
201
  lastLoginProvider: () => string | null;
201
- }, "url" | "isSubscriber">, Pick<{
202
+ }, "isSubscriber">, Pick<{
202
203
  user: vue.Ref<{
203
204
  id: string;
204
205
  isAdmin: boolean;
@@ -286,7 +287,7 @@ declare const useAuthStore: pinia.StoreDefinition<"auth", pinia._UnwrapAll<Pick<
286
287
  };
287
288
  }[];
288
289
  } | null>;
289
- url: any;
290
+ url: string;
290
291
  isLoading: vue.ShallowRef<boolean>;
291
292
  verify: {
292
293
  (force?: boolean): Promise<void>;
@@ -296,7 +297,101 @@ declare const useAuthStore: pinia.StoreDefinition<"auth", pinia._UnwrapAll<Pick<
296
297
  logout: () => Promise<void>;
297
298
  isSubscriber: vue.ComputedRef<boolean | undefined>;
298
299
  lastLoginProvider: () => string | null;
299
- }, "url" | "verify" | "login" | "logout" | "lastLoginProvider">>;
300
+ }, "verify" | "login" | "logout" | "lastLoginProvider">>;
301
+
302
+ type Bin = {
303
+ id: string;
304
+ content: string;
305
+ favorite: boolean;
306
+ pinned: boolean;
307
+ owner: Record<string, unknown>;
308
+ visibility: 'private' | 'public';
309
+ };
310
+ declare const useBinsStore: pinia.StoreDefinition<"bins", pinia._UnwrapAll<Pick<{
311
+ isOwner: vue.ComputedRef<boolean>;
312
+ all: vue.Ref<{
313
+ id: string;
314
+ content: string;
315
+ favorite: boolean;
316
+ pinned: boolean;
317
+ owner: Record<string, unknown>;
318
+ visibility: 'private' | 'public';
319
+ }[]>;
320
+ create: (bin: Bin) => Promise<{
321
+ bin: Bin;
322
+ }>;
323
+ delete: (id: string) => Promise<Response>;
324
+ current: vue.Ref<Bin | undefined>;
325
+ find: (id: string) => Promise<{
326
+ bin: Bin;
327
+ }>;
328
+ get: () => Promise<Bin[]>;
329
+ update: (bin: Bin, id: string) => Promise<{
330
+ bin: Bin;
331
+ }>;
332
+ updateOrCreate: (bin: Bin, id?: string) => Promise<{
333
+ bin: Bin;
334
+ }>;
335
+ }, "all" | "current">>, Pick<{
336
+ isOwner: vue.ComputedRef<boolean>;
337
+ all: vue.Ref<{
338
+ id: string;
339
+ content: string;
340
+ favorite: boolean;
341
+ pinned: boolean;
342
+ owner: Record<string, unknown>;
343
+ visibility: 'private' | 'public';
344
+ }[]>;
345
+ create: (bin: Bin) => Promise<{
346
+ bin: Bin;
347
+ }>;
348
+ delete: (id: string) => Promise<Response>;
349
+ current: vue.Ref<Bin | undefined>;
350
+ find: (id: string) => Promise<{
351
+ bin: Bin;
352
+ }>;
353
+ get: () => Promise<Bin[]>;
354
+ update: (bin: Bin, id: string) => Promise<{
355
+ bin: Bin;
356
+ }>;
357
+ updateOrCreate: (bin: Bin, id?: string) => Promise<{
358
+ bin: Bin;
359
+ }>;
360
+ }, "isOwner">, Pick<{
361
+ isOwner: vue.ComputedRef<boolean>;
362
+ all: vue.Ref<{
363
+ id: string;
364
+ content: string;
365
+ favorite: boolean;
366
+ pinned: boolean;
367
+ owner: Record<string, unknown>;
368
+ visibility: 'private' | 'public';
369
+ }[]>;
370
+ create: (bin: Bin) => Promise<{
371
+ bin: Bin;
372
+ }>;
373
+ delete: (id: string) => Promise<Response>;
374
+ current: vue.Ref<Bin | undefined>;
375
+ find: (id: string) => Promise<{
376
+ bin: Bin;
377
+ }>;
378
+ get: () => Promise<Bin[]>;
379
+ update: (bin: Bin, id: string) => Promise<{
380
+ bin: Bin;
381
+ }>;
382
+ updateOrCreate: (bin: Bin, id?: string) => Promise<{
383
+ bin: Bin;
384
+ }>;
385
+ }, "get" | "delete" | "update" | "find" | "create" | "updateOrCreate">>;
386
+
387
+ declare const useHttpStore: pinia.StoreDefinition<"http", {
388
+ url: string;
389
+ }, {}, {
390
+ fetch<T = any>(url: string, options?: RequestInit): Promise<T>;
391
+ post<T_1 = any>(url: string, body?: any, options?: RequestInit): Promise<T_1>;
392
+ get<T_2 = any>(url: string, options?: RequestInit): Promise<T_2>;
393
+ delete(url: string, options?: RequestInit): Promise<Response>;
394
+ }>;
300
395
 
301
396
  declare const useOneStore: pinia.StoreDefinition<"one", pinia._UnwrapAll<Pick<{
302
397
  activate: () => Promise<void>;
@@ -632,5 +727,6 @@ declare const useUserStore: pinia.StoreDefinition<"user", pinia._UnwrapAll<Pick<
632
727
  declare function createOne(): {
633
728
  install: (app: App) => void;
634
729
  };
730
+ declare function one(ctx: PiniaPluginContext): void;
635
731
 
636
- export { createOne, useAuthStore, useOneStore, useUserStore };
732
+ export { createOne, one, useAuthStore, useBinsStore, useHttpStore, useOneStore, useUserStore };
package/dist/index.js CHANGED
@@ -1,19 +1,51 @@
1
- import { reactive as Y, toRefs as Z, ref as K, shallowRef as U, computed as A, watch as B, defineComponent as L, openBlock as m, createBlock as v, unref as a, withCtx as d, createVNode as u, createTextVNode as w, toDisplayString as S, createCommentVNode as Q, mergeProps as ee, createElementVNode as b, createElementBlock as te, Fragment as oe, renderList as ie, pushScopeId as se, popScopeId as ne, onBeforeMount as re } from "vue";
2
- import { defineStore as O } from "pinia";
3
- import { merge as j } from "lodash-es";
4
- import { mdiDiscord as R, mdiGithub as F, mdiViewDashboard as ae, mdiLogoutVariant as le, mdiLogin as ce, mdiShieldStarOutline as ue, mdiReddit as de } from "@mdi/js";
5
- import { VListItem as E, VList as G, VListSubheader as fe } from "vuetify/lib/components/VList/index.mjs";
6
- import { VAvatar as pe } from "vuetify/lib/components/VAvatar/index.mjs";
7
- import { VBtn as M } from "vuetify/lib/components/VBtn/index.mjs";
8
- import { VMenu as me } from "vuetify/lib/components/VMenu/index.mjs";
9
- import { VSkeletonLoader as he } from "vuetify/lib/components/VSkeletonLoader/index.mjs";
10
- import { useDisplay as ve, useTheme as ge } from "vuetify";
11
- import { VCard as ye, VCardTitle as _e, VCardSubtitle as be } from "vuetify/lib/components/VCard/index.mjs";
12
- import { VDialog as we } from "vuetify/lib/components/VDialog/index.mjs";
13
- import { VImg as J } from "vuetify/lib/components/VImg/index.mjs";
1
+ import { reactive as Y, toRefs as Z, ref as O, shallowRef as T, computed as x, watch as H, defineComponent as V, openBlock as h, createBlock as b, unref as l, withCtx as f, createVNode as d, createTextVNode as S, toDisplayString as B, createCommentVNode as K, mergeProps as Q, createElementVNode as k, createElementBlock as ee, Fragment as te, renderList as oe, pushScopeId as se, popScopeId as ne, onBeforeMount as ie } from "vue";
2
+ import { defineStore as $ } from "pinia";
3
+ import { merge as D } from "lodash-es";
4
+ import { mdiDiscord as M, mdiGithub as G, mdiViewDashboard as re, mdiLogoutVariant as ae, mdiLogin as le, mdiShieldStarOutline as ce, mdiReddit as ue } from "@mdi/js";
5
+ import { VListItem as z, VList as J, VListSubheader as de } from "vuetify/lib/components/VList/index.mjs";
6
+ import { VAvatar as fe } from "vuetify/lib/components/VAvatar/index.mjs";
7
+ import { VBtn as W } from "vuetify/lib/components/VBtn/index.mjs";
8
+ import { VMenu as pe } from "vuetify/lib/components/VMenu/index.mjs";
9
+ import { VSkeletonLoader as me } from "vuetify/lib/components/VSkeletonLoader/index.mjs";
10
+ import { useDisplay as ve, useTheme as he } from "vuetify";
11
+ import { VCard as ye, VCardTitle as ge, VCardSubtitle as be } from "vuetify/lib/components/VCard/index.mjs";
12
+ import { VDialog as _e } from "vuetify/lib/components/VDialog/index.mjs";
13
+ import { VImg as we } from "vuetify/lib/components/VImg/index.mjs";
14
14
  import { VFooter as Le } from "vuetify/lib/components/VFooter/index.mjs";
15
15
  import { VIcon as xe } from "vuetify/lib/components/VIcon/index.mjs";
16
- const I = typeof window < "u", H = {
16
+ const N = $("http", {
17
+ state: () => ({
18
+ url: ""
19
+ }),
20
+ actions: {
21
+ async fetch(o, t = {}) {
22
+ const s = await fetch(`${this.url}${o}`, {
23
+ credentials: "include",
24
+ ...t
25
+ });
26
+ return s.status === 204 ? s : s.json();
27
+ },
28
+ async post(o, t, s = {}) {
29
+ return this.fetch(o, {
30
+ method: "POST",
31
+ headers: {
32
+ "Content-Type": "application/json"
33
+ },
34
+ body: JSON.stringify(t),
35
+ ...s
36
+ });
37
+ },
38
+ async get(o, t = {}) {
39
+ return this.fetch(o, t);
40
+ },
41
+ async delete(o, t = {}) {
42
+ return this.fetch(o, {
43
+ method: "DELETE",
44
+ ...t
45
+ });
46
+ }
47
+ }
48
+ }), C = typeof window < "u", P = {
17
49
  v: 4,
18
50
  api: "link-only",
19
51
  avatar: "",
@@ -40,279 +72,273 @@ const I = typeof window < "u", H = {
40
72
  jobs: null
41
73
  }
42
74
  }
43
- }, W = O("user", () => {
44
- const i = Y(j({}, H));
75
+ }, q = $("user", () => {
76
+ const o = Y(D({}, P));
45
77
  function t() {
46
- if (!I)
78
+ if (!C)
47
79
  return;
48
- const r = localStorage.getItem("vuetify@user"), e = r ? JSON.parse(r) : {}, c = e.v === i.v;
49
- 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.last = e.last, delete e.last)), 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.syncSettings = !0, e.disableAds = !1, e.v = 3), e.v === 3 && (e.quickbar = !1), e.v = i.v, Object.assign(i, j(i, e)), c && s();
80
+ const a = localStorage.getItem("vuetify@user"), e = a ? JSON.parse(a) : {}, p = e.v === o.v;
81
+ 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.last = e.last, delete e.last)), 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.syncSettings = !0, e.disableAds = !1, e.v = 3), e.v === 3 && (e.quickbar = !1), e.v = o.v, Object.assign(o, D(o, e)), p && s();
50
82
  }
51
83
  function s() {
52
- I && localStorage.setItem("vuetify@user", JSON.stringify(i, null, 2));
84
+ C && localStorage.setItem("vuetify@user", JSON.stringify(o, null, 2));
53
85
  }
54
86
  function n() {
55
- I && (Object.assign(i, j({}, H)), s());
87
+ C && (Object.assign(o, D({}, P)), s());
56
88
  }
57
89
  return t(), {
58
- ...Z(i),
90
+ ...Z(o),
59
91
  load: t,
60
92
  save: s,
61
93
  reset: n
62
94
  };
63
- }), g = "https://api.vuetifyjs.com", x = O("auth", () => {
64
- const i = K(null), t = W(), s = U(!1), n = A(() => {
65
- var o, l;
66
- return ((o = i.value) == null ? void 0 : o.isAdmin) || ((l = i.value) == null ? void 0 : l.sponsorships.some((f) => f.isActive));
95
+ }), w = $("auth", () => {
96
+ const o = O(null), t = N(), s = q(), n = T(!1), a = x(() => {
97
+ var i, r;
98
+ return !t.url || ((i = o.value) == null ? void 0 : i.isAdmin) || ((r = o.value) == null ? void 0 : r.sponsorships.some((c) => c.isActive));
67
99
  });
68
- let r = !1;
69
- B(i, (o) => {
70
- if (!(o != null && o.settings))
100
+ let e = !1;
101
+ H(o, (i) => {
102
+ if (!(i != null && i.settings))
71
103
  return;
72
- const l = localStorage.getItem("vuetify@user") || "{}";
73
- JSON.stringify(o.settings, null, 2) !== l && (r = !0, Object.assign(t, o.settings));
74
- }), t.$subscribe(() => {
75
- r || e(), r = !1;
104
+ const r = localStorage.getItem("vuetify@user") || "{}";
105
+ JSON.stringify(i.settings, null, 2) !== r && (e = !0, Object.assign(s, i.settings));
106
+ }), s.$subscribe(() => {
107
+ e || p(), e = !1;
76
108
  });
77
- async function e() {
109
+ async function p() {
78
110
  try {
79
- await fetch(`${g}/user/settings`, {
80
- method: "POST",
81
- credentials: "include",
82
- headers: {
83
- "Content-Type": "application/json"
84
- },
85
- body: JSON.stringify({
86
- settings: t.$state
87
- })
88
- });
89
- } catch (o) {
90
- console.error(o);
111
+ await t.post("/user/settings", { settings: s.$state });
112
+ } catch (i) {
113
+ console.error(i);
91
114
  }
92
115
  }
93
- async function c(o = !1) {
94
- if (c.promise)
95
- return c.promise;
96
- s.value = !0, c.promise = fetch(`${g}/auth/verify`, {
116
+ async function u(i = !1) {
117
+ if (u.promise)
118
+ return u.promise;
119
+ n.value = !0, u.promise = fetch(`${t.url}/auth/verify`, {
97
120
  credentials: "include",
98
- headers: o ? {
121
+ headers: i ? {
99
122
  "Cache-Control": "no-cache"
100
123
  } : void 0
101
124
  }).then(
102
- async (l) => {
103
- l.ok ? i.value = (await l.json()).user : l.status === 401 ? i.value = null : console.error(l.statusText);
125
+ async (r) => {
126
+ r.ok ? o.value = (await r.json()).user : r.status === 401 ? o.value = null : console.error(r.statusText);
104
127
  },
105
128
  () => {
106
129
  }
107
130
  ).finally(() => {
108
- s.value = !1, c.promise = null;
131
+ n.value = !1, u.promise = null;
109
132
  });
110
133
  }
111
- c.promise = null;
112
- async function h(o = "github") {
113
- s.value = !0;
114
- const l = `${g}/auth/${o}/redirect`, f = 400, D = 600, z = window.screenX + (window.innerWidth - f) / 2, X = window.screenY + (window.innerHeight - D) / 2, p = window.open(
134
+ u.promise = null;
135
+ async function _(i = "github") {
136
+ n.value = !0;
137
+ const r = `${t.url}/auth/${i}/redirect`, c = 400, m = 600, I = window.screenX + (window.innerWidth - c) / 2, A = window.screenY + (window.innerHeight - m) / 2, v = window.open(
115
138
  "",
116
139
  "vuetify:authorize:popup",
117
- `popup,left=${z},top=${X},width=${f},height=${D},resizable`
140
+ `popup,left=${I},top=${A},width=${c},height=${m},resizable`
118
141
  );
119
- if (!p) {
142
+ if (!v) {
120
143
  console.error("Failed to open popup");
121
144
  return;
122
145
  }
123
- p.location.href = l;
124
- let C = -1, T = -1;
125
- function N(_) {
126
- var P;
127
- _.origin === g && ((P = _.data) == null ? void 0 : P.type) === "auth-response" && (_.data.status === "success" ? (i.value || localStorage.setItem("vuetify@lastLoginProvider", o), i.value = _.data.body.user) : console.error(_.data.message), k());
146
+ v.location.href = r;
147
+ let U = -1, R = -1;
148
+ function E(L) {
149
+ var F;
150
+ L.origin === t.url && ((F = L.data) == null ? void 0 : F.type) === "auth-response" && (L.data.status === "success" ? (o.value || localStorage.setItem("vuetify@lastLoginProvider", i), o.value = L.data.body.user) : console.error(L.data.message), j());
128
151
  }
129
- function k() {
130
- window.removeEventListener("message", N), window.clearInterval(C), window.clearTimeout(T), p == null || p.close(), s.value = !1;
152
+ function j() {
153
+ window.removeEventListener("message", E), window.clearInterval(U), window.clearTimeout(R), v == null || v.close(), n.value = !1;
131
154
  }
132
- window.addEventListener("message", N), C = window.setInterval(() => {
133
- !p || p.closed ? (console.error("Auth popup closed"), k()) : p.postMessage({ type: "auth-request" }, "*");
134
- }, 1e3), T = window.setTimeout(() => {
135
- k(), console.error("Auth timed out");
155
+ window.addEventListener("message", E), U = window.setInterval(() => {
156
+ !v || v.closed ? (console.error("Auth popup closed"), j()) : v.postMessage({ type: "auth-request" }, "*");
157
+ }, 1e3), R = window.setTimeout(() => {
158
+ j(), console.error("Auth timed out");
136
159
  }, 120 * 1e3);
137
160
  }
138
- async function $() {
139
- s.value = !0;
161
+ async function y() {
162
+ n.value = !0;
140
163
  try {
141
- await fetch(`${g}/auth/logout`, {
142
- method: "POST",
143
- credentials: "include"
144
- }), await c(!0), i.value = null;
145
- } catch (o) {
146
- console.error(o);
164
+ await t.post("/auth/logout"), await u(!0), o.value = null;
165
+ } catch (i) {
166
+ console.error(i);
147
167
  } finally {
148
- s.value = !1;
168
+ n.value = !1;
149
169
  }
150
170
  }
151
- function y() {
171
+ function g() {
152
172
  return localStorage.getItem("vuetify@lastLoginProvider");
153
173
  }
154
- return y() && c(), {
155
- user: i,
156
- url: g,
157
- isLoading: s,
158
- verify: c,
159
- login: h,
160
- logout: $,
161
- isSubscriber: n,
162
- lastLoginProvider: y
174
+ return g() && u(), {
175
+ user: o,
176
+ url: t.url,
177
+ isLoading: n,
178
+ verify: u,
179
+ login: _,
180
+ logout: y,
181
+ isSubscriber: a,
182
+ lastLoginProvider: g
163
183
  };
164
- }), Ve = /* @__PURE__ */ L({
184
+ }), Ve = /* @__PURE__ */ V({
165
185
  __name: "VoDiscordLogin",
166
- setup(i) {
167
- const t = x();
168
- return (s, n) => (m(), v(E, {
169
- "prepend-icon": `svg:${a(R)}`,
170
- title: a(t).user ? "Connect Discord" : "Log in with Discord",
171
- subtitle: !a(t).user && a(t).lastLoginProvider() === "discord" ? "Last Used" : "",
186
+ setup(o) {
187
+ const t = w();
188
+ return (s, n) => (h(), b(z, {
189
+ "prepend-icon": `svg:${l(M)}`,
190
+ title: l(t).user ? "Connect Discord" : "Log in with Discord",
191
+ subtitle: !l(t).user && l(t).lastLoginProvider() === "discord" ? "Last Used" : "",
172
192
  nav: "",
173
193
  "base-color": "#5865F2",
174
194
  slim: "",
175
195
  variant: "flat",
176
- onClick: n[0] || (n[0] = (r) => a(t).login("discord"))
196
+ onClick: n[0] || (n[0] = (a) => l(t).login("discord"))
177
197
  }, null, 8, ["prepend-icon", "title", "subtitle"]));
178
198
  }
179
- }), Se = /* @__PURE__ */ L({
199
+ }), $e = /* @__PURE__ */ V({
180
200
  __name: "VoGithubLogin",
181
- setup(i) {
182
- const t = x();
183
- return (s, n) => (m(), v(E, {
184
- "prepend-icon": `svg:${a(F)}`,
185
- title: a(t).user ? "Connect GitHub" : "Log in with GitHub",
186
- subtitle: !a(t).user && a(t).lastLoginProvider() === "github" ? "Last Used" : "",
201
+ setup(o) {
202
+ const t = w();
203
+ return (s, n) => (h(), b(z, {
204
+ "prepend-icon": `svg:${l(G)}`,
205
+ title: l(t).user ? "Connect GitHub" : "Log in with GitHub",
206
+ subtitle: !l(t).user && l(t).lastLoginProvider() === "github" ? "Last Used" : "",
187
207
  "base-color": "#2a2a2a",
188
208
  nav: "",
189
209
  slim: "",
190
210
  variant: "flat",
191
- onClick: n[0] || (n[0] = (r) => a(t).login("github"))
211
+ onClick: n[0] || (n[0] = (a) => l(t).login("github"))
192
212
  }, null, 8, ["prepend-icon", "title", "subtitle"]));
193
213
  }
194
- }), $e = /* @__PURE__ */ L({
214
+ }), Se = /* @__PURE__ */ V({
195
215
  __name: "VoUserBtn",
196
216
  props: {
197
217
  external: Boolean
198
218
  },
199
- setup(i) {
200
- const t = i, s = x(), n = W(), r = [
219
+ setup(o) {
220
+ const t = o, s = w(), n = q(), a = x(() => [
201
221
  { title: "Options", type: "subheader" },
202
222
  {
203
223
  title: "My Dashboard",
204
- appendIcon: `svg:${ae}`,
224
+ appendIcon: `svg:${re}`,
205
225
  to: t.external ? void 0 : "/user/dashboard",
206
226
  href: t.external ? "https://vuetifyjs.com/user/dashboard/" : void 0,
207
227
  target: t.external ? "_blank" : void 0
208
228
  },
229
+ {
230
+ title: "My Subscriptions",
231
+ appendIcon: "$vuetify",
232
+ href: "https://vuetifyjs.com/user/subscriptions/",
233
+ target: "_blank"
234
+ },
209
235
  {
210
236
  title: "Logout",
211
- appendIcon: `svg:${le}`,
237
+ appendIcon: `svg:${ae}`,
212
238
  onClick: () => {
213
239
  s.logout();
214
240
  }
215
241
  }
216
- ];
217
- return (e, c) => (m(), v(M, {
242
+ ]);
243
+ return (e, p) => (h(), b(W, {
218
244
  class: "vo-user-btn",
219
- loading: a(s).isLoading,
245
+ loading: l(s).isLoading,
220
246
  icon: ""
221
247
  }, {
222
- loader: d(() => [
223
- u(he, { type: "avatar" })
248
+ loader: f(() => [
249
+ d(me, { type: "avatar" })
224
250
  ]),
225
- default: d(() => [
226
- u(me, {
227
- disabled: !a(s).user || a(s).isLoading,
251
+ default: f(() => [
252
+ d(pe, {
253
+ disabled: !l(s).user || l(s).isLoading,
228
254
  activator: "parent",
229
255
  location: "bottom end"
230
256
  }, {
231
- default: d(() => [
232
- u(G, {
233
- items: r,
257
+ default: f(() => [
258
+ d(J, {
259
+ items: a.value,
234
260
  lines: !1,
235
261
  density: "compact",
236
262
  "item-props": "",
237
263
  nav: ""
238
264
  }, {
239
- subheader: d(({ props: h }) => [
240
- u(fe, { class: "text-high-emphasis text-uppercase font-weight-black" }, {
241
- default: d(() => [
242
- w(S(h.title), 1)
265
+ subheader: f(({ props: u }) => [
266
+ d(de, { class: "text-high-emphasis text-uppercase font-weight-black" }, {
267
+ default: f(() => [
268
+ S(B(u.title), 1)
243
269
  ]),
244
270
  _: 2
245
271
  }, 1024)
246
272
  ]),
247
273
  _: 1
248
- })
274
+ }, 8, ["items"])
249
275
  ]),
250
276
  _: 1
251
277
  }, 8, ["disabled"]),
252
- a(s).user ? (m(), v(pe, {
278
+ l(s).user ? (h(), b(fe, {
253
279
  key: 0,
254
- image: a(n).avatar || a(s).user.picture || ""
255
- }, null, 8, ["image"])) : Q("", !0)
280
+ image: l(n).avatar || l(s).user.picture || ""
281
+ }, null, 8, ["image"])) : K("", !0)
256
282
  ]),
257
283
  _: 1
258
284
  }, 8, ["loading"]));
259
285
  }
260
286
  });
261
- const q = (i, t) => {
262
- const s = i.__vccOpts || i;
263
- for (const [n, r] of t)
264
- s[n] = r;
287
+ const X = (o, t) => {
288
+ const s = o.__vccOpts || o;
289
+ for (const [n, a] of t)
290
+ s[n] = a;
265
291
  return s;
266
- }, ke = /* @__PURE__ */ q($e, [["__scopeId", "data-v-8e6fff6f"]]), je = { class: "text-center mb-6" }, Ie = /* @__PURE__ */ L({
292
+ }, ke = /* @__PURE__ */ X(Se, [["__scopeId", "data-v-aeb16535"]]), Ie = { class: "text-center mb-6" }, Ae = /* @__PURE__ */ V({
267
293
  __name: "VoAuthDialog",
268
- setup(i) {
269
- const t = x(), { mdAndDown: s, lgAndUp: n } = ve(), r = ge();
270
- return (e, c) => !a(t).user && !a(t).isLoading ? (m(), v(we, {
294
+ setup(o) {
295
+ const t = w(), { mdAndDown: s, lgAndUp: n } = ve(), a = he();
296
+ return (e, p) => !l(t).user && !l(t).isLoading ? (h(), b(_e, {
271
297
  key: 0,
272
298
  "max-width": "480"
273
299
  }, {
274
- activator: d(({ props: h }) => [
275
- u(M, ee({
276
- ...h,
277
- [`${a(n) ? "append-" : ""}icon`]: `svg:${a(ce)}`,
278
- text: a(n) ? "Login" : void 0
300
+ activator: f(({ props: u }) => [
301
+ d(W, Q({
302
+ ...u,
303
+ [`${l(n) ? "append-" : ""}icon`]: `svg:${l(le)}`,
304
+ text: l(n) ? "Login" : void 0
279
305
  }, {
280
- rounded: a(s),
306
+ rounded: l(s),
281
307
  class: "text-none",
282
308
  color: "primary",
283
309
  variant: "outlined"
284
310
  }), null, 16, ["rounded"])
285
311
  ]),
286
- default: d(() => [
287
- u(ye, { class: "pt-6 pb-1 pb-sm-4 px-4 px-sm-8" }, {
288
- default: d(() => [
289
- u(J, {
290
- src: `https://cdn.vuetifyjs.com/docs/images/logos/vuetify-logo-v3-slim-text-${a(r).name.value}.svg`,
312
+ default: f(() => [
313
+ d(ye, { class: "pt-6 pb-1 pb-sm-4 px-4 px-sm-8" }, {
314
+ default: f(() => [
315
+ d(we, {
316
+ src: `https://cdn.vuetifyjs.com/docs/images/logos/vuetify-logo-v3-slim-text-${l(a).name.value}.svg`,
291
317
  class: "mb-4",
292
318
  height: "30"
293
319
  }, null, 8, ["src"]),
294
- b("div", je, [
295
- u(_e, { class: "text-h5 mb-1 text-md-h4 font-weight-bold" }, {
296
- default: d(() => [
297
- w(S(a(t).lastLoginProvider() ? "Welcome Back" : "Log in to Vuetify"), 1)
320
+ k("div", Ie, [
321
+ d(ge, { class: "text-h5 mb-1 text-md-h4 font-weight-bold" }, {
322
+ default: f(() => [
323
+ S(B(l(t).lastLoginProvider() ? "Welcome Back" : "Log in to Vuetify"), 1)
298
324
  ]),
299
325
  _: 1
300
326
  }),
301
- u(be, { class: "text-wrap" }, {
302
- default: d(() => [
303
- w(" Sign in with GitHub or Discord to save your settings and unlock exclusive subscriber perks. ")
327
+ d(be, { class: "text-wrap" }, {
328
+ default: f(() => [
329
+ S(" Sign in with GitHub or Discord to save your settings and unlock exclusive subscriber perks. ")
304
330
  ]),
305
331
  _: 1
306
332
  })
307
333
  ]),
308
- u(G, {
334
+ d(J, {
309
335
  class: "mx-auto",
310
336
  "max-width": "300",
311
337
  width: "100%"
312
338
  }, {
313
- default: d(() => [
314
- u(Se, { class: "mb-3" }),
315
- u(Ve)
339
+ default: f(() => [
340
+ d($e, { class: "mb-3" }),
341
+ d(Ve)
316
342
  ]),
317
343
  _: 1
318
344
  })
@@ -321,24 +347,23 @@ const q = (i, t) => {
321
347
  })
322
348
  ]),
323
349
  _: 1
324
- })) : (m(), v(ke, { key: 1 }));
350
+ })) : (h(), b(ke, { key: 1 }));
325
351
  }
326
- }), Ae = (i) => (se("data-v-6f6b85b8"), i = i(), ne(), i), Oe = {
327
- class: "d-inline-block me-2 text-decoration-none text-primary",
328
- href: "https://vuetifyjs.com/",
329
- target: "_blank",
330
- title: "Vuetify Documentation",
331
- rel: "noopener noreferrer"
332
- }, De = ["href", "title"], Ce = {
333
- class: "text-caption",
352
+ }), je = (o) => (se("data-v-b66944c0"), o = o(), ne(), o), De = ["href", "title"], Ce = {
353
+ class: "text-caption text-disabled",
334
354
  style: { position: "absolute", right: "16px" }
335
- }, Te = /* @__PURE__ */ Ae(() => /* @__PURE__ */ b("span", { class: "d-none d-sm-inline-block" }, "Vuetify, LLC", -1)), Ne = /* @__PURE__ */ L({
355
+ }, Oe = /* @__PURE__ */ je(() => /* @__PURE__ */ k("span", { class: "d-none d-sm-inline-block" }, "Vuetify, LLC", -1)), Te = /* @__PURE__ */ V({
336
356
  __name: "VoFooter",
337
- setup(i) {
357
+ setup(o) {
338
358
  const t = [
359
+ {
360
+ title: "Vuetify Documentation",
361
+ icon: "$vuetify",
362
+ href: "https://vuetifyjs.com/"
363
+ },
339
364
  {
340
365
  title: "Vuetify Support",
341
- icon: `svg:${ue}`,
366
+ icon: `svg:${ce}`,
342
367
  href: "https://support.vuetifyjs.com/"
343
368
  },
344
369
  {
@@ -348,139 +373,169 @@ const q = (i, t) => {
348
373
  },
349
374
  {
350
375
  title: "Vuetify GitHub",
351
- icon: `svg:${F}`,
376
+ icon: `svg:${G}`,
352
377
  href: "https://github.com/vuetifyjs/vuetify"
353
378
  },
354
379
  {
355
380
  title: "Vuetify Discord",
356
- icon: `svg:${R}`,
381
+ icon: `svg:${M}`,
357
382
  href: "https://community.vuetifyjs.com/"
358
383
  },
359
384
  {
360
385
  title: "Vuetify Reddit",
361
- icon: `svg:${de}`,
386
+ icon: `svg:${ue}`,
362
387
  href: "https://reddit.com/r/vuetifyjs"
363
388
  }
364
389
  ];
365
- return (s, n) => (m(), v(Le, {
390
+ return (s, n) => (h(), b(Le, {
366
391
  class: "vo-footer",
367
392
  theme: "dark",
368
393
  height: "40"
369
394
  }, {
370
- default: d(() => [
371
- b("a", Oe, [
372
- u(J, {
373
- alt: "Vuetify logo",
374
- src: "https://cdn.vuetifyjs.com/docs/images/logos/v.svg",
375
- width: "32"
376
- })
377
- ]),
378
- (m(), te(oe, null, ie(t, (r) => b("a", {
379
- key: r.title,
380
- href: r.href,
381
- title: r.title,
395
+ default: f(() => [
396
+ (h(), ee(te, null, oe(t, (a) => k("a", {
397
+ key: a.title,
398
+ href: a.href,
399
+ title: a.title,
382
400
  class: "d-inline-block mx-2 social-link",
383
401
  target: "_blank",
384
402
  rel: "noopener noreferrer"
385
403
  }, [
386
- u(xe, { size: "18" }, {
387
- default: d(() => [
388
- w(S(r.icon), 1)
389
- ]),
390
- _: 2
391
- }, 1024)
404
+ d(xe, {
405
+ icon: a.icon,
406
+ size: a.icon === "$vuetify" ? 24 : 16
407
+ }, null, 8, ["icon", "size"])
392
408
  ], 8, De)), 64)),
393
- b("div", Ce, [
394
- w(" © 2016-" + S((/* @__PURE__ */ new Date()).getFullYear()) + " ", 1),
395
- Te
409
+ k("div", Ce, [
410
+ S(" © 2016-" + B((/* @__PURE__ */ new Date()).getFullYear()) + " ", 1),
411
+ Oe
396
412
  ])
397
413
  ]),
398
414
  _: 1
399
415
  }));
400
416
  }
401
417
  });
402
- const Pe = /* @__PURE__ */ q(Ne, [["__scopeId", "data-v-6f6b85b8"]]), V = "https://api.vuetifyjs.com", Ke = O("one", () => {
403
- const t = new URLSearchParams(window.location.search).get("session_id"), s = x(), n = U(!1), r = A(() => {
404
- var o;
405
- return (o = s.user) == null ? void 0 : o.sponsorships.find((l) => l.platform === "stripe" && l.tierName.startsWith("sub_"));
406
- }), e = A(() => {
407
- var o;
408
- return (o = r.value) == null ? void 0 : o.isActive;
418
+ const He = /* @__PURE__ */ X(Te, [["__scopeId", "data-v-b66944c0"]]), Ze = $("bins", () => {
419
+ const o = w(), t = N(), s = O([]), n = O(), a = T(-1), e = x(() => !o.user || !n.value ? !1 : o.user.id === n.value.owner.id);
420
+ H(() => n, () => {
421
+ window.clearTimeout(a.value), a.value = window.setTimeout(() => {
422
+ !n.value || !e.value || y(n.value, n.value.id);
423
+ }, 100);
424
+ }, { deep: !0 });
425
+ async function p() {
426
+ const r = await t.get("/one/bins");
427
+ return s.value = r.bins, r.bins;
428
+ }
429
+ async function u(r) {
430
+ const c = await t.delete(`/one/bins/${r}`);
431
+ return s.value = s.value.filter((m) => m.id !== r), c;
432
+ }
433
+ async function _(r) {
434
+ const c = await t.post("/one/bins", { bin: r });
435
+ return s.value.push(c.bin), n.value = c.bin, c;
436
+ }
437
+ async function y(r, c) {
438
+ const m = await t.post(`/one/bins/${c}`, { bin: r }), I = s.value.findIndex((A) => A.id === c);
439
+ return s.value.splice(I, 1, m.bin), m;
440
+ }
441
+ async function g(r, c) {
442
+ const m = c ? await y(r, c) : await _(r);
443
+ return n.value = m.bin, m;
444
+ }
445
+ async function i(r) {
446
+ const c = await t.get(`/one/bins/${r}`);
447
+ return n.value = c.bin, c;
448
+ }
449
+ return {
450
+ isOwner: e,
451
+ all: s,
452
+ create: _,
453
+ delete: u,
454
+ current: n,
455
+ find: i,
456
+ get: p,
457
+ update: y,
458
+ updateOrCreate: g
459
+ };
460
+ }), Ke = $("one", () => {
461
+ const t = new URLSearchParams(window.location.search).get("session_id"), s = w(), n = N(), a = T(!1), e = x(() => {
462
+ var i;
463
+ return (i = s.user) == null ? void 0 : i.sponsorships.find((r) => r.platform === "stripe" && r.tierName.startsWith("sub_"));
464
+ }), p = x(() => {
465
+ var i;
466
+ return (i = e.value) == null ? void 0 : i.isActive;
409
467
  });
410
- re(async () => {
411
- t && await c();
412
- }), B(e, (o) => {
413
- o && y();
468
+ ie(async () => {
469
+ t && await u();
470
+ }), H(p, (i) => {
471
+ i && g();
414
472
  });
415
- async function c() {
473
+ async function u() {
416
474
  try {
417
- n.value = !0;
418
- const o = await fetch(`${V}/one/activate`, {
419
- method: "POST",
420
- credentials: "include",
421
- headers: {
422
- "Content-Type": "application/json"
423
- },
424
- body: JSON.stringify({ sessionId: t })
425
- }).then((l) => l.json());
426
- s.user = o.user;
475
+ a.value = !0;
476
+ const i = await n.post("/one/activate", { sessionId: t });
477
+ s.user = i.user;
427
478
  } catch {
428
479
  } finally {
429
- n.value = !1;
480
+ a.value = !1;
430
481
  }
431
482
  }
432
- async function h() {
433
- n.value = !0, window.location.href = `${V}/one/subscribe`;
483
+ async function _() {
484
+ a.value = !0, window.location.href = `${n.url}/one/subscribe`;
434
485
  }
435
- async function $() {
436
- var o;
437
- if (r.value)
486
+ async function y() {
487
+ var i;
488
+ if (e.value)
438
489
  try {
439
- n.value = !0;
440
- const l = await fetch(`${V}/one/cancel?subscriptionId=${(o = r.value) == null ? void 0 : o.tierName}`, {
441
- method: "POST",
442
- credentials: "include"
443
- }).then((f) => f.json());
444
- s.user = l.user;
490
+ a.value = !0;
491
+ const r = await n.post(
492
+ `/one/cancel?subscriptionId=${(i = e.value) == null ? void 0 : i.tierName}`
493
+ );
494
+ s.user = r.user;
445
495
  } catch {
446
496
  } finally {
447
- n.value = !1;
497
+ a.value = !1;
448
498
  }
449
499
  }
450
- async function y() {
451
- var o;
452
- if (r.value)
500
+ async function g() {
501
+ var i;
502
+ if (e.value)
453
503
  try {
454
- n.value = !0;
455
- const l = await fetch(`${V}/one/verify?subscriptionId=${(o = r.value) == null ? void 0 : o.tierName}`, {
456
- method: "POST",
457
- credentials: "include"
458
- }).then((f) => f.json());
459
- s.user = l.user;
504
+ a.value = !0;
505
+ const r = await n.post(
506
+ `/one/verify?subscriptionId=${(i = e.value) == null ? void 0 : i.tierName}`
507
+ );
508
+ s.user = r.user;
460
509
  } catch {
461
510
  } finally {
462
- n.value = !1;
511
+ a.value = !1;
463
512
  }
464
513
  }
465
514
  return {
466
- activate: c,
467
- cancel: $,
468
- subscribe: h,
469
- verify: y,
470
- subscription: r,
471
- isLoading: n,
472
- isSubscriber: e
515
+ activate: u,
516
+ cancel: y,
517
+ subscribe: _,
518
+ verify: g,
519
+ subscription: e,
520
+ isLoading: a,
521
+ isSubscriber: p
473
522
  };
474
523
  });
475
524
  function Qe() {
476
- function i(t) {
477
- t.component("VoAuthDialog", Ie), t.component("VoFooter", Pe);
525
+ function o(t) {
526
+ t.component("VoAuthDialog", Ae), t.component("VoFooter", He);
478
527
  }
479
- return { install: i };
528
+ return { install: o };
529
+ }
530
+ function et(o) {
531
+ o.store.url = "https://api.vuetifyjs.com";
480
532
  }
481
533
  export {
482
534
  Qe as createOne,
483
- x as useAuthStore,
535
+ et as one,
536
+ w as useAuthStore,
537
+ Ze as useBinsStore,
538
+ N as useHttpStore,
484
539
  Ke as useOneStore,
485
- W as useUserStore
540
+ q as useUserStore
486
541
  };
package/dist/style.css CHANGED
@@ -1 +1 @@
1
- .vo-user-btn[data-v-8e6fff6f] .v-skeleton-loader__avatar{min-height:40px;height:40px;width:40px;max-height:40px;min-width:40px;max-width:40px}.social-link[data-v-6f6b85b8] .v-icon{color:#1976d252;text-decoration:none;transition:.2s ease-in-out}.social-link[data-v-6f6b85b8] .v-icon:hover{color:#1976d2}
1
+ .vo-user-btn[data-v-aeb16535] .v-skeleton-loader__avatar{min-height:40px;height:40px;width:40px;max-height:40px;min-width:40px;max-width:40px}.social-link[data-v-b66944c0] .v-icon{color:rgba(var(--v-theme-on-background),var(--v-disabled-opacity));text-decoration:none;transition:.2s ease-in-out}.social-link[data-v-b66944c0] .v-icon:hover{color:#1976d2}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vuetify/one",
3
- "version": "0.1.3",
3
+ "version": "0.3.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -21,10 +21,13 @@
21
21
  "scripts": {
22
22
  "dev": "vite",
23
23
  "build": "vite build --config vite.build.config.ts && yarn build:types",
24
+ "build:dev": "vite build --mode development --config vite.build.config.ts ",
24
25
  "build:types": "rimraf types-temp && vue-tsc --pretty -p tsconfig.json && rollup --config rollup.types.config.js && rimraf types-temp",
25
- "watch": "yarn build --mode development --watch",
26
+ "watch": "yarn build:dev --watch",
26
27
  "preview": "vite preview",
27
- "lint": "eslint . --ext .ts,.vue --fix --ignore-path .gitignore"
28
+ "lint": "eslint . --ext .ts,.vue --fix --ignore-path .gitignore",
29
+ "test": "vitest",
30
+ "coverage": "vitest run --coverage"
28
31
  },
29
32
  "peerDependencies": {
30
33
  "@mdi/js": "6.2.95",
@@ -51,6 +54,7 @@
51
54
  "eslint-plugin-node": "^11.1.0",
52
55
  "eslint-plugin-promise": "^6.1.1",
53
56
  "eslint-plugin-vue": "^9.16.1",
57
+ "jsdom": "^23.0.1",
54
58
  "lodash-es": "^4.17.21",
55
59
  "pinia": "^2.0.0",
56
60
  "rimraf": "^5.0.5",
@@ -65,6 +69,7 @@
65
69
  "vite": "^4.2.0",
66
70
  "vite-plugin-vue-layouts": "^0.8.0",
67
71
  "vite-plugin-vuetify": "^1.0.0",
72
+ "vitest": "^1.1.0",
68
73
  "vue": "^3.2.0",
69
74
  "vue-router": "^4.0.0",
70
75
  "vue-tsc": "^1.2.0",