@howone/sdk 0.2.13 → 0.2.16

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.js CHANGED
@@ -67,9 +67,9 @@ function getGlobalEnvironment() {
67
67
  try {
68
68
  const g = globalThis.__HOWONE_ENV__;
69
69
  if (g === "local" || g === "dev" || g === "prod") return g;
70
- return null;
70
+ return "prod";
71
71
  } catch {
72
- return null;
72
+ return "prod";
73
73
  }
74
74
  }
75
75
  var DEFAULT_PROJECT_ID, env, localEnv, devEnv, prodEnv, envs;
@@ -349,8 +349,29 @@ var API_BASE_URLS = {
349
349
  dev: "https://create-x-backend-dev.fly.dev",
350
350
  prod: "https://create-x-backend.fly.dev"
351
351
  };
352
+ var detectEnvironmentFromHostname = () => {
353
+ try {
354
+ const hostname = window.location.hostname.toLowerCase();
355
+ if (hostname.includes("howone.ai")) {
356
+ return "prod";
357
+ }
358
+ if (hostname.includes("howone.dev")) {
359
+ return "dev";
360
+ }
361
+ if (hostname === "localhost" || hostname === "127.0.0.1" || hostname.startsWith("192.168.") || hostname.endsWith(".local")) {
362
+ return "local";
363
+ }
364
+ const globalEnv = getGlobalEnvironment();
365
+ if (globalEnv) {
366
+ return globalEnv;
367
+ }
368
+ return "prod";
369
+ } catch (error) {
370
+ return getGlobalEnvironment() ?? "dev";
371
+ }
372
+ };
352
373
  var resolveApiBaseUrl = () => {
353
- const env2 = getGlobalEnvironment() ?? "dev";
374
+ const env2 = detectEnvironmentFromHostname();
354
375
  return API_BASE_URLS[env2] ?? API_BASE_URLS.dev;
355
376
  };
356
377
  var UnifiedAuthService = class {
@@ -429,7 +450,13 @@ var UnifiedAuthService = class {
429
450
  };
430
451
  popupCheckInterval = window.setInterval(checkPopupStatus, 1e3);
431
452
  const messageHandler = (event) => {
432
- const validOrigins = [window.location.origin, "https://create-x-backend-dev.fly.dev"];
453
+ const validOrigins = [
454
+ window.location.origin,
455
+ this.API_BASE_URL,
456
+ // 使用当前环境的 API_BASE_URL
457
+ "https://create-x-backend-dev.fly.dev",
458
+ "https://create-x-backend.fly.dev"
459
+ ];
433
460
  const isValidOrigin = validOrigins.some(
434
461
  (origin) => event.origin === origin || event.origin.includes("localhost") || event.origin.includes("127.0.0.1") || event.origin.includes("fly.dev")
435
462
  );
@@ -5198,7 +5225,8 @@ var ClayxButton = ({
5198
5225
  };
5199
5226
 
5200
5227
  // src/components/ui/LimitUpgradeToast.tsx
5201
- var import_react13 = require("@iconify/react");
5228
+ var import_react13 = __toESM(require("react"));
5229
+ var import_react14 = require("@iconify/react");
5202
5230
 
5203
5231
  // src/components/ui/Toast/ClayxToast.tsx
5204
5232
  var import_react11 = __toESM(require("react"));
@@ -5400,8 +5428,20 @@ var ToastContent = ({ type, title, message, component, closeToast }) => {
5400
5428
  return actualTheme === "dark" ? iconConfig.dark : iconConfig.light;
5401
5429
  };
5402
5430
  const themeConfig = getThemeConfig();
5431
+ const lightBaseBackgroundByType = {
5432
+ success: "#f0fdf4",
5433
+ // green-50
5434
+ error: "#fef2f2",
5435
+ // red-50
5436
+ warning: "#fffbeb",
5437
+ // amber-50
5438
+ info: "#eff6ff",
5439
+ // blue-50
5440
+ default: "#f9fafb"
5441
+ // gray-50
5442
+ };
5403
5443
  if (component) {
5404
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: `flex items-start gap-3 !min-h-[90px] w-full backdrop-blur-md p-4 shadow-2xl relative overflow-hidden ${themeConfig.bgGradient}`, children: [
5444
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: `flex items-start gap-3 !min-h-[90px] w-full backdrop-blur-md p-4 shadow-2xl overflow-hidden ${themeConfig.bgGradient}`, children: [
5405
5445
  /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "flex-1 relative z-10", children: component }),
5406
5446
  /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "relative z-10", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(CloseButton, { closeToast: handleClose }) })
5407
5447
  ] });
