@hellocoop/vue 2.0.0 → 2.1.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Hellō
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -12,29 +12,45 @@ type Props = {
12
12
  providerHint?: ProviderHint[];
13
13
  showLoader?: boolean;
14
14
  disabled?: boolean;
15
+ promptLogin?: boolean;
16
+ promptConsent?: boolean;
17
+ loginHint?: string;
18
+ domainHint?: string;
15
19
  };
16
- declare const _default: import('vue').DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<Props>, {
20
+ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<Props>, {
17
21
  label: string;
18
22
  color: string;
19
23
  theme: string;
20
24
  hover: string;
21
25
  showLoader: boolean;
22
26
  disabled: boolean;
23
- }>, {}, unknown, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<Props>, {
27
+ promptLogin: boolean;
28
+ promptConsent: boolean;
29
+ loginHint: string;
30
+ domainHint: string;
31
+ }>>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<Props>, {
24
32
  label: string;
25
33
  color: string;
26
34
  theme: string;
27
35
  hover: string;
28
36
  showLoader: boolean;
29
37
  disabled: boolean;
30
- }>>>, {
38
+ promptLogin: boolean;
39
+ promptConsent: boolean;
40
+ loginHint: string;
41
+ domainHint: string;
42
+ }>>> & Readonly<{}>, {
31
43
  label: string;
32
44
  color: Button.Color;
33
45
  theme: Button.Theme;
34
46
  hover: Button.Hover;
35
47
  showLoader: boolean;
36
48
  disabled: boolean;
37
- }, {}>;
49
+ promptLogin: boolean;
50
+ promptConsent: boolean;
51
+ loginHint: string;
52
+ domainHint: string;
53
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
38
54
  export default _default;
39
55
  type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
40
56
  type __VLS_TypePropsToRuntimeProps<T> = {
@@ -1,2 +1,2 @@
1
- declare const _default: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{}>>, {}, {}>;
1
+ declare const _default: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
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').PublicProps, Readonly<import('vue').ExtractPropTypes<{}>>, {}, {}>;
1
+ declare const _default: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
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').PublicProps, Readonly<import('vue').ExtractPropTypes<{}>>, {}, {}>;
1
+ declare const _default: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
2
2
  export default _default;
package/dist/index.mjs CHANGED
@@ -1,13 +1,13 @@
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 _ = {
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 se, unref as Y, normalizeStyle as ue, createElementVNode as ce, createBlock as j, getCurrentInstance as fe, reactive as de, onUnmounted as he, watch as ve, isReadonly as ge, toRefs as me, renderSlot as Z, createCommentVNode as ee } from "vue";
2
+ const w = {
3
3
  login: "/api/hellocoop?login=true",
4
4
  auth: "/api/hellocoop?auth=true",
5
5
  logout: "/api/hellocoop?logout=true"
6
- }, te = "HelloAuth", me = () => le(te), Be = {
6
+ }, te = "HelloAuth", ye = () => le(te), Be = {
7
7
  props: ["auth", "config"],
8
8
  setup(t) {
9
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);
10
+ (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), oe(te, t.auth);
11
11
  },
12
12
  render() {
13
13
  return this.$slots.default();
@@ -35,7 +35,7 @@ var A;
35
35
  }
36
36
  };
37
37
  })(A || (A = {}));
