en Exports - chiba233/yumeDSL GitHub Wiki

Exports

DslContext | Home

Complete export reference. For detailed documentation of each export, follow the links to individual wiki pages.

Core

Export Signature Description Details
parseRichText (text: string, options?: ParseOptions) => TextToken[] Parse DSL text into token tree API Reference
stripRichText (text: string, options?: ParseOptions) => string Parse and flatten to plain text API Reference
createParser (defaults: ParseOptions) => Parser Reusable parser with pre-filled options API Reference
parseStructural (text: string, options?: StructuralParseOptions) => StructuralNode[] Form-preserving structural tree API Reference
printStructural (nodes: StructuralNode[], options?: PrintOptions) => string Serialize structural tree to DSL API Reference
buildZones (nodes: readonly StructuralNode[]) => Zone[] Group structural nodes into contiguous zones API Reference

Incremental Parsing

parseIncremental and createIncrementalSession are stable public incremental APIs. Runtime heuristics/performance tuning may continue to evolve; check Version Semantics Notes for upgrade-sensitive behavior changes.

Export Signature Description Details
parseIncremental (source: string, options?: IncrementalParseOptions) => IncrementalDocument Build an incremental structural snapshot Incremental Parsing
createIncrementalSession (source: string, options?: IncrementalParseOptions, sessionOptions?: IncrementalSessionOptions) => { getDocument: () => IncrementalDocument; applyEdit: (...) => IncrementalSessionApplyResult; applyEditWithDiff: (...) => IncrementalSessionApplyWithDiffResult; rebuild: (...) => IncrementalDocument } Session-level incremental API with auto fallback, structural diff, and adaptive strategy Incremental Parsing

Configuration

Export Signature Description Details
DEFAULT_SYNTAX SyntaxInput Built-in syntax tokens Custom Syntax
createEasySyntax (overrides?: Partial<SyntaxInput> & { closeMiddle?: string }) => SyntaxConfig Auto-derivation builder Custom Syntax
createSyntax (overrides?: Partial<SyntaxInput>) => SyntaxConfig Plain merge builder Custom Syntax
DEFAULT_TAG_NAME TagNameConfig Built-in tag name rules Custom Tag Name Characters
createTagNameConfig (overrides?: Partial<TagNameConfig>) => TagNameConfig Tag name config builder Custom Tag Name Characters
createEasyStableId (options?: EasyStableIdOptions) => CreateId Content-based stable IDs Stable Token IDs

Handler Helpers

Export Signature Description Details
createPassthroughTags (names: string[]) => Record<string, TagHandler> Legacy passthrough tag helper (deprecated) Handler Helpers
createPipeHandlers (definitions: Record<string, PipeHandlerDefinition>) => Record<string, TagHandler> Pipe-aware multi-form builder Handler Helpers
createPipeBlockHandlers (names: string[]) => Record<string, TagHandler> Block shorthand over createPipeHandlers (deprecated) Handler Helpers
createPipeRawHandlers (names: string[]) => Record<string, TagHandler> Raw shorthand over createPipeHandlers (deprecated) Handler Helpers
createSimpleInlineHandlers (names: string[]) => Record<string, TagHandler> Bulk inline handlers Handler Helpers
createSimpleBlockHandlers (names: string[]) => Record<string, TagHandler> Bulk block handlers Handler Helpers
createSimpleRawHandlers (names: string[]) => Record<string, TagHandler> Bulk raw handlers Handler Helpers
declareMultilineTags (names: BlockTagInput[]) => BlockTagInput[] Declare multiline normalization Handler Helpers

Handler Utilities

Export Signature Description Details
parsePipeArgs (tokens: TextToken[], ctx?: DslContext) => PipeArgs Split tokens by pipe Handler Utilities
parsePipeTextArgs (text: string, ctx?: DslContext) => PipeArgs Split text by pipe Handler Utilities
parsePipeTextList (text: string, ctx?: DslContext) => string[] Split text to string array Handler Utilities
extractText (input?: TextToken | TextToken[]) => string Recursive plain text extraction Handler Utilities
createTextToken (value: string, ctx?: DslContext) => TextToken Create text leaf token Handler Utilities
splitTokensByPipe (tokens: TextToken[], ctx?: DslContext) => TextToken[][] Raw pipe split Handler Utilities
materializeTextTokens (tokens: TextToken[], ctx?: DslContext) => TextToken[] Unescape text leaves Handler Utilities
unescapeInline (str: string, ctx?: DslContext | SyntaxConfig) => string Unescape a string Handler Utilities
readEscapedSequence (text: string, i: number, ctx?: DslContext | SyntaxConfig) => [string | null, number] Escape scanner Handler Utilities
createToken (token: TokenDraft, position?: SourceSpan, ctx?: DslContext | CreateId) => TextToken Build token from draft Handler Utilities
createTokenGuard <TMap>() => (token, type) => token is NarrowToken Type-narrowing guard factory Token Structure
resetTokenIdSeed () => void Legacy global ID counter reset (deprecated) Deprecated API

Legacy Context (deprecated)

Export Signature Description Details
withSyntax <T>(syntax, fn, suppressWarning?) => T Legacy ambient syntax wrapper Deprecated API
getSyntax () => SyntaxConfig Read ambient syntax Deprecated API
withTagNameConfig <T>(tagName, fn, suppressWarning?) => T Legacy ambient tagName wrapper Deprecated API

