UNPKG

ant-design-x-vue-next

Version:

Ant Design X for Vue — community continuation aligned with @ant-design/x

44 lines (43 loc) 1.17 kB
const r = /* @__PURE__ */ new Map(); function a(e) { const t = e.$id || e.catalogId; t && r.set(t, e); } async function f(e, t) { if (r.has(e)) return r.get(e); if (e.startsWith("local://")) return console.warn( `Local catalog "${e}" not registered. Use registerCatalog() to register it.` ), { $id: e, components: {} }; if (!(!t || t.length === 0 || t.includes(e))) throw new Error( `[XCard] Catalog "${e}" is not in allowedCatalogIds. Rejecting remote fetch for security.` ); const n = await fetch(e); if (!n.ok) throw new Error(`Failed to load catalog from ${e}: ${n.statusText}`); const o = await n.json(); return r.set(e, o), o; } function c(e, t, i) { var o; const n = (o = e.components) == null ? void 0 : o[t]; if (!n) return console.warn(`Component "${t}" not found in catalog`), !1; if (n.required) { for (const s of n.required) if (!(s in i)) return console.warn(`Missing required field "${s}" for component "${t}"`), !1; } return !0; } function l() { r.clear(); } export { l as clearCatalogCache, f as loadCatalog, a as registerCatalog, c as validateComponent };