@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.mjs CHANGED
@@ -56,9 +56,9 @@ function getGlobalEnvironment() {
56
56
  try {
57
57
  const g = globalThis.__HOWONE_ENV__;
58
58
  if (g === "local" || g === "dev" || g === "prod") return g;
59
- return null;
59
+ return "prod";
60
60
  } catch {
61
- return null;
61
+ return "prod";
62
62
  }
63
63
  }
64
64
  var DEFAULT_PROJECT_ID, env, localEnv, devEnv, prodEnv, envs;
@@ -278,8 +278,29 @@ var API_BASE_URLS = {
278
278
  dev: "https://create-x-backend-dev.fly.dev",
279
279
  prod: "https://create-x-backend.fly.dev"
280
280
  };
281
+ var detectEnvironmentFromHostname = () => {
282
+ try {
283
+ const hostname = window.location.hostname.toLowerCase();
284
+ if (hostname.includes("howone.ai")) {
285
+ return "prod";
286
+ }
287
+ if (hostname.includes("howone.dev")) {
288
+ return "dev";
289
+ }
290
+ if (hostname === "localhost" || hostname === "127.0.0.1" || hostname.startsWith("192.168.") || hostname.endsWith(".local")) {
291
+ return "local";
292
+ }
293
+ const globalEnv = getGlobalEnvironment();
294
+ if (globalEnv) {
295
+ return globalEnv;
296
+ }
297
+ return "prod";
298
+ } catch (error) {
299
+ return getGlobalEnvironment() ?? "dev";
300
+ }
301
+ };
281
302
  var resolveApiBaseUrl = () => {
282
- const env2 = getGlobalEnvironment() ?? "dev";
303
+ const env2 = detectEnvironmentFromHostname();
283
304
  return API_BASE_URLS[env2] ?? API_BASE_URLS.dev;
284
305
  };