Token Traversal

Export Signature Description Details
walkTokens (tokens: TextToken[], visitor: WalkVisitor) => void Pre-order read-only visitor Token Traversal
mapTokens (tokens: TextToken[], visitor: MapVisitor) => TextToken[] Post-order immutable transform Token Traversal
filterTokens <T>(tokens: TextToken[], predicate: FilterVisitor<T>) => T[] Shorthand for mapTokens keep/drop Token Traversal

Position Tracking

Export Signature Description Details
buildPositionTracker (text: string) => PositionTracker Build line-offset table Source Position Tracking

Types

Token

Type Description Details
TextToken Core token node — type, value, id, optional position Token Structure
TokenDraft Handler return type — type, value, plus extra fields Token Structure
StructuralNode Form-preserving node (inline / raw / block / text / escape / separator) API Reference
Zone Contiguous group of structural nodes with source offsets API Reference

Incremental Parsing

Type Description Details
IncrementalDocument Cached structural snapshot (source, tree, zones) Incremental Parsing
IncrementalEdit Single edit descriptor for session.applyEdit(...) Incremental Parsing
IncrementalParseOptions StructuralParseOptions without trackPositions Incremental Parsing
IncrementalSessionOptions Session strategy options for createIncrementalSession (including softZoneNodeCap and optional default diff config) Incremental Parsing
IncrementalDiffRefinementOptions Diff-refinement budget options used by applyEditWithDiff(...) (session defaults or per-call override) Incremental Parsing
IncrementalSessionApplyResult Result returned by applyEdit(...) Incremental Parsing
IncrementalSessionApplyWithDiffResult Result returned by applyEditWithDiff(...) Incremental Parsing
TokenDiffResult Structured diff payload with top-level patches, unchanged ranges, path-aware ops, and dirty spans Incremental Parsing

TokenDiffPatch, TokenDiffUnchangedRange, StructuralDiffPath, StructuralDiffOp, and the individual concrete op types are intentionally not exported from the root entry point. This is deliberate API-surface control: the stable contract is TokenDiffResult itself, not every fine-grained named fragment type as a separately versioned promise.

When you need those shapes, derive them from the result fields:

type DiffPatch = TokenDiffResult["patches"][number];
type DiffRange = TokenDiffResult["unchangedRanges"][number];
type DiffOp = TokenDiffResult["ops"][number];

Likewise, IncrementalSession, IncrementalSessionApplyMode, and IncrementalSessionFallbackReason are currently not exported from the root entry point. When you need the session object type, prefer ReturnType<typeof createIncrementalSession>.

Type Narrowing

Type Description Details
NarrowToken TextToken & { type: TType } & TExtra — narrowed token type Token Structure
NarrowDraft TokenDraft & { type: TType } & TExtra — narrowed draft type Token Structure
NarrowTokenUnion Union of NarrowToken from a token map Token Structure

Parser & Options

Type Description Details
Parser Object returned by createParserparse, strip, structural, print API Reference
ParseOptions Options for parseRichText — handlers, syntax, tracking, etc. ParseOptions
ParserBaseOptions Shared base for ParseOptions and StructuralParseOptions API Reference
StructuralParseOptions Options for parseStructural API Reference
PrintOptions Options for printStructural / parser.print API Reference
DslContext Syntax config + createId bundle for a parse session DslContext

Handlers

Type Description Details
TagHandler Handler with optional inline, block, raw methods Writing Tag Handlers
TagForm "inline" | "block" | "raw" DSL Syntax
InlineShorthandOption boolean | readonly string[] — shorthand control for implicitInlineShorthand ParseOptions
PipeArgs Parsed pipe-separated arguments with text/token accessors Handler Utilities
PipeHandlerDefinition Per-tag definition for createPipeHandlers Handler Helpers
BlockTagInput Input shape for declareMultilineTags Handler Helpers
BlockTagLookup Resolved block tag lookup table Handler Helpers
MultilineForm "inline" | "raw" | "block" — multiline tag forms (alias of TagForm) Handler Helpers

Syntax & Configuration

Type Description Details
SyntaxInput Input shape for createSyntax; createEasySyntax additionally accepts closeMiddle?: string Custom Syntax
SyntaxConfig Fully resolved syntax configuration (read-only) Custom Syntax
TagNameConfig Rules for valid tag name characters Custom Tag Name Characters
CreateId (draft: TokenDraft) => string — ID factory function Stable Token IDs
EasyStableIdOptions Options for createEasyStableId Stable Token IDs

Position Tracking

Type Description Details
SourcePosition {offset, line, column} — single point in source Source Position Tracking
SourceSpan {start, end} — range covering a token Source Position Tracking
PositionTracker Object with resolve(offset) for offset-to-position mapping Source Position Tracking

Token Traversal

Type Description Details
TokenVisitContext {parent, depth, index} — context passed to walk/map visitors Token Traversal
WalkVisitor Visitor type for walkTokens (function or record) Token Traversal
MapVisitor Visitor type for mapTokens Token Traversal

Errors

Type Description Details
ErrorCode Union of all error code strings Error Handling
ParseError Error object — code, message, line, column, snippet Error Handling
⚠️ **GitHub.com Fallback** ⚠️