@24city/web-console 0.3.12 → 0.3.14
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/CHANGELOG.md +31 -0
- package/README.md +14 -1
- package/dist/account/account-api.d.ts +32 -3
- package/dist/account/index.js +76 -72
- package/dist/account/keepalive-adapter.d.ts +7 -0
- package/dist/account/use-track.d.ts +36 -7
- package/dist/chunks/{auth-provider-Cwib6lRM.js → auth-provider-BzxebTYE.js} +1 -1
- package/dist/chunks/{console-layout-BhmLHO5v.js → console-layout-CaYKllsP.js} +20 -20
- package/dist/chunks/logout-signal-DtOS9Rse.js +434 -0
- package/dist/chunks/{stale-build-CJ5c5sRp.js → stale-build-BvMjthh1.js} +2 -2
- package/dist/chunks/{use-show-once-Cwj5z_Lo.js → use-show-once-BMTl8DL7.js} +140 -140
- package/dist/chunks/wallet-badge-Cu2WL0RX.js +706 -0
- package/dist/index.js +198 -194
- package/dist/layout/index.js +1 -1
- package/dist/runtime/index.js +2 -2
- package/package.json +1 -1
- package/dist/chunks/logout-signal-qvHorCCF.js +0 -385
- package/dist/chunks/wallet-badge-DnWl21es.js +0 -629
|
@@ -0,0 +1,434 @@
|
|
|
1
|
+
import { sanitizeInternalReturnPath as v } from "@24city/web-runtime/core/internal-path";
|
|
2
|
+
import { AxiosError as N } from "axios";
|
|
3
|
+
import { createContext as F, useSyncExternalStore as k, useContext as M } from "react";
|
|
4
|
+
import { summarizeCustomerError as _ } from "@24city/web-runtime/error-summary";
|
|
5
|
+
const T = (t) => t.includes("\\") || [...t].some((e) => {
|
|
6
|
+
const s = e.charCodeAt(0);
|
|
7
|
+
return s <= 31 || s === 127;
|
|
8
|
+
}), St = (t) => !T(t) && t.startsWith("/") && !t.startsWith("//") && (() => {
|
|
9
|
+
try {
|
|
10
|
+
const e = new URL(t, "https://product.invalid");
|
|
11
|
+
return e.origin === "https://product.invalid" && v(t, e.pathname) === t;
|
|
12
|
+
} catch {
|
|
13
|
+
return !1;
|
|
14
|
+
}
|
|
15
|
+
})(), gt = (t, e) => !T(t) && v(t, e) === t, q = (t, e) => !t || T(t) ? e : v(t, e), U = (t) => typeof t == "object" && t !== null && !Array.isArray(t), p = (t, e) => {
|
|
16
|
+
const s = e.data;
|
|
17
|
+
if (!U(s) || s.code !== 0 || !("data" in s))
|
|
18
|
+
throw new Error(`接口 ${t} 返回了无效响应`);
|
|
19
|
+
return s.data;
|
|
20
|
+
}, l = (t, e, s) => {
|
|
21
|
+
if (!U(t)) throw new Error(`接口 ${e} 字段 ${s} 无效`);
|
|
22
|
+
return t;
|
|
23
|
+
}, a = (t, e, s) => {
|
|
24
|
+
const r = t[e];
|
|
25
|
+
if (typeof r != "string" || !r.trim())
|
|
26
|
+
throw new Error(`接口 ${s} 字段 ${e} 无效`);
|
|
27
|
+
return r;
|
|
28
|
+
}, h = (t, e, s) => {
|
|
29
|
+
const r = t[e];
|
|
30
|
+
if (typeof r != "number" || !Number.isSafeInteger(r) || r < 0)
|
|
31
|
+
throw new Error(`接口 ${s} 字段 ${e} 无效`);
|
|
32
|
+
return r;
|
|
33
|
+
}, W = 60 * 1024, B = /^[a-z][a-z\d+.-]*:\/\//i, H = ({ baseURL: t, url: e = "" }) => !t || B.test(e) ? e : `${t.replace(/\/+$/, "")}/${e.replace(/^\/+/, "")}`, V = (t) => {
|
|
34
|
+
const e = new Headers();
|
|
35
|
+
for (const [s, r] of Object.entries(t.headers.toJSON(!0))) e.set(s, String(r));
|
|
36
|
+
return e;
|
|
37
|
+
}, j = (t) => {
|
|
38
|
+
const e = {};
|
|
39
|
+
return t.headers.forEach((s, r) => {
|
|
40
|
+
e[r] = s;
|
|
41
|
+
}), e;
|
|
42
|
+
}, D = async (t) => {
|
|
43
|
+
const e = typeof t.data == "string" ? t.data : t.data == null ? void 0 : JSON.stringify(t.data);
|
|
44
|
+
let s;
|
|
45
|
+
try {
|
|
46
|
+
s = await fetch(H(t), {
|
|
47
|
+
method: (t.method ?? "post").toUpperCase(),
|
|
48
|
+
headers: V(t),
|
|
49
|
+
body: e,
|
|
50
|
+
credentials: t.withCredentials ? "include" : "same-origin",
|
|
51
|
+
keepalive: e === void 0 || new TextEncoder().encode(e).length <= W
|
|
52
|
+
});
|
|
53
|
+
} catch (w) {
|
|
54
|
+
throw N.from(w, N.ERR_NETWORK, t);
|
|
55
|
+
}
|
|
56
|
+
const r = await s.text();
|
|
57
|
+
let n = r;
|
|
58
|
+
try {
|
|
59
|
+
n = r && JSON.parse(r);
|
|
60
|
+
} catch {
|
|
61
|
+
n = r;
|
|
62
|
+
}
|
|
63
|
+
const c = {
|
|
64
|
+
data: n,
|
|
65
|
+
status: s.status,
|
|
66
|
+
statusText: s.statusText,
|
|
67
|
+
headers: j(s),
|
|
68
|
+
config: t
|
|
69
|
+
};
|
|
70
|
+
if (!t.validateStatus || t.validateStatus(s.status)) return c;
|
|
71
|
+
throw new N(
|
|
72
|
+
`Request failed with status code ${s.status}`,
|
|
73
|
+
s.status >= 500 ? N.ERR_BAD_RESPONSE : N.ERR_BAD_REQUEST,
|
|
74
|
+
t,
|
|
75
|
+
void 0,
|
|
76
|
+
c
|
|
77
|
+
);
|
|
78
|
+
}, m = "/account", u = `${m}/session`, P = `${m}/logout`, i = `${m}/spaces`, O = `${i}/switch`, b = `${m}/profile`, g = `${m}/wallet`, $ = `${m}/entitlements`, f = `${m}/subscription`, o = `${m}/plans`, E = `${m}/shown-prompts`, G = `${m}/events`, K = `${m}/visits`, J = /^[a-z][a-z0-9_]{0,31}$/, A = (t, e, s) => {
|
|
79
|
+
const r = t[e];
|
|
80
|
+
if (r !== null && typeof r != "string")
|
|
81
|
+
throw new Error(`接口 ${s} 字段 ${e} 无效`);
|
|
82
|
+
return r;
|
|
83
|
+
}, y = (t, e, s) => {
|
|
84
|
+
const r = t[e];
|
|
85
|
+
if (r != null) {
|
|
86
|
+
if (typeof r != "string")
|
|
87
|
+
throw new Error(`接口 ${s} 字段 ${e} 无效`);
|
|
88
|
+
return r;
|
|
89
|
+
}
|
|
90
|
+
}, Y = (t, e, s) => {
|
|
91
|
+
const r = t[e];
|
|
92
|
+
return r === null ? {} : l(r, s, e);
|
|
93
|
+
}, Q = (t) => {
|
|
94
|
+
const e = l(t, P, "data"), s = y(e, "endSessionUrl", P);
|
|
95
|
+
if (!s) return null;
|
|
96
|
+
try {
|
|
97
|
+
return new URL(s).protocol === "https:" ? s : null;
|
|
98
|
+
} catch {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
}, L = (t) => {
|
|
102
|
+
const e = l(t, u, "data");
|
|
103
|
+
if (e.purpose !== "user") throw new Error("产品用户 Web 只接受 user Purpose 会话");
|
|
104
|
+
return {
|
|
105
|
+
globalUserId: a(e, "globalUserId", u),
|
|
106
|
+
localUserId: h(e, "localUserId", u),
|
|
107
|
+
activeSpaceId: a(e, "activeSpaceId", u),
|
|
108
|
+
authorityId: h(e, "authorityId", u),
|
|
109
|
+
orgId: h(e, "orgId", u),
|
|
110
|
+
purpose: "user",
|
|
111
|
+
csrfToken: a(e, "csrfToken", u),
|
|
112
|
+
issuedAt: a(e, "issuedAt", u),
|
|
113
|
+
lastSeenAt: a(e, "lastSeenAt", u),
|
|
114
|
+
absoluteExpiresAt: a(e, "absoluteExpiresAt", u),
|
|
115
|
+
lastCentralVerifiedAt: a(e, "lastCentralVerifiedAt", u),
|
|
116
|
+
accountCenterUrl: a(e, "accountCenterUrl", u)
|
|
117
|
+
};
|
|
118
|
+
}, x = (t, e, s) => {
|
|
119
|
+
const r = l(t, e, s);
|
|
120
|
+
return {
|
|
121
|
+
id: a(r, "id", e),
|
|
122
|
+
entitlementCode: a(r, "entitlementCode", e),
|
|
123
|
+
status: y(r, "status", e),
|
|
124
|
+
startsAt: a(r, "startsAt", e),
|
|
125
|
+
expiresAt: A(r, "expiresAt", e),
|
|
126
|
+
metadata: Y(r, "metadata", e)
|
|
127
|
+
};
|
|
128
|
+
}, X = (t, e) => {
|
|
129
|
+
const s = l(t, i, `spaces[${e}]`), r = l(s.entitlementSummary, i, "entitlementSummary"), n = r.codes, c = s.entitlements;
|
|
130
|
+
if (!Array.isArray(n) || n.some((w) => typeof w != "string"))
|
|
131
|
+
throw new Error(`接口 ${i} 字段 entitlementSummary.codes 无效`);
|
|
132
|
+
if (!Array.isArray(c))
|
|
133
|
+
throw new Error(`接口 ${i} 字段 entitlements 无效`);
|
|
134
|
+
return {
|
|
135
|
+
id: a(s, "id", i),
|
|
136
|
+
name: a(s, "name", i),
|
|
137
|
+
slug: a(s, "slug", i),
|
|
138
|
+
type: a(s, "type", i),
|
|
139
|
+
role: a(s, "role", i),
|
|
140
|
+
status: a(s, "status", i),
|
|
141
|
+
membershipStatus: a(s, "membershipStatus", i),
|
|
142
|
+
entitlementSummary: {
|
|
143
|
+
activeCount: h(r, "activeCount", i),
|
|
144
|
+
codes: [...n]
|
|
145
|
+
},
|
|
146
|
+
entitlements: c.map(
|
|
147
|
+
(w, d) => x(w, i, `entitlements[${d}]`)
|
|
148
|
+
)
|
|
149
|
+
};
|
|
150
|
+
}, Z = (t) => {
|
|
151
|
+
const e = l(t, i, "data"), s = a(e, "activeSpaceId", i);
|
|
152
|
+
if (!Array.isArray(e.spaces)) throw new Error(`接口 ${i} 字段 spaces 无效`);
|
|
153
|
+
const r = e.spaces.map(X);
|
|
154
|
+
if (!r.some((n) => n.id === s))
|
|
155
|
+
throw new Error(`接口 ${i} 的当前空间不在可用空间列表中`);
|
|
156
|
+
return { activeSpaceId: s, spaces: r };
|
|
157
|
+
}, tt = (t) => {
|
|
158
|
+
const e = l(t, b, "data");
|
|
159
|
+
return { nickName: (y(e, "nickName", b) ?? "").trim() };
|
|
160
|
+
}, et = (t) => {
|
|
161
|
+
const e = l(t, g, "data"), s = (r) => {
|
|
162
|
+
const n = e[r];
|
|
163
|
+
if (typeof n != "number" || !Number.isSafeInteger(n))
|
|
164
|
+
throw new Error(`接口 ${g} 字段 ${r} 无效`);
|
|
165
|
+
return n;
|
|
166
|
+
};
|
|
167
|
+
return {
|
|
168
|
+
spaceId: a(e, "spaceId", g),
|
|
169
|
+
globalUserId: a(e, "globalUserId", g),
|
|
170
|
+
productCode: a(e, "productCode", g),
|
|
171
|
+
availablePoints: s("availablePoints"),
|
|
172
|
+
reservedPoints: s("reservedPoints"),
|
|
173
|
+
globalAvailablePoints: s("globalAvailablePoints"),
|
|
174
|
+
globalReservedPoints: s("globalReservedPoints"),
|
|
175
|
+
productAvailablePoints: s("productAvailablePoints"),
|
|
176
|
+
productReservedPoints: s("productReservedPoints"),
|
|
177
|
+
walletAvailablePoints: s("walletAvailablePoints"),
|
|
178
|
+
walletReservedPoints: s("walletReservedPoints"),
|
|
179
|
+
walletVersion: h(e, "walletVersion", g)
|
|
180
|
+
};
|
|
181
|
+
}, rt = (t) => {
|
|
182
|
+
if (t === null) return null;
|
|
183
|
+
const e = l(t, f, "data"), s = e.tier;
|
|
184
|
+
if (typeof s != "number" || !Number.isSafeInteger(s))
|
|
185
|
+
throw new Error(`接口 ${f} 字段 tier 无效`);
|
|
186
|
+
if (typeof e.isDefault != "boolean")
|
|
187
|
+
throw new Error(`接口 ${f} 字段 isDefault 无效`);
|
|
188
|
+
return {
|
|
189
|
+
subscriptionId: A(e, "subscriptionId", f),
|
|
190
|
+
planCode: a(e, "planCode", f),
|
|
191
|
+
planName: (y(e, "planName", f) ?? "").trim(),
|
|
192
|
+
tier: s,
|
|
193
|
+
isDefault: e.isDefault,
|
|
194
|
+
spaceType: y(e, "spaceType", f) ?? "",
|
|
195
|
+
currentPeriodEnd: A(e, "currentPeriodEnd", f)
|
|
196
|
+
};
|
|
197
|
+
}, st = /* @__PURE__ */ new Set(["month", "year", "one_time"]), nt = (t, e) => {
|
|
198
|
+
const s = l(t, o, e), r = a(s, "billingPeriod", o);
|
|
199
|
+
if (!st.has(r)) throw new Error(`接口 ${o} 字段 ${e}.billingPeriod 无效`);
|
|
200
|
+
return {
|
|
201
|
+
code: a(s, "code", o),
|
|
202
|
+
amountCents: h(s, "amountCents", o),
|
|
203
|
+
currency: a(s, "currency", o),
|
|
204
|
+
billingPeriod: r,
|
|
205
|
+
durationDays: h(s, "durationDays", o),
|
|
206
|
+
pointCycles: h(s, "pointCycles", o)
|
|
207
|
+
};
|
|
208
|
+
}, at = (t, e) => {
|
|
209
|
+
const s = l(t, o, e), r = s.limit;
|
|
210
|
+
if (r != null && (typeof r != "number" || !Number.isSafeInteger(r) || r < 0))
|
|
211
|
+
throw new Error(`接口 ${o} 字段 ${e}.limit 无效`);
|
|
212
|
+
const n = Array.isArray(s.discounts) ? s.discounts.filter((c) => typeof c == "string") : [];
|
|
213
|
+
return {
|
|
214
|
+
key: y(s, "key", o) ?? "",
|
|
215
|
+
name: a(s, "name", o),
|
|
216
|
+
description: y(s, "description", o) ?? "",
|
|
217
|
+
limit: typeof r == "number" ? r : null,
|
|
218
|
+
discounts: n
|
|
219
|
+
};
|
|
220
|
+
}, ot = (t, e) => {
|
|
221
|
+
const s = `data[${e}]`, r = l(t, o, s), n = a(r, "spaceType", o);
|
|
222
|
+
if (n !== "personal" && n !== "team") throw new Error(`接口 ${o} 字段 ${s}.spaceType 无效`);
|
|
223
|
+
if (typeof r.tier != "number" || !Number.isSafeInteger(r.tier)) throw new Error(`接口 ${o} 字段 ${s}.tier 无效`);
|
|
224
|
+
if (typeof r.isDefault != "boolean") throw new Error(`接口 ${o} 字段 ${s}.isDefault 无效`);
|
|
225
|
+
if (!Array.isArray(r.prices)) throw new Error(`接口 ${o} 字段 ${s}.prices 无效`);
|
|
226
|
+
const c = Array.isArray(r.benefits) ? r.benefits : [], w = Array.isArray(r.otherProducts) ? r.otherProducts.filter((d) => typeof d == "string" && d.trim() !== "").map((d) => d.trim()) : [];
|
|
227
|
+
return {
|
|
228
|
+
code: a(r, "code", o),
|
|
229
|
+
name: a(r, "name", o).trim(),
|
|
230
|
+
spaceType: n,
|
|
231
|
+
tier: r.tier,
|
|
232
|
+
isDefault: r.isDefault,
|
|
233
|
+
includedSeats: h(r, "includedSeats", o),
|
|
234
|
+
monthlyPoints: h(r, "monthlyPoints", o),
|
|
235
|
+
prices: r.prices.map((d, I) => nt(d, `${s}.prices[${I}]`)),
|
|
236
|
+
benefits: c.map((d, I) => at(d, `${s}.benefits[${I}]`)),
|
|
237
|
+
otherProducts: w
|
|
238
|
+
};
|
|
239
|
+
}, R = (t, e) => {
|
|
240
|
+
const s = l(t, E, "data")[e];
|
|
241
|
+
if (!Array.isArray(s) || s.some((r) => typeof r != "string"))
|
|
242
|
+
throw new Error(`接口 ${E} 字段 ${e} 无效`);
|
|
243
|
+
return [...s];
|
|
244
|
+
}, it = (t) => {
|
|
245
|
+
if (!Array.isArray(t)) throw new Error(`接口 ${o} 字段 data 无效`);
|
|
246
|
+
return t.map(ot);
|
|
247
|
+
}, yt = (t, e) => {
|
|
248
|
+
const s = e === "/" ? "" : e;
|
|
249
|
+
return {
|
|
250
|
+
async reportBehaviorEvents(r, n) {
|
|
251
|
+
r.length !== 0 && await t.post(G, { events: r }, n != null && n.keepalive ? { adapter: D } : void 0);
|
|
252
|
+
},
|
|
253
|
+
async reportVisits(r, n) {
|
|
254
|
+
r.length !== 0 && await t.post(K, { pageViews: r }, n != null && n.keepalive ? { adapter: D } : void 0);
|
|
255
|
+
},
|
|
256
|
+
startLogin(r, n, c) {
|
|
257
|
+
const w = q(r, n), d = c != null && c.entry && J.test(c.entry) ? `&entry=${c.entry}` : "";
|
|
258
|
+
return `${s}${m}/startLogin?returnPath=${encodeURIComponent(w)}${d}`;
|
|
259
|
+
},
|
|
260
|
+
async getSession() {
|
|
261
|
+
return L(p(u, await t.get(u)));
|
|
262
|
+
},
|
|
263
|
+
async getSpaces() {
|
|
264
|
+
return Z(p(i, await t.get(i)));
|
|
265
|
+
},
|
|
266
|
+
async switchSpace(r) {
|
|
267
|
+
const n = p(O, await t.post(O, { globalSpaceId: r }));
|
|
268
|
+
return L(n);
|
|
269
|
+
},
|
|
270
|
+
async getProfile() {
|
|
271
|
+
return tt(p(b, await t.get(b)));
|
|
272
|
+
},
|
|
273
|
+
async getWallet() {
|
|
274
|
+
return et(p(g, await t.get(g)));
|
|
275
|
+
},
|
|
276
|
+
async getEntitlements() {
|
|
277
|
+
const r = p($, await t.get($));
|
|
278
|
+
if (!Array.isArray(r)) throw new Error(`接口 ${$} 字段 data 无效`);
|
|
279
|
+
return r.map((n, c) => x(n, $, `entitlements[${c}]`));
|
|
280
|
+
},
|
|
281
|
+
async getSubscription() {
|
|
282
|
+
return rt(p(f, await t.get(f)));
|
|
283
|
+
},
|
|
284
|
+
async getPlans() {
|
|
285
|
+
return it(p(o, await t.get(o)));
|
|
286
|
+
},
|
|
287
|
+
async logout() {
|
|
288
|
+
const r = p(P, await t.post(P));
|
|
289
|
+
return { endSessionUrl: Q(r) };
|
|
290
|
+
},
|
|
291
|
+
async getShownPrompts(r) {
|
|
292
|
+
const n = await t.get(E, { params: { keys: r.join(",") } });
|
|
293
|
+
return R(p(E, n), "shown");
|
|
294
|
+
},
|
|
295
|
+
async claimShownPrompts(r) {
|
|
296
|
+
const n = await t.post(E, { keys: [...r] });
|
|
297
|
+
return R(p(E, n), "claimed");
|
|
298
|
+
}
|
|
299
|
+
};
|
|
300
|
+
}, Et = async (t) => {
|
|
301
|
+
let e = await t.getSession();
|
|
302
|
+
const s = await t.getSpaces();
|
|
303
|
+
if (s.activeSpaceId !== e.activeSpaceId && (e = await t.getSession()), s.activeSpaceId !== e.activeSpaceId)
|
|
304
|
+
throw new Error("产品会话与统一空间上下文不一致");
|
|
305
|
+
return { session: e, spaces: s.spaces };
|
|
306
|
+
}, Nt = (t) => t == null || !Number.isFinite(t) ? "暂无" : t >= 1e8 ? `${(Math.floor(t / 1e7) / 10).toFixed(1)}亿` : t >= 1e4 ? `${(Math.floor(t / 1e3) / 10).toFixed(1)}万` : t.toLocaleString("zh-CN"), $t = (t) => t.toLocaleString("zh-CN", { maximumFractionDigits: 0 }), Pt = (t) => t > 0 && t < 0.01 ? "<0.01" : t.toLocaleString("zh-CN", { maximumFractionDigits: 2 }), bt = (t) => t ? `¥${(t / 100).toLocaleString("zh-CN", { minimumFractionDigits: 2, maximumFractionDigits: 2 })}` : "暂无", It = (t) => {
|
|
307
|
+
if (t === void 0 || t <= 0) return "";
|
|
308
|
+
const e = Math.floor(t / 60), s = Math.floor(t % 60);
|
|
309
|
+
return `${e}:${String(s).padStart(2, "0")}`;
|
|
310
|
+
}, At = (t) => {
|
|
311
|
+
if (t === void 0 || t <= 0) return "暂无";
|
|
312
|
+
const e = Math.floor(t / 3600), s = Math.floor(t % 3600 / 60), r = t % 60;
|
|
313
|
+
return e > 0 ? `${e}小时${s}分` : s > 0 ? `${s}分${r}秒` : `${r}秒`;
|
|
314
|
+
}, vt = (t) => {
|
|
315
|
+
const e = new Date(t);
|
|
316
|
+
return Number.isNaN(e.getTime()) ? "暂无" : new Intl.DateTimeFormat("zh-CN", { dateStyle: "short", timeStyle: "short" }).format(e);
|
|
317
|
+
}, Tt = (t) => {
|
|
318
|
+
if (!t) return "长期有效";
|
|
319
|
+
const e = new Date(t);
|
|
320
|
+
return Number.isNaN(e.getTime()) ? "暂无" : new Intl.DateTimeFormat("zh-CN", { dateStyle: "medium" }).format(e);
|
|
321
|
+
}, ct = () => ({
|
|
322
|
+
session: null,
|
|
323
|
+
spaces: [],
|
|
324
|
+
bootstrapped: !1,
|
|
325
|
+
serviceUnavailable: !1
|
|
326
|
+
}), Ct = () => {
|
|
327
|
+
let t = ct();
|
|
328
|
+
const e = /* @__PURE__ */ new Set(), s = (r) => {
|
|
329
|
+
t = r, e.forEach((n) => n());
|
|
330
|
+
};
|
|
331
|
+
return {
|
|
332
|
+
subscribe(r) {
|
|
333
|
+
return e.add(r), () => e.delete(r);
|
|
334
|
+
},
|
|
335
|
+
getState: () => t,
|
|
336
|
+
getCsrfToken: () => {
|
|
337
|
+
var r;
|
|
338
|
+
return ((r = t.session) == null ? void 0 : r.csrfToken) ?? null;
|
|
339
|
+
},
|
|
340
|
+
setContext(r) {
|
|
341
|
+
s({ session: r.session, spaces: [...r.spaces], bootstrapped: !0, serviceUnavailable: !1 });
|
|
342
|
+
},
|
|
343
|
+
setBootstrapping() {
|
|
344
|
+
s({ ...t, bootstrapped: !1, serviceUnavailable: !1 });
|
|
345
|
+
},
|
|
346
|
+
clear(r = {}) {
|
|
347
|
+
s({ session: null, spaces: [], bootstrapped: !0, serviceUnavailable: r.unavailable ?? !1 });
|
|
348
|
+
}
|
|
349
|
+
};
|
|
350
|
+
}, z = F(null), Dt = z.Provider, ut = () => {
|
|
351
|
+
const t = M(z);
|
|
352
|
+
if (!t) throw new Error("AuthStoreProvider 尚未初始化");
|
|
353
|
+
return t;
|
|
354
|
+
}, Ot = () => {
|
|
355
|
+
const t = ut();
|
|
356
|
+
return k(t.subscribe, t.getState, t.getState);
|
|
357
|
+
}, Lt = (t) => t instanceof Error && t.message.trim() ? t.message : "请稍后重试;如问题持续,请联系管理员。", Rt = (t, e) => _(t).status === e, _t = (t) => {
|
|
358
|
+
const { category: e, status: s } = _(t);
|
|
359
|
+
return e === "network" || e === "timeout" || s === 502 || s === 503 || s === 504;
|
|
360
|
+
}, C = "24city.console.logout-at", lt = 15e3;
|
|
361
|
+
let S = null;
|
|
362
|
+
const dt = () => {
|
|
363
|
+
try {
|
|
364
|
+
return Number(window.localStorage.getItem(C) ?? Number.NaN);
|
|
365
|
+
} catch {
|
|
366
|
+
return Number.NaN;
|
|
367
|
+
}
|
|
368
|
+
};
|
|
369
|
+
function Ut(t = Date.now()) {
|
|
370
|
+
try {
|
|
371
|
+
window.localStorage.setItem(C, String(t));
|
|
372
|
+
} catch {
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
function mt() {
|
|
376
|
+
try {
|
|
377
|
+
window.localStorage.removeItem(C);
|
|
378
|
+
} catch {
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
function xt() {
|
|
382
|
+
S = "leaving";
|
|
383
|
+
}
|
|
384
|
+
function zt() {
|
|
385
|
+
return S === "leaving";
|
|
386
|
+
}
|
|
387
|
+
function Ft(t = Date.now()) {
|
|
388
|
+
if (S === "leaving") return !1;
|
|
389
|
+
const e = t - dt();
|
|
390
|
+
return e >= 0 && e < lt && (S = "logged-out"), S === "logged-out";
|
|
391
|
+
}
|
|
392
|
+
function kt() {
|
|
393
|
+
return S === "logged-out";
|
|
394
|
+
}
|
|
395
|
+
function Mt() {
|
|
396
|
+
S === "logged-out" && (S = null);
|
|
397
|
+
}
|
|
398
|
+
function qt() {
|
|
399
|
+
S = null, mt();
|
|
400
|
+
}
|
|
401
|
+
export {
|
|
402
|
+
Dt as A,
|
|
403
|
+
l as B,
|
|
404
|
+
a as C,
|
|
405
|
+
q as D,
|
|
406
|
+
Lt as E,
|
|
407
|
+
p as F,
|
|
408
|
+
Ut as a,
|
|
409
|
+
Ct as b,
|
|
410
|
+
yt as c,
|
|
411
|
+
kt as d,
|
|
412
|
+
qt as e,
|
|
413
|
+
Et as f,
|
|
414
|
+
ut as g,
|
|
415
|
+
Pt as h,
|
|
416
|
+
zt as i,
|
|
417
|
+
It as j,
|
|
418
|
+
Tt as k,
|
|
419
|
+
xt as l,
|
|
420
|
+
vt as m,
|
|
421
|
+
Ft as n,
|
|
422
|
+
At as o,
|
|
423
|
+
Nt as p,
|
|
424
|
+
$t as q,
|
|
425
|
+
Mt as r,
|
|
426
|
+
bt as s,
|
|
427
|
+
Rt as t,
|
|
428
|
+
Ot as u,
|
|
429
|
+
gt as v,
|
|
430
|
+
mt as w,
|
|
431
|
+
St as x,
|
|
432
|
+
_t as y,
|
|
433
|
+
h as z
|
|
434
|
+
};
|
|
@@ -2,8 +2,8 @@ import { jsx as t } from "react/jsx-runtime";
|
|
|
2
2
|
import { QueryClient as c, QueryClientProvider as l } from "@tanstack/react-query";
|
|
3
3
|
import { useMemo as i } from "react";
|
|
4
4
|
import { CustomerRuntimeConfigProvider as f } from "@24city/web-runtime/runtime-config-provider";
|
|
5
|
-
import { A as d } from "./auth-provider-
|
|
6
|
-
import { b as m, A as p } from "./logout-signal-
|
|
5
|
+
import { A as d } from "./auth-provider-BzxebTYE.js";
|
|
6
|
+
import { b as m, A as p } from "./logout-signal-DtOS9Rse.js";
|
|
7
7
|
import { U as C, E as y } from "./unsupported-browser-Dwq1mNRy.js";
|
|
8
8
|
import { C as h } from "./context-CaVim6ZO.js";
|
|
9
9
|
import { parseCustomerRuntimeConfig as R, loadCustomerRuntimeConfig as v } from "@24city/web-runtime/core/runtime-config";
|