{"version":3,"file":"components.mjs","sources":["../../src/registries/components.ts"],"sourcesContent":["import { has } from 'lodash/fp';\nimport type { Struct, UID } from '@strapi/types';\n\nconst componentsRegistry = () => {\n const components: Record = {};\n\n return {\n /**\n * Returns this list of registered components uids\n */\n keys(): UID.Component[] {\n return Object.keys(components) as UID.Component[];\n },\n\n /**\n * Returns the instance of a component. Instantiate the component if not already done\n */\n get(uid: UID.Component) {\n return components[uid];\n },\n\n /**\n * Returns a map with all the components in a namespace\n */\n getAll() {\n return components;\n },\n\n /**\n * Registers a component\n */\n set(uid: UID.Component, component: Struct.ComponentSchema) {\n if (has(uid, components)) {\n throw new Error(`Component ${uid} has already been registered.`);\n }\n\n components[uid] = component;\n\n return this;\n },\n\n /**\n * Registers a map of components for a specific namespace\n */\n add(newComponents: Record) {\n for (const uid of Object.keys(newComponents) as UID.Component[]) {\n this.set(uid, newComponents[uid]);\n }\n },\n };\n};\n\nexport default componentsRegistry;\n"],"names":["componentsRegistry","components","keys","Object","get","uid","getAll","set","component","has","Error","add","newComponents"],"mappings":";;AAGA,MAAMA,kBAAqB,GAAA,IAAA;AACzB,IAAA,MAAMC,aAA4D,EAAC;IAEnE,OAAO;AACL;;QAGAC,IAAAA,CAAAA,GAAAA;YACE,OAAOC,MAAAA,CAAOD,IAAI,CAACD,UAAAA,CAAAA;AACrB,SAAA;AAEA;;AAEC,QACDG,KAAIC,GAAkB,EAAA;YACpB,OAAOJ,UAAU,CAACI,GAAI,CAAA;AACxB,SAAA;AAEA;;QAGAC,MAAAA,CAAAA,GAAAA;YACE,OAAOL,UAAAA;AACT,SAAA;AAEA;;QAGAM,GAAAA,CAAAA,CAAIF,GAAkB,EAAEG,SAAiC,EAAA;YACvD,IAAIC,GAAAA,CAAIJ,KAAKJ,UAAa,CAAA,EAAA;AACxB,gBAAA,MAAM,IAAIS,KAAM,CAAA,CAAC,UAAU,EAAEL,GAAAA,CAAI,6BAA6B,CAAC,CAAA;AACjE;YAEAJ,UAAU,CAACI,IAAI,GAAGG,SAAAA;AAElB,YAAA,OAAO,IAAI;AACb,SAAA;AAEA;;AAEC,QACDG,KAAIC,aAA4D,EAAA;AAC9D,YAAA,KAAK,MAAMP,GAAAA,IAAOF,MAAOD,CAAAA,IAAI,CAACU,aAAmC,CAAA,CAAA;AAC/D,gBAAA,IAAI,CAACL,GAAG,CAACF,GAAKO,EAAAA,aAAa,CAACP,GAAI,CAAA,CAAA;AAClC;AACF;AACF,KAAA;AACF;;;;"}