@optique/core 1.3.0-dev.2529 → 1.3.0-dev.2530
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/doc.cjs +93 -84
- package/dist/doc.d.cts +12 -1
- package/dist/doc.d.ts +12 -1
- package/dist/doc.js +88 -79
- package/dist/facade.cjs +49 -15
- package/dist/facade.d.cts +12 -1
- package/dist/facade.d.ts +12 -1
- package/dist/facade.js +48 -14
- package/dist/index.cjs +3 -0
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +3 -2
- package/dist/internal/terminal.cjs +7 -0
- package/dist/internal/terminal.d.cts +4 -0
- package/dist/internal/terminal.d.ts +4 -0
- package/dist/internal/terminal.js +5 -0
- package/dist/message-registry.cjs +6 -0
- package/dist/message-registry.d.cts +7 -0
- package/dist/message-registry.d.ts +7 -0
- package/dist/message-registry.js +5 -0
- package/dist/message-renderer.cjs +26 -0
- package/dist/message-renderer.d.cts +19 -0
- package/dist/message-renderer.d.ts +19 -0
- package/dist/message-renderer.js +26 -0
- package/dist/message.cjs +49 -85
- package/dist/message.d.cts +31 -1
- package/dist/message.d.ts +31 -1
- package/dist/message.js +49 -86
- package/dist/terminal-internal.cjs +259 -0
- package/dist/terminal-internal.d.cts +36 -0
- package/dist/terminal-internal.d.ts +36 -0
- package/dist/terminal-internal.js +253 -0
- package/dist/terminal.cjs +74 -0
- package/dist/terminal.d.cts +129 -0
- package/dist/terminal.d.ts +129 -0
- package/dist/terminal.js +73 -0
- package/dist/usage.cjs +108 -134
- package/dist/usage.d.cts +6 -0
- package/dist/usage.d.ts +6 -0
- package/dist/usage.js +108 -134
- package/package.json +18 -2
- package/skills/optique/SKILL.md +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Annotations, ParseOptions, getAnnotations } from "./internal/annotations.cjs";
|
|
2
2
|
import { NonEmptyString, ensureNonEmptyString, isNonEmptyString } from "./nonempty.cjs";
|
|
3
|
-
import { Message, MessageFormatOptions, MessageTerm, ValueSetOptions, commandLine, envVar, formatMessage, lineBreak, link, message, metavar, optionName, optionNames, text, value, valueSet, values } from "./message.cjs";
|
|
3
|
+
import { Message, MessageFormatOptions, MessageFormatter, MessageFormatterOptions, MessageTerm, ValueSetOptions, commandLine, createMessageFormatter, envVar, formatMessage, lineBreak, link, message, metavar, optionName, optionNames, text, value, valueSet, values } from "./message.cjs";
|
|
4
|
+
import { ErrorLabelTerm, LabelTerm, ProgramNameTerm, SyntaxPunctuationTerm, TerminalColor, TerminalFormatContext, TerminalFormatter, TerminalFragment, TerminalStyle, TerminalTerm, TerminalTheme, defaultTerminalTheme } from "./terminal.cjs";
|
|
4
5
|
import { HiddenVisibility, OptionName, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, cloneUsage, cloneUsageTerm, extractArgumentMetavars, extractCommandNames, extractLiteralValues, extractOptionNames, formatUsage, formatUsageTerm, isDocHidden, isSuggestionHidden, isUsageHidden, mergeHidden, normalizeUsage } from "./usage.cjs";
|
|
5
6
|
import { DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, ShowChoicesOptions, ShowDefaultOptions, cloneDocEntry, deduplicateDocEntries, deduplicateDocFragments, formatDocPage, isDocEntryHidden } from "./doc.cjs";
|
|
6
7
|
import { ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, Color, ColorFormat, ColorOptions, CronExpression, CronExpressionForOptions, CronOptions, DeferredMap, DomainOptions, EmailOptions, FileSizeOptions, FileSizeOptionsBigInt, FileSizeOptionsNumber, FileSizeUnit, FirstOfOptions, FloatOptions, HostnameOptions, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, Json, JsonOptions, KeyValueOptions, LocaleOptions, MacAddressOptions, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, RegExpOptions, SemVer, SemVerOptionsObject, SemVerOptionsString, SemVerString, SocketAddressOptions, SocketAddressValue, StringOptions, TransformMapping, UrlOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, biject, checkBooleanOption, checkEnumOption, choice, cidr, color, cron, domain, email, fileSize, firstOf, float, hostname, integer, ip, ipv4, ipv6, isValueParser, json, keyValue, locale, macAddress, port, portRange, regExp, semVer, socketAddress, string, transform, url, uuid } from "./valueparser.cjs";
|
|
@@ -12,4 +13,4 @@ import { ParserValuePlaceholder, SourceContext, SourceContextRequest } from "./c
|
|
|
12
13
|
import { AnyDependencySource, CombineMode, CombinedDependencyMode, DependencyMode, DependencySource, DependencySourceInfo, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, dependency, deriveFrom, deriveFromAsync, deriveFromSync, getDependencySourceInfo, isDependencySource, isDerivedValueParser } from "./internal/dependency.cjs";
|
|
13
14
|
import { CommandListMode, CommandSubConfig, ContextOptionsParam, ExtractRequiredOptions, OptionSubConfig, RunOptions, RunParserError, RunWithOptions, SubstituteParserValue, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync } from "./facade.cjs";
|
|
14
15
|
import { ArgumentErrorOptions, ArgumentOptions, CommandErrorOptions, CommandOptions, FlagErrorOptions, FlagOptions, NegatableFlagErrorOptions, NegatableFlagNameList, NegatableFlagNames, NegatableFlagOptions, NegatableFlagState, OptionErrorOptions, OptionOptions, OptionState, PassThroughFormat, PassThroughOptions, argument, command, constant, fail, flag, negatableFlag, option, passThrough } from "./primitives.cjs";
|
|
15
|
-
export { type Annotations, AnyDependencySource, ArgumentErrorOptions, ArgumentOptions, ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, Color, ColorFormat, ColorOptions, CombineMode, CombineModes, CombinedDependencyMode, CommandErrorOptions, CommandListMode, CommandOptions, CommandSubConfig, ConditionalErrorOptions, ConditionalOptions, ContextOptionsParam, CronExpression, CronExpressionForOptions, CronOptions, DeferredMap, DeferredValue, DeferredValueOptions, DeferredValueSource, DependencyMode, DependencySource, DependencySourceInfo, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, DetailedParseResult, DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, DocState, DomainOptions, DuplicateOptionError, EffectfulCompletionSession, EmailOptions, ExecutionContext, ExecutionPhase, ExtractRequiredOptions, FileSizeOptions, FileSizeOptionsBigInt, FileSizeOptionsNumber, FileSizeUnit, FirstOfOptions, FlagErrorOptions, FlagOptions, FloatOptions, FluentParser, GroupOptions, HiddenVisibility, HostnameOptions, InferMode, InferValue, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, Json, JsonOptions, KeyValueOptions, LocaleOptions, LongestMatchErrorOptions, LongestMatchOptions, MacAddressOptions, MergeOptions, type Message, type MessageFormatOptions, type MessageTerm, Mode, ModeIterable, ModeValue, MultipleErrorOptions, MultipleOptions, NegatableFlagErrorOptions, NegatableFlagNameList, NegatableFlagNames, NegatableFlagOptions, NegatableFlagState, NoMatchContext, NonEmptyString, ObjectErrorOptions, ObjectOptions, OptionErrorOptions, OptionName, OptionOptions, OptionState, OptionSubConfig, OrErrorOptions, OrOptions, ParseFrame, type ParseOptions, Parser, ParserContext, ParserModifiers, ParserResult, ParserValuePlaceholder, PassThroughFormat, PassThroughOptions, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, RegExpOptions, Result, RunOptions, RunParserError, RunWithOptions, SemVer, SemVerOptionsObject, SemVerOptionsString, SemVerString, SeqOptions, ShellCompletion, ShowChoicesOptions, ShowDefaultOptions, SocketAddressOptions, SocketAddressValue, SourceContext, SourceContextRequest, StringOptions, SubstituteParserValue, Suggestion, TransformMapping, TupleOptions, UrlOptions, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, type ValueSetOptions, WithDefaultError, WithDefaultOptions, argument, bash, biject, checkBooleanOption, checkEnumOption, choice, cidr, cloneDocEntry, cloneUsage, cloneUsageTerm, color, command, commandLine, concat, conditional, constant, createParserContext, cron, deduplicateDocEntries, deduplicateDocFragments, deferredValue, dependency, deriveFrom, deriveFromAsync, deriveFromSync, domain, email, ensureNonEmptyString, envVar, extractArgumentMetavars, extractCommandNames, extractLiteralValues, extractOptionNames, fail, fileSize, firstOf, fish, flag, float, fluent, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getAnnotations, getDependencySourceInfo, getDocPage, getDocPageAsync, getDocPageSync, group, hostname, integer, ip, ipv4, ipv6, isDeferredValue, isDependencySource, isDerivedValueParser, isDocEntryHidden, isDocHidden, isNonEmptyString, isSuggestionHidden, isUsageHidden, isValueParser, json, keyValue, lineBreak, link, locale, longestMatch, macAddress, map, merge, mergeHidden, message, metavar, multiple, negatableFlag, nonEmpty, normalizeUsage, nu, object, option, optionName, optionNames, optional, or, parse, parseAsync, parseDetailed, parseSync, passThrough, port, portRange, pwsh, regExp, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync, semVer, seq, socketAddress, string, suggest, suggestAsync, suggestSync, text, transform, tuple, url, uuid, value, valueSet, values, withDefault, zsh };
|
|
16
|
+
export { type Annotations, AnyDependencySource, ArgumentErrorOptions, ArgumentOptions, ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, Color, ColorFormat, ColorOptions, CombineMode, CombineModes, CombinedDependencyMode, CommandErrorOptions, CommandListMode, CommandOptions, CommandSubConfig, ConditionalErrorOptions, ConditionalOptions, ContextOptionsParam, CronExpression, CronExpressionForOptions, CronOptions, DeferredMap, DeferredValue, DeferredValueOptions, DeferredValueSource, DependencyMode, DependencySource, DependencySourceInfo, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, DetailedParseResult, DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, DocState, DomainOptions, DuplicateOptionError, EffectfulCompletionSession, EmailOptions, ErrorLabelTerm, ExecutionContext, ExecutionPhase, ExtractRequiredOptions, FileSizeOptions, FileSizeOptionsBigInt, FileSizeOptionsNumber, FileSizeUnit, FirstOfOptions, FlagErrorOptions, FlagOptions, FloatOptions, FluentParser, GroupOptions, HiddenVisibility, HostnameOptions, InferMode, InferValue, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, Json, JsonOptions, KeyValueOptions, LabelTerm, LocaleOptions, LongestMatchErrorOptions, LongestMatchOptions, MacAddressOptions, MergeOptions, type Message, type MessageFormatOptions, type MessageFormatter, type MessageFormatterOptions, type MessageTerm, Mode, ModeIterable, ModeValue, MultipleErrorOptions, MultipleOptions, NegatableFlagErrorOptions, NegatableFlagNameList, NegatableFlagNames, NegatableFlagOptions, NegatableFlagState, NoMatchContext, NonEmptyString, ObjectErrorOptions, ObjectOptions, OptionErrorOptions, OptionName, OptionOptions, OptionState, OptionSubConfig, OrErrorOptions, OrOptions, ParseFrame, type ParseOptions, Parser, ParserContext, ParserModifiers, ParserResult, ParserValuePlaceholder, PassThroughFormat, PassThroughOptions, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, ProgramNameTerm, RegExpOptions, Result, RunOptions, RunParserError, RunWithOptions, SemVer, SemVerOptionsObject, SemVerOptionsString, SemVerString, SeqOptions, ShellCompletion, ShowChoicesOptions, ShowDefaultOptions, SocketAddressOptions, SocketAddressValue, SourceContext, SourceContextRequest, StringOptions, SubstituteParserValue, Suggestion, SyntaxPunctuationTerm, TerminalColor, TerminalFormatContext, TerminalFormatter, TerminalFragment, TerminalStyle, TerminalTerm, TerminalTheme, TransformMapping, TupleOptions, UrlOptions, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, type ValueSetOptions, WithDefaultError, WithDefaultOptions, argument, bash, biject, checkBooleanOption, checkEnumOption, choice, cidr, cloneDocEntry, cloneUsage, cloneUsageTerm, color, command, commandLine, concat, conditional, constant, createMessageFormatter, createParserContext, cron, deduplicateDocEntries, deduplicateDocFragments, defaultTerminalTheme, deferredValue, dependency, deriveFrom, deriveFromAsync, deriveFromSync, domain, email, ensureNonEmptyString, envVar, extractArgumentMetavars, extractCommandNames, extractLiteralValues, extractOptionNames, fail, fileSize, firstOf, fish, flag, float, fluent, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getAnnotations, getDependencySourceInfo, getDocPage, getDocPageAsync, getDocPageSync, group, hostname, integer, ip, ipv4, ipv6, isDeferredValue, isDependencySource, isDerivedValueParser, isDocEntryHidden, isDocHidden, isNonEmptyString, isSuggestionHidden, isUsageHidden, isValueParser, json, keyValue, lineBreak, link, locale, longestMatch, macAddress, map, merge, mergeHidden, message, metavar, multiple, negatableFlag, nonEmpty, normalizeUsage, nu, object, option, optionName, optionNames, optional, or, parse, parseAsync, parseDetailed, parseSync, passThrough, port, portRange, pwsh, regExp, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync, semVer, seq, socketAddress, string, suggest, suggestAsync, suggestSync, text, transform, tuple, url, uuid, value, valueSet, values, withDefault, zsh };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Annotations, ParseOptions, getAnnotations } from "./internal/annotations.js";
|
|
2
2
|
import { NonEmptyString, ensureNonEmptyString, isNonEmptyString } from "./nonempty.js";
|
|
3
|
-
import { Message, MessageFormatOptions, MessageTerm, ValueSetOptions, commandLine, envVar, formatMessage, lineBreak, link, message, metavar, optionName, optionNames, text, value, valueSet, values } from "./message.js";
|
|
3
|
+
import { Message, MessageFormatOptions, MessageFormatter, MessageFormatterOptions, MessageTerm, ValueSetOptions, commandLine, createMessageFormatter, envVar, formatMessage, lineBreak, link, message, metavar, optionName, optionNames, text, value, valueSet, values } from "./message.js";
|
|
4
|
+
import { ErrorLabelTerm, LabelTerm, ProgramNameTerm, SyntaxPunctuationTerm, TerminalColor, TerminalFormatContext, TerminalFormatter, TerminalFragment, TerminalStyle, TerminalTerm, TerminalTheme, defaultTerminalTheme } from "./terminal.js";
|
|
4
5
|
import { HiddenVisibility, OptionName, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, cloneUsage, cloneUsageTerm, extractArgumentMetavars, extractCommandNames, extractLiteralValues, extractOptionNames, formatUsage, formatUsageTerm, isDocHidden, isSuggestionHidden, isUsageHidden, mergeHidden, normalizeUsage } from "./usage.js";
|
|
5
6
|
import { DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, ShowChoicesOptions, ShowDefaultOptions, cloneDocEntry, deduplicateDocEntries, deduplicateDocFragments, formatDocPage, isDocEntryHidden } from "./doc.js";
|
|
6
7
|
import { ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, Color, ColorFormat, ColorOptions, CronExpression, CronExpressionForOptions, CronOptions, DeferredMap, DomainOptions, EmailOptions, FileSizeOptions, FileSizeOptionsBigInt, FileSizeOptionsNumber, FileSizeUnit, FirstOfOptions, FloatOptions, HostnameOptions, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, Json, JsonOptions, KeyValueOptions, LocaleOptions, MacAddressOptions, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, RegExpOptions, SemVer, SemVerOptionsObject, SemVerOptionsString, SemVerString, SocketAddressOptions, SocketAddressValue, StringOptions, TransformMapping, UrlOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, biject, checkBooleanOption, checkEnumOption, choice, cidr, color, cron, domain, email, fileSize, firstOf, float, hostname, integer, ip, ipv4, ipv6, isValueParser, json, keyValue, locale, macAddress, port, portRange, regExp, semVer, socketAddress, string, transform, url, uuid } from "./valueparser.js";
|
|
@@ -12,4 +13,4 @@ import { ParserValuePlaceholder, SourceContext, SourceContextRequest } from "./c
|
|
|
12
13
|
import { AnyDependencySource, CombineMode, CombinedDependencyMode, DependencyMode, DependencySource, DependencySourceInfo, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, dependency, deriveFrom, deriveFromAsync, deriveFromSync, getDependencySourceInfo, isDependencySource, isDerivedValueParser } from "./internal/dependency.js";
|
|
13
14
|
import { CommandListMode, CommandSubConfig, ContextOptionsParam, ExtractRequiredOptions, OptionSubConfig, RunOptions, RunParserError, RunWithOptions, SubstituteParserValue, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync } from "./facade.js";
|
|
14
15
|
import { ArgumentErrorOptions, ArgumentOptions, CommandErrorOptions, CommandOptions, FlagErrorOptions, FlagOptions, NegatableFlagErrorOptions, NegatableFlagNameList, NegatableFlagNames, NegatableFlagOptions, NegatableFlagState, OptionErrorOptions, OptionOptions, OptionState, PassThroughFormat, PassThroughOptions, argument, command, constant, fail, flag, negatableFlag, option, passThrough } from "./primitives.js";
|
|
15
|
-
export { type Annotations, AnyDependencySource, ArgumentErrorOptions, ArgumentOptions, ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, Color, ColorFormat, ColorOptions, CombineMode, CombineModes, CombinedDependencyMode, CommandErrorOptions, CommandListMode, CommandOptions, CommandSubConfig, ConditionalErrorOptions, ConditionalOptions, ContextOptionsParam, CronExpression, CronExpressionForOptions, CronOptions, DeferredMap, DeferredValue, DeferredValueOptions, DeferredValueSource, DependencyMode, DependencySource, DependencySourceInfo, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, DetailedParseResult, DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, DocState, DomainOptions, DuplicateOptionError, EffectfulCompletionSession, EmailOptions, ExecutionContext, ExecutionPhase, ExtractRequiredOptions, FileSizeOptions, FileSizeOptionsBigInt, FileSizeOptionsNumber, FileSizeUnit, FirstOfOptions, FlagErrorOptions, FlagOptions, FloatOptions, FluentParser, GroupOptions, HiddenVisibility, HostnameOptions, InferMode, InferValue, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, Json, JsonOptions, KeyValueOptions, LocaleOptions, LongestMatchErrorOptions, LongestMatchOptions, MacAddressOptions, MergeOptions, type Message, type MessageFormatOptions, type MessageTerm, Mode, ModeIterable, ModeValue, MultipleErrorOptions, MultipleOptions, NegatableFlagErrorOptions, NegatableFlagNameList, NegatableFlagNames, NegatableFlagOptions, NegatableFlagState, NoMatchContext, NonEmptyString, ObjectErrorOptions, ObjectOptions, OptionErrorOptions, OptionName, OptionOptions, OptionState, OptionSubConfig, OrErrorOptions, OrOptions, ParseFrame, type ParseOptions, Parser, ParserContext, ParserModifiers, ParserResult, ParserValuePlaceholder, PassThroughFormat, PassThroughOptions, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, RegExpOptions, Result, RunOptions, RunParserError, RunWithOptions, SemVer, SemVerOptionsObject, SemVerOptionsString, SemVerString, SeqOptions, ShellCompletion, ShowChoicesOptions, ShowDefaultOptions, SocketAddressOptions, SocketAddressValue, SourceContext, SourceContextRequest, StringOptions, SubstituteParserValue, Suggestion, TransformMapping, TupleOptions, UrlOptions, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, type ValueSetOptions, WithDefaultError, WithDefaultOptions, argument, bash, biject, checkBooleanOption, checkEnumOption, choice, cidr, cloneDocEntry, cloneUsage, cloneUsageTerm, color, command, commandLine, concat, conditional, constant, createParserContext, cron, deduplicateDocEntries, deduplicateDocFragments, deferredValue, dependency, deriveFrom, deriveFromAsync, deriveFromSync, domain, email, ensureNonEmptyString, envVar, extractArgumentMetavars, extractCommandNames, extractLiteralValues, extractOptionNames, fail, fileSize, firstOf, fish, flag, float, fluent, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getAnnotations, getDependencySourceInfo, getDocPage, getDocPageAsync, getDocPageSync, group, hostname, integer, ip, ipv4, ipv6, isDeferredValue, isDependencySource, isDerivedValueParser, isDocEntryHidden, isDocHidden, isNonEmptyString, isSuggestionHidden, isUsageHidden, isValueParser, json, keyValue, lineBreak, link, locale, longestMatch, macAddress, map, merge, mergeHidden, message, metavar, multiple, negatableFlag, nonEmpty, normalizeUsage, nu, object, option, optionName, optionNames, optional, or, parse, parseAsync, parseDetailed, parseSync, passThrough, port, portRange, pwsh, regExp, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync, semVer, seq, socketAddress, string, suggest, suggestAsync, suggestSync, text, transform, tuple, url, uuid, value, valueSet, values, withDefault, zsh };
|
|
16
|
+
export { type Annotations, AnyDependencySource, ArgumentErrorOptions, ArgumentOptions, ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, Color, ColorFormat, ColorOptions, CombineMode, CombineModes, CombinedDependencyMode, CommandErrorOptions, CommandListMode, CommandOptions, CommandSubConfig, ConditionalErrorOptions, ConditionalOptions, ContextOptionsParam, CronExpression, CronExpressionForOptions, CronOptions, DeferredMap, DeferredValue, DeferredValueOptions, DeferredValueSource, DependencyMode, DependencySource, DependencySourceInfo, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, DetailedParseResult, DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, DocState, DomainOptions, DuplicateOptionError, EffectfulCompletionSession, EmailOptions, ErrorLabelTerm, ExecutionContext, ExecutionPhase, ExtractRequiredOptions, FileSizeOptions, FileSizeOptionsBigInt, FileSizeOptionsNumber, FileSizeUnit, FirstOfOptions, FlagErrorOptions, FlagOptions, FloatOptions, FluentParser, GroupOptions, HiddenVisibility, HostnameOptions, InferMode, InferValue, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, Json, JsonOptions, KeyValueOptions, LabelTerm, LocaleOptions, LongestMatchErrorOptions, LongestMatchOptions, MacAddressOptions, MergeOptions, type Message, type MessageFormatOptions, type MessageFormatter, type MessageFormatterOptions, type MessageTerm, Mode, ModeIterable, ModeValue, MultipleErrorOptions, MultipleOptions, NegatableFlagErrorOptions, NegatableFlagNameList, NegatableFlagNames, NegatableFlagOptions, NegatableFlagState, NoMatchContext, NonEmptyString, ObjectErrorOptions, ObjectOptions, OptionErrorOptions, OptionName, OptionOptions, OptionState, OptionSubConfig, OrErrorOptions, OrOptions, ParseFrame, type ParseOptions, Parser, ParserContext, ParserModifiers, ParserResult, ParserValuePlaceholder, PassThroughFormat, PassThroughOptions, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, ProgramNameTerm, RegExpOptions, Result, RunOptions, RunParserError, RunWithOptions, SemVer, SemVerOptionsObject, SemVerOptionsString, SemVerString, SeqOptions, ShellCompletion, ShowChoicesOptions, ShowDefaultOptions, SocketAddressOptions, SocketAddressValue, SourceContext, SourceContextRequest, StringOptions, SubstituteParserValue, Suggestion, SyntaxPunctuationTerm, TerminalColor, TerminalFormatContext, TerminalFormatter, TerminalFragment, TerminalStyle, TerminalTerm, TerminalTheme, TransformMapping, TupleOptions, UrlOptions, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, type ValueSetOptions, WithDefaultError, WithDefaultOptions, argument, bash, biject, checkBooleanOption, checkEnumOption, choice, cidr, cloneDocEntry, cloneUsage, cloneUsageTerm, color, command, commandLine, concat, conditional, constant, createMessageFormatter, createParserContext, cron, deduplicateDocEntries, deduplicateDocFragments, defaultTerminalTheme, deferredValue, dependency, deriveFrom, deriveFromAsync, deriveFromSync, domain, email, ensureNonEmptyString, envVar, extractArgumentMetavars, extractCommandNames, extractLiteralValues, extractOptionNames, fail, fileSize, firstOf, fish, flag, float, fluent, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getAnnotations, getDependencySourceInfo, getDocPage, getDocPageAsync, getDocPageSync, group, hostname, integer, ip, ipv4, ipv6, isDeferredValue, isDependencySource, isDerivedValueParser, isDocEntryHidden, isDocHidden, isNonEmptyString, isSuggestionHidden, isUsageHidden, isValueParser, json, keyValue, lineBreak, link, locale, longestMatch, macAddress, map, merge, mergeHidden, message, metavar, multiple, negatableFlag, nonEmpty, normalizeUsage, nu, object, option, optionName, optionNames, optional, or, parse, parseAsync, parseDetailed, parseSync, passThrough, port, portRange, pwsh, regExp, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync, semVer, seq, socketAddress, string, suggest, suggestAsync, suggestSync, text, transform, tuple, url, uuid, value, valueSet, values, withDefault, zsh };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { getAnnotations } from "./internal/annotations.js";
|
|
2
|
-
import {
|
|
2
|
+
import { defaultTerminalTheme } from "./terminal.js";
|
|
3
|
+
import { commandLine, createMessageFormatter, envVar, formatMessage, lineBreak, link, message, metavar, optionName, optionNames, text, value, valueSet, values } from "./message.js";
|
|
3
4
|
import { cloneUsage, cloneUsageTerm, extractArgumentMetavars, extractCommandNames, extractLiteralValues, extractOptionNames, formatUsage, formatUsageTerm, isDocHidden, isSuggestionHidden, isUsageHidden, mergeHidden, normalizeUsage } from "./usage.js";
|
|
4
5
|
import { cloneDocEntry, deduplicateDocEntries, deduplicateDocFragments, formatDocPage, isDocEntryHidden } from "./doc.js";
|
|
5
6
|
import { dependency, deriveFrom, deriveFromAsync, deriveFromSync, getDependencySourceInfo, isDependencySource, isDerivedValueParser } from "./internal/dependency.js";
|
|
@@ -12,4 +13,4 @@ import { biject, checkBooleanOption, checkEnumOption, choice, cidr, color, cron,
|
|
|
12
13
|
import { argument, command, constant, fail, flag, negatableFlag, option, passThrough } from "./primitives.js";
|
|
13
14
|
import { RunParserError, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync } from "./facade.js";
|
|
14
15
|
|
|
15
|
-
export { DuplicateOptionError, RunParserError, WithDefaultError, argument, bash, biject, checkBooleanOption, checkEnumOption, choice, cidr, cloneDocEntry, cloneUsage, cloneUsageTerm, color, command, commandLine, concat, conditional, constant, createParserContext, cron, deduplicateDocEntries, deduplicateDocFragments, deferredValue, dependency, deriveFrom, deriveFromAsync, deriveFromSync, domain, email, ensureNonEmptyString, envVar, extractArgumentMetavars, extractCommandNames, extractLiteralValues, extractOptionNames, fail, fileSize, firstOf, fish, flag, float, fluent, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getAnnotations, getDependencySourceInfo, getDocPage, getDocPageAsync, getDocPageSync, group, hostname, integer, ip, ipv4, ipv6, isDeferredValue, isDependencySource, isDerivedValueParser, isDocEntryHidden, isDocHidden, isNonEmptyString, isSuggestionHidden, isUsageHidden, isValueParser, json, keyValue, lineBreak, link, locale, longestMatch, macAddress, map, merge, mergeHidden, message, metavar, multiple, negatableFlag, nonEmpty, normalizeUsage, nu, object, option, optionName, optionNames, optional, or, parse, parseAsync, parseDetailed, parseSync, passThrough, port, portRange, pwsh, regExp, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync, semVer, seq, socketAddress, string, suggest, suggestAsync, suggestSync, text, transform, tuple, url, uuid, value, valueSet, values, withDefault, zsh };
|
|
16
|
+
export { DuplicateOptionError, RunParserError, WithDefaultError, argument, bash, biject, checkBooleanOption, checkEnumOption, choice, cidr, cloneDocEntry, cloneUsage, cloneUsageTerm, color, command, commandLine, concat, conditional, constant, createMessageFormatter, createParserContext, cron, deduplicateDocEntries, deduplicateDocFragments, defaultTerminalTheme, deferredValue, dependency, deriveFrom, deriveFromAsync, deriveFromSync, domain, email, ensureNonEmptyString, envVar, extractArgumentMetavars, extractCommandNames, extractLiteralValues, extractOptionNames, fail, fileSize, firstOf, fish, flag, float, fluent, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getAnnotations, getDependencySourceInfo, getDocPage, getDocPageAsync, getDocPageSync, group, hostname, integer, ip, ipv4, ipv6, isDeferredValue, isDependencySource, isDerivedValueParser, isDocEntryHidden, isDocHidden, isNonEmptyString, isSuggestionHidden, isUsageHidden, isValueParser, json, keyValue, lineBreak, link, locale, longestMatch, macAddress, map, merge, mergeHidden, message, metavar, multiple, negatableFlag, nonEmpty, normalizeUsage, nu, object, option, optionName, optionNames, optional, or, parse, parseAsync, parseDetailed, parseSync, passThrough, port, portRange, pwsh, regExp, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync, semVer, seq, socketAddress, string, suggest, suggestAsync, suggestSync, text, transform, tuple, url, uuid, value, valueSet, values, withDefault, zsh };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
const require_displaywidth = require('../displaywidth.cjs');
|
|
2
|
+
const require_terminal_internal = require('../terminal-internal.cjs');
|
|
3
|
+
const require_message_renderer = require('../message-renderer.cjs');
|
|
4
|
+
|
|
5
|
+
exports.getDisplayWidth = require_displaywidth.getDisplayWidth;
|
|
6
|
+
exports.renderTerminalTerm = require_terminal_internal.renderTerminalTerm;
|
|
7
|
+
exports.resolveMessageFormatter = require_message_renderer.resolveMessageFormatter;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Message, MessageFormatOptions, MessageFormatter } from "./message.cjs";
|
|
2
|
+
import { TerminalStyle } from "./terminal.cjs";
|
|
3
|
+
|
|
4
|
+
//#region src/message-registry.d.ts
|
|
5
|
+
declare const messageRenderers: WeakMap<MessageFormatter, (message: Message, options: MessageFormatOptions, ambient?: TerminalStyle) => string>;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { messageRenderers };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Message, MessageFormatOptions, MessageFormatter } from "./message.js";
|
|
2
|
+
import { TerminalStyle } from "./terminal.js";
|
|
3
|
+
|
|
4
|
+
//#region src/message-registry.d.ts
|
|
5
|
+
declare const messageRenderers: WeakMap<MessageFormatter, (message: Message, options: MessageFormatOptions, ambient?: TerminalStyle) => string>;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { messageRenderers };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const require_message_registry = require('./message-registry.cjs');
|
|
2
|
+
const require_message = require('./message.cjs');
|
|
3
|
+
|
|
4
|
+
//#region src/message-renderer.ts
|
|
5
|
+
/**
|
|
6
|
+
* Resolves a presentation surface's formatter while preserving built-in
|
|
7
|
+
* ambient styling and normalizing legacy color options for custom formatters.
|
|
8
|
+
* @param options The surface's explicit formatter and fallback theme.
|
|
9
|
+
* @returns A formatter that accepts legacy options and an ambient style.
|
|
10
|
+
* @since 1.3.0
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
function resolveMessageFormatter(options) {
|
|
14
|
+
const formatter = options.messageFormatter ?? (options.theme == null ? require_message.formatMessage : require_message.createMessageFormatter(options.theme));
|
|
15
|
+
return (message, options$1 = {}, ambient) => {
|
|
16
|
+
const builtin = require_message_registry.messageRenderers.get(formatter);
|
|
17
|
+
if (builtin != null) return builtin(message, options$1, ambient);
|
|
18
|
+
return formatter(message, {
|
|
19
|
+
...options$1,
|
|
20
|
+
colors: typeof options$1.colors === "object" ? true : options$1.colors
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
exports.resolveMessageFormatter = resolveMessageFormatter;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Message, MessageFormatOptions, MessageFormatter } from "./message.cjs";
|
|
2
|
+
import { TerminalStyle, TerminalTheme } from "./terminal.cjs";
|
|
3
|
+
|
|
4
|
+
//#region src/message-renderer.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Resolves a presentation surface's formatter while preserving built-in
|
|
8
|
+
* ambient styling and normalizing legacy color options for custom formatters.
|
|
9
|
+
* @param options The surface's explicit formatter and fallback theme.
|
|
10
|
+
* @returns A formatter that accepts legacy options and an ambient style.
|
|
11
|
+
* @since 1.3.0
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
declare function resolveMessageFormatter(options: {
|
|
15
|
+
readonly messageFormatter?: MessageFormatter;
|
|
16
|
+
readonly theme?: TerminalTheme;
|
|
17
|
+
}): (message: Message, options?: MessageFormatOptions, ambient?: TerminalStyle) => string;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { resolveMessageFormatter };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Message, MessageFormatOptions, MessageFormatter } from "./message.js";
|
|
2
|
+
import { TerminalStyle, TerminalTheme } from "./terminal.js";
|
|
3
|
+
|
|
4
|
+
//#region src/message-renderer.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Resolves a presentation surface's formatter while preserving built-in
|
|
8
|
+
* ambient styling and normalizing legacy color options for custom formatters.
|
|
9
|
+
* @param options The surface's explicit formatter and fallback theme.
|
|
10
|
+
* @returns A formatter that accepts legacy options and an ambient style.
|
|
11
|
+
* @since 1.3.0
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
declare function resolveMessageFormatter(options: {
|
|
15
|
+
readonly messageFormatter?: MessageFormatter;
|
|
16
|
+
readonly theme?: TerminalTheme;
|
|
17
|
+
}): (message: Message, options?: MessageFormatOptions, ambient?: TerminalStyle) => string;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { resolveMessageFormatter };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { messageRenderers } from "./message-registry.js";
|
|
2
|
+
import { createMessageFormatter, formatMessage } from "./message.js";
|
|
3
|
+
|
|
4
|
+
//#region src/message-renderer.ts
|
|
5
|
+
/**
|
|
6
|
+
* Resolves a presentation surface's formatter while preserving built-in
|
|
7
|
+
* ambient styling and normalizing legacy color options for custom formatters.
|
|
8
|
+
* @param options The surface's explicit formatter and fallback theme.
|
|
9
|
+
* @returns A formatter that accepts legacy options and an ambient style.
|
|
10
|
+
* @since 1.3.0
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
function resolveMessageFormatter(options) {
|
|
14
|
+
const formatter = options.messageFormatter ?? (options.theme == null ? formatMessage : createMessageFormatter(options.theme));
|
|
15
|
+
return (message, options$1 = {}, ambient) => {
|
|
16
|
+
const builtin = messageRenderers.get(formatter);
|
|
17
|
+
if (builtin != null) return builtin(message, options$1, ambient);
|
|
18
|
+
return formatter(message, {
|
|
19
|
+
...options$1,
|
|
20
|
+
colors: typeof options$1.colors === "object" ? true : options$1.colors
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
export { resolveMessageFormatter };
|
package/dist/message.cjs
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
const require_message_registry = require('./message-registry.cjs');
|
|
1
2
|
const require_displaywidth = require('./displaywidth.cjs');
|
|
3
|
+
const require_terminal_internal = require('./terminal-internal.cjs');
|
|
2
4
|
|
|
3
5
|
//#region src/message.ts
|
|
4
6
|
/**
|
|
@@ -294,11 +296,30 @@ function valueSet(values$1, fallbackOrOptions) {
|
|
|
294
296
|
return result;
|
|
295
297
|
}
|
|
296
298
|
function formatMessage(msg, options = {}) {
|
|
299
|
+
return renderMessage(msg, options, {});
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Creates a message formatter using a snapshot of the supplied theme.
|
|
303
|
+
* @param theme Semantic leaf formatters and annotation styles.
|
|
304
|
+
* @returns A reusable message formatter.
|
|
305
|
+
* @throws {TypeError} If initialWidth is not a finite integer.
|
|
306
|
+
* @throws {RangeError} If initialWidth is negative or a color is invalid.
|
|
307
|
+
* @since 1.3.0
|
|
308
|
+
*/
|
|
309
|
+
function createMessageFormatter(theme) {
|
|
310
|
+
const snapshot = { ...theme };
|
|
311
|
+
const formatter = (msg, options = {}) => renderMessage(msg, options, snapshot);
|
|
312
|
+
require_message_registry.messageRenderers.set(formatter, (msg, options, ambient) => renderMessage(msg, options, snapshot, ambient));
|
|
313
|
+
return formatter;
|
|
314
|
+
}
|
|
315
|
+
function renderMessage(msg, options, theme, ambient) {
|
|
316
|
+
const initialWidth = options.initialWidth ?? 0;
|
|
317
|
+
if (!Number.isFinite(initialWidth) || !Number.isInteger(initialWidth)) throw new TypeError("Initial width must be a finite integer.");
|
|
318
|
+
if (initialWidth < 0) throw new RangeError("Initial width must be nonnegative.");
|
|
297
319
|
const colorConfig = options.colors ?? false;
|
|
298
320
|
const useColors = typeof colorConfig === "boolean" ? colorConfig : true;
|
|
299
321
|
const resetSuffix = typeof colorConfig === "object" ? colorConfig.resetSuffix ?? "" : "";
|
|
300
322
|
const useQuotes = options.quotes ?? true;
|
|
301
|
-
const resetSequence = `\x1b[0m${resetSuffix}`;
|
|
302
323
|
function* stream() {
|
|
303
324
|
const wordPattern = /\s*\S+\s*/g;
|
|
304
325
|
let prevWasLineBreak = false;
|
|
@@ -314,7 +335,8 @@ function formatMessage(msg, options = {}) {
|
|
|
314
335
|
const breakText = isAfterLineBreak && paragraphIndex === 1 ? "\n" : "\n\n";
|
|
315
336
|
yield {
|
|
316
337
|
text: breakText,
|
|
317
|
-
width: -1
|
|
338
|
+
width: -1,
|
|
339
|
+
scopes: []
|
|
318
340
|
};
|
|
319
341
|
}
|
|
320
342
|
const paragraph = paragraphs[paragraphIndex].replace(/\n/g, " ");
|
|
@@ -324,7 +346,8 @@ function formatMessage(msg, options = {}) {
|
|
|
324
346
|
if (match == null) break;
|
|
325
347
|
yield {
|
|
326
348
|
text: match[0],
|
|
327
|
-
width: require_displaywidth.getDisplayWidth(match[0])
|
|
349
|
+
width: require_displaywidth.getDisplayWidth(match[0]),
|
|
350
|
+
scopes: []
|
|
328
351
|
};
|
|
329
352
|
}
|
|
330
353
|
}
|
|
@@ -332,7 +355,8 @@ function formatMessage(msg, options = {}) {
|
|
|
332
355
|
const normalizedText = rawText.replace(/\n/g, " ");
|
|
333
356
|
if (normalizedText.trim() === "" && normalizedText.length > 0) yield {
|
|
334
357
|
text: " ",
|
|
335
|
-
width: 1
|
|
358
|
+
width: 1,
|
|
359
|
+
scopes: []
|
|
336
360
|
};
|
|
337
361
|
else {
|
|
338
362
|
wordPattern.lastIndex = 0;
|
|
@@ -341,110 +365,50 @@ function formatMessage(msg, options = {}) {
|
|
|
341
365
|
if (match == null) break;
|
|
342
366
|
yield {
|
|
343
367
|
text: match[0],
|
|
344
|
-
width: require_displaywidth.getDisplayWidth(match[0])
|
|
368
|
+
width: require_displaywidth.getDisplayWidth(match[0]),
|
|
369
|
+
scopes: []
|
|
345
370
|
};
|
|
346
371
|
}
|
|
347
372
|
}
|
|
348
373
|
}
|
|
349
|
-
} else if (term.type === "optionName") {
|
|
350
|
-
const name = useQuotes ? `\`${term.optionName}\`` : term.optionName;
|
|
351
|
-
yield {
|
|
352
|
-
text: useColors ? `\x1b[3m${name}${resetSequence}` : name,
|
|
353
|
-
width: require_displaywidth.getDisplayWidth(name)
|
|
354
|
-
};
|
|
355
|
-
} else if (term.type === "optionNames") {
|
|
356
|
-
const names = term.optionNames.map((name) => useQuotes ? `\`${name}\`` : name);
|
|
357
|
-
let i = 0;
|
|
358
|
-
for (const name of names) {
|
|
359
|
-
if (i > 0) yield {
|
|
360
|
-
text: "/",
|
|
361
|
-
width: 1
|
|
362
|
-
};
|
|
363
|
-
yield {
|
|
364
|
-
text: useColors ? `\x1b[3m${name}${resetSequence}` : name,
|
|
365
|
-
width: require_displaywidth.getDisplayWidth(name)
|
|
366
|
-
};
|
|
367
|
-
i++;
|
|
368
|
-
}
|
|
369
|
-
} else if (term.type === "metavar") {
|
|
370
|
-
const metavar$1 = useQuotes ? `\`${term.metavar}\`` : term.metavar;
|
|
371
|
-
yield {
|
|
372
|
-
text: useColors ? `\x1b[1m${metavar$1}${resetSequence}` : metavar$1,
|
|
373
|
-
width: require_displaywidth.getDisplayWidth(metavar$1)
|
|
374
|
-
};
|
|
375
|
-
} else if (term.type === "value") {
|
|
376
|
-
const value$1 = useQuotes ? `${JSON.stringify(term.value)}` : term.value;
|
|
377
|
-
yield {
|
|
378
|
-
text: useColors ? `\x1b[32m${value$1}${resetSequence}` : value$1,
|
|
379
|
-
width: require_displaywidth.getDisplayWidth(value$1)
|
|
380
|
-
};
|
|
381
|
-
} else if (term.type === "values") for (let i = 0; i < term.values.length; i++) {
|
|
382
|
-
if (i > 0) yield {
|
|
383
|
-
text: " ",
|
|
384
|
-
width: 1
|
|
385
|
-
};
|
|
386
|
-
const value$1 = useQuotes ? JSON.stringify(term.values[i]) : term.values[i];
|
|
387
|
-
yield {
|
|
388
|
-
text: useColors ? `${i === 0 ? "\x1B[32m" : ""}${value$1}${i + 1 === term.values.length ? resetSequence : ""}` : value$1,
|
|
389
|
-
width: require_displaywidth.getDisplayWidth(value$1)
|
|
390
|
-
};
|
|
391
|
-
}
|
|
392
|
-
else if (term.type === "envVar") {
|
|
393
|
-
const envVar$1 = useQuotes ? `\`${term.envVar}\`` : term.envVar;
|
|
394
|
-
yield {
|
|
395
|
-
text: useColors ? `\x1b[1;4m${envVar$1}${resetSequence}` : envVar$1,
|
|
396
|
-
width: require_displaywidth.getDisplayWidth(envVar$1)
|
|
397
|
-
};
|
|
398
|
-
} else if (term.type === "commandLine") {
|
|
399
|
-
const cmd = useQuotes ? `\`${term.commandLine}\`` : term.commandLine;
|
|
400
|
-
yield {
|
|
401
|
-
text: useColors ? `\x1b[36m${cmd}${resetSequence}` : cmd,
|
|
402
|
-
width: require_displaywidth.getDisplayWidth(cmd)
|
|
403
|
-
};
|
|
404
374
|
} else if (term.type === "lineBreak") {
|
|
405
375
|
yield {
|
|
406
376
|
text: "\n",
|
|
407
|
-
width: -1
|
|
377
|
+
width: -1,
|
|
378
|
+
scopes: []
|
|
408
379
|
};
|
|
409
380
|
prevWasLineBreak = true;
|
|
410
|
-
} else
|
|
411
|
-
const urlString = term.url.href;
|
|
412
|
-
const displayText = useQuotes ? `<${urlString}>` : urlString;
|
|
413
|
-
if (useColors) {
|
|
414
|
-
const hyperlink = `\x1b]8;;${urlString}\x1b\\${displayText}\x1b]8;;\x1b\\${resetSuffix}`;
|
|
415
|
-
yield {
|
|
416
|
-
text: hyperlink,
|
|
417
|
-
width: require_displaywidth.getDisplayWidth(displayText)
|
|
418
|
-
};
|
|
419
|
-
} else yield {
|
|
420
|
-
text: displayText,
|
|
421
|
-
width: require_displaywidth.getDisplayWidth(displayText)
|
|
422
|
-
};
|
|
423
|
-
} else throw new TypeError(`Invalid MessageTerm type: ${term["type"]}.`);
|
|
381
|
+
} else yield* require_terminal_internal.fragmentTokens(require_terminal_internal.formatTerminalTerm(term, theme, useQuotes));
|
|
424
382
|
}
|
|
425
383
|
}
|
|
426
|
-
|
|
427
|
-
let totalWidth =
|
|
428
|
-
for (const
|
|
429
|
-
if (width === -1) {
|
|
430
|
-
|
|
384
|
+
const tokens = [];
|
|
385
|
+
let totalWidth = initialWidth;
|
|
386
|
+
for (const token of stream()) {
|
|
387
|
+
if (token.width === -1) {
|
|
388
|
+
tokens.push(token);
|
|
431
389
|
totalWidth = 0;
|
|
432
390
|
continue;
|
|
433
391
|
}
|
|
434
|
-
if (options.maxWidth != null && totalWidth > 0 && totalWidth + width > options.maxWidth) {
|
|
435
|
-
|
|
392
|
+
if (options.maxWidth != null && totalWidth > 0 && totalWidth + token.width > options.maxWidth) {
|
|
393
|
+
tokens.push({
|
|
394
|
+
text: "\n",
|
|
395
|
+
width: -1,
|
|
396
|
+
scopes: []
|
|
397
|
+
});
|
|
436
398
|
totalWidth = 0;
|
|
437
399
|
}
|
|
438
|
-
|
|
439
|
-
totalWidth += width;
|
|
400
|
+
tokens.push(token);
|
|
401
|
+
totalWidth += token.width;
|
|
440
402
|
}
|
|
441
|
-
return
|
|
403
|
+
return require_terminal_internal.serializeTokens(tokens, useColors, ambient == null ? resetSuffix : "", ambient);
|
|
442
404
|
}
|
|
405
|
+
require_message_registry.messageRenderers.set(formatMessage, (msg, options, ambient) => renderMessage(msg, options, {}, ambient));
|
|
443
406
|
|
|
444
407
|
//#endregion
|
|
445
408
|
exports.cloneMessage = cloneMessage;
|
|
446
409
|
exports.cloneMessageTerm = cloneMessageTerm;
|
|
447
410
|
exports.commandLine = commandLine;
|
|
411
|
+
exports.createMessageFormatter = createMessageFormatter;
|
|
448
412
|
exports.envVar = envVar;
|
|
449
413
|
exports.formatMessage = formatMessage;
|
|
450
414
|
exports.lineBreak = lineBreak;
|
package/dist/message.d.cts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { NonEmptyString } from "./nonempty.cjs";
|
|
2
|
+
import { TerminalTheme } from "./terminal.cjs";
|
|
2
3
|
|
|
3
4
|
//#region src/message.d.ts
|
|
4
5
|
|
|
@@ -376,6 +377,11 @@ declare function valueSet(values: readonly string[], fallbackOrOptions: string |
|
|
|
376
377
|
* Options for the {@link formatMessage} function.
|
|
377
378
|
*/
|
|
378
379
|
interface MessageFormatOptions {
|
|
380
|
+
/**
|
|
381
|
+
* Columns already occupied on the first line.
|
|
382
|
+
* @since 1.3.0
|
|
383
|
+
*/
|
|
384
|
+
readonly initialWidth?: number;
|
|
379
385
|
/**
|
|
380
386
|
* Whether to use colors in the formatted message. If `true`,
|
|
381
387
|
* the formatted message will include ANSI escape codes for colors.
|
|
@@ -417,7 +423,31 @@ interface MessageFormatOptions {
|
|
|
417
423
|
* {@link MessageTerm} objects.
|
|
418
424
|
* @param options Optional formatting options to customize the output.
|
|
419
425
|
* @returns A formatted string representation of the message.
|
|
426
|
+
* @throws {TypeError} If initialWidth is not a finite integer.
|
|
427
|
+
* @throws {RangeError} If initialWidth is negative.
|
|
420
428
|
*/
|
|
421
429
|
declare function formatMessage(msg: Message, options?: MessageFormatOptions): string;
|
|
430
|
+
/**
|
|
431
|
+
* Options passed to an injected message formatter.
|
|
432
|
+
* @since 1.3.0
|
|
433
|
+
*/
|
|
434
|
+
interface MessageFormatterOptions extends Omit<MessageFormatOptions, "colors"> {
|
|
435
|
+
/** Whether to emit terminal colors and hyperlinks. */
|
|
436
|
+
readonly colors?: boolean;
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* Formats a structured message for terminal output.
|
|
440
|
+
* @since 1.3.0
|
|
441
|
+
*/
|
|
442
|
+
type MessageFormatter = (message: Message, options?: MessageFormatterOptions) => string;
|
|
443
|
+
/**
|
|
444
|
+
* Creates a message formatter using a snapshot of the supplied theme.
|
|
445
|
+
* @param theme Semantic leaf formatters and annotation styles.
|
|
446
|
+
* @returns A reusable message formatter.
|
|
447
|
+
* @throws {TypeError} If initialWidth is not a finite integer.
|
|
448
|
+
* @throws {RangeError} If initialWidth is negative or a color is invalid.
|
|
449
|
+
* @since 1.3.0
|
|
450
|
+
*/
|
|
451
|
+
declare function createMessageFormatter(theme: TerminalTheme): MessageFormatter;
|
|
422
452
|
//#endregion
|
|
423
|
-
export { Message, MessageFormatOptions, MessageTerm, ValueSetOptions, cloneMessage, cloneMessageTerm, commandLine, envVar, formatMessage, lineBreak, link, message, metavar, optionName, optionNames, text, url, value, valueSet, values };
|
|
453
|
+
export { Message, MessageFormatOptions, MessageFormatter, MessageFormatterOptions, MessageTerm, ValueSetOptions, cloneMessage, cloneMessageTerm, commandLine, createMessageFormatter, envVar, formatMessage, lineBreak, link, message, metavar, optionName, optionNames, text, url, value, valueSet, values };
|
package/dist/message.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { NonEmptyString } from "./nonempty.js";
|
|
2
|
+
import { TerminalTheme } from "./terminal.js";
|
|
2
3
|
|
|
3
4
|
//#region src/message.d.ts
|
|
4
5
|
|
|
@@ -376,6 +377,11 @@ declare function valueSet(values: readonly string[], fallbackOrOptions: string |
|
|
|
376
377
|
* Options for the {@link formatMessage} function.
|
|
377
378
|
*/
|
|
378
379
|
interface MessageFormatOptions {
|
|
380
|
+
/**
|
|
381
|
+
* Columns already occupied on the first line.
|
|
382
|
+
* @since 1.3.0
|
|
383
|
+
*/
|
|
384
|
+
readonly initialWidth?: number;
|
|
379
385
|
/**
|
|
380
386
|
* Whether to use colors in the formatted message. If `true`,
|
|
381
387
|
* the formatted message will include ANSI escape codes for colors.
|
|
@@ -417,7 +423,31 @@ interface MessageFormatOptions {
|
|
|
417
423
|
* {@link MessageTerm} objects.
|
|
418
424
|
* @param options Optional formatting options to customize the output.
|
|
419
425
|
* @returns A formatted string representation of the message.
|
|
426
|
+
* @throws {TypeError} If initialWidth is not a finite integer.
|
|
427
|
+
* @throws {RangeError} If initialWidth is negative.
|
|
420
428
|
*/
|
|
421
429
|
declare function formatMessage(msg: Message, options?: MessageFormatOptions): string;
|
|
430
|
+
/**
|
|
431
|
+
* Options passed to an injected message formatter.
|
|
432
|
+
* @since 1.3.0
|
|
433
|
+
*/
|
|
434
|
+
interface MessageFormatterOptions extends Omit<MessageFormatOptions, "colors"> {
|
|
435
|
+
/** Whether to emit terminal colors and hyperlinks. */
|
|
436
|
+
readonly colors?: boolean;
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* Formats a structured message for terminal output.
|
|
440
|
+
* @since 1.3.0
|
|
441
|
+
*/
|
|
442
|
+
type MessageFormatter = (message: Message, options?: MessageFormatterOptions) => string;
|
|
443
|
+
/**
|
|
444
|
+
* Creates a message formatter using a snapshot of the supplied theme.
|
|
445
|
+
* @param theme Semantic leaf formatters and annotation styles.
|
|
446
|
+
* @returns A reusable message formatter.
|
|
447
|
+
* @throws {TypeError} If initialWidth is not a finite integer.
|
|
448
|
+
* @throws {RangeError} If initialWidth is negative or a color is invalid.
|
|
449
|
+
* @since 1.3.0
|
|
450
|
+
*/
|
|
451
|
+
declare function createMessageFormatter(theme: TerminalTheme): MessageFormatter;
|
|
422
452
|
//#endregion
|
|
423
|
-
export { Message, MessageFormatOptions, MessageTerm, ValueSetOptions, cloneMessage, cloneMessageTerm, commandLine, envVar, formatMessage, lineBreak, link, message, metavar, optionName, optionNames, text, url, value, valueSet, values };
|
|
453
|
+
export { Message, MessageFormatOptions, MessageFormatter, MessageFormatterOptions, MessageTerm, ValueSetOptions, cloneMessage, cloneMessageTerm, commandLine, createMessageFormatter, envVar, formatMessage, lineBreak, link, message, metavar, optionName, optionNames, text, url, value, valueSet, values };
|