@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.cjs.js CHANGED
@@ -488,7 +488,14 @@ var setInterval2 = (fn, t) => {
488
488
  };
489
489
  };
490
490
  var genNonDuplicateID = () => {
491
- return crypto.randomUUID();
491
+ if (crypto?.randomUUID) {
492
+ return crypto.randomUUID();
493
+ }
494
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
495
+ const r = Math.random() * 16 | 0;
496
+ const v = c === "x" ? r : r & 3 | 8;
497
+ return v.toString(16);
498
+ });
492
499
  };
493
500
  var copyText = async (text, prompt = "\u590D\u5236\u6210\u529F") => {
494
501
  try {
@@ -1376,14 +1383,17 @@ var styles_module_default2 = {
1376
1383
  var baseComponentMap = {
1377
1384
  // renderMarkdown: () => import('@/components/RenderMarkdown')
1378
1385
  };
1386
+ var lazyCache = /* @__PURE__ */ new Map();
1379
1387
  var LazyComponent_default = ({ type, customComponents, unknownContent, ...rest }) => {
1380
- const componentMap = React.useMemo(() => {
1381
- return { ...baseComponentMap, ...customComponents };
1382
- }, [customComponents]);
1388
+ const loader = customComponents?.[type] || baseComponentMap[type];
1383
1389
  const LazyComponent = React.useMemo(() => {
1384
- const loader = componentMap[type];
1385
- return loader ? React.lazy(loader) : null;
1386
- }, [type, componentMap]);
1390
+ if (!loader) return null;
1391
+ const cached = lazyCache.get(type);
1392
+ if (cached) return cached;
1393
+ const component = React.lazy(loader);
1394
+ lazyCache.set(type, component);
1395
+ return component;
1396
+ }, [loader]);
1387
1397
  if (!LazyComponent) return unknownContent || /* @__PURE__ */ jsxRuntime.jsx(antd.Alert, { message: `\u672A\u77E5\u7C7B\u578B\uFF1A${type}`, type: "warning" });
1388
1398
  return /* @__PURE__ */ jsxRuntime.jsx(
1389
1399
  React.Suspense,