@@ -5412,7 +5452,7 @@ var ToastContent = ({ type, title, message, component, closeToast }) => {
5412
5452
  {
5413
5453
  className: "absolute left-0 top-0 w-full h-full rounded-xl",
5414
5454
  style: {
5415
- background: theme === "dark" || theme === "system" && window.matchMedia("(prefers-color-scheme: dark)").matches ? "#0f1419" : "#ffffff",
5455
+ background: theme === "dark" || theme === "system" && window.matchMedia("(prefers-color-scheme: dark)").matches ? "#0f1419" : lightBaseBackgroundByType[type],
5416
5456
  zIndex: -2
5417
5457
  }
5418
5458
  }
@@ -5422,7 +5462,7 @@ var ToastContent = ({ type, title, message, component, closeToast }) => {
5422
5462
  {
5423
5463
  className: "absolute left-0 top-0 w-full h-full pointer-events-none rounded-xl",
5424
5464
  style: {
5425
- background: theme === "dark" || theme === "system" && window.matchMedia("(prefers-color-scheme: dark)").matches ? `linear-gradient(135deg, ${themeConfig.gradientColor}30 0%, ${themeConfig.gradientColor}20 15%, #14181df2 30%)` : `linear-gradient(135deg, ${themeConfig.gradientColor}15 0%, ${themeConfig.gradientColor}08 15%, #fafafaff 30%)`,
5465
+ background: theme === "dark" || theme === "system" && window.matchMedia("(prefers-color-scheme: dark)").matches ? `linear-gradient(135deg, ${themeConfig.gradientColor}30 0%, ${themeConfig.gradientColor}20 15%, #14181df2 30%)` : `linear-gradient(135deg, ${themeConfig.gradientColor}20 0%, ${themeConfig.gradientColor}12 15%, #ffffff 30%)`,
5426
5466
  zIndex: -1
5427
5467
  }
5428
5468
  }
@@ -5433,13 +5473,12 @@ var ToastContent = ({ type, title, message, component, closeToast }) => {
5433
5473
  className: "absolute left-0 top-0 w-full h-full pointer-events-none rounded-xl",
5434
5474
  style: {
5435
5475
  border: "2px solid transparent",
5436
- backgroundImage: theme === "dark" || theme === "system" && window.matchMedia("(prefers-color-scheme: dark)").matches ? `linear-gradient(135deg, ${themeConfig.borderGradientColor}60 0%, ${themeConfig.borderGradientColor}40 5%, transparent 22%)` : `linear-gradient(135deg, ${themeConfig.borderGradientColor}40 0%, ${themeConfig.borderGradientColor}25 5%, transparent 22%)`,
5476
+ backgroundImage: theme === "dark" || theme === "system" && window.matchMedia("(prefers-color-scheme: dark)").matches ? `linear-gradient(135deg, ${themeConfig.borderGradientColor}60 0%, ${themeConfig.borderGradientColor}40 5%, transparent 22%)` : `linear-gradient(135deg, ${themeConfig.borderGradientColor}99 0%, ${themeConfig.borderGradientColor}66 5%, transparent 22%)`,
5437
5477
  backgroundOrigin: "border-box",
5438
5478
  backgroundClip: "border-box",
5439
- WebkitMask: "linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0)",
5479
+ WebkitMask: "linear-gradient(#ffffff 0 0) padding-box, linear-gradient(#ffffff 0 0)",
5440
5480
  WebkitMaskComposite: "xor",
5441
- mask: "linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0)",
5442
- maskComposite: "exclude"
5481
+ zIndex: 0
5443
5482
  }
5444
5483
  }
5445
5484
  ),
@@ -5490,9 +5529,17 @@ var defaultToastOptions = {
5490
5529
  pauseOnHover: true,
5491
5530
  draggable: true,
5492
5531
  pauseOnFocusLoss: false,
5493
- theme: "dark",
5494
5532
  transition: import_react_toastify2.Bounce
5495
5533
  };
5534
+ var getToastifyTheme = () => {
5535
+ if (typeof window !== "undefined") {
5536
+ const root = document.documentElement;
5537
+ if (root.classList.contains("dark")) return "dark";
5538
+ if (root.classList.contains("light")) return "light";
5539
+ return window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
5540
+ }
5541
+ return "light";
5542
+ };
5496
5543
  var createToast = (type) => {
5497
5544
  return (params) => {
5498
5545
  const { title, message, component, options } = params;
@@ -5513,6 +5560,7 @@ var createToast = (type) => {
5513
5560
  {
5514
5561
  ...defaultToastOptions,
5515
5562
  ...options,
5563
+ theme: getToastifyTheme(),
5516
5564
  // 确保圆角样式不被覆盖,添加 rounded-xl 类
5517
5565
  className: "!p-0 !shadow-none !rounded-xl",
5518
5566
  style: { padding: 0, borderRadius: "0.75rem" }
@@ -5531,6 +5579,8 @@ var ClayxToast = {
5531
5579
  // src/components/ui/LimitUpgradeToast.tsx
5532
5580
  var import_jsx_runtime13 = require("react/jsx-runtime");
5533
5581
  var LimitToastContainer = ({ message, onUpgrade, closeToast }) => {
5582
+ const [hover, setHover] = import_react13.default.useState(false);
5583
+ const [closeHover, setCloseHover] = import_react13.default.useState(false);
5534
5584
  return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "relative w-full max-w-[420px] overflow-hidden rounded-md bg-gradient-to-br from-[#1A1A1A] via-[#151515] to-[#1A1A1A] shadow-[0_20px_60px_rgba(168,85,247,0.2)] backdrop-blur-sm", children: [
5535
5585
  /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
5536
5586
  "div",
@@ -5573,7 +5623,7 @@ var LimitToastContainer = ({ message, onUpgrade, closeToast }) => {
5573
5623
  /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "relative z-10 flex items-start gap-4 p-4", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex flex-1 flex-col gap-3", children: [
5574
5624
  /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex items-center justify-between", children: [
5575
5625
  /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex items-center gap-2", children: [
5576
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "text-lg font-bold bg-gradient-to-r from-white to-gray-400 bg-clip-text text-transparent", children: "Upgrade Required" }),
5626
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "text-lg font-bold text-white", children: "Upgrade Required" }),
5577
5627
  /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "px-2 py-0.5 text-xs font-bold bg-purple-500/20 text-purple-400 rounded-md border border-purple-500/30", children: "Premium" })
5578
5628
  ] }),
