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