UNPKG

studiocms

Version:

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

72 lines (71 loc) 3.54 kB
import type { StudioCMSConfig } from '../schemas/index.js'; /** * Builds a string representing a default export of the provided module object. * * @param mod - The module object to be stringified and exported as default. * @returns A string containing a TypeScript/JavaScript default export statement with the serialized module. */ export declare const buildDefaultOnlyVirtual: (mod: any) => string; /** * Builds a string containing multiple named ES module exports from a record of key-value pairs. * * Each key in the input object becomes the exported constant's name, and each value is stringified * and assigned to the corresponding export. * * @param items - An object where each key-value pair represents the name and value of an export. * @returns A string containing multiple export statements, one for each entry in the input object. * * @example * ```typescript * const exports = buildNamedMultiExportVirtual({ foo: "bar", baz: "qux" }); * // exports: * // export const foo = "bar"; * // export const baz = "qux"; * ``` */ export declare const buildNamedMultiExportVirtual: (items: Record<string, string>) => string; /** * Builds the virtual configuration file content by injecting the provided StudioCMS options * into a configuration stub template. * * @param options - The configuration options to be injected into the stub template. * @returns The resulting configuration file content as a string with the options embedded. */ export declare const buildVirtualConfig: (options: StudioCMSConfig) => string; /** * Builds the content for a logger virtual file by reading a logger stub file and replacing * the `$$verbose$$` placeholder with the provided verbosity flag. * * @param verbose - Determines whether verbose logging should be enabled. * @returns The logger file content with the verbosity setting applied. */ export declare const buildLoggerVirtual: (verbose: boolean) => string; /** * Factory function to build utilities for generating virtual module code strings. * * @param resolve - A function that resolves a list of path segments into a string path. * @returns An object containing utilities for generating virtual module code: * - `dynamicVirtual`: Generates export statements for a list of module paths. * - `ambientScripts`: Generates import statements for a list of module paths (for side effects). * - `namedVirtual`: Generates code to re-export a named export (and optionally as default) from a module. * - `astroComponentVirtual`: Generates export statements for Astro components with custom names. * - `dynamicWithAstroVirtual`: Generates combined exports for dynamic modules and Astro components. */ export declare const VirtualModuleBuilder: (resolve: (...path: Array<string>) => string) => { dynamicVirtual: (items: Array<string>) => string; ambientScripts: (items: Array<string>) => string; namedVirtual: ({ namedExport, path, exportDefault, }: { namedExport: string; path: string; exportDefault?: boolean; }) => string; astroComponentVirtual: (items: Record<string, string>) => string; dynamicWithAstroVirtual: ({ dynamicExports, astroComponents, }: { dynamicExports: Array<string>; astroComponents: Record<string, string>; }) => string; buildDefaultOnlyVirtual: (mod: any) => string; buildLoggerVirtual: (verbose: boolean) => string; buildNamedMultiExportVirtual: (items: Record<string, string>) => string; buildVirtualConfig: (options: StudioCMSConfig) => string; };