5579
5629
  /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
@@ -5582,8 +5632,18 @@ var LimitToastContainer = ({ message, onUpgrade, closeToast }) => {
5582
5632
  onClick: closeToast,
5583
5633
  isIconOnly: true,
5584
5634
  size: "sm",
5585
- className: "h-6 w-6 min-w-6 rounded-full bg-white/5 hover:bg-white/10 transition-colors",
5586
- children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react13.Icon, { icon: "iconamoon:close", className: "w-4 h-4 text-gray-400" })
5635
+ onMouseEnter: () => setCloseHover(true),
5636
+ onMouseLeave: () => setCloseHover(false),
5637
+ style: {
5638
+ height: "1.5rem",
5639
+ width: "1.5rem",
5640
+ minWidth: "1.5rem",
5641
+ borderRadius: "9999px",
5642
+ backgroundColor: closeHover ? "rgba(255,255,255,0.1)" : "rgba(255,255,255,0.05)",
5643
+ transition: "background-color 150ms ease",
5644
+ cursor: "pointer"
5645
+ },
5646
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react14.Icon, { icon: "iconamoon:close", className: "w-4 h-4 text-gray-400" })
5587
5647
  }
5588
5648
  )
5589
5649
  ] }),
@@ -5595,10 +5655,19 @@ var LimitToastContainer = ({ message, onUpgrade, closeToast }) => {
5595
5655
  onUpgrade();
5596
5656
  closeToast?.();
5597
5657
  },
5598
- className: "flex-1 bg-gradient-to-r from-purple-500 to-pink-500 hover:from-purple-600 hover:to-pink-600 text-white font-semibold transition-all duration-300 hover:shadow-lg hover:shadow-purple-500/30 cursor-pointer",
5599
- style: { cursor: "pointer" },
5658
+ onMouseEnter: () => setHover(true),
5659
+ onMouseLeave: () => setHover(false),
5660
+ style: {
5661
+ flex: 1,
5662
+ color: "#ffffff",
5663
+ fontWeight: 600,
5664
+ cursor: "pointer",
5665
+ transition: "all 300ms ease-in-out",
5666
+ backgroundImage: hover ? "linear-gradient(to right, #9333ea, #db2777)" : "linear-gradient(to right, #a855f7, #ec4899)",
5667
+ boxShadow: hover ? "0 10px 15px -3px rgba(168,85,247,0.3), 0 4px 6px -2px rgba(168,85,247,0.3)" : "none"
5668
+ },
5600
5669
  children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("span", { className: "flex items-center gap-2", children: [
5601
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react13.Icon, { icon: "solar:rocket-2-bold", className: "w-4 h-4" }),
5670
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react14.Icon, { icon: "solar:rocket-2-bold", className: "w-4 h-4" }),
5602
5671
  "Upgrade Now"
5603
5672
  ] })
5604
5673
  }
@@ -6117,11 +6186,11 @@ function createClient(opts) {
6117
6186
  }
6118
6187
 
6119
6188
  // src/hooks/use-mobile.ts
6120
- var React8 = __toESM(require("react"));
6189
+ var React9 = __toESM(require("react"));
6121
6190
  var MOBILE_BREAKPOINT = 768;
6122
6191
  function useIsMobile() {
6123
- const [isMobile, setIsMobile] = React8.useState(void 0);
6124
- React8.useEffect(() => {
6192
+ const [isMobile, setIsMobile] = React9.useState(void 0);
6193
+ React9.useEffect(() => {
6125
6194
  const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
6126
6195
  const onChange = () => {
6127
6196
  setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
@@ -6134,10 +6203,10 @@ function useIsMobile() {
6134
6203
  }
6135
6204
 
6136
6205
  // src/hooks/use-debounce.ts
6137
- var import_react14 = require("react");
6206
+ var import_react15 = require("react");
6138
6207
  function useDebounce(value, delay) {
6139
- const [debouncedValue, setDebouncedValue] = (0, import_react14.useState)(value);
6140
- (0, import_react14.useEffect)(() => {
6208
+ const [debouncedValue, setDebouncedValue] = (0, import_react15.useState)(value);
6209
+ (0, import_react15.useEffect)(() => {
6141
6210
  const handler = setTimeout(() => {
6142
6211
  setDebouncedValue(value);
6143
6212
  }, delay);