@zero-library/common 2.3.3 → 2.3.5

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
@@ -909,6 +909,7 @@ declare const setInterval: (fn: () => void | Promise<void>, t: number) => {
909
909
  /**
910
910
  * 生成唯一的 UUID v4 格式 ID
911
911
  * 使用 crypto.randomUUID() 生成符合 RFC 4122 标准的 UUID
912
+ * 如果浏览器不支持 crypto.randomUUID(),则使用 Math.random() 生成随机数
912
913
  *
913
914
  * @returns 符合 UUID v4 格式的唯一标识符字符串
914
915
  *
package/dist/index.d.ts CHANGED
@@ -909,6 +909,7 @@ declare const setInterval: (fn: () => void | Promise<void>, t: number) => {
909
909
  /**
910
910
  * 生成唯一的 UUID v4 格式 ID
911
911
  * 使用 crypto.randomUUID() 生成符合 RFC 4122 标准的 UUID
912
+ * 如果浏览器不支持 crypto.randomUUID(),则使用 Math.random() 生成随机数
912
913
  *
913
914
  * @returns 符合 UUID v4 格式的唯一标识符字符串
914
915
  *
package/dist/index.esm.js CHANGED
@@ -445,7 +445,14 @@ var setInterval2 = (fn, t) => {
445
445
  };
446
446
  };
447
447
  var genNonDuplicateID = () => {
448
- return crypto.randomUUID();
448
+ if (crypto?.randomUUID) {
449
+ return crypto.randomUUID();
450
+ }
451
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
452
+ const r = Math.random() * 16 | 0;
453
+ const v = c === "x" ? r : r & 3 | 8;
454
+ return v.toString(16);
455
+ });
449
456
  };
450
457
  var copyText = async (text, prompt = "\u590D\u5236\u6210\u529F") => {
451
458
  try {
@@ -1333,14 +1340,17 @@ var styles_module_default2 = {
1333
1340
  var baseComponentMap = {
1334
1341
  // renderMarkdown: () => import('@/components/RenderMarkdown')
1335
1342
  };
1343
+ var lazyCache = /* @__PURE__ */ new Map();
1336
1344
  var LazyComponent_default = ({ type, customComponents, unknownContent, ...rest }) => {
1337
- const componentMap = useMemo(() => {
1338
- return { ...baseComponentMap, ...customComponents };
1339
- }, [customComponents]);
1345
+ const loader = customComponents?.[type] || baseComponentMap[type];
1340
1346
  const LazyComponent = useMemo(() => {
1341
- const loader = componentMap[type];
1342
- return loader ? lazy(loader) : null;
1343
- }, [type, componentMap]);
1347
+ if (!loader) return null;
1348
+ const cached = lazyCache.get(type);
1349
+ if (cached) return cached;
1350
+ const component = lazy(loader);
1351
+ lazyCache.set(type, component);
1352
+ return component;
1353
+ }, [loader]);
1344
1354
  if (!LazyComponent) return unknownContent || /* @__PURE__ */ jsx(Alert, { message: `\u672A\u77E5\u7C7B\u578B\uFF1A${type}`, type: "warning" });
1345
1355
  return /* @__PURE__ */ jsx(
1346
1356
  Suspense,