@hellocoop/vue 1.0.1 → 2.0.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.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import type { Claims } from './types';
1
+ import { Claims } from './types';
2
+
2
3
  type AuthCookie = {
3
4
  sub: string;
4
5
  iat: number;
@@ -1,4 +1,5 @@
1
- import { Button, type ProviderHint, type Scope } from '../types';
1
+ import { Button, ProviderHint, Scope } from '../types';
2
+
2
3
  type Props = {
3
4
  label?: string;
4
5
  style?: any;
@@ -6,20 +7,20 @@ type Props = {
6
7
  theme?: Button.Theme;
7
8
  hover?: Button.Hover;
8
9
  scope?: Scope[];
9
- updateScope?: Button.UpdateScope;
10
+ update?: Button.Update;
10
11
  targetURI?: string;
11
12
  providerHint?: ProviderHint[];
12
13
  showLoader?: boolean;
13
14
  disabled?: boolean;
14
15
  };
15
- declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<Props>, {
16
+ declare const _default: import('vue').DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<Props>, {
16
17
  label: string;
17
18
  color: string;
18
19
  theme: string;
19
20
  hover: string;
20
21
  showLoader: boolean;
21
22
  disabled: boolean;
22
- }>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<Props>, {
23
+ }>, {}, unknown, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<Props>, {
23
24
  label: string;
24
25
  color: string;
25
26
  theme: string;
@@ -1,2 +1,2 @@
1
- declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>;
1
+ declare const _default: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{}>>, {}, {}>;
2
2
  export default _default;
@@ -1,2 +1,2 @@
1
- declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>;
1
+ declare const _default: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{}>>, {}, {}>;
2
2
  export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{}>>, {}, {}>;
2
+ export default _default;
package/dist/index.d.ts CHANGED
@@ -1,11 +1,6 @@
1
1
  export { default as ContinueButton } from './buttons/ContinueButton.vue';
2
2
  export { default as LoginButton } from './buttons/LoginButton.vue';
3
- export { default as UpdateEmailButton } from './buttons/UpdateEmailButton.vue';
4
- export { default as UpdatePictureButton } from './buttons/UpdatePictureButton.vue';
5
- export { default as UpdateTwitterButton } from './buttons/UpdateTwitterButton.vue';
6
- export { default as UpdateDiscordButton } from './buttons/UpdateDiscordButton.vue';
7
- export { default as UpdateGitHubButton } from './buttons/UpdateGitHubButton.vue';
8
- export { default as UpdateGitLabButton } from './buttons/UpdateGitLabButton.vue';
3
+ export { default as UpdateProfileButton } from './buttons/UpdateProfileButton.vue';
9
4
  export { default as LoggedIn } from './login-status/LoggedIn.vue';
10
5
  export { default as LoggedOut } from './login-status/LoggedOut.vue';
11
6
  export * from './auth.js';
package/dist/index.mjs CHANGED
@@ -1,26 +1,26 @@
1
- import { provide as v, inject as H, defineComponent as a, onMounted as S, ref as B, openBlock as l, createElementBlock as p, normalizeClass as U, unref as g, normalizeStyle as k, createElementVNode as y, createBlock as i, renderSlot as f, createCommentVNode as b } from "vue";
2
- const s = {
1
+ import { provide as oe, inject as le, defineComponent as C, onMounted as Q, ref as X, openBlock as E, createElementBlock as M, normalizeClass as ue, unref as Y, normalizeStyle as se, createElementVNode as ce, createBlock as j, getCurrentInstance as fe, reactive as de, onUnmounted as he, watch as ve, isReadonly as ge, toRefs as ye, renderSlot as Z, createCommentVNode as ee } from "vue";
2
+ const _ = {
3
3
  login: "/api/hellocoop?login=true",
4
4
  auth: "/api/hellocoop?auth=true",
5
5
  logout: "/api/hellocoop?logout=true"
6
- }, m = "HelloAuth", P = () => H(m), G = {
6
+ }, te = "HelloAuth", me = () => le(te), Be = {
7
7
  props: ["auth", "config"],
8
- setup(e) {
9
- var o, t, n;
10
- (o = e == null ? void 0 : e.config) != null && o.login && (s.login = e.config.login), (t = e == null ? void 0 : e.config) != null && t.auth && (s.auth = e.config.auth), (n = e == null ? void 0 : e.config) != null && n.logout && (s.logout = e.config.logout), v(m, e.auth);
8
+ setup(t) {
9
+ var n, e, i;
10
+ (n = t == null ? void 0 : t.config) != null && n.login && (_.login = t.config.login), (e = t == null ? void 0 : t.config) != null && e.auth && (_.auth = t.config.auth), (i = t == null ? void 0 : t.config) != null && i.logout && (_.logout = t.config.logout), oe(te, t.auth);
11
11
  },
12
12
  render() {
13
13
  return this.$slots.default();
14
14
  }
15
15
  };
16
- var h;
17
- ((e) => {
18
- e.STYLES_URL = "https://cdn.hello.coop/css/hello-btn.css", e.HOVER_MAPPING = {
16
+ var A;
17
+ ((t) => {
18
+ t.STYLES_URL = "https://cdn.hello.coop/css/hello-btn.css", t.HOVER_MAPPING = {
19
19
  pop: "",
20
20
  glow: "hello-btn-hover-glow",
21
21
  flare: "hello-btn-hover-flare",
22
22
  none: "hello-btn-hover-none"
23
- }, e.CLASS_MAPPING = {
23
+ }, t.CLASS_MAPPING = {
24
24
  black: {
25
25
  "ignore-light": "",
26
26
  "ignore-dark": "hello-btn-black-on-dark",
@@ -34,8 +34,8 @@ var h;
34
34
  "aware-static": "hello-btn-white-and-static"
35
35
  }
36
36
  };
37
- })(h || (h = {}));
38
- const I = ["disabled"], $ = ["innerHTML"], r = /* @__PURE__ */ a({
37
+ })(A || (A = {}));
38
+ const be = ["disabled"], we = ["innerHTML"], U = /* @__PURE__ */ C({
39
39
  __name: "BaseButton",
40
40
  props: {
41
41
  label: { default: "ō&nbsp;&nbsp;&nbsp;Continue with Hellō" },
@@ -44,152 +44,488 @@ const I = ["disabled"], $ = ["innerHTML"], r = /* @__PURE__ */ a({
44
44
  theme: { default: "ignore-light" },
45
45
  hover: { default: "pop" },
46
46
  scope: {},
47
- updateScope: {},
47
+ update: { type: Boolean },
48
48
  targetURI: {},
49
49
  providerHint: {},
50
50
  showLoader: { type: Boolean, default: !1 },
51
51
  disabled: { type: Boolean, default: !1 }
52
52
  },
53
- setup(e) {
54
- let o = !1;
55
- S(() => {
56
- typeof window < "u" && !o && (Array.from(document.head.getElementsByTagName("link")).find(
57
- (_) => {
58
- var d;
59
- return _.getAttribute("rel") === "stylesheet" && ((d = _.getAttribute("href")) == null ? void 0 : d.startsWith(h.STYLES_URL));
53
+ setup(t) {
54
+ let n = !1;
55
+ Q(() => {
56
+ typeof window < "u" && !n && (Array.from(document.head.getElementsByTagName("link")).find(
57
+ (f) => {
58
+ var u;
59
+ return f.getAttribute("rel") === "stylesheet" && ((u = f.getAttribute("href")) == null ? void 0 : u.startsWith(A.STYLES_URL));
60
60
  }
61
- ) || console.warn("Could not find Hellō stylesheet. Please add to pages with Hellō buttons. See http://hello.dev/docs/buttons/#stylesheet for more info."), o = !0);
61
+ ) || console.warn("Could not find Hellō stylesheet. Please add to pages with Hellō buttons. See http://hello.dev/docs/buttons/#stylesheet for more info."), n = !0);
62
62
  });
63
- const t = B(!1), n = e, c = new URL(s.login, window.location.origin);
64
- n.scope && c.searchParams.set("scope", n.scope.join(" ")), c.searchParams.set("target_uri", n.targetURI || window.location.pathname), n.updateScope && c.searchParams.set("scope", "profile_update " + n.updateScope), n.providerHint && c.searchParams.set("provider_hint", n.providerHint.join(" "));
65
- const L = () => {
66
- t.value = !0, window.location.href = c.href;
63
+ const e = X(!1), i = t, a = new URL(_.login, window.location.origin);
64
+ i.scope && a.searchParams.set("scope", i.scope.join(" ")), a.searchParams.set("target_uri", i.targetURI || window.location.pathname), i.update && a.searchParams.set("prompt", "consent"), i.providerHint && a.searchParams.set("provider_hint", i.providerHint.join(" "));
65
+ const r = () => {
66
+ e.value = !0, window.location.href = a.href;
67
67
  };
68
- return (u, _) => {
69
- var d;
70
- return l(), p("button", {
71
- onClick: L,
72
- class: U(["hello-btn", (d = g(h).CLASS_MAPPING[n.color]) == null ? void 0 : d[n.theme], g(h).HOVER_MAPPING[u.hover], (u.showLoader || t.value) && "hello-btn-loader"]),
73
- disabled: n.disabled || t.value,
74
- style: k(u.style)
68
+ return (l, f) => {
69
+ var u;
70
+ return E(), M("button", {
71
+ onClick: r,
72
+ class: ue(["hello-btn", (u = Y(A).CLASS_MAPPING[i.color]) == null ? void 0 : u[i.theme], Y(A).HOVER_MAPPING[l.hover], (l.showLoader || e.value) && "hello-btn-loader"]),
73
+ disabled: i.disabled || e.value,
74
+ style: se(l.style)
75
75
  }, [
76
- y("span", { innerHTML: u.label }, null, 8, $)
77
- ], 14, I);
76
+ ce("span", { innerHTML: l.label }, null, 8, we)
77
+ ], 14, be);
78
78
  };
79
79
  }
80
- }), T = /* @__PURE__ */ a({
80
+ }), De = /* @__PURE__ */ C({
81
81
  __name: "ContinueButton",
82
- setup(e) {
83
- return (o, t) => (l(), i(r));
82
+ setup(t) {
83
+ return (n, e) => (E(), j(U));
84
84
  }
85
- }), x = /* @__PURE__ */ a({
85
+ }), xe = /* @__PURE__ */ C({
86
86
  __name: "LoginButton",
87
- setup(e) {
88
- return (o, t) => (l(), i(r, { label: "ō   Login with Hellō" }));
89
- }
90
- }), M = /* @__PURE__ */ a({
91
- __name: "UpdateEmailButton",
92
- setup(e) {
93
- return (o, t) => (l(), i(r, {
94
- label: "ō   Update Email with Hellō",
95
- updateScope: "email"
96
- }));
87
+ setup(t) {
88
+ return (n, e) => (E(), j(U, { label: "ō   Login with Hellō" }));
97
89
  }
98
- }), N = /* @__PURE__ */ a({
99
- __name: "UpdatePictureButton",
100
- setup(e) {
101
- return (o, t) => (l(), i(r, {
102
- label: "ō   Update Picture with Hellō",
103
- updateScope: "picture"
90
+ }), $e = /* @__PURE__ */ C({
91
+ __name: "UpdateProfileButton",
92
+ setup(t) {
93
+ return (n, e) => (E(), j(U, {
94
+ label: "ō   Update Profile with Hellō",
95
+ update: !0
104
96
  }));
105
97
  }
106
- }), O = /* @__PURE__ */ a({
107
- __name: "UpdateTwitterButton",
108
- setup(e) {
109
- return (o, t) => (l(), i(r, {
110
- label: "ō   Update Twitter with Hellō",
111
- updateScope: "twitter"
112
- }));
98
+ });
99
+ var D = /* @__PURE__ */ new WeakMap(), q = 0;
100
+ function _e(t) {
101
+ if (!t.length)
102
+ return "";
103
+ for (var n = "arg", e = 0; e < t.length; ++e) {
104
+ var i = void 0;
105
+ t[e] === null || typeof t[e] != "object" && typeof t[e] != "function" ? typeof t[e] == "string" ? i = '"' + t[e] + '"' : i = String(t[e]) : D.has(t[e]) ? i = D.get(t[e]) : (i = q, D.set(t[e], q++)), n += "@" + i;
113
106
  }
114
- }), V = /* @__PURE__ */ a({
115
- __name: "UpdateDiscordButton",
116
- setup(e) {
117
- return (o, t) => (l(), i(r, {
118
- label: "ō   Update Discord with Hellō",
119
- updateScope: "discord"
120
- }));
107
+ return n;
108
+ }
109
+ function pe(t) {
110
+ if (typeof t == "function")
111
+ try {
112
+ t = t();
113
+ } catch {
114
+ t = "";
115
+ }
116
+ return Array.isArray(t) ? t = _e(t) : t = String(t || ""), t;
117
+ }
118
+ var F = (
119
+ /** @class */
120
+ function() {
121
+ function t(n) {
122
+ n === void 0 && (n = 0), this.items = /* @__PURE__ */ new Map(), this.ttl = n;
123
+ }
124
+ return t.prototype.serializeKey = function(n) {
125
+ return pe(n);
126
+ }, t.prototype.get = function(n) {
127
+ var e = this.serializeKey(n);
128
+ return this.items.get(e);
129
+ }, t.prototype.set = function(n, e, i) {
130
+ var a = this.serializeKey(n), r = i || this.ttl, l = Date.now(), f = {
131
+ data: e,
132
+ createdAt: l,
133
+ expiresAt: r ? l + r : 1 / 0
134
+ };
135
+ this.dispatchExpire(r, f, a), this.items.set(a, f);
136
+ }, t.prototype.dispatchExpire = function(n, e, i) {
137
+ var a = this;
138
+ n && setTimeout(function() {
139
+ var r = Date.now(), l = r >= e.expiresAt;
140
+ l && a.delete(i);
141
+ }, n);
142
+ }, t.prototype.delete = function(n) {
143
+ this.items.delete(n);
144
+ }, t;
145
+ }()
146
+ );
147
+ function Re() {
148
+ return typeof navigator.onLine < "u" ? navigator.onLine : !0;
149
+ }
150
+ function Le() {
151
+ return typeof document < "u" && typeof document.visibilityState < "u" ? document.visibilityState !== "hidden" : !0;
152
+ }
153
+ var Ce = function(t) {
154
+ return fetch(t).then(function(n) {
155
+ return n.json();
156
+ });
157
+ };
158
+ const x = {
159
+ isOnline: Re,
160
+ isDocumentVisible: Le,
161
+ fetcher: Ce
162
+ };
163
+ var m = function() {
164
+ return m = Object.assign || function(t) {
165
+ for (var n, e = 1, i = arguments.length; e < i; e++) {
166
+ n = arguments[e];
167
+ for (var a in n) Object.prototype.hasOwnProperty.call(n, a) && (t[a] = n[a]);
168
+ }
169
+ return t;
170
+ }, m.apply(this, arguments);
171
+ }, R = function(t, n, e, i) {
172
+ function a(r) {
173
+ return r instanceof e ? r : new e(function(l) {
174
+ l(r);
175
+ });
121
176
  }
122
- }), j = /* @__PURE__ */ a({
123
- __name: "UpdateGitHubButton",
124
- setup(e) {
125
- return (o, t) => (l(), i(r, {
126
- label: "ō   Update GitHub with Hellō",
127
- updateScope: "github"
128
- }));
177
+ return new (e || (e = Promise))(function(r, l) {
178
+ function f(s) {
179
+ try {
180
+ o(i.next(s));
181
+ } catch (g) {
182
+ l(g);
183
+ }
184
+ }
185
+ function u(s) {
186
+ try {
187
+ o(i.throw(s));
188
+ } catch (g) {
189
+ l(g);
190
+ }
191
+ }
192
+ function o(s) {
193
+ s.done ? r(s.value) : a(s.value).then(f, u);
194
+ }
195
+ o((i = i.apply(t, n || [])).next());
196
+ });
197
+ }, L = function(t, n) {
198
+ var e = { label: 0, sent: function() {
199
+ if (r[0] & 1) throw r[1];
200
+ return r[1];
201
+ }, trys: [], ops: [] }, i, a, r, l;
202
+ return l = { next: f(0), throw: f(1), return: f(2) }, typeof Symbol == "function" && (l[Symbol.iterator] = function() {
203
+ return this;
204
+ }), l;
205
+ function f(o) {
206
+ return function(s) {
207
+ return u([o, s]);
208
+ };
209
+ }
210
+ function u(o) {
211
+ if (i) throw new TypeError("Generator is already executing.");
212
+ for (; e; ) try {
213
+ if (i = 1, a && (r = o[0] & 2 ? a.return : o[0] ? a.throw || ((r = a.return) && r.call(a), 0) : a.next) && !(r = r.call(a, o[1])).done) return r;
214
+ switch (a = 0, r && (o = [o[0] & 2, r.value]), o[0]) {
215
+ case 0:
216
+ case 1:
217
+ r = o;
218
+ break;
219
+ case 4:
220
+ return e.label++, { value: o[1], done: !1 };
221
+ case 5:
222
+ e.label++, a = o[1], o = [0];
223
+ continue;
224
+ case 7:
225
+ o = e.ops.pop(), e.trys.pop();
226
+ continue;
227
+ default:
228
+ if (r = e.trys, !(r = r.length > 0 && r[r.length - 1]) && (o[0] === 6 || o[0] === 2)) {
229
+ e = 0;
230
+ continue;
231
+ }
232
+ if (o[0] === 3 && (!r || o[1] > r[0] && o[1] < r[3])) {
233
+ e.label = o[1];
234
+ break;
235
+ }
236
+ if (o[0] === 6 && e.label < r[1]) {
237
+ e.label = r[1], r = o;
238
+ break;
239
+ }
240
+ if (r && e.label < r[2]) {
241
+ e.label = r[2], e.ops.push(o);
242
+ break;
243
+ }
244
+ r[2] && e.ops.pop(), e.trys.pop();
245
+ continue;
246
+ }
247
+ o = n.call(t, e);
248
+ } catch (s) {
249
+ o = [6, s], a = 0;
250
+ } finally {
251
+ i = r = 0;
252
+ }
253
+ if (o[0] & 5) throw o[1];
254
+ return { value: o[0] ? o[1] : void 0, done: !0 };
255
+ }
256
+ }, Ee = function(t, n) {
257
+ var e = typeof Symbol == "function" && t[Symbol.iterator];
258
+ if (!e) return t;
259
+ var i = e.call(t), a, r = [], l;
260
+ try {
261
+ for (; (n === void 0 || n-- > 0) && !(a = i.next()).done; ) r.push(a.value);
262
+ } catch (f) {
263
+ l = { error: f };
264
+ } finally {
265
+ try {
266
+ a && !a.done && (e = i.return) && e.call(i);
267
+ } finally {
268
+ if (l) throw l.error;
269
+ }
270
+ }
271
+ return r;
272
+ }, Ie = function(t, n, e) {
273
+ if (e || arguments.length === 2) for (var i = 0, a = n.length, r; i < a; i++)
274
+ (r || !(i in n)) && (r || (r = Array.prototype.slice.call(n, 0, i)), r[i] = n[i]);
275
+ return t.concat(r || Array.prototype.slice.call(n));
276
+ }, ne = new F(), k = new F(), $ = new F(), re = {
277
+ cache: ne,
278
+ refreshInterval: 0,
279
+ ttl: 0,
280
+ serverTTL: 1e3,
281
+ dedupingInterval: 2e3,
282
+ revalidateOnFocus: !0,
283
+ revalidateDebounce: 0,
284
+ shouldRetryOnError: !0,
285
+ errorRetryInterval: 5e3,
286
+ errorRetryCount: 5,
287
+ fetcher: x.fetcher,
288
+ isOnline: x.isOnline,
289
+ isDocumentVisible: x.isDocumentVisible
290
+ };
291
+ function Se(t, n, e) {
292
+ var i = k.get(t);
293
+ if (i)
294
+ i.data.push(n);
295
+ else {
296
+ var a = 5e3;
297
+ k.set(t, [n], e > 0 ? e + a : e);
298
+ }
299
+ }
300
+ function Ae(t, n, e) {
301
+ if (e.isDocumentVisible() && !(e.errorRetryCount !== void 0 && n > e.errorRetryCount)) {
302
+ var i = Math.min(n || 0, e.errorRetryCount), a = i * e.errorRetryInterval;
303
+ setTimeout(function() {
304
+ t(null, { errorRetryCount: i + 1, shouldRetryOnError: !0 });
305
+ }, a);
129
306
  }
130
- }), D = /* @__PURE__ */ a({
131
- __name: "UpdateGitLabButton",
132
- setup(e) {
133
- return (o, t) => (l(), i(r, {
134
- label: "ō   Update GitLab with Hellō",
135
- updateScope: "gitlab"
307
+ }
308
+ var J = function(t, n, e, i) {
309
+ return e === void 0 && (e = ne), i === void 0 && (i = re.ttl), R(void 0, void 0, void 0, function() {
310
+ var a, r, l, f, u, o, s;
311
+ return L(this, function(g) {
312
+ switch (g.label) {
313
+ case 0:
314
+ if (!Oe(n)) return [3, 5];
315
+ g.label = 1;
316
+ case 1:
317
+ return g.trys.push([1, 3, , 4]), [4, n];
318
+ case 2:
319
+ return a = g.sent(), [3, 4];
320
+ case 3:
321
+ return f = g.sent(), r = f, [3, 4];
322
+ case 4:
323
+ return [3, 6];
324
+ case 5:
325
+ a = n, g.label = 6;
326
+ case 6:
327
+ if (l = !1, u = { data: a, error: r, isValidating: l }, typeof a < "u")
328
+ try {
329
+ e.set(t, u, i);
330
+ } catch (v) {
331
+ console.error("swrv(mutate): failed to set cache", v);
332
+ }
333
+ return o = k.get(t), o && o.data.length && (s = o.data.filter(function(v) {
334
+ return v.key === t;
335
+ }), s.forEach(function(v, d) {
336
+ typeof u.data < "u" && (v.data = u.data), v.error = u.error, v.isValidating = u.isValidating;
337
+ var b = d === s.length - 1;
338
+ b || delete s[d];
339
+ }), s = s.filter(Boolean)), [2, u];
340
+ }
341
+ });
342
+ });
343
+ };
344
+ function Ve() {
345
+ for (var t = this, n = [], e = 0; e < arguments.length; e++)
346
+ n[e] = arguments[e];
347
+ var i, a, r = m({}, re), l = !1, f = !1, u = fe(), o = (u == null ? void 0 : u.proxy) || u;
348
+ if (!o)
349
+ return console.error("Could not get current instance, check to make sure that `useSwrv` is declared in the top level of the setup function."), null;
350
+ var s = (o == null ? void 0 : o.$isServer) || !1;
351
+ n.length >= 1 && (i = n[0]), n.length >= 2 && (a = n[1]), n.length > 2 && (r = m(m({}, r), n[2]));
352
+ var g = s ? r.serverTTL : r.ttl, v = typeof i == "function" ? i : X(i);
353
+ typeof a > "u" && (a = r.fetcher);
354
+ var d = null;
355
+ d || (d = de({
356
+ data: void 0,
357
+ error: void 0,
358
+ isValidating: !0,
359
+ key: null
360
+ }));
361
+ var b = function(h, c) {
362
+ return R(t, void 0, void 0, function() {
363
+ var N, y, I, S, P, z, H, G = this;
364
+ return L(this, function(T) {
365
+ switch (T.label) {
366
+ case 0:
367
+ return N = d.data === void 0, y = v.value, y ? (I = r.cache.get(y), S = I && I.data, d.isValidating = !0, S && (d.data = S.data, d.error = S.error), P = h || a, !P || !r.isDocumentVisible() && !N || (c == null ? void 0 : c.forceRevalidate) !== void 0 && !(c != null && c.forceRevalidate) ? (d.isValidating = !1, [
368
+ 2
369
+ /*return*/
370
+ ]) : I && (z = !!(Date.now() - I.createdAt >= r.dedupingInterval || c != null && c.forceRevalidate), !z) ? (d.isValidating = !1, [
371
+ 2
372
+ /*return*/
373
+ ]) : (H = function() {
374
+ return R(G, void 0, void 0, function() {
375
+ var w, K, B, W;
376
+ return L(this, function(O) {
377
+ switch (O.label) {
378
+ case 0:
379
+ return w = $.get(y), w ? [3, 2] : (K = Array.isArray(y) ? y : [y], B = P.apply(void 0, Ie([], Ee(K), !1)), $.set(y, B, r.dedupingInterval), [4, J(y, B, r.cache, g)]);
380
+ case 1:
381
+ return O.sent(), [3, 4];
382
+ case 2:
383
+ return [4, J(y, w.data, r.cache, g)];
384
+ case 3:
385
+ O.sent(), O.label = 4;
386
+ case 4:
387
+ return d.isValidating = !1, $.delete(y), d.error !== void 0 && (W = !l && r.shouldRetryOnError && (c ? c.shouldRetryOnError : !0), W && Ae(b, c ? c.errorRetryCount : 1, r)), [
388
+ 2
389
+ /*return*/
390
+ ];
391
+ }
392
+ });
393
+ });
394
+ }, S && r.revalidateDebounce ? (setTimeout(function() {
395
+ return R(G, void 0, void 0, function() {
396
+ return L(this, function(w) {
397
+ switch (w.label) {
398
+ case 0:
399
+ return l ? [3, 2] : [4, H()];
400
+ case 1:
401
+ w.sent(), w.label = 2;
402
+ case 2:
403
+ return [
404
+ 2
405
+ /*return*/
406
+ ];
407
+ }
408
+ });
409
+ });
410
+ }, r.revalidateDebounce), [3, 3]) : [3, 1])) : [
411
+ 2
412
+ /*return*/
413
+ ];
414
+ case 1:
415
+ return [4, H()];
416
+ case 2:
417
+ T.sent(), T.label = 3;
418
+ case 3:
419
+ return [
420
+ 2
421
+ /*return*/
422
+ ];
423
+ }
424
+ });
425
+ });
426
+ }, V = function() {
427
+ return R(t, void 0, void 0, function() {
428
+ return L(this, function(h) {
429
+ return [2, b(null, { shouldRetryOnError: !1 })];
430
+ });
431
+ });
432
+ }, p = null;
433
+ Q(function() {
434
+ var h = function() {
435
+ return R(t, void 0, void 0, function() {
436
+ return L(this, function(c) {
437
+ switch (c.label) {
438
+ case 0:
439
+ return !d.error && r.isOnline() ? [4, b()] : [3, 2];
440
+ case 1:
441
+ return c.sent(), [3, 3];
442
+ case 2:
443
+ p && clearTimeout(p), c.label = 3;
444
+ case 3:
445
+ return r.refreshInterval && !l && (p = setTimeout(h, r.refreshInterval)), [
446
+ 2
447
+ /*return*/
448
+ ];
449
+ }
450
+ });
451
+ });
452
+ };
453
+ r.refreshInterval && (p = setTimeout(h, r.refreshInterval)), r.revalidateOnFocus && (document.addEventListener("visibilitychange", V, !1), window.addEventListener("focus", V, !1));
454
+ }), he(function() {
455
+ l = !0, p && clearTimeout(p), r.revalidateOnFocus && (document.removeEventListener("visibilitychange", V, !1), window.removeEventListener("focus", V, !1));
456
+ var h = k.get(v.value);
457
+ h && (h.data = h.data.filter(function(c) {
458
+ return c !== d;
136
459
  }));
460
+ });
461
+ try {
462
+ ve(v, function(h) {
463
+ ge(v) || (v.value = h), d.key = h, d.isValidating = !!h, Se(v.value, d, g), !s && !f && v.value && b(), f = !1;
464
+ }, {
465
+ immediate: !0
466
+ });
467
+ } catch {
137
468
  }
138
- }), C = async (e) => {
469
+ var ae = m(m({}, ye(d)), { mutate: function(h, c) {
470
+ return b(h, m(m({}, c), { forceRevalidate: !0 }));
471
+ } });
472
+ return ae;
473
+ }
474
+ function Oe(t) {
475
+ return t !== null && typeof t == "object" && typeof t.then == "function";
476
+ }
477
+ const ke = async (t) => {
139
478
  try {
140
- return await (await fetch(e)).json();
141
- } catch (o) {
142
- console.error(o);
479
+ return await (await fetch(t)).json();
480
+ } catch (n) {
481
+ console.error(n);
143
482
  return;
144
483
  }
145
- }, w = () => {
146
- const e = P(), { data: o = e, isValidating: t } = useSWR(s.auth, C);
484
+ }, ie = () => {
485
+ const t = me(), { data: n = t, isValidating: e } = Ve(_.auth, ke);
147
486
  return {
148
- auth: o || {},
149
- isLoading: t,
150
- isLoggedIn: o == null ? void 0 : o.isLoggedIn
487
+ auth: n || {},
488
+ // @ts-ignore //TBD
489
+ isLoading: e,
490
+ // @ts-ignore
491
+ isLoggedIn: n == null ? void 0 : n.isLoggedIn
151
492
  };
152
- }, A = { key: 0 }, Y = /* @__PURE__ */ a({
493
+ }, Pe = { key: 0 }, Me = /* @__PURE__ */ C({
153
494
  __name: "LoggedIn",
154
- setup(e) {
155
- const o = () => {
156
- var t;
157
- return ((t = w()) == null ? void 0 : t.isLoggedIn) || !1;
495
+ setup(t) {
496
+ const n = () => {
497
+ var e;
498
+ return ((e = ie()) == null ? void 0 : e.isLoggedIn) || !1;
158
499
  };
159
- return (t, n) => o() ? (l(), p("div", A, [
160
- f(t.$slots, "default")
161
- ])) : b("", !0);
500
+ return (e, i) => n() ? (E(), M("div", Pe, [
501
+ Z(e.$slots, "default")
502
+ ])) : ee("", !0);
162
503
  }
163
- }), E = { key: 0 }, z = /* @__PURE__ */ a({
504
+ }), He = { key: 0 }, je = /* @__PURE__ */ C({
164
505
  __name: "LoggedOut",
165
- setup(e) {
166
- const o = () => {
167
- var t;
168
- return ((t = w()) == null ? void 0 : t.isLoggedIn) || !1;
506
+ setup(t) {
507
+ const n = () => {
508
+ var e;
509
+ return ((e = ie()) == null ? void 0 : e.isLoggedIn) || !1;
169
510
  };
170
- return (t, n) => o() ? b("", !0) : (l(), p("div", E, [
171
- f(t.$slots, "default")
511
+ return (e, i) => n() ? ee("", !0) : (E(), M("div", He, [
512
+ Z(e.$slots, "default")
172
513
  ]));
173
514
  }
174
- }), W = () => s.logout;
175
- function F() {
176
- window.location.href = s.logout;
515
+ }), Ue = () => _.logout;
516
+ function Fe() {
517
+ window.location.href = _.logout;
177
518
  }
178
519
  export {
179
- T as ContinueButton,
180
- G as HelloProvider,
181
- Y as LoggedIn,
182
- z as LoggedOut,
183
- x as LoginButton,
184
- V as UpdateDiscordButton,
185
- M as UpdateEmailButton,
186
- j as UpdateGitHubButton,
187
- D as UpdateGitLabButton,
188
- N as UpdatePictureButton,
189
- O as UpdateTwitterButton,
190
- W as getLogOutRoute,
191
- F as logOut,
192
- s as routeConfig,
193
- w as useAuth,
194
- P as useHelloProviderContext
520
+ De as ContinueButton,
521
+ Be as HelloProvider,
522
+ Me as LoggedIn,
523
+ je as LoggedOut,
524
+ xe as LoginButton,
525
+ $e as UpdateProfileButton,
526
+ Ue as getLogOutRoute,
527
+ Fe as logOut,
528
+ _ as routeConfig,
529
+ ie as useAuth,
530
+ me as useHelloProviderContext
195
531
  };
package/dist/index.umd.js CHANGED
@@ -1 +1 @@
1
- (function(l,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(l=typeof globalThis<"u"?globalThis:l||self,e(l["@hellocoop/vue"]={},l.Vue))})(this,function(l,e){"use strict";const i={login:"/api/hellocoop?login=true",auth:"/api/hellocoop?auth=true",logout:"/api/hellocoop?logout=true"},p="HelloAuth",f=()=>e.inject(p),g={props:["auth","config"],setup(t){var n,o,a;(n=t==null?void 0:t.config)!=null&&n.login&&(i.login=t.config.login),(o=t==null?void 0:t.config)!=null&&o.auth&&(i.auth=t.config.auth),(a=t==null?void 0:t.config)!=null&&a.logout&&(i.logout=t.config.logout),e.provide(p,t.auth)},render(){return this.$slots.default()}};var r;(t=>{t.STYLES_URL="https://cdn.hello.coop/css/hello-btn.css",t.HOVER_MAPPING={pop:"",glow:"hello-btn-hover-glow",flare:"hello-btn-hover-flare",none:"hello-btn-hover-none"},t.CLASS_MAPPING={black:{"ignore-light":"","ignore-dark":"hello-btn-black-on-dark","aware-invert":"hello-btn-black-and-invert","aware-static":"hello-btn-black-and-static"},white:{"ignore-light":"hello-btn-white-on-light","ignore-dark":"hello-btn-white-on-dark","aware-invert":"hello-btn-white-and-invert","aware-static":"hello-btn-white-and-static"}}})(r||(r={}));const m=["disabled"],b=["innerHTML"],c=e.defineComponent({__name:"BaseButton",props:{label:{default:"ō&nbsp;&nbsp;&nbsp;Continue with Hellō"},style:{},color:{default:"black"},theme:{default:"ignore-light"},hover:{default:"pop"},scope:{},updateScope:{},targetURI:{},providerHint:{},showLoader:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1}},setup(t){let n=!1;e.onMounted(()=>{typeof window<"u"&&!n&&(Array.from(document.head.getElementsByTagName("link")).find(_=>{var u;return _.getAttribute("rel")==="stylesheet"&&((u=_.getAttribute("href"))==null?void 0:u.startsWith(r.STYLES_URL))})||console.warn("Could not find Hellō stylesheet. Please add to pages with Hellō buttons. See http://hello.dev/docs/buttons/#stylesheet for more info."),n=!0)});const o=e.ref(!1),a=t,s=new URL(i.login,window.location.origin);a.scope&&s.searchParams.set("scope",a.scope.join(" ")),s.searchParams.set("target_uri",a.targetURI||window.location.pathname),a.updateScope&&s.searchParams.set("scope","profile_update "+a.updateScope),a.providerHint&&s.searchParams.set("provider_hint",a.providerHint.join(" "));const T=()=>{o.value=!0,window.location.href=s.href};return(d,_)=>{var u;return e.openBlock(),e.createElementBlock("button",{onClick:T,class:e.normalizeClass(["hello-btn",(u=e.unref(r).CLASS_MAPPING[a.color])==null?void 0:u[a.theme],e.unref(r).HOVER_MAPPING[d.hover],(d.showLoader||o.value)&&"hello-btn-loader"]),disabled:a.disabled||o.value,style:e.normalizeStyle(d.style)},[e.createElementVNode("span",{innerHTML:d.label},null,8,b)],14,m)}}}),B=e.defineComponent({__name:"ContinueButton",setup(t){return(n,o)=>(e.openBlock(),e.createBlock(c))}}),w=e.defineComponent({__name:"LoginButton",setup(t){return(n,o)=>(e.openBlock(),e.createBlock(c,{label:"ō   Login with Hellō"}))}}),k=e.defineComponent({__name:"UpdateEmailButton",setup(t){return(n,o)=>(e.openBlock(),e.createBlock(c,{label:"ō   Update Email with Hellō",updateScope:"email"}))}}),L=e.defineComponent({__name:"UpdatePictureButton",setup(t){return(n,o)=>(e.openBlock(),e.createBlock(c,{label:"ō   Update Picture with Hellō",updateScope:"picture"}))}}),S=e.defineComponent({__name:"UpdateTwitterButton",setup(t){return(n,o)=>(e.openBlock(),e.createBlock(c,{label:"ō   Update Twitter with Hellō",updateScope:"twitter"}))}}),C=e.defineComponent({__name:"UpdateDiscordButton",setup(t){return(n,o)=>(e.openBlock(),e.createBlock(c,{label:"ō   Update Discord with Hellō",updateScope:"discord"}))}}),H=e.defineComponent({__name:"UpdateGitHubButton",setup(t){return(n,o)=>(e.openBlock(),e.createBlock(c,{label:"ō   Update GitHub with Hellō",updateScope:"github"}))}}),y=e.defineComponent({__name:"UpdateGitLabButton",setup(t){return(n,o)=>(e.openBlock(),e.createBlock(c,{label:"ō   Update GitLab with Hellō",updateScope:"gitlab"}))}}),U=async t=>{try{return await(await fetch(t)).json()}catch(n){console.error(n);return}},h=()=>{const t=f(),{data:n=t,isValidating:o}=useSWR(i.auth,U);return{auth:n||{},isLoading:o,isLoggedIn:n==null?void 0:n.isLoggedIn}},P={key:0},I=e.defineComponent({__name:"LoggedIn",setup(t){const n=()=>{var o;return((o=h())==null?void 0:o.isLoggedIn)||!1};return(o,a)=>n()?(e.openBlock(),e.createElementBlock("div",P,[e.renderSlot(o.$slots,"default")])):e.createCommentVNode("",!0)}}),$={key:0},E=e.defineComponent({__name:"LoggedOut",setup(t){const n=()=>{var o;return((o=h())==null?void 0:o.isLoggedIn)||!1};return(o,a)=>n()?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",$,[e.renderSlot(o.$slots,"default")]))}}),A=()=>i.logout;function R(){window.location.href=i.logout}l.ContinueButton=B,l.HelloProvider=g,l.LoggedIn=I,l.LoggedOut=E,l.LoginButton=w,l.UpdateDiscordButton=C,l.UpdateEmailButton=k,l.UpdateGitHubButton=H,l.UpdateGitLabButton=y,l.UpdatePictureButton=L,l.UpdateTwitterButton=S,l.getLogOutRoute=A,l.logOut=R,l.routeConfig=i,l.useAuth=h,l.useHelloProviderContext=f,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});
1
+ (function(v,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],a):(v=typeof globalThis<"u"?globalThis:v||self,a(v["@hellocoop/vue"]={},v.Vue))})(this,function(v,a){"use strict";const w={login:"/api/hellocoop?login=true",auth:"/api/hellocoop?auth=true",logout:"/api/hellocoop?logout=true"},N="HelloAuth",z=()=>a.inject(N),Z={props:["auth","config"],setup(t){var n,e,i;(n=t==null?void 0:t.config)!=null&&n.login&&(w.login=t.config.login),(e=t==null?void 0:t.config)!=null&&e.auth&&(w.auth=t.config.auth),(i=t==null?void 0:t.config)!=null&&i.logout&&(w.logout=t.config.logout),a.provide(N,t.auth)},render(){return this.$slots.default()}};var S;(t=>{t.STYLES_URL="https://cdn.hello.coop/css/hello-btn.css",t.HOVER_MAPPING={pop:"",glow:"hello-btn-hover-glow",flare:"hello-btn-hover-flare",none:"hello-btn-hover-none"},t.CLASS_MAPPING={black:{"ignore-light":"","ignore-dark":"hello-btn-black-on-dark","aware-invert":"hello-btn-black-and-invert","aware-static":"hello-btn-black-and-static"},white:{"ignore-light":"hello-btn-white-on-light","ignore-dark":"hello-btn-white-on-dark","aware-invert":"hello-btn-white-and-invert","aware-static":"hello-btn-white-and-static"}}})(S||(S={}));const ee=["disabled"],te=["innerHTML"],B=a.defineComponent({__name:"BaseButton",props:{label:{default:"ō&nbsp;&nbsp;&nbsp;Continue with Hellō"},style:{},color:{default:"black"},theme:{default:"ignore-light"},hover:{default:"pop"},scope:{},update:{type:Boolean},targetURI:{},providerHint:{},showLoader:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1}},setup(t){let n=!1;a.onMounted(()=>{typeof window<"u"&&!n&&(Array.from(document.head.getElementsByTagName("link")).find(d=>{var c;return d.getAttribute("rel")==="stylesheet"&&((c=d.getAttribute("href"))==null?void 0:c.startsWith(S.STYLES_URL))})||console.warn("Could not find Hellō stylesheet. Please add to pages with Hellō buttons. See http://hello.dev/docs/buttons/#stylesheet for more info."),n=!0)});const e=a.ref(!1),i=t,o=new URL(w.login,window.location.origin);i.scope&&o.searchParams.set("scope",i.scope.join(" ")),o.searchParams.set("target_uri",i.targetURI||window.location.pathname),i.update&&o.searchParams.set("prompt","consent"),i.providerHint&&o.searchParams.set("provider_hint",i.providerHint.join(" "));const r=()=>{e.value=!0,window.location.href=o.href};return(u,d)=>{var c;return a.openBlock(),a.createElementBlock("button",{onClick:r,class:a.normalizeClass(["hello-btn",(c=a.unref(S).CLASS_MAPPING[i.color])==null?void 0:c[i.theme],a.unref(S).HOVER_MAPPING[u.hover],(u.showLoader||e.value)&&"hello-btn-loader"]),disabled:i.disabled||e.value,style:a.normalizeStyle(u.style)},[a.createElementVNode("span",{innerHTML:u.label},null,8,te)],14,ee)}}}),ne=a.defineComponent({__name:"ContinueButton",setup(t){return(n,e)=>(a.openBlock(),a.createBlock(B))}}),re=a.defineComponent({__name:"LoginButton",setup(t){return(n,e)=>(a.openBlock(),a.createBlock(B,{label:"ō   Login with Hellō"}))}}),ie=a.defineComponent({__name:"UpdateProfileButton",setup(t){return(n,e)=>(a.openBlock(),a.createBlock(B,{label:"ō   Update Profile with Hellō",update:!0}))}});var P=new WeakMap,x=0;function oe(t){if(!t.length)return"";for(var n="arg",e=0;e<t.length;++e){var i=void 0;t[e]===null||typeof t[e]!="object"&&typeof t[e]!="function"?typeof t[e]=="string"?i='"'+t[e]+'"':i=String(t[e]):P.has(t[e])?i=P.get(t[e]):(i=x,P.set(t[e],x++)),n+="@"+i}return n}function ae(t){if(typeof t=="function")try{t=t()}catch{t=""}return Array.isArray(t)?t=oe(t):t=String(t||""),t}var T=function(){function t(n){n===void 0&&(n=0),this.items=new Map,this.ttl=n}return t.prototype.serializeKey=function(n){return ae(n)},t.prototype.get=function(n){var e=this.serializeKey(n);return this.items.get(e)},t.prototype.set=function(n,e,i){var o=this.serializeKey(n),r=i||this.ttl,u=Date.now(),d={data:e,createdAt:u,expiresAt:r?u+r:1/0};this.dispatchExpire(r,d,o),this.items.set(o,d)},t.prototype.dispatchExpire=function(n,e,i){var o=this;n&&setTimeout(function(){var r=Date.now(),u=r>=e.expiresAt;u&&o.delete(i)},n)},t.prototype.delete=function(n){this.items.delete(n)},t}();function le(){return typeof navigator.onLine<"u"?navigator.onLine:!0}function ue(){return typeof document<"u"&&typeof document.visibilityState<"u"?document.visibilityState!=="hidden":!0}var ce=function(t){return fetch(t).then(function(n){return n.json()})};const H={isOnline:le,isDocumentVisible:ue,fetcher:ce};var p=function(){return p=Object.assign||function(t){for(var n,e=1,i=arguments.length;e<i;e++){n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},p.apply(this,arguments)},C=function(t,n,e,i){function o(r){return r instanceof e?r:new e(function(u){u(r)})}return new(e||(e=Promise))(function(r,u){function d(s){try{l(i.next(s))}catch(m){u(m)}}function c(s){try{l(i.throw(s))}catch(m){u(m)}}function l(s){s.done?r(s.value):o(s.value).then(d,c)}l((i=i.apply(t,n||[])).next())})},L=function(t,n){var e={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},i,o,r,u;return u={next:d(0),throw:d(1),return:d(2)},typeof Symbol=="function"&&(u[Symbol.iterator]=function(){return this}),u;function d(l){return function(s){return c([l,s])}}function c(l){if(i)throw new TypeError("Generator is already executing.");for(;e;)try{if(i=1,o&&(r=l[0]&2?o.return:l[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,l[1])).done)return r;switch(o=0,r&&(l=[l[0]&2,r.value]),l[0]){case 0:case 1:r=l;break;case 4:return e.label++,{value:l[1],done:!1};case 5:e.label++,o=l[1],l=[0];continue;case 7:l=e.ops.pop(),e.trys.pop();continue;default:if(r=e.trys,!(r=r.length>0&&r[r.length-1])&&(l[0]===6||l[0]===2)){e=0;continue}if(l[0]===3&&(!r||l[1]>r[0]&&l[1]<r[3])){e.label=l[1];break}if(l[0]===6&&e.label<r[1]){e.label=r[1],r=l;break}if(r&&e.label<r[2]){e.label=r[2],e.ops.push(l);break}r[2]&&e.ops.pop(),e.trys.pop();continue}l=n.call(t,e)}catch(s){l=[6,s],o=0}finally{i=r=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}},se=function(t,n){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var i=e.call(t),o,r=[],u;try{for(;(n===void 0||n-- >0)&&!(o=i.next()).done;)r.push(o.value)}catch(d){u={error:d}}finally{try{o&&!o.done&&(e=i.return)&&e.call(i)}finally{if(u)throw u.error}}return r},fe=function(t,n,e){if(e||arguments.length===2)for(var i=0,o=n.length,r;i<o;i++)(r||!(i in n))&&(r||(r=Array.prototype.slice.call(n,0,i)),r[i]=n[i]);return t.concat(r||Array.prototype.slice.call(n))},G=new T,A=new T,D=new T,K={cache:G,refreshInterval:0,ttl:0,serverTTL:1e3,dedupingInterval:2e3,revalidateOnFocus:!0,revalidateDebounce:0,shouldRetryOnError:!0,errorRetryInterval:5e3,errorRetryCount:5,fetcher:H.fetcher,isOnline:H.isOnline,isDocumentVisible:H.isDocumentVisible};function de(t,n,e){var i=A.get(t);if(i)i.data.push(n);else{var o=5e3;A.set(t,[n],e>0?e+o:e)}}function he(t,n,e){if(e.isDocumentVisible()&&!(e.errorRetryCount!==void 0&&n>e.errorRetryCount)){var i=Math.min(n||0,e.errorRetryCount),o=i*e.errorRetryInterval;setTimeout(function(){t(null,{errorRetryCount:i+1,shouldRetryOnError:!0})},o)}}var W=function(t,n,e,i){return e===void 0&&(e=G),i===void 0&&(i=K.ttl),C(void 0,void 0,void 0,function(){var o,r,u,d,c,l,s;return L(this,function(m){switch(m.label){case 0:if(!ge(n))return[3,5];m.label=1;case 1:return m.trys.push([1,3,,4]),[4,n];case 2:return o=m.sent(),[3,4];case 3:return d=m.sent(),r=d,[3,4];case 4:return[3,6];case 5:o=n,m.label=6;case 6:if(u=!1,c={data:o,error:r,isValidating:u},typeof o<"u")try{e.set(t,c,i)}catch(y){console.error("swrv(mutate): failed to set cache",y)}return l=A.get(t),l&&l.data.length&&(s=l.data.filter(function(y){return y.key===t}),s.forEach(function(y,h){typeof c.data<"u"&&(y.data=c.data),y.error=c.error,y.isValidating=c.isValidating;var _=h===s.length-1;_||delete s[h]}),s=s.filter(Boolean)),[2,c]}})})};function ve(){for(var t=this,n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];var i,o,r=p({},K),u=!1,d=!1,c=a.getCurrentInstance(),l=(c==null?void 0:c.proxy)||c;if(!l)return console.error("Could not get current instance, check to make sure that `useSwrv` is declared in the top level of the setup function."),null;var s=(l==null?void 0:l.$isServer)||!1;n.length>=1&&(i=n[0]),n.length>=2&&(o=n[1]),n.length>2&&(r=p(p({},r),n[2]));var m=s?r.serverTTL:r.ttl,y=typeof i=="function"?i:a.ref(i);typeof o>"u"&&(o=r.fetcher);var h=null;h||(h=a.reactive({data:void 0,error:void 0,isValidating:!0,key:null}));var _=function(g,f){return C(t,void 0,void 0,function(){var Y,b,k,I,$,q,j,J=this;return L(this,function(U){switch(U.label){case 0:return Y=h.data===void 0,b=y.value,b?(k=r.cache.get(b),I=k&&k.data,h.isValidating=!0,I&&(h.data=I.data,h.error=I.error),$=g||o,!$||!r.isDocumentVisible()&&!Y||(f==null?void 0:f.forceRevalidate)!==void 0&&!(f!=null&&f.forceRevalidate)?(h.isValidating=!1,[2]):k&&(q=!!(Date.now()-k.createdAt>=r.dedupingInterval||f!=null&&f.forceRevalidate),!q)?(h.isValidating=!1,[2]):(j=function(){return C(J,void 0,void 0,function(){var R,Q,F,X;return L(this,function(O){switch(O.label){case 0:return R=D.get(b),R?[3,2]:(Q=Array.isArray(b)?b:[b],F=$.apply(void 0,fe([],se(Q),!1)),D.set(b,F,r.dedupingInterval),[4,W(b,F,r.cache,m)]);case 1:return O.sent(),[3,4];case 2:return[4,W(b,R.data,r.cache,m)];case 3:O.sent(),O.label=4;case 4:return h.isValidating=!1,D.delete(b),h.error!==void 0&&(X=!u&&r.shouldRetryOnError&&(f?f.shouldRetryOnError:!0),X&&he(_,f?f.errorRetryCount:1,r)),[2]}})})},I&&r.revalidateDebounce?(setTimeout(function(){return C(J,void 0,void 0,function(){return L(this,function(R){switch(R.label){case 0:return u?[3,2]:[4,j()];case 1:R.sent(),R.label=2;case 2:return[2]}})})},r.revalidateDebounce),[3,3]):[3,1])):[2];case 1:return[4,j()];case 2:U.sent(),U.label=3;case 3:return[2]}})})},V=function(){return C(t,void 0,void 0,function(){return L(this,function(g){return[2,_(null,{shouldRetryOnError:!1})]})})},E=null;a.onMounted(function(){var g=function(){return C(t,void 0,void 0,function(){return L(this,function(f){switch(f.label){case 0:return!h.error&&r.isOnline()?[4,_()]:[3,2];case 1:return f.sent(),[3,3];case 2:E&&clearTimeout(E),f.label=3;case 3:return r.refreshInterval&&!u&&(E=setTimeout(g,r.refreshInterval)),[2]}})})};r.refreshInterval&&(E=setTimeout(g,r.refreshInterval)),r.revalidateOnFocus&&(document.addEventListener("visibilitychange",V,!1),window.addEventListener("focus",V,!1))}),a.onUnmounted(function(){u=!0,E&&clearTimeout(E),r.revalidateOnFocus&&(document.removeEventListener("visibilitychange",V,!1),window.removeEventListener("focus",V,!1));var g=A.get(y.value);g&&(g.data=g.data.filter(function(f){return f!==h}))});try{a.watch(y,function(g){a.isReadonly(y)||(y.value=g),h.key=g,h.isValidating=!!g,de(y.value,h,m),!s&&!d&&y.value&&_(),d=!1},{immediate:!0})}catch{}var Ce=p(p({},a.toRefs(h)),{mutate:function(g,f){return _(g,p(p({},f),{forceRevalidate:!0}))}});return Ce}function ge(t){return t!==null&&typeof t=="object"&&typeof t.then=="function"}const ye=async t=>{try{return await(await fetch(t)).json()}catch(n){console.error(n);return}},M=()=>{const t=z(),{data:n=t,isValidating:e}=ve(w.auth,ye);return{auth:n||{},isLoading:e,isLoggedIn:n==null?void 0:n.isLoggedIn}},me={key:0},be=a.defineComponent({__name:"LoggedIn",setup(t){const n=()=>{var e;return((e=M())==null?void 0:e.isLoggedIn)||!1};return(e,i)=>n()?(a.openBlock(),a.createElementBlock("div",me,[a.renderSlot(e.$slots,"default")])):a.createCommentVNode("",!0)}}),pe={key:0},we=a.defineComponent({__name:"LoggedOut",setup(t){const n=()=>{var e;return((e=M())==null?void 0:e.isLoggedIn)||!1};return(e,i)=>n()?a.createCommentVNode("",!0):(a.openBlock(),a.createElementBlock("div",pe,[a.renderSlot(e.$slots,"default")]))}}),_e=()=>w.logout;function Re(){window.location.href=w.logout}v.ContinueButton=ne,v.HelloProvider=Z,v.LoggedIn=be,v.LoggedOut=we,v.LoginButton=re,v.UpdateProfileButton=ie,v.getLogOutRoute=_e,v.logOut=Re,v.routeConfig=w,v.useAuth=M,v.useHelloProviderContext=z,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})});
@@ -1,4 +1,4 @@
1
- declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>, {
1
+ declare const _default: __VLS_WithTemplateSlots<import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{}>>, {}, {}>, {
2
2
  default?(_: {}): any;
3
3
  }>;
4
4
  export default _default;
@@ -1,4 +1,4 @@
1
- declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>, {
1
+ declare const _default: __VLS_WithTemplateSlots<import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{}>>, {}, {}>, {
2
2
  default?(_: {}): any;
3
3
  }>;
4
4
  export default _default;
package/dist/types.d.ts CHANGED
@@ -37,7 +37,7 @@ export declare namespace Button {
37
37
  type Color = "black" | "white";
38
38
  type Theme = "ignore-light" | "ignore-dark" | "aware-invert" | "aware-static";
39
39
  type Hover = "pop" | "glow" | "flare" | "none";
40
- type UpdateScope = "email" | "picture" | "twitter" | "discord" | "github" | "gitlab";
40
+ type Update = boolean;
41
41
  const STYLES_URL = "https://cdn.hello.coop/css/hello-btn.css";
42
42
  const HOVER_MAPPING: {
43
43
  pop: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hellocoop/vue",
3
- "version": "1.0.1",
3
+ "version": "2.0.0",
4
4
  "description": "Svelte SDK for Hellō https://hello.dev",
5
5
  "repository": {
6
6
  "type": "git",
@@ -42,6 +42,7 @@
42
42
  "build": "vite build"
43
43
  },
44
44
  "dependencies": {
45
+ "@vitejs/plugin-vue": "^5.1.2",
45
46
  "swrv": "^1.0.4",
46
47
  "vue": "^3.0.5"
47
48
  },
@@ -1,2 +0,0 @@
1
- declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>;
2
- export default _default;
@@ -1,2 +0,0 @@
1
- declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>;
2
- export default _default;
@@ -1,2 +0,0 @@
1
- declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>;
2
- export default _default;
@@ -1,2 +0,0 @@
1
- declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>;
2
- export default _default;
@@ -1,2 +0,0 @@
1
- declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>;
2
- export default _default;
@@ -1,2 +0,0 @@
1
- declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>;
2
- export default _default;