38
- const be = ["disabled"], we = ["innerHTML"], U = /* @__PURE__ */ C({
38
+ const be = ["disabled"], pe = ["innerHTML"], U = /* @__PURE__ */ C({
39
39
  __name: "BaseButton",
40
40
  props: {
41
41
  label: { default: "ō&nbsp;&nbsp;&nbsp;Continue with Hellō" },
@@ -48,32 +48,36 @@ const be = ["disabled"], we = ["innerHTML"], U = /* @__PURE__ */ C({
48
48
  targetURI: {},
49
49
  providerHint: {},
50
50
  showLoader: { type: Boolean, default: !1 },
51
- disabled: { type: Boolean, default: !1 }
51
+ disabled: { type: Boolean, default: !1 },
52
+ promptLogin: { type: Boolean, default: !1 },
53
+ promptConsent: { type: Boolean, default: !1 },
54
+ loginHint: { default: "" },
55
+ domainHint: { default: "" }
52
56
  },
53
57
  setup(t) {
54
58
  let n = !1;
55
59
  Q(() => {
56
60
  typeof window < "u" && !n && (Array.from(document.head.getElementsByTagName("link")).find(
57
61
  (f) => {
58
- var u;
59
- return f.getAttribute("rel") === "stylesheet" && ((u = f.getAttribute("href")) == null ? void 0 : u.startsWith(A.STYLES_URL));
62
+ var s;
63
+ return f.getAttribute("rel") === "stylesheet" && ((s = f.getAttribute("href")) == null ? void 0 : s.startsWith(A.STYLES_URL));
60
64
  }
61
65
  ) || 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
66
  });
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(" "));
67
+ const e = X(!1), i = t, a = new URL(w.login, window.location.origin);
68
+ 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.promptLogin && i.promptConsent ? a.searchParams.set("prompt", "login consent") : i.promptLogin ? a.searchParams.set("prompt", "login") : i.promptConsent && a.searchParams.set("prompt", "consent"), i.loginHint && a.searchParams.set("login_hint", i.loginHint), i.domainHint && a.searchParams.set("login_hint", i.domainHint), i.providerHint && a.searchParams.set("provider_hint", i.providerHint.join(" "));
65
69
  const r = () => {
66
70
  e.value = !0, window.location.href = a.href;
67
71
  };
68
72
  return (l, f) => {
69
- var u;
73
+ var s;
70
74
  return E(), M("button", {
71
75
  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"]),
76
+ class: se(["hello-btn", (s = Y(A).CLASS_MAPPING[i.color]) == null ? void 0 : s[i.theme], Y(A).HOVER_MAPPING[l.hover], (l.showLoader || e.value) && "hello-btn-loader"]),
73
77
  disabled: i.disabled || e.value,
74
- style: se(l.style)
78
+ style: ue(l.style)
75
79
  }, [
76
- ce("span", { innerHTML: l.label }, null, 8, we)
80
+ ce("span", { innerHTML: l.label }, null, 8, pe)
77
81
  ], 14, be);
78
82
  };
79
83
  }
@@ -97,7 +101,7 @@ const be = ["disabled"], we = ["innerHTML"], U = /* @__PURE__ */ C({
97
101
  }
98
102
  });
99
103
  var D = /* @__PURE__ */ new WeakMap(), q = 0;
100
- function _e(t) {
104
+ function we(t) {
101
105
  if (!t.length)
102
106
  return "";
103
107
  for (var n = "arg", e = 0; e < t.length; ++e) {
@@ -106,14 +110,14 @@ function _e(t) {
106
110
  }
107
111
  return n;
108
112
  }
109
- function pe(t) {
113
+ function _e(t) {
110
114
  if (typeof t == "function")
111
115
  try {
112
116
  t = t();
113
117
  } catch {
114
118
  t = "";
115
119
  }
116
- return Array.isArray(t) ? t = _e(t) : t = String(t || ""), t;
120
+ return Array.isArray(t) ? t = we(t) : t = String(t || ""), t;
117
121
  }
118
122
  var F = (
119
123
  /** @class */
@@ -122,7 +126,7 @@ var F = (
122
126
  n === void 0 && (n = 0), this.items = /* @__PURE__ */ new Map(), this.ttl = n;
123
127
  }
124
128
  return t.prototype.serializeKey = function(n) {
125
- return pe(n);
129
+ return _e(n);
126
130
  }, t.prototype.get = function(n) {
127
131
  var e = this.serializeKey(n);
128
132
  return this.items.get(e);
@@ -160,120 +164,130 @@ const x = {
160
164
  isDocumentVisible: Le,
161
165
  fetcher: Ce
162
166
  };
163
- var m = function() {
164
- return m = Object.assign || function(t) {
167
+ var y = globalThis && globalThis.__assign || function() {
168
+ return y = Object.assign || function(t) {
165
169
  for (var n, e = 1, i = arguments.length; e < i; e++) {
166
170
  n = arguments[e];
167
- for (var a in n) Object.prototype.hasOwnProperty.call(n, a) && (t[a] = n[a]);
171
+ for (var a in n)
172
+ Object.prototype.hasOwnProperty.call(n, a) && (t[a] = n[a]);
168
173
  }
169
174
  return t;
170
- }, m.apply(this, arguments);
171
- }, R = function(t, n, e, i) {
175
+ }, y.apply(this, arguments);
176
+ }, R = globalThis && globalThis.__awaiter || function(t, n, e, i) {
172
177
  function a(r) {
173
178
  return r instanceof e ? r : new e(function(l) {
174
179
  l(r);
175
180
  });
176
181
  }
177
182
  return new (e || (e = Promise))(function(r, l) {
178
- function f(s) {
183
+ function f(u) {
179
184
  try {
180
- o(i.next(s));
185
+ o(i.next(u));
181
186
  } catch (g) {
182
187
  l(g);
183
188
  }
184
189
  }
185
- function u(s) {
190
+ function s(u) {
186
191
  try {
187
- o(i.throw(s));
192
+ o(i.throw(u));
188
193
  } catch (g) {
189
194
  l(g);
190
195
  }
191
196
  }
192
- function o(s) {
193
- s.done ? r(s.value) : a(s.value).then(f, u);
197
+ function o(u) {
198
+ u.done ? r(u.value) : a(u.value).then(f, s);
194
199
  }
195
200
  o((i = i.apply(t, n || [])).next());
196
201
  });
197
- }, L = function(t, n) {
202
+ }, L = globalThis && globalThis.__generator || function(t, n) {
198
203
  var e = { label: 0, sent: function() {
199
- if (r[0] & 1) throw r[1];
204
+ if (r[0] & 1)
205
+ throw r[1];
200
206
  return r[1];
201
207
  }, trys: [], ops: [] }, i, a, r, l;
202
208
  return l = { next: f(0), throw: f(1), return: f(2) }, typeof Symbol == "function" && (l[Symbol.iterator] = function() {
203
209
  return this;
204
210
  }), l;
205
211
  function f(o) {
206
- return function(s) {
207
- return u([o, s]);
212
+ return function(u) {
213
+ return s([o, u]);
208
214
  };
209
215
  }
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);
216
+ function s(o) {
217
+ if (i)
218
+ throw new TypeError("Generator is already executing.");
219
+ for (; e; )
220
+ try {
221
+ 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)
222
+ return r;
223
+ switch (a = 0, r && (o = [o[0] & 2, r.value]), o[0]) {
224
+ case 0:
225
+ case 1:
226
+ r = o;
242
227
  break;
243
- }
244
- r[2] && e.ops.pop(), e.trys.pop();
245
- continue;
228
+ case 4:
229
+ return e.label++, { value: o[1], done: !1 };
230
+ case 5:
231
+ e.label++, a = o[1], o = [0];
232
+ continue;
233
+ case 7:
234
+ o = e.ops.pop(), e.trys.pop();
235
+ continue;
236
+ default:
237
+ if (r = e.trys, !(r = r.length > 0 && r[r.length - 1]) && (o[0] === 6 || o[0] === 2)) {
238
+ e = 0;
239
+ continue;
240
+ }
241
+ if (o[0] === 3 && (!r || o[1] > r[0] && o[1] < r[3])) {
242
+ e.label = o[1];
243
+ break;
244
+ }
245
+ if (o[0] === 6 && e.label < r[1]) {
246
+ e.label = r[1], r = o;
247
+ break;
248
+ }
249
+ if (r && e.label < r[2]) {
250
+ e.label = r[2], e.ops.push(o);
251
+ break;
252
+ }
253
+ r[2] && e.ops.pop(), e.trys.pop();
254
+ continue;
255
+ }
256
+ o = n.call(t, e);
257
+ } catch (u) {
258
+ o = [6, u], a = 0;
259
+ } finally {
260
+ i = r = 0;
246
261
  }
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];
262
+ if (o[0] & 5)
263
+ throw o[1];
254
264
  return { value: o[0] ? o[1] : void 0, done: !0 };
255
265
  }
256
- }, Ee = function(t, n) {
266
+ }, Ee = globalThis && globalThis.__read || function(t, n) {
257
267
  var e = typeof Symbol == "function" && t[Symbol.iterator];
258
- if (!e) return t;
268
+ if (!e)
269
+ return t;
259
270
  var i = e.call(t), a, r = [], l;
260
271
  try {
261
- for (; (n === void 0 || n-- > 0) && !(a = i.next()).done; ) r.push(a.value);
272
+ for (; (n === void 0 || n-- > 0) && !(a = i.next()).done; )
273
+ r.push(a.value);
262
274
  } catch (f) {
263
275
  l = { error: f };
264
276
  } finally {
265
277
  try {
266
278
  a && !a.done && (e = i.return) && e.call(i);
267
279
  } finally {
268
- if (l) throw l.error;
280
+ if (l)
281
+ throw l.error;
269
282
  }
270
283
  }
271
284
  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]);
285
+ }, Ie = globalThis && globalThis.__spreadArray || function(t, n, e) {
286
+ if (e || arguments.length === 2)
287
+ for (var i = 0, a = n.length, r; i < a; i++)
288
+ (r || !(i in n)) && (r || (r = Array.prototype.slice.call(n, 0, i)), r[i] = n[i]);
275
289
  return t.concat(r || Array.prototype.slice.call(n));
276
- }, ne = new F(), k = new F(), $ = new F(), re = {
290
+ }, ne = new F(), V = new F(), $ = new F(), re = {
277
291
  cache: ne,
278
292
  refreshInterval: 0,
279
293
  ttl: 0,
@@ -289,12 +303,12 @@ var m = function() {
289
303
  isDocumentVisible: x.isDocumentVisible
290
304
  };
291
305
  function Se(t, n, e) {
292
- var i = k.get(t);
306
+ var i = V.get(t);
293
307
  if (i)
294
308
  i.data.push(n);
295
309
  else {
296
310
  var a = 5e3;
297
- k.set(t, [n], e > 0 ? e + a : e);
311
+ V.set(t, [n], e > 0 ? e + a : e);
298
312
  }
299
313
  }
300
314
  function Ae(t, n, e) {
@@ -307,11 +321,12 @@ function Ae(t, n, e) {
307
321
  }
308
322
  var J = function(t, n, e, i) {
309
323
  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;
324
+ var a, r, l, f, s, o, u;
311
325
  return L(this, function(g) {
312
326
  switch (g.label) {
313
327
  case 0:
314
- if (!Oe(n)) return [3, 5];
328
+ if (!Pe(n))
329
+ return [3, 5];
315
330
  g.label = 1;
316
331
  case 1:
317
332
  return g.trys.push([1, 3, , 4]), [4, n];
@@ -324,32 +339,32 @@ var J = function(t, n, e, i) {
324
339
  case 5:
325
340
  a = n, g.label = 6;
326
341
  case 6:
327
- if (l = !1, u = { data: a, error: r, isValidating: l }, typeof a < "u")
342
+ if (l = !1, s = { data: a, error: r, isValidating: l }, typeof a < "u")
328
343
  try {
329
- e.set(t, u, i);
344
+ e.set(t, s, i);
330
345
  } catch (v) {
331
346
  console.error("swrv(mutate): failed to set cache", v);
332
347
  }
333
- return o = k.get(t), o && o.data.length && (s = o.data.filter(function(v) {
348
+ return o = V.get(t), o && o.data.length && (u = o.data.filter(function(v) {
334
349
  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];
350
+ }), u.forEach(function(v, d) {
351
+ typeof s.data < "u" && (v.data = s.data), v.error = s.error, v.isValidating = s.isValidating;
352
+ var b = d === u.length - 1;
353
+ b || delete u[d];
354
+ }), u = u.filter(Boolean)), [2, s];
340
355
  }
341
356
  });
342
357
  });
343
358
  };
344
- function Ve() {
359
+ function Te() {
345
360
  for (var t = this, n = [], e = 0; e < arguments.length; e++)
346
361
  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;
362
+ var i, a, r = y({}, re), l = !1, f = !1, s = fe(), o = (s == null ? void 0 : s.proxy) || s;
348
363
  if (!o)
349
364
  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);
365
+ var u = (o == null ? void 0 : o.$isServer) || !1;
366
+ n.length >= 1 && (i = n[0]), n.length >= 2 && (a = n[1]), n.length > 2 && (r = y(y({}, r), n[2]));
367
+ var g = u ? r.serverTTL : r.ttl, v = typeof i == "function" ? i : X(i);
353
368
  typeof a > "u" && (a = r.fetcher);
354
369
  var d = null;
355
370
  d || (d = de({
@@ -360,31 +375,31 @@ function Ve() {
360
375
  }));
361
376
  var b = function(h, c) {
362
377
  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) {
378
+ var N, m, I, S, H, z, O, G = this;
379
+ return L(this, function(k) {
380
+ switch (k.label) {
366
381
  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, [
382
+ return N = d.data === void 0, m = v.value, m ? (I = r.cache.get(m), S = I && I.data, d.isValidating = !0, S && (d.data = S.data, d.error = S.error), H = h || a, !H || !r.isDocumentVisible() && !N || (c == null ? void 0 : c.forceRevalidate) !== void 0 && !(c != null && c.forceRevalidate) ? (d.isValidating = !1, [
368
383
  2
369
384
  /*return*/
370
385
  ]) : I && (z = !!(Date.now() - I.createdAt >= r.dedupingInterval || c != null && c.forceRevalidate), !z) ? (d.isValidating = !1, [
371
386
  2
372
387
  /*return*/
373
- ]) : (H = function() {
388
+ ]) : (O = function() {
374
389
  return R(G, void 0, void 0, function() {
375
- var w, K, B, W;
376
- return L(this, function(O) {
377
- switch (O.label) {
390
+ var p, K, B, W;
391
+ return L(this, function(P) {
392
+ switch (P.label) {
378
393
  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)]);
394
+ return p = $.get(m), p ? [3, 2] : (K = Array.isArray(m) ? m : [m], B = H.apply(void 0, Ie([], Ee(K), !1)), $.set(m, B, r.dedupingInterval), [4, J(m, B, r.cache, g)]);
380
395
  case 1:
381
- return O.sent(), [3, 4];
396
+ return P.sent(), [3, 4];
382
397
  case 2:
383
- return [4, J(y, w.data, r.cache, g)];
398
+ return [4, J(m, p.data, r.cache, g)];
384
399
  case 3:
385
- O.sent(), O.label = 4;
400
+ P.sent(), P.label = 4;
386
401
  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)), [
402
+ return d.isValidating = !1, $.delete(m), d.error !== void 0 && (W = !l && r.shouldRetryOnError && (c ? c.shouldRetryOnError : !0), W && Ae(b, c ? c.errorRetryCount : 1, r)), [
388
403
  2
389
404
  /*return*/
390
405
  ];
@@ -393,12 +408,12 @@ function Ve() {
393
408
  });
394
409
  }, S && r.revalidateDebounce ? (setTimeout(function() {
395
410
  return R(G, void 0, void 0, function() {
396
- return L(this, function(w) {
397
- switch (w.label) {
411
+ return L(this, function(p) {
412
+ switch (p.label) {
398
413
  case 0:
399
- return l ? [3, 2] : [4, H()];
414
+ return l ? [3, 2] : [4, O()];
400
415
  case 1:
401
- w.sent(), w.label = 2;
416
+ p.sent(), p.label = 2;
402
417
  case 2:
403
418
  return [
404
419
  2
@@ -412,9 +427,9 @@ function Ve() {
412
427
  /*return*/
413
428
  ];
414
429
  case 1:
415
- return [4, H()];
430
+ return [4, O()];
416
431
  case 2:
417
- T.sent(), T.label = 3;
432
+ k.sent(), k.label = 3;
418
433
  case 3:
419
434
  return [
420
435
  2
@@ -423,13 +438,13 @@ function Ve() {
423
438
  }
424
439
  });
425
440
  });
426
- }, V = function() {
441
+ }, T = function() {
427
442
  return R(t, void 0, void 0, function() {
428
443
  return L(this, function(h) {
429
444
  return [2, b(null, { shouldRetryOnError: !1 })];
430
445
  });
431
446
  });
432
- }, p = null;
447
+ }, _ = null;
433
448
  Q(function() {
434
449
  var h = function() {
435
450
  return R(t, void 0, void 0, function() {
@@ -440,9 +455,9 @@ function Ve() {
440
455
  case 1:
441
456
  return c.sent(), [3, 3];
442
457
  case 2:
443
- p && clearTimeout(p), c.label = 3;
458
+ _ && clearTimeout(_), c.label = 3;
444
459
  case 3:
445
- return r.refreshInterval && !l && (p = setTimeout(h, r.refreshInterval)), [
460
+ return r.refreshInterval && !l && (_ = setTimeout(h, r.refreshInterval)), [
446
461
  2
447
462
  /*return*/
448
463
  ];
@@ -450,31 +465,31 @@ function Ve() {
450
465
  });
451
466
  });
452
467
  };
453
- r.refreshInterval && (p = setTimeout(h, r.refreshInterval)), r.revalidateOnFocus && (document.addEventListener("visibilitychange", V, !1), window.addEventListener("focus", V, !1));
468
+ r.refreshInterval && (_ = setTimeout(h, r.refreshInterval)), r.revalidateOnFocus && (document.addEventListener("visibilitychange", T, !1), window.addEventListener("focus", T, !1));
454
469
  }), 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);
470
+ l = !0, _ && clearTimeout(_), r.revalidateOnFocus && (document.removeEventListener("visibilitychange", T, !1), window.removeEventListener("focus", T, !1));
471
+ var h = V.get(v.value);
457
472
  h && (h.data = h.data.filter(function(c) {
458
473
  return c !== d;
459
474
  }));
460
475
  });
461
476
  try {
462
477
  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;
478
+ ge(v) || (v.value = h), d.key = h, d.isValidating = !!h, Se(v.value, d, g), !u && !f && v.value && b(), f = !1;
464
479
  }, {
465
480
  immediate: !0
466
481
  });
467
482
  } catch {
468
483
  }
469
- var ae = m(m({}, ye(d)), { mutate: function(h, c) {
470
- return b(h, m(m({}, c), { forceRevalidate: !0 }));
484
+ var ae = y(y({}, me(d)), { mutate: function(h, c) {
485
+ return b(h, y(y({}, c), { forceRevalidate: !0 }));
471
486
  } });
472
487
  return ae;
473
488
  }
474
- function Oe(t) {
489
+ function Pe(t) {
475
490
  return t !== null && typeof t == "object" && typeof t.then == "function";
476
491
  }
477
- const ke = async (t) => {
492
+ const Ve = async (t) => {
478
493
  try {
479
494
  return await (await fetch(t)).json();
480
495
  } catch (n) {
@@ -482,7 +497,7 @@ const ke = async (t) => {
482
497
  return;
483
498
  }
484
499
  }, ie = () => {
485
- const t = me(), { data: n = t, isValidating: e } = Ve(_.auth, ke);
500
+ const t = ye(), { data: n = t, isValidating: e } = Te(w.auth, Ve);
486
501
  return {
487
502
  auth: n || {},
488
503
  // @ts-ignore //TBD
@@ -490,31 +505,31 @@ const ke = async (t) => {
490
505
  // @ts-ignore
491
506
  isLoggedIn: n == null ? void 0 : n.isLoggedIn
492
507
  };
493
- }, Pe = { key: 0 }, Me = /* @__PURE__ */ C({
508
+ }, He = { key: 0 }, Me = /* @__PURE__ */ C({
494
509
  __name: "LoggedIn",
495
510
  setup(t) {
496
511
  const n = () => {
497
512
  var e;
498
513
  return ((e = ie()) == null ? void 0 : e.isLoggedIn) || !1;
499
514
  };
500
- return (e, i) => n() ? (E(), M("div", Pe, [
515
+ return (e, i) => n() ? (E(), M("div", He, [
501
516
  Z(e.$slots, "default")
502
517
  ])) : ee("", !0);
503
518
  }
504
- }), He = { key: 0 }, je = /* @__PURE__ */ C({
519
+ }), Oe = { key: 0 }, je = /* @__PURE__ */ C({
505
520
  __name: "LoggedOut",
506
521
  setup(t) {
507
522
  const n = () => {
508
523
  var e;
509
524
  return ((e = ie()) == null ? void 0 : e.isLoggedIn) || !1;
510
525
  };
511
- return (e, i) => n() ? ee("", !0) : (E(), M("div", He, [
526
+ return (e, i) => n() ? ee("", !0) : (E(), M("div", Oe, [
512
527
  Z(e.$slots, "default")
513
528
  ]));
514
529
  }
515
- }), Ue = () => _.logout;
530
+ }), Ue = () => w.logout;
516
531
  function Fe() {
517
- window.location.href = _.logout;
532
+ window.location.href = w.logout;
518
533
  }
519
534
  export {
520
535
  De as ContinueButton,
@@ -525,7 +540,7 @@ export {
525
540
  $e as UpdateProfileButton,
526
541
  Ue as getLogOutRoute,
527
542
  Fe as logOut,
528
- _ as routeConfig,
543
+ w as routeConfig,
529
544
  ie as useAuth,
530
- me as useHelloProviderContext
545
+ ye as useHelloProviderContext
531
546
  };
package/dist/index.umd.js CHANGED
@@ -1 +1 @@
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
+ (function(g,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],a):(g=typeof globalThis<"u"?globalThis:g||self,a(g["@hellocoop/vue"]={},g.Vue))})(this,function(g,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"],V=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},promptLogin:{type:Boolean,default:!1},promptConsent:{type:Boolean,default:!1},loginHint:{default:""},domainHint:{default:""}},setup(t){let n=!1;a.onMounted(()=>{typeof window<"u"&&!n&&(Array.from(document.head.getElementsByTagName("link")).find(d=>{var u;return d.getAttribute("rel")==="stylesheet"&&((u=d.getAttribute("href"))==null?void 0:u.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.promptLogin&&i.promptConsent?o.searchParams.set("prompt","login consent"):i.promptLogin?o.searchParams.set("prompt","login"):i.promptConsent&&o.searchParams.set("prompt","consent"),i.loginHint&&o.searchParams.set("login_hint",i.loginHint),i.domainHint&&o.searchParams.set("login_hint",i.domainHint),i.providerHint&&o.searchParams.set("provider_hint",i.providerHint.join(" "));const r=()=>{e.value=!0,window.location.href=o.href};return(s,d)=>{var u;return a.openBlock(),a.createElementBlock("button",{onClick:r,class:a.normalizeClass(["hello-btn",(u=a.unref(S).CLASS_MAPPING[i.color])==null?void 0:u[i.theme],a.unref(S).HOVER_MAPPING[s.hover],(s.showLoader||e.value)&&"hello-btn-loader"]),disabled:i.disabled||e.value,style:a.normalizeStyle(s.style)},[a.createElementVNode("span",{innerHTML:s.label},null,8,te)],14,ee)}}}),ne=a.defineComponent({__name:"ContinueButton",setup(t){return(n,e)=>(a.openBlock(),a.createBlock(V))}}),re=a.defineComponent({__name:"LoginButton",setup(t){return(n,e)=>(a.openBlock(),a.createBlock(V,{label:"ō   Login with Hellō"}))}}),ie=a.defineComponent({__name:"UpdateProfileButton",setup(t){return(n,e)=>(a.openBlock(),a.createBlock(V,{label:"ō   Update Profile with Hellō",update:!0}))}});var B=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]):B.has(t[e])?i=B.get(t[e]):(i=x,B.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 O=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,s=Date.now(),d={data:e,createdAt:s,expiresAt:r?s+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(),s=r>=e.expiresAt;s&&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 se(){return typeof document<"u"&&typeof document.visibilityState<"u"?document.visibilityState!=="hidden":!0}var ue=function(t){return fetch(t).then(function(n){return n.json()})};const H={isOnline:le,isDocumentVisible:se,fetcher:ue};var b=globalThis&&globalThis.__assign||function(){return b=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},b.apply(this,arguments)},R=globalThis&&globalThis.__awaiter||function(t,n,e,i){function o(r){return r instanceof e?r:new e(function(s){s(r)})}return new(e||(e=Promise))(function(r,s){function d(c){try{l(i.next(c))}catch(y){s(y)}}function u(c){try{l(i.throw(c))}catch(y){s(y)}}function l(c){c.done?r(c.value):o(c.value).then(d,u)}l((i=i.apply(t,n||[])).next())})},L=globalThis&&globalThis.__generator||function(t,n){var e={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},i,o,r,s;return s={next:d(0),throw:d(1),return:d(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function d(l){return function(c){return u([l,c])}}function u(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(c){l=[6,c],o=0}finally{i=r=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}},ce=globalThis&&globalThis.__read||function(t,n){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var i=e.call(t),o,r=[],s;try{for(;(n===void 0||n-- >0)&&!(o=i.next()).done;)r.push(o.value)}catch(d){s={error:d}}finally{try{o&&!o.done&&(e=i.return)&&e.call(i)}finally{if(s)throw s.error}}return r},fe=globalThis&&globalThis.__spreadArray||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 O,T=new O,D=new O,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=T.get(t);if(i)i.data.push(n);else{var o=5e3;T.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),R(void 0,void 0,void 0,function(){var o,r,s,d,u,l,c;return L(this,function(y){switch(y.label){case 0:if(!ve(n))return[3,5];y.label=1;case 1:return y.trys.push([1,3,,4]),[4,n];case 2:return o=y.sent(),[3,4];case 3:return d=y.sent(),r=d,[3,4];case 4:return[3,6];case 5:o=n,y.label=6;case 6:if(s=!1,u={data:o,error:r,isValidating:s},typeof o<"u")try{e.set(t,u,i)}catch(m){console.error("swrv(mutate): failed to set cache",m)}return l=T.get(t),l&&l.data.length&&(c=l.data.filter(function(m){return m.key===t}),c.forEach(function(m,h){typeof u.data<"u"&&(m.data=u.data),m.error=u.error,m.isValidating=u.isValidating;var _=h===c.length-1;_||delete c[h]}),c=c.filter(Boolean)),[2,u]}})})};function ge(){for(var t=this,n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];var i,o,r=b({},K),s=!1,d=!1,u=a.getCurrentInstance(),l=(u==null?void 0:u.proxy)||u;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 c=(l==null?void 0:l.$isServer)||!1;n.length>=1&&(i=n[0]),n.length>=2&&(o=n[1]),n.length>2&&(r=b(b({},r),n[2]));var y=c?r.serverTTL:r.ttl,m=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(v,f){return R(t,void 0,void 0,function(){var Y,p,k,I,$,q,j,J=this;return L(this,function(U){switch(U.label){case 0:return Y=h.data===void 0,p=m.value,p?(k=r.cache.get(p),I=k&&k.data,h.isValidating=!0,I&&(h.data=I.data,h.error=I.error),$=v||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 R(J,void 0,void 0,function(){var C,Q,F,X;return L(this,function(P){switch(P.label){case 0:return C=D.get(p),C?[3,2]:(Q=Array.isArray(p)?p:[p],F=$.apply(void 0,fe([],ce(Q),!1)),D.set(p,F,r.dedupingInterval),[4,W(p,F,r.cache,y)]);case 1:return P.sent(),[3,4];case 2:return[4,W(p,C.data,r.cache,y)];case 3:P.sent(),P.label=4;case 4:return h.isValidating=!1,D.delete(p),h.error!==void 0&&(X=!s&&r.shouldRetryOnError&&(f?f.shouldRetryOnError:!0),X&&he(_,f?f.errorRetryCount:1,r)),[2]}})})},I&&r.revalidateDebounce?(setTimeout(function(){return R(J,void 0,void 0,function(){return L(this,function(C){switch(C.label){case 0:return s?[3,2]:[4,j()];case 1:C.sent(),C.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]}})})},A=function(){return R(t,void 0,void 0,function(){return L(this,function(v){return[2,_(null,{shouldRetryOnError:!1})]})})},E=null;a.onMounted(function(){var v=function(){return R(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&&!s&&(E=setTimeout(v,r.refreshInterval)),[2]}})})};r.refreshInterval&&(E=setTimeout(v,r.refreshInterval)),r.revalidateOnFocus&&(document.addEventListener("visibilitychange",A,!1),window.addEventListener("focus",A,!1))}),a.onUnmounted(function(){s=!0,E&&clearTimeout(E),r.revalidateOnFocus&&(document.removeEventListener("visibilitychange",A,!1),window.removeEventListener("focus",A,!1));var v=T.get(m.value);v&&(v.data=v.data.filter(function(f){return f!==h}))});try{a.watch(m,function(v){a.isReadonly(m)||(m.value=v),h.key=v,h.isValidating=!!v,de(m.value,h,y),!c&&!d&&m.value&&_(),d=!1},{immediate:!0})}catch{}var Re=b(b({},a.toRefs(h)),{mutate:function(v,f){return _(v,b(b({},f),{forceRevalidate:!0}))}});return Re}function ve(t){return t!==null&&typeof t=="object"&&typeof t.then=="function"}const me=async t=>{try{return await(await fetch(t)).json()}catch(n){console.error(n);return}},M=()=>{const t=z(),{data:n=t,isValidating:e}=ge(w.auth,me);return{auth:n||{},isLoading:e,isLoggedIn:n==null?void 0:n.isLoggedIn}},ye={key:0},pe=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",ye,[a.renderSlot(e.$slots,"default")])):a.createCommentVNode("",!0)}}),be={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",be,[a.renderSlot(e.$slots,"default")]))}}),_e=()=>w.logout;function Ce(){window.location.href=w.logout}g.ContinueButton=ne,g.HelloProvider=Z,g.LoggedIn=pe,g.LoggedOut=we,g.LoginButton=re,g.UpdateProfileButton=ie,g.getLogOutRoute=_e,g.logOut=Ce,g.routeConfig=w,g.useAuth=M,g.useHelloProviderContext=z,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})});
@@ -1,6 +1,8 @@
1
- declare const _default: __VLS_WithTemplateSlots<import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{}>>, {}, {}>, {
1
+ declare function __VLS_template(): {
2
2
  default?(_: {}): any;
3
- }>;
3
+ };
4
+ declare const __VLS_component: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
5
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
4
6
  export default _default;
5
7
  type __VLS_WithTemplateSlots<T, S> = T & {
6
8
  new (): {
@@ -1,6 +1,8 @@
1
- declare const _default: __VLS_WithTemplateSlots<import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{}>>, {}, {}>, {
1
+ declare function __VLS_template(): {
2
2
  default?(_: {}): any;
3
- }>;
3
+ };
4
+ declare const __VLS_component: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
5
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
4
6
  export default _default;
5
7
  type __VLS_WithTemplateSlots<T, S> = T & {
6
8
  new (): {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hellocoop/vue",
3
- "version": "2.0.0",
3
+ "version": "2.1.1",
4
4
  "description": "Svelte SDK for Hellō https://hello.dev",
5
5
  "repository": {
6
6
  "type": "git",
@@ -39,15 +39,17 @@
39
39
  "dist"
40
40
  ],
41
41
  "scripts": {
42
- "build": "vite build"
42
+ "build": "vite build",
43
+ "prebuild": "rimraf dist node_modules"
43
44
  },
44
45
  "dependencies": {
45
- "@vitejs/plugin-vue": "^5.1.2",
46
+ "@vitejs/plugin-vue": "^5.1.4",
46
47
  "swrv": "^1.0.4",
47
48
  "vue": "^3.0.5"
48
49
  },
49
50
  "devDependencies": {
50
51
  "typescript": "^5.2.2",
51
52
  "vite-plugin-dts": "^3.6.3"
52
- }
53
+ },
54
+ "gitHead": "b418b4e249a7fe7025d467688e52132848b465a2"
53
55
  }