@zero-library/common 2.3.4 → 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 +9 -6
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +9 -6
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1340,14 +1340,17 @@ var styles_module_default2 = {
|
|
|
1340
1340
|
var baseComponentMap = {
|
|
1341
1341
|
// renderMarkdown: () => import('@/components/RenderMarkdown')
|
|
1342
1342
|
};
|
|
1343
|
+
var lazyCache = /* @__PURE__ */ new Map();
|
|
1343
1344
|
var LazyComponent_default = ({ type, customComponents, unknownContent, ...rest }) => {
|
|
1344
|
-
const
|
|
1345
|
-
return { ...baseComponentMap, ...customComponents };
|
|
1346
|
-
}, [customComponents]);
|
|
1345
|
+
const loader = customComponents?.[type] || baseComponentMap[type];
|
|
1347
1346
|
const LazyComponent = useMemo(() => {
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
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]);
|
|
1351
1354
|
if (!LazyComponent) return unknownContent || /* @__PURE__ */ jsx(Alert, { message: `\u672A\u77E5\u7C7B\u578B\uFF1A${type}`, type: "warning" });
|
|
1352
1355
|
return /* @__PURE__ */ jsx(
|
|
1353
1356
|
Suspense,
|