@howone/sdk 0.2.5 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +0 -2
- package/dist/index.d.ts +0 -2
- package/dist/index.js +37 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +38 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -444,7 +444,6 @@ interface HowOneProviderProps {
|
|
|
444
444
|
defaultTheme?: Theme$1;
|
|
445
445
|
themeStorageKey?: string;
|
|
446
446
|
forceDefaultTheme?: boolean;
|
|
447
|
-
authUrl?: string;
|
|
448
447
|
redirectOnUnauthenticated?: boolean;
|
|
449
448
|
}
|
|
450
449
|
/**
|
|
@@ -462,7 +461,6 @@ interface HowOneProviderProps {
|
|
|
462
461
|
* defaultTheme="dark"
|
|
463
462
|
* themeStorageKey="my-app-theme"
|
|
464
463
|
* showFloatingButton={true}
|
|
465
|
-
* authUrl="https://howone.dev/auth"
|
|
466
464
|
* redirectOnUnauthenticated={true}
|
|
467
465
|
* >
|
|
468
466
|
* <App />
|
package/dist/index.d.ts
CHANGED
|
@@ -444,7 +444,6 @@ interface HowOneProviderProps {
|
|
|
444
444
|
defaultTheme?: Theme$1;
|
|
445
445
|
themeStorageKey?: string;
|
|
446
446
|
forceDefaultTheme?: boolean;
|
|
447
|
-
authUrl?: string;
|
|
448
447
|
redirectOnUnauthenticated?: boolean;
|
|
449
448
|
}
|
|
450
449
|
/**
|
|
@@ -462,7 +461,6 @@ interface HowOneProviderProps {
|
|
|
462
461
|
* defaultTheme="dark"
|
|
463
462
|
* themeStorageKey="my-app-theme"
|
|
464
463
|
* showFloatingButton={true}
|
|
465
|
-
* authUrl="https://howone.dev/auth"
|
|
466
464
|
* redirectOnUnauthenticated={true}
|
|
467
465
|
* >
|
|
468
466
|
* <App />
|
package/dist/index.js
CHANGED
|
@@ -3179,6 +3179,7 @@ var ErrorTracking = class {
|
|
|
3179
3179
|
window.addEventListener("unhandledrejection", (event) => {
|
|
3180
3180
|
event.preventDefault();
|
|
3181
3181
|
const error = event.reason instanceof Error ? event.reason : new Error(String(event.reason));
|
|
3182
|
+
this.internalLog("warn", "\u{1F680}\u{1F680}\u{1F680}\u{1F680}\u{1F680}\u{1F680}\u{1F680}\u{1F680}\u{1F680}\u{1F680}\u{1F680}\u{1F680}\u6355\u83B7 unhandledrejection:", error.message);
|
|
3182
3183
|
this.handleError(error, {
|
|
3183
3184
|
type: "promise",
|
|
3184
3185
|
source: "unhandledrejection"
|
|
@@ -3213,7 +3214,12 @@ var ErrorTracking = class {
|
|
|
3213
3214
|
*/
|
|
3214
3215
|
safeForwardConsoleToParent(method, args) {
|
|
3215
3216
|
if (window.parent === window) return;
|
|
3216
|
-
|
|
3217
|
+
const argsStr = args.map((arg) => String(arg)).join(" ").toLowerCase();
|
|
3218
|
+
const is504Error = argsStr.includes("504") || argsStr.includes("gateway timeout");
|
|
3219
|
+
if (is504Error) {
|
|
3220
|
+
this.internalLog("warn", "\u{1F697}\u{1F697}\u{1F697}\u{1F697}\u{1F697}\u{1F697}\u{1F697}\u{1F697}\u{1F697}\u{1F697}\u{1F697}\u{1F697}\u{1F697}\u{1F697}\u{1F697}\u{1F697}[ErrorTracking] \u63A7\u5236\u53F0\u6355\u83B7 504 \u9519\u8BEF:", argsStr.substring(0, 100));
|
|
3221
|
+
}
|
|
3222
|
+
if (!is504Error && !this.fullyInitialized) return;
|
|
3217
3223
|
try {
|
|
3218
3224
|
let stack = null;
|
|
3219
3225
|
if (method === "warn" || method === "error") {
|
|
@@ -3421,12 +3427,25 @@ var ErrorTracking = class {
|
|
|
3421
3427
|
}, 5e3);
|
|
3422
3428
|
return false;
|
|
3423
3429
|
}
|
|
3430
|
+
/**
|
|
3431
|
+
* 判断是否是 504 错误,需要立即发送
|
|
3432
|
+
*/
|
|
3433
|
+
isCriticalNetworkError(error, details) {
|
|
3434
|
+
const message = error.message?.toLowerCase() || "";
|
|
3435
|
+
return message.includes("504") || message.includes("gateway timeout");
|
|
3436
|
+
}
|
|
3424
3437
|
/**
|
|
3425
3438
|
* 发送统一格式的错误
|
|
3426
3439
|
*/
|
|
3427
3440
|
sendUnifiedError(error, details = {}) {
|
|
3428
3441
|
if (window.parent === window) return;
|
|
3429
|
-
|
|
3442
|
+
const isCriticalError = this.isCriticalNetworkError(error, details);
|
|
3443
|
+
if (isCriticalError) {
|
|
3444
|
+
this.internalLog("warn", "\u{1F31E}\u{1F31E}\u{1F31E}\u{1F31E}\u{1F31E}\u{1F31E}\u{1F31E}\u{1F31E}\u{1F31E}\u{1F31E}\u{1F31E}\u68C0\u6D4B\u5230 504 \u9519\u8BEF\uFF0C\u7ACB\u5373\u53D1\u9001:", error.message);
|
|
3445
|
+
}
|
|
3446
|
+
if (!isCriticalError && !this.fullyInitialized) {
|
|
3447
|
+
return;
|
|
3448
|
+
}
|
|
3430
3449
|
try {
|
|
3431
3450
|
const currentViewInfo = this.viewDetector?.getCurrentViewInfo();
|
|
3432
3451
|
const payload = {
|
|
@@ -4798,6 +4817,7 @@ var ErrorHandler = class {
|
|
|
4798
4817
|
};
|
|
4799
4818
|
|
|
4800
4819
|
// src/components/auth/HowoneProvider.tsx
|
|
4820
|
+
init_config();
|
|
4801
4821
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
4802
4822
|
var globalErrorHandler = null;
|
|
4803
4823
|
var initializeErrorHandler = () => {
|
|
@@ -4821,7 +4841,6 @@ var HowOneProvider = ({
|
|
|
4821
4841
|
defaultTheme = "system",
|
|
4822
4842
|
themeStorageKey = "howone-theme",
|
|
4823
4843
|
forceDefaultTheme = false,
|
|
4824
|
-
authUrl = "https://howone.dev/auth",
|
|
4825
4844
|
redirectOnUnauthenticated = true
|
|
4826
4845
|
}) => {
|
|
4827
4846
|
const [user, setUser] = (0, import_react8.useState)(() => parseUserFromToken(getToken()));
|
|
@@ -4852,6 +4871,18 @@ var HowOneProvider = ({
|
|
|
4852
4871
|
setHasCheckedUrlToken(true);
|
|
4853
4872
|
}
|
|
4854
4873
|
}, []);
|
|
4874
|
+
const resolvedAuthUrl = (0, import_react8.useMemo)(() => {
|
|
4875
|
+
const env2 = getGlobalEnvironment() ?? "dev";
|
|
4876
|
+
switch (env2) {
|
|
4877
|
+
case "local":
|
|
4878
|
+
return "http://localhost:3000/auth";
|
|
4879
|
+
case "prod":
|
|
4880
|
+
return "https://howone.ai/auth";
|
|
4881
|
+
case "dev":
|
|
4882
|
+
default:
|
|
4883
|
+
return "https://howone.dev/auth";
|
|
4884
|
+
}
|
|
4885
|
+
}, []);
|
|
4855
4886
|
(0, import_react8.useEffect)(() => {
|
|
4856
4887
|
if (!hasCheckedUrlToken) {
|
|
4857
4888
|
return;
|
|
@@ -4860,7 +4891,7 @@ var HowOneProvider = ({
|
|
|
4860
4891
|
const currentUrl = new URL(window.location.href);
|
|
4861
4892
|
if (!currentUrl.pathname.includes("/auth")) {
|
|
4862
4893
|
try {
|
|
4863
|
-
const authUrlObj = new URL(
|
|
4894
|
+
const authUrlObj = new URL(resolvedAuthUrl);
|
|
4864
4895
|
const redirectUri = window.location.href;
|
|
4865
4896
|
authUrlObj.searchParams.set("redirect_uri", redirectUri);
|
|
4866
4897
|
if (projectId) {
|
|
@@ -4869,11 +4900,11 @@ var HowOneProvider = ({
|
|
|
4869
4900
|
window.location.href = authUrlObj.toString();
|
|
4870
4901
|
} catch (error) {
|
|
4871
4902
|
console.error("[HowOneProvider] Failed to build auth URL:", error);
|
|
4872
|
-
window.location.href =
|
|
4903
|
+
window.location.href = resolvedAuthUrl;
|
|
4873
4904
|
}
|
|
4874
4905
|
}
|
|
4875
4906
|
}
|
|
4876
|
-
}, [token, user, redirectOnUnauthenticated,
|
|
4907
|
+
}, [token, user, redirectOnUnauthenticated, resolvedAuthUrl, projectId, hasCheckedUrlToken]);
|
|
4877
4908
|
const logout = () => {
|
|
4878
4909
|
try {
|
|
4879
4910
|
setToken(null);
|