285
306
  var UnifiedAuthService = class {
@@ -358,7 +379,13 @@ var UnifiedAuthService = class {
358
379
  };
359
380
  popupCheckInterval = window.setInterval(checkPopupStatus, 1e3);
360
381
  const messageHandler = (event) => {
361
- const validOrigins = [window.location.origin, "https://create-x-backend-dev.fly.dev"];
382
+ const validOrigins = [
383
+ window.location.origin,
384
+ this.API_BASE_URL,
385
+ // 使用当前环境的 API_BASE_URL
386
+ "https://create-x-backend-dev.fly.dev",
387
+ "https://create-x-backend.fly.dev"
388
+ ];
362
389
  const isValidOrigin = validOrigins.some(
363
390
  (origin) => event.origin === origin || event.origin.includes("localhost") || event.origin.includes("127.0.0.1") || event.origin.includes("fly.dev")
364
391
  );
@@ -5127,6 +5154,7 @@ var ClayxButton = ({
5127
5154
  };
5128
5155
 
5129
5156
  // src/components/ui/LimitUpgradeToast.tsx
5157
+ import React8 from "react";
5130
5158
  import { Icon as Icon5 } from "@iconify/react";
5131
5159
 
5132
5160
  // src/components/ui/Toast/ClayxToast.tsx
@@ -5329,8 +5357,20 @@ var ToastContent = ({ type, title, message, component, closeToast }) => {
5329
5357
  return actualTheme === "dark" ? iconConfig.dark : iconConfig.light;
5330
5358
  };
5331
5359
  const themeConfig = getThemeConfig();
5360
+ const lightBaseBackgroundByType = {
5361
+ success: "#f0fdf4",
5362
+ // green-50
5363
+ error: "#fef2f2",
5364
+ // red-50
5365
+ warning: "#fffbeb",
5366
+ // amber-50
5367
+ info: "#eff6ff",
5368
+ // blue-50
5369
+ default: "#f9fafb"
5370
+ // gray-50
5371
+ };
5332
5372
  if (component) {
5333
- return /* @__PURE__ */ jsxs9("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: [
5373
+ return /* @__PURE__ */ jsxs9("div", { className: `flex items-start gap-3 !min-h-[90px] w-full backdrop-blur-md p-4 shadow-2xl overflow-hidden ${themeConfig.bgGradient}`, children: [
5334
5374
  /* @__PURE__ */ jsx12("div", { className: "flex-1 relative z-10", children: component }),
5335
5375
  /* @__PURE__ */ jsx12("div", { className: "relative z-10", children: /* @__PURE__ */ jsx12(CloseButton, { closeToast: handleClose }) })
5336
5376
  ] });
@@ -5341,7 +5381,7 @@ var ToastContent = ({ type, title, message, component, closeToast }) => {
5341
5381
  {
5342
5382
  className: "absolute left-0 top-0 w-full h-full rounded-xl",
5343
5383
  style: {
5344
- background: theme === "dark" || theme === "system" && window.matchMedia("(prefers-color-scheme: dark)").matches ? "#0f1419" : "#ffffff",
5384
+ background: theme === "dark" || theme === "system" && window.matchMedia("(prefers-color-scheme: dark)").matches ? "#0f1419" : lightBaseBackgroundByType[type],
5345
5385
  zIndex: -2
5346
5386
  }
5347
5387
  }
@@ -5351,7 +5391,7 @@ var ToastContent = ({ type, title, message, component, closeToast }) => {
5351
5391
  {
5352
5392
  className: "absolute left-0 top-0 w-full h-full pointer-events-none rounded-xl",
5353
5393
  style: {
5354
- 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%)`,
5394
+ 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%)`,
5355
5395
  zIndex: -1
5356
5396
  }
5357
5397
  }
@@ -5362,13 +5402,12 @@ var ToastContent = ({ type, title, message, component, closeToast }) => {
5362
5402
  className: "absolute left-0 top-0 w-full h-full pointer-events-none rounded-xl",
5363
5403
  style: {
5364
5404
  border: "2px solid transparent",
5365
- 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%)`,
5405
+ 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%)`,
5366
5406
  backgroundOrigin: "border-box",
5367
5407
  backgroundClip: "border-box",
5368
- WebkitMask: "linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0)",
5408
+ WebkitMask: "linear-gradient(#ffffff 0 0) padding-box, linear-gradient(#ffffff 0 0)",
5369
5409
  WebkitMaskComposite: "xor",
5370
- mask: "linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0)",
5371
- maskComposite: "exclude"
5410
+ zIndex: 0
5372
5411
  }
5373
5412
  }
5374
5413
  ),
@@ -5419,9 +5458,17 @@ var defaultToastOptions = {
5419
5458
  pauseOnHover: true,
5420
5459
  draggable: true,
5421
5460
  pauseOnFocusLoss: false,
5422
- theme: "dark",
5423
5461
  transition: Bounce
5424
5462
  };
5463
+ var getToastifyTheme = () => {
5464
+ if (typeof window !== "undefined") {
5465
+ const root = document.documentElement;
5466
+ if (root.classList.contains("dark")) return "dark";
5467
+ if (root.classList.contains("light")) return "light";
5468
+ return window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
5469
+ }
5470
+ return "light";
5471
+ };
5425
5472
  var createToast = (type) => {
5426
5473
  return (params) => {
5427
5474
  const { title, message, component, options } = params;
@@ -5442,6 +5489,7 @@ var createToast = (type) => {
5442
5489
  {
5443
5490
  ...defaultToastOptions,
5444
5491
  ...options,
5492
+ theme: getToastifyTheme(),
5445
5493
  // 确保圆角样式不被覆盖,添加 rounded-xl 类
5446
5494
  className: "!p-0 !shadow-none !rounded-xl",
5447
5495
  style: { padding: 0, borderRadius: "0.75rem" }
@@ -5460,6 +5508,8 @@ var ClayxToast = {
5460
5508
  // src/components/ui/LimitUpgradeToast.tsx
5461
5509
  import { jsx as jsx13, jsxs as jsxs10 } from "react/jsx-runtime";
5462
5510
  var LimitToastContainer = ({ message, onUpgrade, closeToast }) => {
5511
+ const [hover, setHover] = React8.useState(false);
5512
+ const [closeHover, setCloseHover] = React8.useState(false);
5463
5513
  return /* @__PURE__ */ jsxs10("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: [
5464
5514
  /* @__PURE__ */ jsx13(
5465
5515
  "div",
@@ -5502,7 +5552,7 @@ var LimitToastContainer = ({ message, onUpgrade, closeToast }) => {
5502
5552
  /* @__PURE__ */ jsx13("div", { className: "relative z-10 flex items-start gap-4 p-4", children: /* @__PURE__ */ jsxs10("div", { className: "flex flex-1 flex-col gap-3", children: [
5503
5553
  /* @__PURE__ */ jsxs10("div", { className: "flex items-center justify-between", children: [
5504
5554
  /* @__PURE__ */ jsxs10("div", { className: "flex items-center gap-2", children: [
5505
- /* @__PURE__ */ jsx13("div", { className: "text-lg font-bold bg-gradient-to-r from-white to-gray-400 bg-clip-text text-transparent", children: "Upgrade Required" }),
5555
+ /* @__PURE__ */ jsx13("div", { className: "text-lg font-bold text-white", children: "Upgrade Required" }),
5506
5556
  /* @__PURE__ */ jsx13("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" })
5507
5557
  ] }),
5508
5558
  /* @__PURE__ */ jsx13(
@@ -5511,7 +5561,17 @@ var LimitToastContainer = ({ message, onUpgrade, closeToast }) => {
5511
5561
  onClick: closeToast,
5512
5562
  isIconOnly: true,
5513
5563
  size: "sm",
5514
- className: "h-6 w-6 min-w-6 rounded-full bg-white/5 hover:bg-white/10 transition-colors",
5564
+ onMouseEnter: () => setCloseHover(true),
5565
+ onMouseLeave: () => setCloseHover(false),
5566
+ style: {
5567
+ height: "1.5rem",
5568
+ width: "1.5rem",
5569
+ minWidth: "1.5rem",
5570
+ borderRadius: "9999px",
5571
+ backgroundColor: closeHover ? "rgba(255,255,255,0.1)" : "rgba(255,255,255,0.05)",
5572
+ transition: "background-color 150ms ease",
5573
+ cursor: "pointer"
5574
+ },
5515
5575
  children: /* @__PURE__ */ jsx13(Icon5, { icon: "iconamoon:close", className: "w-4 h-4 text-gray-400" })
5516
5576
  }
5517
5577
  )
@@ -5524,8 +5584,17 @@ var LimitToastContainer = ({ message, onUpgrade, closeToast }) => {
5524
5584
  onUpgrade();
5525
5585
  closeToast?.();
5526
5586
  },
5527
- 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",
5528
- style: { cursor: "pointer" },
5587
+ onMouseEnter: () => setHover(true),
5588
+ onMouseLeave: () => setHover(false),
5589
+ style: {
5590
+ flex: 1,
5591
+ color: "#ffffff",
5592
+ fontWeight: 600,
5593
+ cursor: "pointer",
5594
+ transition: "all 300ms ease-in-out",
5595
+ backgroundImage: hover ? "linear-gradient(to right, #9333ea, #db2777)" : "linear-gradient(to right, #a855f7, #ec4899)",
5596
+ boxShadow: hover ? "0 10px 15px -3px rgba(168,85,247,0.3), 0 4px 6px -2px rgba(168,85,247,0.3)" : "none"
5597
+ },
5529
5598
  children: /* @__PURE__ */ jsxs10("span", { className: "flex items-center gap-2", children: [
5530
5599
  /* @__PURE__ */ jsx13(Icon5, { icon: "solar:rocket-2-bold", className: "w-4 h-4" }),
5531
5600
  "Upgrade Now"
@@ -6046,11 +6115,11 @@ function createClient(opts) {
6046
6115
  }
6047
6116
 
6048
6117
  // src/hooks/use-mobile.ts
6049
- import * as React8 from "react";
6118
+ import * as React9 from "react";
6050
6119
  var MOBILE_BREAKPOINT = 768;
6051
6120
  function useIsMobile() {
6052
- const [isMobile, setIsMobile] = React8.useState(void 0);
6053
- React8.useEffect(() => {
6121
+ const [isMobile, setIsMobile] = React9.useState(void 0);
6122
+ React9.useEffect(() => {
6054
6123
  const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
6055
6124
  const onChange = () => {
6056
6125
  setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);