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