@howone/sdk 0.2.6 → 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 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
- if (!this.fullyInitialized) return;
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") {
@@ -3434,6 +3440,9 @@ var ErrorTracking = class {
3434
3440
  sendUnifiedError(error, details = {}) {
3435
3441
  if (window.parent === window) return;
3436
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
+ }
3437
3446
  if (!isCriticalError && !this.fullyInitialized) {
3438
3447
  return;
3439
3448
  }
@@ -4808,6 +4817,7 @@ var ErrorHandler = class {
4808
4817
  };
4809
4818
 
4810
4819
  // src/components/auth/HowoneProvider.tsx
4820
+ init_config();
4811
4821
  var import_jsx_runtime7 = require("react/jsx-runtime");
4812
4822
  var globalErrorHandler = null;
4813
4823
  var initializeErrorHandler = () => {
@@ -4831,7 +4841,6 @@ var HowOneProvider = ({
4831
4841
  defaultTheme = "system",
4832
4842
  themeStorageKey = "howone-theme",
4833
4843
  forceDefaultTheme = false,
4834
- authUrl = "https://howone.dev/auth",
4835
4844
  redirectOnUnauthenticated = true
4836
4845
  }) => {
4837
4846
  const [user, setUser] = (0, import_react8.useState)(() => parseUserFromToken(getToken()));
@@ -4862,6 +4871,18 @@ var HowOneProvider = ({
4862
4871
  setHasCheckedUrlToken(true);
4863
4872
  }
4864
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
+ }, []);
4865
4886
  (0, import_react8.useEffect)(() => {
4866
4887
  if (!hasCheckedUrlToken) {
4867
4888
  return;
@@ -4870,7 +4891,7 @@ var HowOneProvider = ({
4870
4891
  const currentUrl = new URL(window.location.href);
4871
4892
  if (!currentUrl.pathname.includes("/auth")) {
4872
4893
  try {
4873
- const authUrlObj = new URL(authUrl);
4894
+ const authUrlObj = new URL(resolvedAuthUrl);
4874
4895
  const redirectUri = window.location.href;
4875
4896
  authUrlObj.searchParams.set("redirect_uri", redirectUri);
4876
4897
  if (projectId) {
@@ -4879,11 +4900,11 @@ var HowOneProvider = ({
4879
4900
  window.location.href = authUrlObj.toString();
4880
4901
  } catch (error) {
4881
4902
  console.error("[HowOneProvider] Failed to build auth URL:", error);
4882
- window.location.href = authUrl;
4903
+ window.location.href = resolvedAuthUrl;
4883
4904
  }
4884
4905
  }
4885
4906
  }
4886
- }, [token, user, redirectOnUnauthenticated, authUrl, projectId, hasCheckedUrlToken]);
4907
+ }, [token, user, redirectOnUnauthenticated, resolvedAuthUrl, projectId, hasCheckedUrlToken]);
4887
4908
  const logout = () => {
4888
4909
  try {
4889
4910
  setToken(null);