/** * [[include:src/codecs/dir/README.md]] * * @module codecs/dir */ import schema from '@stencila/schema'; import * as vfile from '../../util/vfile'; import { Codec, CommonEncodeOptions, CommonDecodeOptions } from '../types'; export interface EncodeOptions extends CommonEncodeOptions { /** * The format to decode parts of the `Collection` as. * Defaults to `html`. Different from the common option * `format`, which in this case is `dir`. */ fileFormat?: string; } export interface DecodeOptions extends CommonDecodeOptions { /** * Minimatch patterns to use to select only some of the included * files. Defaults to '**\/\*' (i.e. everything, including in * nested directories) */ patterns?: string | string[]; /** * The file base names (i.e. without extension) that should * be considered to be the "main" file in a directory. * Defaults to `['main', 'index', 'README']` */ mainNames?: string | string[]; } export declare class DirCodec extends Codec implements Codec { readonly extNames: string[]; /** * Sniff the path to see if it is a directory */ readonly sniff: (content: string) => Promise; /** * Decode a directory into a Stencila `Collection`, that may include * other `CreativeWork`s, such as `Article`s or other `Collection`s. */ readonly decode: (file: vfile.VFile, options?: DecodeOptions) => Promise; readonly encode: (node: schema.Node, options?: EncodeOptions) => Promise; /** * @override Override of {@link Codec.read} to "read" from a * directory and return a `Collection`. */ read(source: string, options?: DecodeOptions): Promise; }