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