UNPKG

studiocms

Version:

Astro Native CMS for AstroDB. Built from the ground up by the Astro community.

33 lines (32 loc) 1.16 kB
import * as mod from "virtual:studiocms/components/Editors"; import { prefixError } from "@withstudiocms/component-registry/errors"; import { StudioCMSError } from "../../../../errors.js"; import { convertToSafeString } from "../../../../utils/safeString.js"; async function importEditorKeys(keys) { const predefinedComponents = {}; for (const key of keys) { try { predefinedComponents[convertToSafeString(key)] = mod[convertToSafeString(key)]; } catch (e) { if (e instanceof Error) { const newErr2 = prefixError( e, `Failed to import component "${key}" from Virtual Module "virtual:studiocms/components/Editors"` ); console.error(newErr2); throw new StudioCMSError(newErr2.message, newErr2.stack); } const newErr = prefixError( new Error("Unknown error"), `Failed to import component "${key}" from Virtual Module "virtual:studiocms/components/Editors"` ); console.error(newErr); throw new StudioCMSError(newErr.message, newErr.stack); } } return predefinedComponents; } export { convertToSafeString, importEditorKeys };