compose-node.d.ts 1.2 KB

1234567891011121314151617181920212223242526272829
  1. import type { Directives } from '../doc/directives.js';
  2. import type { ParsedNode } from '../nodes/Node.js';
  3. import type { ParseOptions } from '../options.js';
  4. import type { SourceToken, Token } from '../parse/cst.js';
  5. import type { Schema } from '../schema/Schema.js';
  6. import type { ComposeErrorHandler } from './composer.js';
  7. export interface ComposeContext {
  8. atKey: boolean;
  9. atRoot: boolean;
  10. directives: Directives;
  11. options: Readonly<Required<Omit<ParseOptions, 'lineCounter'>>>;
  12. schema: Readonly<Schema>;
  13. }
  14. interface Props {
  15. spaceBefore: boolean;
  16. comment: string;
  17. anchor: SourceToken | null;
  18. tag: SourceToken | null;
  19. newlineAfterProp: SourceToken | null;
  20. end: number;
  21. }
  22. declare const CN: {
  23. composeNode: typeof composeNode;
  24. composeEmptyNode: typeof composeEmptyNode;
  25. };
  26. export type ComposeNode = typeof CN;
  27. export declare function composeNode(ctx: ComposeContext, token: Token, props: Props, onError: ComposeErrorHandler): ParsedNode;
  28. export declare function composeEmptyNode(ctx: ComposeContext, offset: number, before: Token[] | undefined, pos: number | null, { spaceBefore, comment, anchor, tag, end }: Props, onError: ComposeErrorHandler): import("../index.js").Scalar.Parsed;
  29. export {};