@eddyskywalker/dsh-chatgpt-subscription 0.2.9 → 0.2.11
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 +28 -24
- package/LICENSE +21 -21
- package/README.md +169 -169
- package/bin/antigravity-login.mjs +15 -4
- package/cordis.patch.yml +6 -6
- package/lib/client.js +42 -8
- package/lib/client.js.map +1 -1
- package/lib/index.js +206 -91
- package/lib/types/client/antigravity/AntigravityComposerQuota.d.ts.map +1 -1
- package/lib/types/client/antigravity/AntigravitySection.d.ts.map +1 -1
- package/lib/types/client/locales.d.ts +1 -1
- package/lib/types/host/antigravity/adapter.d.ts +4 -1
- package/lib/types/host/antigravity/adapter.d.ts.map +1 -1
- package/lib/types/host/antigravity/client.d.ts +23 -1
- package/lib/types/host/antigravity/client.d.ts.map +1 -1
- package/lib/types/host/antigravity/oauth.d.ts +9 -3
- package/lib/types/host/antigravity/oauth.d.ts.map +1 -1
- package/lib/types/host/antigravity/routes.d.ts.map +1 -1
- package/lib/types/host/antigravity/types.d.ts +6 -0
- package/lib/types/host/antigravity/types.d.ts.map +1 -1
- package/lib/types/host/model-catalog.d.ts.map +1 -1
- package/lib/types/index.d.ts +1 -1
- package/lib/types/index.d.ts.map +1 -1
- package/package.json +134 -134
package/lib/client.js
CHANGED
|
@@ -1886,6 +1886,8 @@ window.__ModuleLoader__.load({
|
|
|
1886
1886
|
const [loading, setLoading] = (0, react.useState)(true);
|
|
1887
1887
|
const [busy, setBusy] = (0, react.useState)(null);
|
|
1888
1888
|
const [error, setError] = (0, react.useState)(null);
|
|
1889
|
+
const [validationUrl, setValidationUrl] = (0, react.useState)(null);
|
|
1890
|
+
const [loginProgress, setLoginProgress] = (0, react.useState)(null);
|
|
1889
1891
|
const [contextDrafts, setContextDrafts] = (0, react.useState)({});
|
|
1890
1892
|
const [savingModel, setSavingModel] = (0, react.useState)(null);
|
|
1891
1893
|
const t = zh;
|
|
@@ -1894,10 +1896,14 @@ window.__ModuleLoader__.load({
|
|
|
1894
1896
|
loadModelDirectory?.();
|
|
1895
1897
|
}, [onModelChange, loadModelDirectory]);
|
|
1896
1898
|
const loadStatus = (0, react.useCallback)(async (quiet = false) => {
|
|
1897
|
-
if (!quiet)
|
|
1899
|
+
if (!quiet) {
|
|
1900
|
+
setError(null);
|
|
1901
|
+
setValidationUrl(null);
|
|
1902
|
+
}
|
|
1898
1903
|
try {
|
|
1899
1904
|
const data = await fetchApi$1("/status");
|
|
1900
1905
|
setStatus(data);
|
|
1906
|
+
if (data.authenticated && (!data.quota || data.quota.groups.length === 0)) fetchApi$1("/quota", { method: "POST" }).then((updated) => setStatus(updated)).catch(() => void 0);
|
|
1901
1907
|
const drafts = {};
|
|
1902
1908
|
for (const m of data.models) {
|
|
1903
1909
|
const val = data.contextWindowOverrides[m.id] || m.defaultContextWindow;
|
|
@@ -1926,29 +1932,37 @@ window.__ModuleLoader__.load({
|
|
|
1926
1932
|
try {
|
|
1927
1933
|
setBusy("login");
|
|
1928
1934
|
setError(null);
|
|
1935
|
+
setValidationUrl(null);
|
|
1936
|
+
setLoginProgress(null);
|
|
1929
1937
|
const flow = await fetchApi$1("/login", { method: "POST" });
|
|
1930
1938
|
if (flow.authUrl) window.open(flow.authUrl, "_blank");
|
|
1931
1939
|
const pollTimer = setInterval(async () => {
|
|
1932
1940
|
try {
|
|
1933
1941
|
const pollStatus = await fetchApi$1("/login/status");
|
|
1942
|
+
if (pollStatus.progress) setLoginProgress(pollStatus.progress);
|
|
1934
1943
|
if (pollStatus.status === "complete") {
|
|
1935
1944
|
clearInterval(pollTimer);
|
|
1936
1945
|
setBusy(null);
|
|
1946
|
+
setLoginProgress(null);
|
|
1937
1947
|
await loadStatus();
|
|
1938
1948
|
notifyChange();
|
|
1939
1949
|
} else if (pollStatus.status === "error") {
|
|
1940
1950
|
clearInterval(pollTimer);
|
|
1941
1951
|
setBusy(null);
|
|
1942
|
-
|
|
1952
|
+
setLoginProgress(null);
|
|
1953
|
+
setError(pollStatus.error || t.loginFailed);
|
|
1954
|
+
if (pollStatus.validationUrl) setValidationUrl(pollStatus.validationUrl);
|
|
1943
1955
|
}
|
|
1944
1956
|
} catch {}
|
|
1945
1957
|
}, 1500);
|
|
1946
1958
|
setTimeout(() => {
|
|
1947
1959
|
clearInterval(pollTimer);
|
|
1948
1960
|
setBusy(null);
|
|
1961
|
+
setLoginProgress(null);
|
|
1949
1962
|
}, 300 * 1e3);
|
|
1950
1963
|
} catch (err) {
|
|
1951
1964
|
setBusy(null);
|
|
1965
|
+
setLoginProgress(null);
|
|
1952
1966
|
setError(err instanceof Error ? err.message : String(err));
|
|
1953
1967
|
}
|
|
1954
1968
|
};
|
|
@@ -2127,13 +2141,13 @@ window.__ModuleLoader__.load({
|
|
|
2127
2141
|
className: "dsha-btn dsha-btn-primary",
|
|
2128
2142
|
disabled: busy !== null,
|
|
2129
2143
|
onClick: handleLogin,
|
|
2130
|
-
children: busy === "login" ? t.signingIn : t.signIn
|
|
2144
|
+
children: busy === "login" ? loginProgress || t.signingIn : t.signIn
|
|
2131
2145
|
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
2132
2146
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2133
2147
|
className: "dsha-btn dsha-btn-primary",
|
|
2134
2148
|
disabled: busy !== null,
|
|
2135
2149
|
onClick: handleLogin,
|
|
2136
|
-
children: t.signInAgain
|
|
2150
|
+
children: busy === "login" ? loginProgress || t.signingIn : t.signInAgain
|
|
2137
2151
|
}),
|
|
2138
2152
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2139
2153
|
className: "dsha-btn",
|
|
@@ -2319,7 +2333,7 @@ window.__ModuleLoader__.load({
|
|
|
2319
2333
|
children: t.signedOut
|
|
2320
2334
|
}) : groups.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2321
2335
|
className: "dsha-empty",
|
|
2322
|
-
children: "
|
|
2336
|
+
children: busy === "quota" ? t.refreshingQuota : "正在获取配额用量数据..."
|
|
2323
2337
|
}) : groups.map((group, gIdx) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2324
2338
|
className: "dsha-quota-card",
|
|
2325
2339
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
@@ -2354,9 +2368,24 @@ window.__ModuleLoader__.load({
|
|
|
2354
2368
|
})
|
|
2355
2369
|
]
|
|
2356
2370
|
}),
|
|
2357
|
-
error && /* @__PURE__ */ (0, react_jsx_runtime.
|
|
2371
|
+
error && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2358
2372
|
className: "dsha-error",
|
|
2359
|
-
children: error
|
|
2373
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: error }), validationUrl && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2374
|
+
style: { marginTop: "8px" },
|
|
2375
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
|
|
2376
|
+
href: validationUrl,
|
|
2377
|
+
target: "_blank",
|
|
2378
|
+
rel: "noreferrer",
|
|
2379
|
+
className: "dsha-btn dsha-btn-primary",
|
|
2380
|
+
style: {
|
|
2381
|
+
display: "inline-block",
|
|
2382
|
+
textDecoration: "none",
|
|
2383
|
+
padding: "4px 10px",
|
|
2384
|
+
fontSize: "12px"
|
|
2385
|
+
},
|
|
2386
|
+
children: "前往 Google 完成账号验证"
|
|
2387
|
+
})
|
|
2388
|
+
})]
|
|
2360
2389
|
})
|
|
2361
2390
|
]
|
|
2362
2391
|
});
|
|
@@ -2494,7 +2523,12 @@ window.__ModuleLoader__.load({
|
|
|
2494
2523
|
setLoading(true);
|
|
2495
2524
|
try {
|
|
2496
2525
|
const data = refresh ? await fetchApi("/quota", { method: "POST" }) : await fetchApi("/status");
|
|
2497
|
-
if (mountedRef.current)
|
|
2526
|
+
if (mountedRef.current) {
|
|
2527
|
+
setStatus(data);
|
|
2528
|
+
if (data.authenticated && (!data.quota || data.quota.groups.length === 0) && !refresh) fetchApi("/quota", { method: "POST" }).then((updated) => {
|
|
2529
|
+
if (mountedRef.current) setStatus(updated);
|
|
2530
|
+
}).catch(() => void 0);
|
|
2531
|
+
}
|
|
2498
2532
|
} catch {} finally {
|
|
2499
2533
|
if (mountedRef.current) setLoading(false);
|
|
2500
2534
|
}
|