@howone/sdk 0.5.3 → 0.7.0

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
@@ -154,7 +154,20 @@ function decodeJwtPayload(token) {
154
154
  if (pad === 2) base64 += "==";
155
155
  else if (pad === 3) base64 += "=";
156
156
  else if (pad !== 0) return null;
157
- const json = atob(base64);
157
+ const binary = atob(base64);
158
+ let json = binary;
159
+ try {
160
+ if (typeof TextDecoder !== "undefined") {
161
+ const bytes = Uint8Array.from(binary, (ch) => ch.charCodeAt(0));
162
+ json = new TextDecoder("utf-8", { fatal: false }).decode(bytes);
163
+ } else {
164
+ json = decodeURIComponent(
165
+ binary.split("").map((ch) => `%${ch.charCodeAt(0).toString(16).padStart(2, "0")}`).join("")
166
+ );
167
+ }
168
+ } catch {
169
+ json = binary;
170
+ }
158
171
  return JSON.parse(json);
159
172
  } catch {
160
173
  return null;
@@ -1856,18 +1869,14 @@ var TOAST_ICONS = {
1856
1869
  icon: "mdi:success",
1857
1870
  color: "text-green-400",
1858
1871
  className: "text-green-400",
1859
- // 深色主题配置
1860
1872
  dark: {
1861
1873
  bgGradient: "bg-[#14181d]",
1862
- // 移除透明度 f2
1863
1874
  gradientColor: "#389726",
1864
1875
  borderGradient: "border-[#389726]",
1865
1876
  borderGradientColor: "#389726"
1866
1877
  },
1867
- // 浅色主题配置
1868
1878
  light: {
1869
1879
  bgGradient: "bg-[#fafafa]",
1870
- // 移除透明度 ff
1871
1880
  gradientColor: "#22c55e",
1872
1881
  borderGradient: "border-[#22c55e]",
1873
1882
  borderGradientColor: "#22c55e"
@@ -1879,14 +1888,12 @@ var TOAST_ICONS = {
1879
1888
  className: "text-red-400",
1880
1889
  dark: {
1881
1890
  bgGradient: "bg-[#14181d]",
1882
- // 移除透明度 f2
1883
1891
  gradientColor: "#ef4444",
1884
1892
  borderGradient: "border-[#ef4444]",
1885
1893
  borderGradientColor: "#ef4444"
1886
1894
  },
1887
1895
  light: {
1888
1896
  bgGradient: "bg-[#fafafa]",
1889
- // 移除透明度 ff
1890
1897
  gradientColor: "#f87171",
1891
1898
  borderGradient: "border-[#f87171]",
1892
1899
  borderGradientColor: "#f87171"
@@ -1898,14 +1905,12 @@ var TOAST_ICONS = {
1898
1905
  className: "text-yellow-400",
1899
1906
  dark: {
1900
1907
  bgGradient: "bg-[#14181d]",
1901
- // 移除透明度 f2
1902
1908
  gradientColor: "#facc15",
1903
1909
  borderGradient: "border-[#facc15]",
1904
1910
  borderGradientColor: "#facc15"
1905
1911
  },
1906
1912
  light: {
1907
1913
  bgGradient: "bg-[#fafafa]",
1908
- // 移除透明度 ff
1909
1914
  gradientColor: "#f59e0b",
1910
1915
  borderGradient: "border-[#f59e0b]",
1911
1916
  borderGradientColor: "#f59e0b"
@@ -1917,14 +1922,12 @@ var TOAST_ICONS = {
1917
1922
  className: "text-blue-400",
1918
1923
  dark: {
1919
1924
  bgGradient: "bg-[#14181d]",
1920
- // 移除透明度 f2
1921
1925
  gradientColor: "#60a5fa",
1922
1926
  borderGradient: "border-[#60a5fa]",
1923
1927
  borderGradientColor: "#f0f0f0"
1924
1928
  },
1925
1929
  light: {
1926
1930
  bgGradient: "bg-[#fafafa]",
1927
- // 移除透明度 ff
1928
1931
  gradientColor: "#3b82f6",
1929
1932
  borderGradient: "border-[#3b82f6]",
1930
1933
  borderGradientColor: "#3b82f6"
@@ -1936,14 +1939,12 @@ var TOAST_ICONS = {
1936
1939
  className: "text-gray-400",
1937
1940
  dark: {
1938
1941
  bgGradient: "bg-[#14181d]",
1939
- // 移除透明度 f2
1940
1942
  gradientColor: "#9ca3af",
1941
1943
  borderGradient: "border-[#9ca3af]",
1942
1944
  borderGradientColor: "#9ca3af"
1943
1945
  },
1944
1946
  light: {
1945
1947
  bgGradient: "bg-[#fafafa]",
1946
- // 移除透明度 ff
1947
1948
  gradientColor: "#6b7280",
1948
1949
  borderGradient: "border-[#6b7280]",
1949
1950
  borderGradientColor: "#6b7280"
@@ -1969,7 +1970,7 @@ var CloseButton = React7.memo(({ closeToast }) => {
1969
1970
  Icon4,
1970
1971
  {
1971
1972
  icon: "vaadin:close",
1972
- className: "flex items-center justify-center rounded-full relative z-10 flex-shrink-0 cursor-pointer \n transition-colors duration-200 drop-shadow-sm",
1973
+ className: "flex items-center justify-center rounded-full relative z-10 flex-shrink-0 cursor-pointer transition-colors duration-200 drop-shadow-sm",
1973
1974
  onClick: handleClick,
1974
1975
  width: 14,
1975
1976
  height: 14,
@@ -2003,15 +2004,10 @@ var ToastContent = ({ type, title, message, component, closeToast }) => {
2003
2004
  const themeConfig = getThemeConfig();
2004
2005
  const lightBaseBackgroundByType = {
2005
2006
  success: "#f0fdf4",
2006
- // green-50
2007
2007
  error: "#fef2f2",
2008
- // red-50
2009
2008
  warning: "#fffbeb",
2010
- // amber-50
2011
2009
  info: "#eff6ff",
2012
- // blue-50
2013
2010
  default: "#f9fafb"
2014
- // gray-50
2015
2011
  };
2016
2012
  if (component) {
2017
2013
  return /* @__PURE__ */ jsxs8("div", { className: `flex items-start gap-3 !min-h-[90px] w-full backdrop-blur-md p-4 shadow-2xl overflow-hidden ${themeConfig.bgGradient}`, children: [
@@ -2055,30 +2051,18 @@ var ToastContent = ({ type, title, message, component, closeToast }) => {
2055
2051
  }
2056
2052
  }
2057
2053
  ),
2058
- /* @__PURE__ */ jsx12("div", { className: "flex-shrink-0 flex-grow-0 mt-0.5 relative z-10", children: /* @__PURE__ */ jsx12(
2059
- "div",
2054
+ /* @__PURE__ */ jsx12("div", { className: "flex-shrink-0 mt-0.5 relative z-10", children: /* @__PURE__ */ jsx12("div", { className: `w-7 h-7 backdrop-blur-sm rounded-full flex items-center justify-center ${theme === "dark" || theme === "system" && window.matchMedia("(prefers-color-scheme: dark)").matches ? "bg-white/10" : "bg-black/5"}`, children: /* @__PURE__ */ jsx12(
2055
+ Icon4,
2060
2056
  {
2061
- className: "backdrop-blur-sm rounded-full flex items-center justify-center overflow-hidden flex-shrink-0 flex-grow-0",
2057
+ icon: iconConfig.icon,
2058
+ width: 16,
2059
+ height: 16,
2060
+ className: iconConfig.color,
2062
2061
  style: {
2063
- backgroundColor: theme === "dark" || theme === "system" && window.matchMedia("(prefers-color-scheme: dark)").matches ? "rgba(255, 255, 255, 0.1)" : "rgba(0, 0, 0, 0.05)",
2064
- width: "28px",
2065
- height: "28px"
2066
- },
2067
- children: /* @__PURE__ */ jsx12("div", { className: "rounded-full flex items-center justify-center", children: /* @__PURE__ */ jsx12(
2068
- Icon4,
2069
- {
2070
- icon: iconConfig.icon,
2071
- width: 16,
2072
- height: 16,
2073
- className: `flex-shrink-0`,
2074
- style: {
2075
- color: themeConfig.gradientColor,
2076
- display: "block"
2077
- }
2078
- }
2079
- ) })
2062
+ color: themeConfig.gradientColor
2063
+ }
2080
2064
  }
2081
- ) }),
2065
+ ) }) }),
2082
2066
  /* @__PURE__ */ jsxs8("div", { className: "flex flex-col gap-1 flex-1 relative z-10", children: [
2083
2067
  title && /* @__PURE__ */ jsx12(
2084
2068
  "div",
@@ -2108,7 +2092,7 @@ var ToastContent = ({ type, title, message, component, closeToast }) => {
2108
2092
  };
2109
2093
  var defaultToastOptions = {
2110
2094
  position: "bottom-right",
2111
- autoClose: 1500,
2095
+ autoClose: 3e3,
2112
2096
  hideProgressBar: true,
2113
2097
  closeOnClick: false,
2114
2098
  pauseOnHover: true,
@@ -2130,7 +2114,8 @@ var createToast = (type) => {
2130
2114
  const { title, message, component, options } = params;
2131
2115
  toast(
2132
2116
  ({ closeToast }) => {
2133
- if (params.render) return params.render(closeToast);
2117
+ if (params.render) return params.render(closeToast ?? (() => {
2118
+ }));
2134
2119
  return /* @__PURE__ */ jsx12(
2135
2120
  ToastContent,
2136
2121
  {
@@ -2146,9 +2131,8 @@ var createToast = (type) => {
2146
2131
  ...defaultToastOptions,
2147
2132
  ...options,
2148
2133
  theme: getToastifyTheme(),
2149
- // 确保圆角样式不被覆盖,添加 rounded-xl 类
2150
2134
  className: "!p-0 !shadow-none !rounded-xl",
2151
- style: { padding: 0, borderRadius: "0.75rem", backgroundColor: "transparent" }
2135
+ style: { padding: 0, borderRadius: "0.75rem" }
2152
2136
  }
2153
2137
  );
2154
2138
  };
@@ -2264,19 +2248,7 @@ function showLimitUpgradeToast(message, onUpgrade) {
2264
2248
  ClayxToast.default({
2265
2249
  render: (closeToast) => /* @__PURE__ */ jsx13(LimitToastContainer, { message, onUpgrade, closeToast }),
2266
2250
  options: {
2267
- position: "bottom-right",
2268
- closeOnClick: false,
2269
- autoClose: false,
2270
- hideProgressBar: true,
2271
- draggable: false,
2272
- pauseOnHover: true,
2273
- className: "!bg-transparent !shadow-none",
2274
- style: {
2275
- background: "transparent",
2276
- padding: 0,
2277
- width: "auto",
2278
- maxWidth: "420px"
2279
- }
2251
+ autoClose: false
2280
2252
  }
2281
2253
  });
2282
2254
  }