Trim vendored svgo-client payload
Remove unused svgo-client files while keeping bin/svgo-client/svgo.cmd runtime behavior intact. Drop node_modules/.bin wrappers, TypeScript declaration files (*.d.ts), and obsolete svgo-cli.js wrapper script. Co-Authored-By: Abacus.AI CLI <agent@abacus.ai>
This commit is contained in:
-16
@@ -1,16 +0,0 @@
|
||||
#!/bin/sh
|
||||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
||||
|
||||
case `uname` in
|
||||
*CYGWIN*|*MINGW*|*MSYS*)
|
||||
if command -v cygpath > /dev/null 2>&1; then
|
||||
basedir=`cygpath -w "$basedir"`
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -x "$basedir/node" ]; then
|
||||
exec "$basedir/node" "$basedir/../svgo/bin/svgo.js" "$@"
|
||||
else
|
||||
exec node "$basedir/../svgo/bin/svgo.js" "$@"
|
||||
fi
|
||||
-17
@@ -1,17 +0,0 @@
|
||||
@ECHO off
|
||||
GOTO start
|
||||
:find_dp0
|
||||
SET dp0=%~dp0
|
||||
EXIT /b
|
||||
:start
|
||||
SETLOCAL
|
||||
CALL :find_dp0
|
||||
|
||||
IF EXIST "%dp0%\node.exe" (
|
||||
SET "_prog=%dp0%\node.exe"
|
||||
) ELSE (
|
||||
SET "_prog=node"
|
||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
)
|
||||
|
||||
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\svgo\bin\svgo.js" %*
|
||||
-28
@@ -1,28 +0,0 @@
|
||||
#!/usr/bin/env pwsh
|
||||
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
||||
|
||||
$exe=""
|
||||
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
||||
# Fix case when both the Windows and Linux builds of Node
|
||||
# are installed in the same directory
|
||||
$exe=".exe"
|
||||
}
|
||||
$ret=0
|
||||
if (Test-Path "$basedir/node$exe") {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "$basedir/node$exe" "$basedir/../svgo/bin/svgo.js" $args
|
||||
} else {
|
||||
& "$basedir/node$exe" "$basedir/../svgo/bin/svgo.js" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
} else {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "node$exe" "$basedir/../svgo/bin/svgo.js" $args
|
||||
} else {
|
||||
& "node$exe" "$basedir/../svgo/bin/svgo.js" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
}
|
||||
exit $ret
|
||||
-884
@@ -1,884 +0,0 @@
|
||||
// Type definitions for commander
|
||||
// Original definitions by: Alan Agius <https://github.com/alan-agius4>, Marcelo Dezem <https://github.com/mdezem>, vvakame <https://github.com/vvakame>, Jules Randolph <https://github.com/sveinburne>
|
||||
|
||||
// Using method rather than property for method-signature-style, to document method overloads separately. Allow either.
|
||||
/* eslint-disable @typescript-eslint/method-signature-style */
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
|
||||
// This is a trick to encourage editor to suggest the known literals while still
|
||||
// allowing any BaseType value.
|
||||
// References:
|
||||
// - https://github.com/microsoft/TypeScript/issues/29729
|
||||
// - https://github.com/sindresorhus/type-fest/blob/main/source/literal-union.d.ts
|
||||
// - https://github.com/sindresorhus/type-fest/blob/main/source/primitive.d.ts
|
||||
type LiteralUnion<LiteralType, BaseType extends string | number> = LiteralType | (BaseType & Record<never, never>);
|
||||
|
||||
export class CommanderError extends Error {
|
||||
code: string;
|
||||
exitCode: number;
|
||||
message: string;
|
||||
nestedError?: string;
|
||||
|
||||
/**
|
||||
* Constructs the CommanderError class
|
||||
* @param exitCode - suggested exit code which could be used with process.exit
|
||||
* @param code - an id string representing the error
|
||||
* @param message - human-readable description of the error
|
||||
* @constructor
|
||||
*/
|
||||
constructor(exitCode: number, code: string, message: string);
|
||||
}
|
||||
|
||||
export class InvalidArgumentError extends CommanderError {
|
||||
/**
|
||||
* Constructs the InvalidArgumentError class
|
||||
* @param message - explanation of why argument is invalid
|
||||
* @constructor
|
||||
*/
|
||||
constructor(message: string);
|
||||
}
|
||||
export { InvalidArgumentError as InvalidOptionArgumentError }; // deprecated old name
|
||||
|
||||
export interface ErrorOptions { // optional parameter for error()
|
||||
/** an id string representing the error */
|
||||
code?: string;
|
||||
/** suggested exit code which could be used with process.exit */
|
||||
exitCode?: number;
|
||||
}
|
||||
|
||||
export class Argument {
|
||||
description: string;
|
||||
required: boolean;
|
||||
variadic: boolean;
|
||||
defaultValue?: any;
|
||||
defaultValueDescription?: string;
|
||||
argChoices?: string[];
|
||||
|
||||
/**
|
||||
* Initialize a new command argument with the given name and description.
|
||||
* The default is that the argument is required, and you can explicitly
|
||||
* indicate this with <> around the name. Put [] around the name for an optional argument.
|
||||
*/
|
||||
constructor(arg: string, description?: string);
|
||||
|
||||
/**
|
||||
* Return argument name.
|
||||
*/
|
||||
name(): string;
|
||||
|
||||
/**
|
||||
* Set the default value, and optionally supply the description to be displayed in the help.
|
||||
*/
|
||||
default(value: unknown, description?: string): this;
|
||||
|
||||
/**
|
||||
* Set the custom handler for processing CLI command arguments into argument values.
|
||||
*/
|
||||
argParser<T>(fn: (value: string, previous: T) => T): this;
|
||||
|
||||
/**
|
||||
* Only allow argument value to be one of choices.
|
||||
*/
|
||||
choices(values: readonly string[]): this;
|
||||
|
||||
/**
|
||||
* Make argument required.
|
||||
*/
|
||||
argRequired(): this;
|
||||
|
||||
/**
|
||||
* Make argument optional.
|
||||
*/
|
||||
argOptional(): this;
|
||||
}
|
||||
|
||||
export class Option {
|
||||
flags: string;
|
||||
description: string;
|
||||
|
||||
required: boolean; // A value must be supplied when the option is specified.
|
||||
optional: boolean; // A value is optional when the option is specified.
|
||||
variadic: boolean;
|
||||
mandatory: boolean; // The option must have a value after parsing, which usually means it must be specified on command line.
|
||||
short?: string;
|
||||
long?: string;
|
||||
negate: boolean;
|
||||
defaultValue?: any;
|
||||
defaultValueDescription?: string;
|
||||
presetArg?: unknown;
|
||||
envVar?: string;
|
||||
parseArg?: <T>(value: string, previous: T) => T;
|
||||
hidden: boolean;
|
||||
argChoices?: string[];
|
||||
|
||||
constructor(flags: string, description?: string);
|
||||
|
||||
/**
|
||||
* Set the default value, and optionally supply the description to be displayed in the help.
|
||||
*/
|
||||
default(value: unknown, description?: string): this;
|
||||
|
||||
/**
|
||||
* Preset to use when option used without option-argument, especially optional but also boolean and negated.
|
||||
* The custom processing (parseArg) is called.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* new Option('--color').default('GREYSCALE').preset('RGB');
|
||||
* new Option('--donate [amount]').preset('20').argParser(parseFloat);
|
||||
* ```
|
||||
*/
|
||||
preset(arg: unknown): this;
|
||||
|
||||
/**
|
||||
* Add option name(s) that conflict with this option.
|
||||
* An error will be displayed if conflicting options are found during parsing.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* new Option('--rgb').conflicts('cmyk');
|
||||
* new Option('--js').conflicts(['ts', 'jsx']);
|
||||
* ```
|
||||
*/
|
||||
conflicts(names: string | string[]): this;
|
||||
|
||||
/**
|
||||
* Specify implied option values for when this option is set and the implied options are not.
|
||||
*
|
||||
* The custom processing (parseArg) is not called on the implied values.
|
||||
*
|
||||
* @example
|
||||
* program
|
||||
* .addOption(new Option('--log', 'write logging information to file'))
|
||||
* .addOption(new Option('--trace', 'log extra details').implies({ log: 'trace.txt' }));
|
||||
*/
|
||||
implies(optionValues: OptionValues): this;
|
||||
|
||||
/**
|
||||
* Set environment variable to check for option value.
|
||||
*
|
||||
* An environment variables is only used if when processed the current option value is
|
||||
* undefined, or the source of the current value is 'default' or 'config' or 'env'.
|
||||
*/
|
||||
env(name: string): this;
|
||||
|
||||
/**
|
||||
* Calculate the full description, including defaultValue etc.
|
||||
*/
|
||||
fullDescription(): string;
|
||||
|
||||
/**
|
||||
* Set the custom handler for processing CLI option arguments into option values.
|
||||
*/
|
||||
argParser<T>(fn: (value: string, previous: T) => T): this;
|
||||
|
||||
/**
|
||||
* Whether the option is mandatory and must have a value after parsing.
|
||||
*/
|
||||
makeOptionMandatory(mandatory?: boolean): this;
|
||||
|
||||
/**
|
||||
* Hide option in help.
|
||||
*/
|
||||
hideHelp(hide?: boolean): this;
|
||||
|
||||
/**
|
||||
* Only allow option value to be one of choices.
|
||||
*/
|
||||
choices(values: readonly string[]): this;
|
||||
|
||||
/**
|
||||
* Return option name.
|
||||
*/
|
||||
name(): string;
|
||||
|
||||
/**
|
||||
* Return option name, in a camelcase format that can be used
|
||||
* as a object attribute key.
|
||||
*/
|
||||
attributeName(): string;
|
||||
|
||||
/**
|
||||
* Return whether a boolean option.
|
||||
*
|
||||
* Options are one of boolean, negated, required argument, or optional argument.
|
||||
*/
|
||||
isBoolean(): boolean;
|
||||
}
|
||||
|
||||
export class Help {
|
||||
/** output helpWidth, long lines are wrapped to fit */
|
||||
helpWidth?: number;
|
||||
sortSubcommands: boolean;
|
||||
sortOptions: boolean;
|
||||
showGlobalOptions: boolean;
|
||||
|
||||
constructor();
|
||||
|
||||
/** Get the command term to show in the list of subcommands. */
|
||||
subcommandTerm(cmd: Command): string;
|
||||
/** Get the command summary to show in the list of subcommands. */
|
||||
subcommandDescription(cmd: Command): string;
|
||||
/** Get the option term to show in the list of options. */
|
||||
optionTerm(option: Option): string;
|
||||
/** Get the option description to show in the list of options. */
|
||||
optionDescription(option: Option): string;
|
||||
/** Get the argument term to show in the list of arguments. */
|
||||
argumentTerm(argument: Argument): string;
|
||||
/** Get the argument description to show in the list of arguments. */
|
||||
argumentDescription(argument: Argument): string;
|
||||
|
||||
/** Get the command usage to be displayed at the top of the built-in help. */
|
||||
commandUsage(cmd: Command): string;
|
||||
/** Get the description for the command. */
|
||||
commandDescription(cmd: Command): string;
|
||||
|
||||
/** Get an array of the visible subcommands. Includes a placeholder for the implicit help command, if there is one. */
|
||||
visibleCommands(cmd: Command): Command[];
|
||||
/** Get an array of the visible options. Includes a placeholder for the implicit help option, if there is one. */
|
||||
visibleOptions(cmd: Command): Option[];
|
||||
/** Get an array of the visible global options. (Not including help.) */
|
||||
visibleGlobalOptions(cmd: Command): Option[];
|
||||
/** Get an array of the arguments which have descriptions. */
|
||||
visibleArguments(cmd: Command): Argument[];
|
||||
|
||||
/** Get the longest command term length. */
|
||||
longestSubcommandTermLength(cmd: Command, helper: Help): number;
|
||||
/** Get the longest option term length. */
|
||||
longestOptionTermLength(cmd: Command, helper: Help): number;
|
||||
/** Get the longest global option term length. */
|
||||
longestGlobalOptionTermLength(cmd: Command, helper: Help): number;
|
||||
/** Get the longest argument term length. */
|
||||
longestArgumentTermLength(cmd: Command, helper: Help): number;
|
||||
/** Calculate the pad width from the maximum term length. */
|
||||
padWidth(cmd: Command, helper: Help): number;
|
||||
|
||||
/**
|
||||
* Wrap the given string to width characters per line, with lines after the first indented.
|
||||
* Do not wrap if insufficient room for wrapping (minColumnWidth), or string is manually formatted.
|
||||
*/
|
||||
wrap(str: string, width: number, indent: number, minColumnWidth?: number): string;
|
||||
|
||||
/** Generate the built-in help text. */
|
||||
formatHelp(cmd: Command, helper: Help): string;
|
||||
}
|
||||
export type HelpConfiguration = Partial<Help>;
|
||||
|
||||
export interface ParseOptions {
|
||||
from: 'node' | 'electron' | 'user';
|
||||
}
|
||||
export interface HelpContext { // optional parameter for .help() and .outputHelp()
|
||||
error: boolean;
|
||||
}
|
||||
export interface AddHelpTextContext { // passed to text function used with .addHelpText()
|
||||
error: boolean;
|
||||
command: Command;
|
||||
}
|
||||
export interface OutputConfiguration {
|
||||
writeOut?(str: string): void;
|
||||
writeErr?(str: string): void;
|
||||
getOutHelpWidth?(): number;
|
||||
getErrHelpWidth?(): number;
|
||||
outputError?(str: string, write: (str: string) => void): void;
|
||||
|
||||
}
|
||||
|
||||
export type AddHelpTextPosition = 'beforeAll' | 'before' | 'after' | 'afterAll';
|
||||
export type HookEvent = 'preSubcommand' | 'preAction' | 'postAction';
|
||||
// The source is a string so author can define their own too.
|
||||
export type OptionValueSource = LiteralUnion<'default' | 'config' | 'env' | 'cli' | 'implied', string> | undefined;
|
||||
|
||||
export type OptionValues = Record<string, any>;
|
||||
|
||||
export class Command {
|
||||
args: string[];
|
||||
processedArgs: any[];
|
||||
readonly commands: readonly Command[];
|
||||
readonly options: readonly Option[];
|
||||
readonly registeredArguments: readonly Argument[];
|
||||
parent: Command | null;
|
||||
|
||||
constructor(name?: string);
|
||||
|
||||
/**
|
||||
* Set the program version to `str`.
|
||||
*
|
||||
* This method auto-registers the "-V, --version" flag
|
||||
* which will print the version number when passed.
|
||||
*
|
||||
* You can optionally supply the flags and description to override the defaults.
|
||||
*/
|
||||
version(str: string, flags?: string, description?: string): this;
|
||||
/**
|
||||
* Get the program version.
|
||||
*/
|
||||
version(): string | undefined;
|
||||
|
||||
/**
|
||||
* Define a command, implemented using an action handler.
|
||||
*
|
||||
* @remarks
|
||||
* The command description is supplied using `.description`, not as a parameter to `.command`.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* program
|
||||
* .command('clone <source> [destination]')
|
||||
* .description('clone a repository into a newly created directory')
|
||||
* .action((source, destination) => {
|
||||
* console.log('clone command called');
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* @param nameAndArgs - command name and arguments, args are `<required>` or `[optional]` and last may also be `variadic...`
|
||||
* @param opts - configuration options
|
||||
* @returns new command
|
||||
*/
|
||||
command(nameAndArgs: string, opts?: CommandOptions): ReturnType<this['createCommand']>;
|
||||
/**
|
||||
* Define a command, implemented in a separate executable file.
|
||||
*
|
||||
* @remarks
|
||||
* The command description is supplied as the second parameter to `.command`.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* program
|
||||
* .command('start <service>', 'start named service')
|
||||
* .command('stop [service]', 'stop named service, or all if no name supplied');
|
||||
* ```
|
||||
*
|
||||
* @param nameAndArgs - command name and arguments, args are `<required>` or `[optional]` and last may also be `variadic...`
|
||||
* @param description - description of executable command
|
||||
* @param opts - configuration options
|
||||
* @returns `this` command for chaining
|
||||
*/
|
||||
command(nameAndArgs: string, description: string, opts?: ExecutableCommandOptions): this;
|
||||
|
||||
/**
|
||||
* Factory routine to create a new unattached command.
|
||||
*
|
||||
* See .command() for creating an attached subcommand, which uses this routine to
|
||||
* create the command. You can override createCommand to customise subcommands.
|
||||
*/
|
||||
createCommand(name?: string): Command;
|
||||
|
||||
/**
|
||||
* Add a prepared subcommand.
|
||||
*
|
||||
* See .command() for creating an attached subcommand which inherits settings from its parent.
|
||||
*
|
||||
* @returns `this` command for chaining
|
||||
*/
|
||||
addCommand(cmd: Command, opts?: CommandOptions): this;
|
||||
|
||||
/**
|
||||
* Factory routine to create a new unattached argument.
|
||||
*
|
||||
* See .argument() for creating an attached argument, which uses this routine to
|
||||
* create the argument. You can override createArgument to return a custom argument.
|
||||
*/
|
||||
createArgument(name: string, description?: string): Argument;
|
||||
|
||||
/**
|
||||
* Define argument syntax for command.
|
||||
*
|
||||
* The default is that the argument is required, and you can explicitly
|
||||
* indicate this with <> around the name. Put [] around the name for an optional argument.
|
||||
*
|
||||
* @example
|
||||
* ```
|
||||
* program.argument('<input-file>');
|
||||
* program.argument('[output-file]');
|
||||
* ```
|
||||
*
|
||||
* @returns `this` command for chaining
|
||||
*/
|
||||
argument<T>(flags: string, description: string, fn: (value: string, previous: T) => T, defaultValue?: T): this;
|
||||
argument(name: string, description?: string, defaultValue?: unknown): this;
|
||||
|
||||
/**
|
||||
* Define argument syntax for command, adding a prepared argument.
|
||||
*
|
||||
* @returns `this` command for chaining
|
||||
*/
|
||||
addArgument(arg: Argument): this;
|
||||
|
||||
/**
|
||||
* Define argument syntax for command, adding multiple at once (without descriptions).
|
||||
*
|
||||
* See also .argument().
|
||||
*
|
||||
* @example
|
||||
* ```
|
||||
* program.arguments('<cmd> [env]');
|
||||
* ```
|
||||
*
|
||||
* @returns `this` command for chaining
|
||||
*/
|
||||
arguments(names: string): this;
|
||||
|
||||
/**
|
||||
* Override default decision whether to add implicit help command.
|
||||
*
|
||||
* @example
|
||||
* ```
|
||||
* addHelpCommand() // force on
|
||||
* addHelpCommand(false); // force off
|
||||
* addHelpCommand('help [cmd]', 'display help for [cmd]'); // force on with custom details
|
||||
* ```
|
||||
*
|
||||
* @returns `this` command for chaining
|
||||
*/
|
||||
addHelpCommand(enableOrNameAndArgs?: string | boolean, description?: string): this;
|
||||
|
||||
/**
|
||||
* Add hook for life cycle event.
|
||||
*/
|
||||
hook(event: HookEvent, listener: (thisCommand: Command, actionCommand: Command) => void | Promise<void>): this;
|
||||
|
||||
/**
|
||||
* Register callback to use as replacement for calling process.exit.
|
||||
*/
|
||||
exitOverride(callback?: (err: CommanderError) => never | void): this;
|
||||
|
||||
/**
|
||||
* Display error message and exit (or call exitOverride).
|
||||
*/
|
||||
error(message: string, errorOptions?: ErrorOptions): never;
|
||||
|
||||
/**
|
||||
* You can customise the help with a subclass of Help by overriding createHelp,
|
||||
* or by overriding Help properties using configureHelp().
|
||||
*/
|
||||
createHelp(): Help;
|
||||
|
||||
/**
|
||||
* You can customise the help by overriding Help properties using configureHelp(),
|
||||
* or with a subclass of Help by overriding createHelp().
|
||||
*/
|
||||
configureHelp(configuration: HelpConfiguration): this;
|
||||
/** Get configuration */
|
||||
configureHelp(): HelpConfiguration;
|
||||
|
||||
/**
|
||||
* The default output goes to stdout and stderr. You can customise this for special
|
||||
* applications. You can also customise the display of errors by overriding outputError.
|
||||
*
|
||||
* The configuration properties are all functions:
|
||||
* ```
|
||||
* // functions to change where being written, stdout and stderr
|
||||
* writeOut(str)
|
||||
* writeErr(str)
|
||||
* // matching functions to specify width for wrapping help
|
||||
* getOutHelpWidth()
|
||||
* getErrHelpWidth()
|
||||
* // functions based on what is being written out
|
||||
* outputError(str, write) // used for displaying errors, and not used for displaying help
|
||||
* ```
|
||||
*/
|
||||
configureOutput(configuration: OutputConfiguration): this;
|
||||
/** Get configuration */
|
||||
configureOutput(): OutputConfiguration;
|
||||
|
||||
/**
|
||||
* Copy settings that are useful to have in common across root command and subcommands.
|
||||
*
|
||||
* (Used internally when adding a command using `.command()` so subcommands inherit parent settings.)
|
||||
*/
|
||||
copyInheritedSettings(sourceCommand: Command): this;
|
||||
|
||||
/**
|
||||
* Display the help or a custom message after an error occurs.
|
||||
*/
|
||||
showHelpAfterError(displayHelp?: boolean | string): this;
|
||||
|
||||
/**
|
||||
* Display suggestion of similar commands for unknown commands, or options for unknown options.
|
||||
*/
|
||||
showSuggestionAfterError(displaySuggestion?: boolean): this;
|
||||
|
||||
/**
|
||||
* Register callback `fn` for the command.
|
||||
*
|
||||
* @example
|
||||
* ```
|
||||
* program
|
||||
* .command('serve')
|
||||
* .description('start service')
|
||||
* .action(function() {
|
||||
* // do work here
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* @returns `this` command for chaining
|
||||
*/
|
||||
action(fn: (...args: any[]) => void | Promise<void>): this;
|
||||
|
||||
/**
|
||||
* Define option with `flags`, `description`, and optional argument parsing function or `defaultValue` or both.
|
||||
*
|
||||
* The `flags` string contains the short and/or long flags, separated by comma, a pipe or space. A required
|
||||
* option-argument is indicated by `<>` and an optional option-argument by `[]`.
|
||||
*
|
||||
* See the README for more details, and see also addOption() and requiredOption().
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```js
|
||||
* program
|
||||
* .option('-p, --pepper', 'add pepper')
|
||||
* .option('-p, --pizza-type <TYPE>', 'type of pizza') // required option-argument
|
||||
* .option('-c, --cheese [CHEESE]', 'add extra cheese', 'mozzarella') // optional option-argument with default
|
||||
* .option('-t, --tip <VALUE>', 'add tip to purchase cost', parseFloat) // custom parse function
|
||||
* ```
|
||||
*
|
||||
* @returns `this` command for chaining
|
||||
*/
|
||||
option(flags: string, description?: string, defaultValue?: string | boolean | string[]): this;
|
||||
option<T>(flags: string, description: string, parseArg: (value: string, previous: T) => T, defaultValue?: T): this;
|
||||
/** @deprecated since v7, instead use choices or a custom function */
|
||||
option(flags: string, description: string, regexp: RegExp, defaultValue?: string | boolean | string[]): this;
|
||||
|
||||
/**
|
||||
* Define a required option, which must have a value after parsing. This usually means
|
||||
* the option must be specified on the command line. (Otherwise the same as .option().)
|
||||
*
|
||||
* The `flags` string contains the short and/or long flags, separated by comma, a pipe or space.
|
||||
*/
|
||||
requiredOption(flags: string, description?: string, defaultValue?: string | boolean | string[]): this;
|
||||
requiredOption<T>(flags: string, description: string, parseArg: (value: string, previous: T) => T, defaultValue?: T): this;
|
||||
/** @deprecated since v7, instead use choices or a custom function */
|
||||
requiredOption(flags: string, description: string, regexp: RegExp, defaultValue?: string | boolean | string[]): this;
|
||||
|
||||
/**
|
||||
* Factory routine to create a new unattached option.
|
||||
*
|
||||
* See .option() for creating an attached option, which uses this routine to
|
||||
* create the option. You can override createOption to return a custom option.
|
||||
*/
|
||||
|
||||
createOption(flags: string, description?: string): Option;
|
||||
|
||||
/**
|
||||
* Add a prepared Option.
|
||||
*
|
||||
* See .option() and .requiredOption() for creating and attaching an option in a single call.
|
||||
*/
|
||||
addOption(option: Option): this;
|
||||
|
||||
/**
|
||||
* Whether to store option values as properties on command object,
|
||||
* or store separately (specify false). In both cases the option values can be accessed using .opts().
|
||||
*
|
||||
* @returns `this` command for chaining
|
||||
*/
|
||||
storeOptionsAsProperties<T extends OptionValues>(): this & T;
|
||||
storeOptionsAsProperties<T extends OptionValues>(storeAsProperties: true): this & T;
|
||||
storeOptionsAsProperties(storeAsProperties?: boolean): this;
|
||||
|
||||
/**
|
||||
* Retrieve option value.
|
||||
*/
|
||||
getOptionValue(key: string): any;
|
||||
|
||||
/**
|
||||
* Store option value.
|
||||
*/
|
||||
setOptionValue(key: string, value: unknown): this;
|
||||
|
||||
/**
|
||||
* Store option value and where the value came from.
|
||||
*/
|
||||
setOptionValueWithSource(key: string, value: unknown, source: OptionValueSource): this;
|
||||
|
||||
/**
|
||||
* Get source of option value.
|
||||
*/
|
||||
getOptionValueSource(key: string): OptionValueSource | undefined;
|
||||
|
||||
/**
|
||||
* Get source of option value. See also .optsWithGlobals().
|
||||
*/
|
||||
getOptionValueSourceWithGlobals(key: string): OptionValueSource | undefined;
|
||||
|
||||
/**
|
||||
* Alter parsing of short flags with optional values.
|
||||
*
|
||||
* @example
|
||||
* ```
|
||||
* // for `.option('-f,--flag [value]'):
|
||||
* .combineFlagAndOptionalValue(true) // `-f80` is treated like `--flag=80`, this is the default behaviour
|
||||
* .combineFlagAndOptionalValue(false) // `-fb` is treated like `-f -b`
|
||||
* ```
|
||||
*
|
||||
* @returns `this` command for chaining
|
||||
*/
|
||||
combineFlagAndOptionalValue(combine?: boolean): this;
|
||||
|
||||
/**
|
||||
* Allow unknown options on the command line.
|
||||
*
|
||||
* @returns `this` command for chaining
|
||||
*/
|
||||
allowUnknownOption(allowUnknown?: boolean): this;
|
||||
|
||||
/**
|
||||
* Allow excess command-arguments on the command line. Pass false to make excess arguments an error.
|
||||
*
|
||||
* @returns `this` command for chaining
|
||||
*/
|
||||
allowExcessArguments(allowExcess?: boolean): this;
|
||||
|
||||
/**
|
||||
* Enable positional options. Positional means global options are specified before subcommands which lets
|
||||
* subcommands reuse the same option names, and also enables subcommands to turn on passThroughOptions.
|
||||
*
|
||||
* The default behaviour is non-positional and global options may appear anywhere on the command line.
|
||||
*
|
||||
* @returns `this` command for chaining
|
||||
*/
|
||||
enablePositionalOptions(positional?: boolean): this;
|
||||
|
||||
/**
|
||||
* Pass through options that come after command-arguments rather than treat them as command-options,
|
||||
* so actual command-options come before command-arguments. Turning this on for a subcommand requires
|
||||
* positional options to have been enabled on the program (parent commands).
|
||||
*
|
||||
* The default behaviour is non-positional and options may appear before or after command-arguments.
|
||||
*
|
||||
* @returns `this` command for chaining
|
||||
*/
|
||||
passThroughOptions(passThrough?: boolean): this;
|
||||
|
||||
/**
|
||||
* Parse `argv`, setting options and invoking commands when defined.
|
||||
*
|
||||
* The default expectation is that the arguments are from node and have the application as argv[0]
|
||||
* and the script being run in argv[1], with user parameters after that.
|
||||
*
|
||||
* @example
|
||||
* ```
|
||||
* program.parse(process.argv);
|
||||
* program.parse(); // implicitly use process.argv and auto-detect node vs electron conventions
|
||||
* program.parse(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0]
|
||||
* ```
|
||||
*
|
||||
* @returns `this` command for chaining
|
||||
*/
|
||||
parse(argv?: readonly string[], options?: ParseOptions): this;
|
||||
|
||||
/**
|
||||
* Parse `argv`, setting options and invoking commands when defined.
|
||||
*
|
||||
* Use parseAsync instead of parse if any of your action handlers are async. Returns a Promise.
|
||||
*
|
||||
* The default expectation is that the arguments are from node and have the application as argv[0]
|
||||
* and the script being run in argv[1], with user parameters after that.
|
||||
*
|
||||
* @example
|
||||
* ```
|
||||
* program.parseAsync(process.argv);
|
||||
* program.parseAsync(); // implicitly use process.argv and auto-detect node vs electron conventions
|
||||
* program.parseAsync(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0]
|
||||
* ```
|
||||
*
|
||||
* @returns Promise
|
||||
*/
|
||||
parseAsync(argv?: readonly string[], options?: ParseOptions): Promise<this>;
|
||||
|
||||
/**
|
||||
* Parse options from `argv` removing known options,
|
||||
* and return argv split into operands and unknown arguments.
|
||||
*
|
||||
* argv => operands, unknown
|
||||
* --known kkk op => [op], []
|
||||
* op --known kkk => [op], []
|
||||
* sub --unknown uuu op => [sub], [--unknown uuu op]
|
||||
* sub -- --unknown uuu op => [sub --unknown uuu op], []
|
||||
*/
|
||||
parseOptions(argv: string[]): ParseOptionsResult;
|
||||
|
||||
/**
|
||||
* Return an object containing local option values as key-value pairs
|
||||
*/
|
||||
opts<T extends OptionValues>(): T;
|
||||
|
||||
/**
|
||||
* Return an object containing merged local and global option values as key-value pairs.
|
||||
*/
|
||||
optsWithGlobals<T extends OptionValues>(): T;
|
||||
|
||||
/**
|
||||
* Set the description.
|
||||
*
|
||||
* @returns `this` command for chaining
|
||||
*/
|
||||
|
||||
description(str: string): this;
|
||||
/** @deprecated since v8, instead use .argument to add command argument with description */
|
||||
description(str: string, argsDescription: Record<string, string>): this;
|
||||
/**
|
||||
* Get the description.
|
||||
*/
|
||||
description(): string;
|
||||
|
||||
/**
|
||||
* Set the summary. Used when listed as subcommand of parent.
|
||||
*
|
||||
* @returns `this` command for chaining
|
||||
*/
|
||||
|
||||
summary(str: string): this;
|
||||
/**
|
||||
* Get the summary.
|
||||
*/
|
||||
summary(): string;
|
||||
|
||||
/**
|
||||
* Set an alias for the command.
|
||||
*
|
||||
* You may call more than once to add multiple aliases. Only the first alias is shown in the auto-generated help.
|
||||
*
|
||||
* @returns `this` command for chaining
|
||||
*/
|
||||
alias(alias: string): this;
|
||||
/**
|
||||
* Get alias for the command.
|
||||
*/
|
||||
alias(): string;
|
||||
|
||||
/**
|
||||
* Set aliases for the command.
|
||||
*
|
||||
* Only the first alias is shown in the auto-generated help.
|
||||
*
|
||||
* @returns `this` command for chaining
|
||||
*/
|
||||
aliases(aliases: readonly string[]): this;
|
||||
/**
|
||||
* Get aliases for the command.
|
||||
*/
|
||||
aliases(): string[];
|
||||
|
||||
/**
|
||||
* Set the command usage.
|
||||
*
|
||||
* @returns `this` command for chaining
|
||||
*/
|
||||
usage(str: string): this;
|
||||
/**
|
||||
* Get the command usage.
|
||||
*/
|
||||
usage(): string;
|
||||
|
||||
/**
|
||||
* Set the name of the command.
|
||||
*
|
||||
* @returns `this` command for chaining
|
||||
*/
|
||||
name(str: string): this;
|
||||
/**
|
||||
* Get the name of the command.
|
||||
*/
|
||||
name(): string;
|
||||
|
||||
/**
|
||||
* Set the name of the command from script filename, such as process.argv[1],
|
||||
* or require.main.filename, or __filename.
|
||||
*
|
||||
* (Used internally and public although not documented in README.)
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* program.nameFromFilename(require.main.filename);
|
||||
* ```
|
||||
*
|
||||
* @returns `this` command for chaining
|
||||
*/
|
||||
nameFromFilename(filename: string): this;
|
||||
|
||||
/**
|
||||
* Set the directory for searching for executable subcommands of this command.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* program.executableDir(__dirname);
|
||||
* // or
|
||||
* program.executableDir('subcommands');
|
||||
* ```
|
||||
*
|
||||
* @returns `this` command for chaining
|
||||
*/
|
||||
executableDir(path: string): this;
|
||||
/**
|
||||
* Get the executable search directory.
|
||||
*/
|
||||
executableDir(): string | null;
|
||||
|
||||
/**
|
||||
* Output help information for this command.
|
||||
*
|
||||
* Outputs built-in help, and custom text added using `.addHelpText()`.
|
||||
*
|
||||
*/
|
||||
outputHelp(context?: HelpContext): void;
|
||||
/** @deprecated since v7 */
|
||||
outputHelp(cb?: (str: string) => string): void;
|
||||
|
||||
/**
|
||||
* Return command help documentation.
|
||||
*/
|
||||
helpInformation(context?: HelpContext): string;
|
||||
|
||||
/**
|
||||
* You can pass in flags and a description to override the help
|
||||
* flags and help description for your command. Pass in false
|
||||
* to disable the built-in help option.
|
||||
*/
|
||||
helpOption(flags?: string | boolean, description?: string): this;
|
||||
|
||||
/**
|
||||
* Output help information and exit.
|
||||
*
|
||||
* Outputs built-in help, and custom text added using `.addHelpText()`.
|
||||
*/
|
||||
help(context?: HelpContext): never;
|
||||
/** @deprecated since v7 */
|
||||
help(cb?: (str: string) => string): never;
|
||||
|
||||
/**
|
||||
* Add additional text to be displayed with the built-in help.
|
||||
*
|
||||
* Position is 'before' or 'after' to affect just this command,
|
||||
* and 'beforeAll' or 'afterAll' to affect this command and all its subcommands.
|
||||
*/
|
||||
addHelpText(position: AddHelpTextPosition, text: string): this;
|
||||
addHelpText(position: AddHelpTextPosition, text: (context: AddHelpTextContext) => string): this;
|
||||
|
||||
/**
|
||||
* Add a listener (callback) for when events occur. (Implemented using EventEmitter.)
|
||||
*/
|
||||
on(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
}
|
||||
|
||||
export interface CommandOptions {
|
||||
hidden?: boolean;
|
||||
isDefault?: boolean;
|
||||
/** @deprecated since v7, replaced by hidden */
|
||||
noHelp?: boolean;
|
||||
}
|
||||
export interface ExecutableCommandOptions extends CommandOptions {
|
||||
executableFile?: string;
|
||||
}
|
||||
|
||||
export interface ParseOptionsResult {
|
||||
operands: string[];
|
||||
unknown: string[];
|
||||
}
|
||||
|
||||
export function createCommand(name?: string): Command;
|
||||
export function createOption(flags: string, description?: string): Option;
|
||||
export function createArgument(name: string, description?: string): Argument;
|
||||
|
||||
export const program: Command;
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
import type { CompiledQuery, InternalOptions } from "./types.js";
|
||||
import type { AttributeSelector, AttributeAction } from "css-what";
|
||||
/**
|
||||
* Attribute selectors
|
||||
*/
|
||||
export declare const attributeRules: Record<AttributeAction, <Node, ElementNode extends Node>(next: CompiledQuery<ElementNode>, data: AttributeSelector, options: InternalOptions<Node, ElementNode>) => CompiledQuery<ElementNode>>;
|
||||
//# sourceMappingURL=attributes.d.ts.map
|
||||
-13
@@ -1,13 +0,0 @@
|
||||
import { Selector } from "css-what";
|
||||
import type { CompiledQuery, InternalOptions, InternalSelector } from "./types.js";
|
||||
/**
|
||||
* Compiles a selector to an executable function.
|
||||
*
|
||||
* @param selector Selector to compile.
|
||||
* @param options Compilation options.
|
||||
* @param context Optional context for the selector.
|
||||
*/
|
||||
export declare function compile<Node, ElementNode extends Node>(selector: string | Selector[][], options: InternalOptions<Node, ElementNode>, context?: Node[] | Node): CompiledQuery<Node>;
|
||||
export declare function compileUnsafe<Node, ElementNode extends Node>(selector: string | Selector[][], options: InternalOptions<Node, ElementNode>, context?: Node[] | Node): CompiledQuery<ElementNode>;
|
||||
export declare function compileToken<Node, ElementNode extends Node>(token: InternalSelector[][], options: InternalOptions<Node, ElementNode>, context?: Node[] | Node): CompiledQuery<ElementNode>;
|
||||
//# sourceMappingURL=compile.d.ts.map
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
import type { CompiledQuery, InternalOptions } from "./types.js";
|
||||
import type { AttributeSelector, AttributeAction } from "css-what";
|
||||
/**
|
||||
* Attribute selectors
|
||||
*/
|
||||
export declare const attributeRules: Record<AttributeAction, <Node, ElementNode extends Node>(next: CompiledQuery<ElementNode>, data: AttributeSelector, options: InternalOptions<Node, ElementNode>) => CompiledQuery<ElementNode>>;
|
||||
//# sourceMappingURL=attributes.d.ts.map
|
||||
-13
@@ -1,13 +0,0 @@
|
||||
import { Selector } from "css-what";
|
||||
import type { CompiledQuery, InternalOptions, InternalSelector } from "./types.js";
|
||||
/**
|
||||
* Compiles a selector to an executable function.
|
||||
*
|
||||
* @param selector Selector to compile.
|
||||
* @param options Compilation options.
|
||||
* @param context Optional context for the selector.
|
||||
*/
|
||||
export declare function compile<Node, ElementNode extends Node>(selector: string | Selector[][], options: InternalOptions<Node, ElementNode>, context?: Node[] | Node): CompiledQuery<Node>;
|
||||
export declare function compileUnsafe<Node, ElementNode extends Node>(selector: string | Selector[][], options: InternalOptions<Node, ElementNode>, context?: Node[] | Node): CompiledQuery<ElementNode>;
|
||||
export declare function compileToken<Node, ElementNode extends Node>(token: InternalSelector[][], options: InternalOptions<Node, ElementNode>, context?: Node[] | Node): CompiledQuery<ElementNode>;
|
||||
//# sourceMappingURL=compile.d.ts.map
|
||||
-3
@@ -1,3 +0,0 @@
|
||||
import type { CompiledQuery, InternalOptions, InternalSelector, CompileToken } from "./types.js";
|
||||
export declare function compileGeneralSelector<Node, ElementNode extends Node>(next: CompiledQuery<ElementNode>, selector: InternalSelector, options: InternalOptions<Node, ElementNode>, context: Node[] | undefined, compileToken: CompileToken<Node, ElementNode>): CompiledQuery<ElementNode>;
|
||||
//# sourceMappingURL=general.d.ts.map
|
||||
-12
@@ -1,12 +0,0 @@
|
||||
import type { CompiledQuery, InternalOptions } from "../types.js";
|
||||
/**
|
||||
* Some selectors such as `:contains` and (non-relative) `:has` will only be
|
||||
* able to match elements if their parents match the selector (as they contain
|
||||
* a subset of the elements that the parent contains).
|
||||
*
|
||||
* This function wraps the given `matches` function in a function that caches
|
||||
* the results of the parent elements, so that the `matches` function only
|
||||
* needs to be called once for each subtree.
|
||||
*/
|
||||
export declare function cacheParentResults<Node, ElementNode extends Node>(next: CompiledQuery<ElementNode>, { adapter, cacheResults }: InternalOptions<Node, ElementNode>, matches: (elem: ElementNode) => boolean): CompiledQuery<ElementNode>;
|
||||
//# sourceMappingURL=cache.d.ts.map
|
||||
-24
@@ -1,24 +0,0 @@
|
||||
import type { InternalOptions, Predicate, Adapter } from "../types.js";
|
||||
/**
|
||||
* Find all elements matching the query. If not in XML mode, the query will ignore
|
||||
* the contents of `<template>` elements.
|
||||
*
|
||||
* @param query - Function that returns true if the element matches the query.
|
||||
* @param elems - Nodes to query. If a node is an element, its children will be queried.
|
||||
* @param options - Options for querying the document.
|
||||
* @returns All matching elements.
|
||||
*/
|
||||
export declare function findAll<Node, ElementNode extends Node>(query: Predicate<ElementNode>, elems: Node[], options: InternalOptions<Node, ElementNode>): ElementNode[];
|
||||
/**
|
||||
* Find the first element matching the query. If not in XML mode, the query will ignore
|
||||
* the contents of `<template>` elements.
|
||||
*
|
||||
* @param query - Function that returns true if the element matches the query.
|
||||
* @param elems - Nodes to query. If a node is an element, its children will be queried.
|
||||
* @param options - Options for querying the document.
|
||||
* @returns The first matching element, or null if there was no match.
|
||||
*/
|
||||
export declare function findOne<Node, ElementNode extends Node>(query: Predicate<ElementNode>, elems: Node[], options: InternalOptions<Node, ElementNode>): ElementNode | null;
|
||||
export declare function getNextSiblings<Node, ElementNode extends Node>(elem: Node, adapter: Adapter<Node, ElementNode>): ElementNode[];
|
||||
export declare function getElementParent<Node, ElementNode extends Node>(node: ElementNode, adapter: Adapter<Node, ElementNode>): ElementNode | null;
|
||||
//# sourceMappingURL=querying.d.ts.map
|
||||
-20
@@ -1,20 +0,0 @@
|
||||
import type { InternalSelector } from "../types.js";
|
||||
import { type Traversal } from "css-what";
|
||||
export declare function isTraversal(token: InternalSelector): token is Traversal;
|
||||
/**
|
||||
* Sort the parts of the passed selector, as there is potential for
|
||||
* optimization (some types of selectors are faster than others).
|
||||
*
|
||||
* @param arr Selector to sort
|
||||
*/
|
||||
export declare function sortRules(arr: InternalSelector[]): void;
|
||||
/**
|
||||
* Determine the quality of the passed token. The higher the number, the
|
||||
* faster the token is to execute.
|
||||
*
|
||||
* @param token Token to get the quality of.
|
||||
* @returns The token's quality.
|
||||
*/
|
||||
export declare function getQuality(token: InternalSelector): number;
|
||||
export declare function includesScopePseudo(t: InternalSelector): boolean;
|
||||
//# sourceMappingURL=selectors.d.ts.map
|
||||
-50
@@ -1,50 +0,0 @@
|
||||
import type { CompiledQuery, Options, Query, Adapter } from "./types.js";
|
||||
export type { Options };
|
||||
/**
|
||||
* Compiles the query, returns a function.
|
||||
*/
|
||||
export declare const compile: <Node, ElementNode extends Node>(selector: string | import("css-what").Selector[][], options?: Options<Node, ElementNode> | undefined, context?: Node | Node[] | undefined) => CompiledQuery<Node>;
|
||||
export declare const _compileUnsafe: <Node, ElementNode extends Node>(selector: string | import("css-what").Selector[][], options?: Options<Node, ElementNode> | undefined, context?: Node | Node[] | undefined) => CompiledQuery<ElementNode>;
|
||||
export declare const _compileToken: <Node, ElementNode extends Node>(selector: import("./types.js").InternalSelector[][], options?: Options<Node, ElementNode> | undefined, context?: Node | Node[] | undefined) => CompiledQuery<ElementNode>;
|
||||
export declare function prepareContext<Node, ElementNode extends Node>(elems: Node | Node[], adapter: Adapter<Node, ElementNode>, shouldTestNextSiblings?: boolean): Node[];
|
||||
/**
|
||||
* @template Node The generic Node type for the DOM adapter being used.
|
||||
* @template ElementNode The Node type for elements for the DOM adapter being used.
|
||||
* @param elems Elements to query. If it is an element, its children will be queried..
|
||||
* @param query can be either a CSS selector string or a compiled query function.
|
||||
* @param [options] options for querying the document.
|
||||
* @see compile for supported selector queries.
|
||||
* @returns All matching elements.
|
||||
*
|
||||
*/
|
||||
export declare const selectAll: <Node, ElementNode extends Node>(query: Query<ElementNode>, elements: Node | Node[], options?: Options<Node, ElementNode> | undefined) => ElementNode[];
|
||||
/**
|
||||
* @template Node The generic Node type for the DOM adapter being used.
|
||||
* @template ElementNode The Node type for elements for the DOM adapter being used.
|
||||
* @param elems Elements to query. If it is an element, its children will be queried..
|
||||
* @param query can be either a CSS selector string or a compiled query function.
|
||||
* @param [options] options for querying the document.
|
||||
* @see compile for supported selector queries.
|
||||
* @returns the first match, or null if there was no match.
|
||||
*/
|
||||
export declare const selectOne: <Node, ElementNode extends Node>(query: Query<ElementNode>, elements: Node | Node[], options?: Options<Node, ElementNode> | undefined) => ElementNode | null;
|
||||
/**
|
||||
* Tests whether or not an element is matched by query.
|
||||
*
|
||||
* @template Node The generic Node type for the DOM adapter being used.
|
||||
* @template ElementNode The Node type for elements for the DOM adapter being used.
|
||||
* @param elem The element to test if it matches the query.
|
||||
* @param query can be either a CSS selector string or a compiled query function.
|
||||
* @param [options] options for querying the document.
|
||||
* @see compile for supported selector queries.
|
||||
* @returns
|
||||
*/
|
||||
export declare function is<Node, ElementNode extends Node>(elem: ElementNode, query: Query<ElementNode>, options?: Options<Node, ElementNode>): boolean;
|
||||
/**
|
||||
* Alias for selectAll(query, elems, options).
|
||||
* @see [compile] for supported selector queries.
|
||||
*/
|
||||
export default selectAll;
|
||||
/** @deprecated Use the `pseudos` option instead. */
|
||||
export { filters, pseudos, aliases } from "./pseudo-selectors/index.js";
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
-5
@@ -1,5 +0,0 @@
|
||||
/**
|
||||
* Aliases are pseudos that are expressed as selectors.
|
||||
*/
|
||||
export declare const aliases: Record<string, string>;
|
||||
//# sourceMappingURL=aliases.d.ts.map
|
||||
-4
@@ -1,4 +0,0 @@
|
||||
import type { CompiledQuery, InternalOptions } from "../types.js";
|
||||
export declare type Filter = <Node, ElementNode extends Node>(next: CompiledQuery<ElementNode>, text: string, options: InternalOptions<Node, ElementNode>, context?: Node[]) => CompiledQuery<ElementNode>;
|
||||
export declare const filters: Record<string, Filter>;
|
||||
//# sourceMappingURL=filters.d.ts.map
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
import type { CompiledQuery, InternalOptions, CompileToken } from "../types.js";
|
||||
import { PseudoSelector } from "css-what";
|
||||
import { filters } from "./filters.js";
|
||||
import { pseudos } from "./pseudos.js";
|
||||
import { aliases } from "./aliases.js";
|
||||
export { filters, pseudos, aliases };
|
||||
export declare function compilePseudoSelector<Node, ElementNode extends Node>(next: CompiledQuery<ElementNode>, selector: PseudoSelector, options: InternalOptions<Node, ElementNode>, context: Node[] | undefined, compileToken: CompileToken<Node, ElementNode>): CompiledQuery<ElementNode>;
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
-6
@@ -1,6 +0,0 @@
|
||||
import type { PseudoSelector } from "css-what";
|
||||
import type { InternalOptions } from "../types.js";
|
||||
export declare type Pseudo = <Node, ElementNode extends Node>(elem: ElementNode, options: InternalOptions<Node, ElementNode>, subselect?: string | null) => boolean;
|
||||
export declare const pseudos: Record<string, Pseudo>;
|
||||
export declare function verifyPseudoArgs<T extends Array<unknown>>(func: (...args: T) => boolean, name: string, subselect: PseudoSelector["data"], argIndex: number): void;
|
||||
//# sourceMappingURL=pseudos.d.ts.map
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
import type { Selector } from "css-what";
|
||||
import type { CompiledQuery, InternalOptions, CompileToken, Adapter } from "../types.js";
|
||||
/** Used as a placeholder for :has. Will be replaced with the actual element. */
|
||||
export declare const PLACEHOLDER_ELEMENT: {};
|
||||
export declare function ensureIsTag<Node, ElementNode extends Node>(next: CompiledQuery<ElementNode>, adapter: Adapter<Node, ElementNode>): CompiledQuery<Node>;
|
||||
export declare type Subselect = <Node, ElementNode extends Node>(next: CompiledQuery<ElementNode>, subselect: Selector[][], options: InternalOptions<Node, ElementNode>, context: Node[] | undefined, compileToken: CompileToken<Node, ElementNode>) => CompiledQuery<ElementNode>;
|
||||
export declare function getNextSiblings<Node, ElementNode extends Node>(elem: Node, adapter: Adapter<Node, ElementNode>): ElementNode[];
|
||||
export declare const subselects: Record<string, Subselect>;
|
||||
//# sourceMappingURL=subselects.d.ts.map
|
||||
-12
@@ -1,12 +0,0 @@
|
||||
import type { InternalSelector } from "./types.js";
|
||||
import { type Traversal } from "css-what";
|
||||
export declare function isTraversal(token: InternalSelector): token is Traversal;
|
||||
/**
|
||||
* Sort the parts of the passed selector,
|
||||
* as there is potential for optimization
|
||||
* (some types of selectors are faster than others)
|
||||
*
|
||||
* @param arr Selector to sort
|
||||
*/
|
||||
export default function sortByProcedure(arr: InternalSelector[]): void;
|
||||
//# sourceMappingURL=sort.d.ts.map
|
||||
-167
@@ -1,167 +0,0 @@
|
||||
import type { Selector } from "css-what";
|
||||
export declare type InternalSelector = Selector | {
|
||||
type: "_flexibleDescendant";
|
||||
};
|
||||
export declare type Predicate<Value> = (v: Value) => boolean;
|
||||
export interface Adapter<Node, ElementNode extends Node> {
|
||||
/**
|
||||
* Is the node a tag?
|
||||
*/
|
||||
isTag: (node: Node) => node is ElementNode;
|
||||
/**
|
||||
* Does at least one of passed element nodes pass the test predicate?
|
||||
*/
|
||||
existsOne: (test: Predicate<ElementNode>, elems: Node[]) => boolean;
|
||||
/**
|
||||
* Get the attribute value.
|
||||
*/
|
||||
getAttributeValue: (elem: ElementNode, name: string) => string | undefined;
|
||||
/**
|
||||
* Get the node's children
|
||||
*/
|
||||
getChildren: (node: Node) => Node[];
|
||||
/**
|
||||
* Get the name of the tag
|
||||
*/
|
||||
getName: (elem: ElementNode) => string;
|
||||
/**
|
||||
* Get the parent of the node
|
||||
*/
|
||||
getParent: (node: ElementNode) => Node | null;
|
||||
/**
|
||||
* Get the siblings of the node. Note that unlike jQuery's `siblings` method,
|
||||
* this is expected to include the current node as well
|
||||
*/
|
||||
getSiblings: (node: Node) => Node[];
|
||||
/**
|
||||
* Returns the previous element sibling of a node.
|
||||
*/
|
||||
prevElementSibling?: (node: Node) => ElementNode | null;
|
||||
/**
|
||||
* Get the text content of the node, and its children if it has any.
|
||||
*/
|
||||
getText: (node: Node) => string;
|
||||
/**
|
||||
* Does the element have the named attribute?
|
||||
*/
|
||||
hasAttrib: (elem: ElementNode, name: string) => boolean;
|
||||
/**
|
||||
* Takes an array of nodes, and removes any duplicates, as well as any
|
||||
* nodes whose ancestors are also in the array.
|
||||
*/
|
||||
removeSubsets: (nodes: Node[]) => Node[];
|
||||
/**
|
||||
* Finds all of the element nodes in the array that match the test predicate,
|
||||
* as well as any of their children that match it.
|
||||
*/
|
||||
findAll: (test: Predicate<ElementNode>, nodes: Node[]) => ElementNode[];
|
||||
/**
|
||||
* Finds the first node in the array that matches the test predicate, or one
|
||||
* of its children.
|
||||
*/
|
||||
findOne: (test: Predicate<ElementNode>, elems: Node[]) => ElementNode | null;
|
||||
/**
|
||||
* The adapter can also optionally include an equals method, if your DOM
|
||||
* structure needs a custom equality test to compare two objects which refer
|
||||
* to the same underlying node. If not provided, `css-select` will fall back to
|
||||
* `a === b`.
|
||||
*/
|
||||
equals?: (a: Node, b: Node) => boolean;
|
||||
/**
|
||||
* Is the element in hovered state?
|
||||
*/
|
||||
isHovered?: (elem: ElementNode) => boolean;
|
||||
/**
|
||||
* Is the element in visited state?
|
||||
*/
|
||||
isVisited?: (elem: ElementNode) => boolean;
|
||||
/**
|
||||
* Is the element in active state?
|
||||
*/
|
||||
isActive?: (elem: ElementNode) => boolean;
|
||||
}
|
||||
export interface Options<Node, ElementNode extends Node> {
|
||||
/**
|
||||
* When enabled, tag names will be case-sensitive.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
xmlMode?: boolean;
|
||||
/**
|
||||
* Lower-case attribute names.
|
||||
*
|
||||
* @default !xmlMode
|
||||
*/
|
||||
lowerCaseAttributeNames?: boolean;
|
||||
/**
|
||||
* Lower-case tag names.
|
||||
*
|
||||
* @default !xmlMode
|
||||
*/
|
||||
lowerCaseTags?: boolean;
|
||||
/**
|
||||
* Is the document in quirks mode?
|
||||
*
|
||||
* This will lead to .className and #id being case-insensitive.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
quirksMode?: boolean;
|
||||
/**
|
||||
* Pseudo-classes that override the default ones.
|
||||
*
|
||||
* Maps from names to either strings of functions.
|
||||
* - A string value is a selector that the element must match to be selected.
|
||||
* - A function is called with the element as its first argument, and optional
|
||||
* parameters second. If it returns true, the element is selected.
|
||||
*/
|
||||
pseudos?: Record<string, string | ((elem: ElementNode, value?: string | null) => boolean)> | undefined;
|
||||
/**
|
||||
* The last function in the stack, will be called with the last element
|
||||
* that's looked at.
|
||||
*/
|
||||
rootFunc?: (element: ElementNode) => boolean;
|
||||
/**
|
||||
* The adapter to use when interacting with the backing DOM structure. By
|
||||
* default it uses the `domutils` module.
|
||||
*/
|
||||
adapter?: Adapter<Node, ElementNode>;
|
||||
/**
|
||||
* The context of the current query. Used to limit the scope of searches.
|
||||
* Can be matched directly using the `:scope` pseudo-class.
|
||||
*/
|
||||
context?: Node | Node[];
|
||||
/**
|
||||
* Indicates whether to consider the selector as a relative selector.
|
||||
*
|
||||
* Relative selectors that don't include a `:scope` pseudo-class behave
|
||||
* as if they have a `:scope ` prefix (a `:scope` pseudo-class, followed by
|
||||
* a descendant selector).
|
||||
*
|
||||
* If relative selectors are disabled, selectors starting with a traversal
|
||||
* will lead to an error.
|
||||
*
|
||||
* @default true
|
||||
* @see {@link https://www.w3.org/TR/selectors-4/#relative}
|
||||
*/
|
||||
relativeSelector?: boolean;
|
||||
/**
|
||||
* Allow css-select to cache results for some selectors, sometimes greatly
|
||||
* improving querying performance. Disable this if your document can
|
||||
* change in between queries with the same compiled selector.
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
cacheResults?: boolean;
|
||||
}
|
||||
export interface InternalOptions<Node, ElementNode extends Node> extends Options<Node, ElementNode> {
|
||||
adapter: Adapter<Node, ElementNode>;
|
||||
equals: (a: Node, b: Node) => boolean;
|
||||
}
|
||||
export interface CompiledQuery<ElementNode> {
|
||||
(node: ElementNode): boolean;
|
||||
shouldTestNextSiblings?: boolean;
|
||||
}
|
||||
export declare type Query<ElementNode> = string | CompiledQuery<ElementNode> | Selector[][];
|
||||
export declare type CompileToken<Node, ElementNode extends Node> = (token: InternalSelector[][], options: InternalOptions<Node, ElementNode>, context?: Node[] | Node) => CompiledQuery<ElementNode>;
|
||||
//# sourceMappingURL=types.d.ts.map
|
||||
-3
@@ -1,3 +0,0 @@
|
||||
import type { CompiledQuery, InternalOptions, InternalSelector, CompileToken } from "./types.js";
|
||||
export declare function compileGeneralSelector<Node, ElementNode extends Node>(next: CompiledQuery<ElementNode>, selector: InternalSelector, options: InternalOptions<Node, ElementNode>, context: Node[] | undefined, compileToken: CompileToken<Node, ElementNode>): CompiledQuery<ElementNode>;
|
||||
//# sourceMappingURL=general.d.ts.map
|
||||
-12
@@ -1,12 +0,0 @@
|
||||
import type { CompiledQuery, InternalOptions } from "../types.js";
|
||||
/**
|
||||
* Some selectors such as `:contains` and (non-relative) `:has` will only be
|
||||
* able to match elements if their parents match the selector (as they contain
|
||||
* a subset of the elements that the parent contains).
|
||||
*
|
||||
* This function wraps the given `matches` function in a function that caches
|
||||
* the results of the parent elements, so that the `matches` function only
|
||||
* needs to be called once for each subtree.
|
||||
*/
|
||||
export declare function cacheParentResults<Node, ElementNode extends Node>(next: CompiledQuery<ElementNode>, { adapter, cacheResults }: InternalOptions<Node, ElementNode>, matches: (elem: ElementNode) => boolean): CompiledQuery<ElementNode>;
|
||||
//# sourceMappingURL=cache.d.ts.map
|
||||
-24
@@ -1,24 +0,0 @@
|
||||
import type { InternalOptions, Predicate, Adapter } from "../types.js";
|
||||
/**
|
||||
* Find all elements matching the query. If not in XML mode, the query will ignore
|
||||
* the contents of `<template>` elements.
|
||||
*
|
||||
* @param query - Function that returns true if the element matches the query.
|
||||
* @param elems - Nodes to query. If a node is an element, its children will be queried.
|
||||
* @param options - Options for querying the document.
|
||||
* @returns All matching elements.
|
||||
*/
|
||||
export declare function findAll<Node, ElementNode extends Node>(query: Predicate<ElementNode>, elems: Node[], options: InternalOptions<Node, ElementNode>): ElementNode[];
|
||||
/**
|
||||
* Find the first element matching the query. If not in XML mode, the query will ignore
|
||||
* the contents of `<template>` elements.
|
||||
*
|
||||
* @param query - Function that returns true if the element matches the query.
|
||||
* @param elems - Nodes to query. If a node is an element, its children will be queried.
|
||||
* @param options - Options for querying the document.
|
||||
* @returns The first matching element, or null if there was no match.
|
||||
*/
|
||||
export declare function findOne<Node, ElementNode extends Node>(query: Predicate<ElementNode>, elems: Node[], options: InternalOptions<Node, ElementNode>): ElementNode | null;
|
||||
export declare function getNextSiblings<Node, ElementNode extends Node>(elem: Node, adapter: Adapter<Node, ElementNode>): ElementNode[];
|
||||
export declare function getElementParent<Node, ElementNode extends Node>(node: ElementNode, adapter: Adapter<Node, ElementNode>): ElementNode | null;
|
||||
//# sourceMappingURL=querying.d.ts.map
|
||||
-20
@@ -1,20 +0,0 @@
|
||||
import type { InternalSelector } from "../types.js";
|
||||
import { type Traversal } from "css-what";
|
||||
export declare function isTraversal(token: InternalSelector): token is Traversal;
|
||||
/**
|
||||
* Sort the parts of the passed selector, as there is potential for
|
||||
* optimization (some types of selectors are faster than others).
|
||||
*
|
||||
* @param arr Selector to sort
|
||||
*/
|
||||
export declare function sortRules(arr: InternalSelector[]): void;
|
||||
/**
|
||||
* Determine the quality of the passed token. The higher the number, the
|
||||
* faster the token is to execute.
|
||||
*
|
||||
* @param token Token to get the quality of.
|
||||
* @returns The token's quality.
|
||||
*/
|
||||
export declare function getQuality(token: InternalSelector): number;
|
||||
export declare function includesScopePseudo(t: InternalSelector): boolean;
|
||||
//# sourceMappingURL=selectors.d.ts.map
|
||||
-50
@@ -1,50 +0,0 @@
|
||||
import type { CompiledQuery, Options, Query, Adapter } from "./types.js";
|
||||
export type { Options };
|
||||
/**
|
||||
* Compiles the query, returns a function.
|
||||
*/
|
||||
export declare const compile: <Node, ElementNode extends Node>(selector: string | import("css-what").Selector[][], options?: Options<Node, ElementNode> | undefined, context?: Node | Node[] | undefined) => CompiledQuery<Node>;
|
||||
export declare const _compileUnsafe: <Node, ElementNode extends Node>(selector: string | import("css-what").Selector[][], options?: Options<Node, ElementNode> | undefined, context?: Node | Node[] | undefined) => CompiledQuery<ElementNode>;
|
||||
export declare const _compileToken: <Node, ElementNode extends Node>(selector: import("./types.js").InternalSelector[][], options?: Options<Node, ElementNode> | undefined, context?: Node | Node[] | undefined) => CompiledQuery<ElementNode>;
|
||||
export declare function prepareContext<Node, ElementNode extends Node>(elems: Node | Node[], adapter: Adapter<Node, ElementNode>, shouldTestNextSiblings?: boolean): Node[];
|
||||
/**
|
||||
* @template Node The generic Node type for the DOM adapter being used.
|
||||
* @template ElementNode The Node type for elements for the DOM adapter being used.
|
||||
* @param elems Elements to query. If it is an element, its children will be queried..
|
||||
* @param query can be either a CSS selector string or a compiled query function.
|
||||
* @param [options] options for querying the document.
|
||||
* @see compile for supported selector queries.
|
||||
* @returns All matching elements.
|
||||
*
|
||||
*/
|
||||
export declare const selectAll: <Node, ElementNode extends Node>(query: Query<ElementNode>, elements: Node | Node[], options?: Options<Node, ElementNode> | undefined) => ElementNode[];
|
||||
/**
|
||||
* @template Node The generic Node type for the DOM adapter being used.
|
||||
* @template ElementNode The Node type for elements for the DOM adapter being used.
|
||||
* @param elems Elements to query. If it is an element, its children will be queried..
|
||||
* @param query can be either a CSS selector string or a compiled query function.
|
||||
* @param [options] options for querying the document.
|
||||
* @see compile for supported selector queries.
|
||||
* @returns the first match, or null if there was no match.
|
||||
*/
|
||||
export declare const selectOne: <Node, ElementNode extends Node>(query: Query<ElementNode>, elements: Node | Node[], options?: Options<Node, ElementNode> | undefined) => ElementNode | null;
|
||||
/**
|
||||
* Tests whether or not an element is matched by query.
|
||||
*
|
||||
* @template Node The generic Node type for the DOM adapter being used.
|
||||
* @template ElementNode The Node type for elements for the DOM adapter being used.
|
||||
* @param elem The element to test if it matches the query.
|
||||
* @param query can be either a CSS selector string or a compiled query function.
|
||||
* @param [options] options for querying the document.
|
||||
* @see compile for supported selector queries.
|
||||
* @returns
|
||||
*/
|
||||
export declare function is<Node, ElementNode extends Node>(elem: ElementNode, query: Query<ElementNode>, options?: Options<Node, ElementNode>): boolean;
|
||||
/**
|
||||
* Alias for selectAll(query, elems, options).
|
||||
* @see [compile] for supported selector queries.
|
||||
*/
|
||||
export default selectAll;
|
||||
/** @deprecated Use the `pseudos` option instead. */
|
||||
export { filters, pseudos, aliases } from "./pseudo-selectors/index.js";
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
-5
@@ -1,5 +0,0 @@
|
||||
/**
|
||||
* Aliases are pseudos that are expressed as selectors.
|
||||
*/
|
||||
export declare const aliases: Record<string, string>;
|
||||
//# sourceMappingURL=aliases.d.ts.map
|
||||
-4
@@ -1,4 +0,0 @@
|
||||
import type { CompiledQuery, InternalOptions } from "../types.js";
|
||||
export declare type Filter = <Node, ElementNode extends Node>(next: CompiledQuery<ElementNode>, text: string, options: InternalOptions<Node, ElementNode>, context?: Node[]) => CompiledQuery<ElementNode>;
|
||||
export declare const filters: Record<string, Filter>;
|
||||
//# sourceMappingURL=filters.d.ts.map
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
import type { CompiledQuery, InternalOptions, CompileToken } from "../types.js";
|
||||
import { PseudoSelector } from "css-what";
|
||||
import { filters } from "./filters.js";
|
||||
import { pseudos } from "./pseudos.js";
|
||||
import { aliases } from "./aliases.js";
|
||||
export { filters, pseudos, aliases };
|
||||
export declare function compilePseudoSelector<Node, ElementNode extends Node>(next: CompiledQuery<ElementNode>, selector: PseudoSelector, options: InternalOptions<Node, ElementNode>, context: Node[] | undefined, compileToken: CompileToken<Node, ElementNode>): CompiledQuery<ElementNode>;
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
-6
@@ -1,6 +0,0 @@
|
||||
import type { PseudoSelector } from "css-what";
|
||||
import type { InternalOptions } from "../types.js";
|
||||
export declare type Pseudo = <Node, ElementNode extends Node>(elem: ElementNode, options: InternalOptions<Node, ElementNode>, subselect?: string | null) => boolean;
|
||||
export declare const pseudos: Record<string, Pseudo>;
|
||||
export declare function verifyPseudoArgs<T extends Array<unknown>>(func: (...args: T) => boolean, name: string, subselect: PseudoSelector["data"], argIndex: number): void;
|
||||
//# sourceMappingURL=pseudos.d.ts.map
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
import type { Selector } from "css-what";
|
||||
import type { CompiledQuery, InternalOptions, CompileToken, Adapter } from "../types.js";
|
||||
/** Used as a placeholder for :has. Will be replaced with the actual element. */
|
||||
export declare const PLACEHOLDER_ELEMENT: {};
|
||||
export declare function ensureIsTag<Node, ElementNode extends Node>(next: CompiledQuery<ElementNode>, adapter: Adapter<Node, ElementNode>): CompiledQuery<Node>;
|
||||
export declare type Subselect = <Node, ElementNode extends Node>(next: CompiledQuery<ElementNode>, subselect: Selector[][], options: InternalOptions<Node, ElementNode>, context: Node[] | undefined, compileToken: CompileToken<Node, ElementNode>) => CompiledQuery<ElementNode>;
|
||||
export declare function getNextSiblings<Node, ElementNode extends Node>(elem: Node, adapter: Adapter<Node, ElementNode>): ElementNode[];
|
||||
export declare const subselects: Record<string, Subselect>;
|
||||
//# sourceMappingURL=subselects.d.ts.map
|
||||
-12
@@ -1,12 +0,0 @@
|
||||
import type { InternalSelector } from "./types.js";
|
||||
import { type Traversal } from "css-what";
|
||||
export declare function isTraversal(token: InternalSelector): token is Traversal;
|
||||
/**
|
||||
* Sort the parts of the passed selector,
|
||||
* as there is potential for optimization
|
||||
* (some types of selectors are faster than others)
|
||||
*
|
||||
* @param arr Selector to sort
|
||||
*/
|
||||
export default function sortByProcedure(arr: InternalSelector[]): void;
|
||||
//# sourceMappingURL=sort.d.ts.map
|
||||
-167
@@ -1,167 +0,0 @@
|
||||
import type { Selector } from "css-what";
|
||||
export declare type InternalSelector = Selector | {
|
||||
type: "_flexibleDescendant";
|
||||
};
|
||||
export declare type Predicate<Value> = (v: Value) => boolean;
|
||||
export interface Adapter<Node, ElementNode extends Node> {
|
||||
/**
|
||||
* Is the node a tag?
|
||||
*/
|
||||
isTag: (node: Node) => node is ElementNode;
|
||||
/**
|
||||
* Does at least one of passed element nodes pass the test predicate?
|
||||
*/
|
||||
existsOne: (test: Predicate<ElementNode>, elems: Node[]) => boolean;
|
||||
/**
|
||||
* Get the attribute value.
|
||||
*/
|
||||
getAttributeValue: (elem: ElementNode, name: string) => string | undefined;
|
||||
/**
|
||||
* Get the node's children
|
||||
*/
|
||||
getChildren: (node: Node) => Node[];
|
||||
/**
|
||||
* Get the name of the tag
|
||||
*/
|
||||
getName: (elem: ElementNode) => string;
|
||||
/**
|
||||
* Get the parent of the node
|
||||
*/
|
||||
getParent: (node: ElementNode) => Node | null;
|
||||
/**
|
||||
* Get the siblings of the node. Note that unlike jQuery's `siblings` method,
|
||||
* this is expected to include the current node as well
|
||||
*/
|
||||
getSiblings: (node: Node) => Node[];
|
||||
/**
|
||||
* Returns the previous element sibling of a node.
|
||||
*/
|
||||
prevElementSibling?: (node: Node) => ElementNode | null;
|
||||
/**
|
||||
* Get the text content of the node, and its children if it has any.
|
||||
*/
|
||||
getText: (node: Node) => string;
|
||||
/**
|
||||
* Does the element have the named attribute?
|
||||
*/
|
||||
hasAttrib: (elem: ElementNode, name: string) => boolean;
|
||||
/**
|
||||
* Takes an array of nodes, and removes any duplicates, as well as any
|
||||
* nodes whose ancestors are also in the array.
|
||||
*/
|
||||
removeSubsets: (nodes: Node[]) => Node[];
|
||||
/**
|
||||
* Finds all of the element nodes in the array that match the test predicate,
|
||||
* as well as any of their children that match it.
|
||||
*/
|
||||
findAll: (test: Predicate<ElementNode>, nodes: Node[]) => ElementNode[];
|
||||
/**
|
||||
* Finds the first node in the array that matches the test predicate, or one
|
||||
* of its children.
|
||||
*/
|
||||
findOne: (test: Predicate<ElementNode>, elems: Node[]) => ElementNode | null;
|
||||
/**
|
||||
* The adapter can also optionally include an equals method, if your DOM
|
||||
* structure needs a custom equality test to compare two objects which refer
|
||||
* to the same underlying node. If not provided, `css-select` will fall back to
|
||||
* `a === b`.
|
||||
*/
|
||||
equals?: (a: Node, b: Node) => boolean;
|
||||
/**
|
||||
* Is the element in hovered state?
|
||||
*/
|
||||
isHovered?: (elem: ElementNode) => boolean;
|
||||
/**
|
||||
* Is the element in visited state?
|
||||
*/
|
||||
isVisited?: (elem: ElementNode) => boolean;
|
||||
/**
|
||||
* Is the element in active state?
|
||||
*/
|
||||
isActive?: (elem: ElementNode) => boolean;
|
||||
}
|
||||
export interface Options<Node, ElementNode extends Node> {
|
||||
/**
|
||||
* When enabled, tag names will be case-sensitive.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
xmlMode?: boolean;
|
||||
/**
|
||||
* Lower-case attribute names.
|
||||
*
|
||||
* @default !xmlMode
|
||||
*/
|
||||
lowerCaseAttributeNames?: boolean;
|
||||
/**
|
||||
* Lower-case tag names.
|
||||
*
|
||||
* @default !xmlMode
|
||||
*/
|
||||
lowerCaseTags?: boolean;
|
||||
/**
|
||||
* Is the document in quirks mode?
|
||||
*
|
||||
* This will lead to .className and #id being case-insensitive.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
quirksMode?: boolean;
|
||||
/**
|
||||
* Pseudo-classes that override the default ones.
|
||||
*
|
||||
* Maps from names to either strings of functions.
|
||||
* - A string value is a selector that the element must match to be selected.
|
||||
* - A function is called with the element as its first argument, and optional
|
||||
* parameters second. If it returns true, the element is selected.
|
||||
*/
|
||||
pseudos?: Record<string, string | ((elem: ElementNode, value?: string | null) => boolean)> | undefined;
|
||||
/**
|
||||
* The last function in the stack, will be called with the last element
|
||||
* that's looked at.
|
||||
*/
|
||||
rootFunc?: (element: ElementNode) => boolean;
|
||||
/**
|
||||
* The adapter to use when interacting with the backing DOM structure. By
|
||||
* default it uses the `domutils` module.
|
||||
*/
|
||||
adapter?: Adapter<Node, ElementNode>;
|
||||
/**
|
||||
* The context of the current query. Used to limit the scope of searches.
|
||||
* Can be matched directly using the `:scope` pseudo-class.
|
||||
*/
|
||||
context?: Node | Node[];
|
||||
/**
|
||||
* Indicates whether to consider the selector as a relative selector.
|
||||
*
|
||||
* Relative selectors that don't include a `:scope` pseudo-class behave
|
||||
* as if they have a `:scope ` prefix (a `:scope` pseudo-class, followed by
|
||||
* a descendant selector).
|
||||
*
|
||||
* If relative selectors are disabled, selectors starting with a traversal
|
||||
* will lead to an error.
|
||||
*
|
||||
* @default true
|
||||
* @see {@link https://www.w3.org/TR/selectors-4/#relative}
|
||||
*/
|
||||
relativeSelector?: boolean;
|
||||
/**
|
||||
* Allow css-select to cache results for some selectors, sometimes greatly
|
||||
* improving querying performance. Disable this if your document can
|
||||
* change in between queries with the same compiled selector.
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
cacheResults?: boolean;
|
||||
}
|
||||
export interface InternalOptions<Node, ElementNode extends Node> extends Options<Node, ElementNode> {
|
||||
adapter: Adapter<Node, ElementNode>;
|
||||
equals: (a: Node, b: Node) => boolean;
|
||||
}
|
||||
export interface CompiledQuery<ElementNode> {
|
||||
(node: ElementNode): boolean;
|
||||
shouldTestNextSiblings?: boolean;
|
||||
}
|
||||
export declare type Query<ElementNode> = string | CompiledQuery<ElementNode> | Selector[][];
|
||||
export declare type CompileToken<Node, ElementNode extends Node> = (token: InternalSelector[][], options: InternalOptions<Node, ElementNode>, context?: Node[] | Node) => CompiledQuery<ElementNode>;
|
||||
//# sourceMappingURL=types.d.ts.map
|
||||
-4
@@ -1,4 +0,0 @@
|
||||
export * from "./types";
|
||||
export { isTraversal, parse } from "./parse";
|
||||
export { stringify } from "./stringify";
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
-20
@@ -1,20 +0,0 @@
|
||||
import { Selector, Traversal } from "./types";
|
||||
/**
|
||||
* Checks whether a specific selector is a traversal.
|
||||
* This is useful eg. in swapping the order of elements that
|
||||
* are not traversals.
|
||||
*
|
||||
* @param selector Selector to check.
|
||||
*/
|
||||
export declare function isTraversal(selector: Selector): selector is Traversal;
|
||||
/**
|
||||
* Parses `selector`, optionally with the passed `options`.
|
||||
*
|
||||
* @param selector Selector to parse.
|
||||
* @param options Options for parsing.
|
||||
* @returns Returns a two-dimensional array.
|
||||
* The first dimension represents selectors separated by commas (eg. `sub1, sub2`),
|
||||
* the second contains the relevant tokens for that selector.
|
||||
*/
|
||||
export declare function parse(selector: string): Selector[][];
|
||||
//# sourceMappingURL=parse.d.ts.map
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
import { Selector } from "./types";
|
||||
/**
|
||||
* Turns `selector` back into a string.
|
||||
*
|
||||
* @param selector Selector to stringify.
|
||||
*/
|
||||
export declare function stringify(selector: Selector[][]): string;
|
||||
//# sourceMappingURL=stringify.d.ts.map
|
||||
-70
@@ -1,70 +0,0 @@
|
||||
export declare type Selector = PseudoSelector | PseudoElement | AttributeSelector | TagSelector | UniversalSelector | Traversal;
|
||||
export declare enum SelectorType {
|
||||
Attribute = "attribute",
|
||||
Pseudo = "pseudo",
|
||||
PseudoElement = "pseudo-element",
|
||||
Tag = "tag",
|
||||
Universal = "universal",
|
||||
Adjacent = "adjacent",
|
||||
Child = "child",
|
||||
Descendant = "descendant",
|
||||
Parent = "parent",
|
||||
Sibling = "sibling",
|
||||
ColumnCombinator = "column-combinator"
|
||||
}
|
||||
/**
|
||||
* Modes for ignore case.
|
||||
*
|
||||
* This could be updated to an enum, and the object is
|
||||
* the current stand-in that will allow code to be updated
|
||||
* without big changes.
|
||||
*/
|
||||
export declare const IgnoreCaseMode: {
|
||||
readonly Unknown: null;
|
||||
readonly QuirksMode: "quirks";
|
||||
readonly IgnoreCase: true;
|
||||
readonly CaseSensitive: false;
|
||||
};
|
||||
export interface AttributeSelector {
|
||||
type: SelectorType.Attribute;
|
||||
name: string;
|
||||
action: AttributeAction;
|
||||
value: string;
|
||||
ignoreCase: "quirks" | boolean | null;
|
||||
namespace: string | null;
|
||||
}
|
||||
export declare type DataType = Selector[][] | null | string;
|
||||
export interface PseudoSelector {
|
||||
type: SelectorType.Pseudo;
|
||||
name: string;
|
||||
data: DataType;
|
||||
}
|
||||
export interface PseudoElement {
|
||||
type: SelectorType.PseudoElement;
|
||||
name: string;
|
||||
data: string | null;
|
||||
}
|
||||
export interface TagSelector {
|
||||
type: SelectorType.Tag;
|
||||
name: string;
|
||||
namespace: string | null;
|
||||
}
|
||||
export interface UniversalSelector {
|
||||
type: SelectorType.Universal;
|
||||
namespace: string | null;
|
||||
}
|
||||
export interface Traversal {
|
||||
type: TraversalType;
|
||||
}
|
||||
export declare enum AttributeAction {
|
||||
Any = "any",
|
||||
Element = "element",
|
||||
End = "end",
|
||||
Equals = "equals",
|
||||
Exists = "exists",
|
||||
Hyphen = "hyphen",
|
||||
Not = "not",
|
||||
Start = "start"
|
||||
}
|
||||
export declare type TraversalType = SelectorType.Adjacent | SelectorType.Child | SelectorType.Descendant | SelectorType.Parent | SelectorType.Sibling | SelectorType.ColumnCombinator;
|
||||
//# sourceMappingURL=types.d.ts.map
|
||||
-4
@@ -1,4 +0,0 @@
|
||||
export * from "./types";
|
||||
export { isTraversal, parse } from "./parse";
|
||||
export { stringify } from "./stringify";
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
-20
@@ -1,20 +0,0 @@
|
||||
import { Selector, Traversal } from "./types";
|
||||
/**
|
||||
* Checks whether a specific selector is a traversal.
|
||||
* This is useful eg. in swapping the order of elements that
|
||||
* are not traversals.
|
||||
*
|
||||
* @param selector Selector to check.
|
||||
*/
|
||||
export declare function isTraversal(selector: Selector): selector is Traversal;
|
||||
/**
|
||||
* Parses `selector`, optionally with the passed `options`.
|
||||
*
|
||||
* @param selector Selector to parse.
|
||||
* @param options Options for parsing.
|
||||
* @returns Returns a two-dimensional array.
|
||||
* The first dimension represents selectors separated by commas (eg. `sub1, sub2`),
|
||||
* the second contains the relevant tokens for that selector.
|
||||
*/
|
||||
export declare function parse(selector: string): Selector[][];
|
||||
//# sourceMappingURL=parse.d.ts.map
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
import { Selector } from "./types";
|
||||
/**
|
||||
* Turns `selector` back into a string.
|
||||
*
|
||||
* @param selector Selector to stringify.
|
||||
*/
|
||||
export declare function stringify(selector: Selector[][]): string;
|
||||
//# sourceMappingURL=stringify.d.ts.map
|
||||
-70
@@ -1,70 +0,0 @@
|
||||
export declare type Selector = PseudoSelector | PseudoElement | AttributeSelector | TagSelector | UniversalSelector | Traversal;
|
||||
export declare enum SelectorType {
|
||||
Attribute = "attribute",
|
||||
Pseudo = "pseudo",
|
||||
PseudoElement = "pseudo-element",
|
||||
Tag = "tag",
|
||||
Universal = "universal",
|
||||
Adjacent = "adjacent",
|
||||
Child = "child",
|
||||
Descendant = "descendant",
|
||||
Parent = "parent",
|
||||
Sibling = "sibling",
|
||||
ColumnCombinator = "column-combinator"
|
||||
}
|
||||
/**
|
||||
* Modes for ignore case.
|
||||
*
|
||||
* This could be updated to an enum, and the object is
|
||||
* the current stand-in that will allow code to be updated
|
||||
* without big changes.
|
||||
*/
|
||||
export declare const IgnoreCaseMode: {
|
||||
readonly Unknown: null;
|
||||
readonly QuirksMode: "quirks";
|
||||
readonly IgnoreCase: true;
|
||||
readonly CaseSensitive: false;
|
||||
};
|
||||
export interface AttributeSelector {
|
||||
type: SelectorType.Attribute;
|
||||
name: string;
|
||||
action: AttributeAction;
|
||||
value: string;
|
||||
ignoreCase: "quirks" | boolean | null;
|
||||
namespace: string | null;
|
||||
}
|
||||
export declare type DataType = Selector[][] | null | string;
|
||||
export interface PseudoSelector {
|
||||
type: SelectorType.Pseudo;
|
||||
name: string;
|
||||
data: DataType;
|
||||
}
|
||||
export interface PseudoElement {
|
||||
type: SelectorType.PseudoElement;
|
||||
name: string;
|
||||
data: string | null;
|
||||
}
|
||||
export interface TagSelector {
|
||||
type: SelectorType.Tag;
|
||||
name: string;
|
||||
namespace: string | null;
|
||||
}
|
||||
export interface UniversalSelector {
|
||||
type: SelectorType.Universal;
|
||||
namespace: string | null;
|
||||
}
|
||||
export interface Traversal {
|
||||
type: TraversalType;
|
||||
}
|
||||
export declare enum AttributeAction {
|
||||
Any = "any",
|
||||
Element = "element",
|
||||
End = "end",
|
||||
Equals = "equals",
|
||||
Exists = "exists",
|
||||
Hyphen = "hyphen",
|
||||
Not = "not",
|
||||
Start = "start"
|
||||
}
|
||||
export declare type TraversalType = SelectorType.Adjacent | SelectorType.Child | SelectorType.Descendant | SelectorType.Parent | SelectorType.Sibling | SelectorType.ColumnCombinator;
|
||||
//# sourceMappingURL=types.d.ts.map
|
||||
-3
@@ -1,3 +0,0 @@
|
||||
export declare const elementNames: Map<string, string>;
|
||||
export declare const attributeNames: Map<string, string>;
|
||||
//# sourceMappingURL=foreignNames.d.ts.map
|
||||
-52
@@ -1,52 +0,0 @@
|
||||
import type { AnyNode } from "domhandler";
|
||||
export interface DomSerializerOptions {
|
||||
/**
|
||||
* Print an empty attribute's value.
|
||||
*
|
||||
* @default xmlMode
|
||||
* @example With <code>emptyAttrs: false</code>: <code><input checked></code>
|
||||
* @example With <code>emptyAttrs: true</code>: <code><input checked=""></code>
|
||||
*/
|
||||
emptyAttrs?: boolean;
|
||||
/**
|
||||
* Print self-closing tags for tags without contents.
|
||||
*
|
||||
* @default xmlMode
|
||||
* @example With <code>selfClosingTags: false</code>: <code><foo></foo></code>
|
||||
* @example With <code>selfClosingTags: true</code>: <code><foo /></code>
|
||||
*/
|
||||
selfClosingTags?: boolean;
|
||||
/**
|
||||
* Treat the input as an XML document; enables the `emptyAttrs` and `selfClosingTags` options.
|
||||
*
|
||||
* If the value is `"foreign"`, it will try to correct mixed-case attribute names.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
xmlMode?: boolean | "foreign";
|
||||
/**
|
||||
* Encode characters that are either reserved in HTML or XML.
|
||||
*
|
||||
* If `xmlMode` is `true` or the value not `'utf8'`, characters outside of the utf8 range will be encoded as well.
|
||||
*
|
||||
* @default `decodeEntities`
|
||||
*/
|
||||
encodeEntities?: boolean | "utf8";
|
||||
/**
|
||||
* Option inherited from parsing; will be used as the default value for `encodeEntities`.
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
decodeEntities?: boolean;
|
||||
}
|
||||
/**
|
||||
* Renders a DOM node or an array of DOM nodes to a string.
|
||||
*
|
||||
* Can be thought of as the equivalent of the `outerHTML` of the passed node(s).
|
||||
*
|
||||
* @param node Node to be rendered.
|
||||
* @param options Changes serialization behavior
|
||||
*/
|
||||
export declare function render(node: AnyNode | ArrayLike<AnyNode>, options?: DomSerializerOptions): string;
|
||||
export default render;
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
-3
@@ -1,3 +0,0 @@
|
||||
export declare const elementNames: Map<string, string>;
|
||||
export declare const attributeNames: Map<string, string>;
|
||||
//# sourceMappingURL=foreignNames.d.ts.map
|
||||
-52
@@ -1,52 +0,0 @@
|
||||
import type { AnyNode } from "domhandler";
|
||||
export interface DomSerializerOptions {
|
||||
/**
|
||||
* Print an empty attribute's value.
|
||||
*
|
||||
* @default xmlMode
|
||||
* @example With <code>emptyAttrs: false</code>: <code><input checked></code>
|
||||
* @example With <code>emptyAttrs: true</code>: <code><input checked=""></code>
|
||||
*/
|
||||
emptyAttrs?: boolean;
|
||||
/**
|
||||
* Print self-closing tags for tags without contents.
|
||||
*
|
||||
* @default xmlMode
|
||||
* @example With <code>selfClosingTags: false</code>: <code><foo></foo></code>
|
||||
* @example With <code>selfClosingTags: true</code>: <code><foo /></code>
|
||||
*/
|
||||
selfClosingTags?: boolean;
|
||||
/**
|
||||
* Treat the input as an XML document; enables the `emptyAttrs` and `selfClosingTags` options.
|
||||
*
|
||||
* If the value is `"foreign"`, it will try to correct mixed-case attribute names.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
xmlMode?: boolean | "foreign";
|
||||
/**
|
||||
* Encode characters that are either reserved in HTML or XML.
|
||||
*
|
||||
* If `xmlMode` is `true` or the value not `'utf8'`, characters outside of the utf8 range will be encoded as well.
|
||||
*
|
||||
* @default `decodeEntities`
|
||||
*/
|
||||
encodeEntities?: boolean | "utf8";
|
||||
/**
|
||||
* Option inherited from parsing; will be used as the default value for `encodeEntities`.
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
decodeEntities?: boolean;
|
||||
}
|
||||
/**
|
||||
* Renders a DOM node or an array of DOM nodes to a string.
|
||||
*
|
||||
* Can be thought of as the equivalent of the `outerHTML` of the passed node(s).
|
||||
*
|
||||
* @param node Node to be rendered.
|
||||
* @param options Changes serialization behavior
|
||||
*/
|
||||
export declare function render(node: AnyNode | ArrayLike<AnyNode>, options?: DomSerializerOptions): string;
|
||||
export default render;
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
-48
@@ -1,48 +0,0 @@
|
||||
/** Types of elements found in htmlparser2's DOM */
|
||||
export declare enum ElementType {
|
||||
/** Type for the root element of a document */
|
||||
Root = "root",
|
||||
/** Type for Text */
|
||||
Text = "text",
|
||||
/** Type for <? ... ?> */
|
||||
Directive = "directive",
|
||||
/** Type for <!-- ... --> */
|
||||
Comment = "comment",
|
||||
/** Type for <script> tags */
|
||||
Script = "script",
|
||||
/** Type for <style> tags */
|
||||
Style = "style",
|
||||
/** Type for Any tag */
|
||||
Tag = "tag",
|
||||
/** Type for <![CDATA[ ... ]]> */
|
||||
CDATA = "cdata",
|
||||
/** Type for <!doctype ...> */
|
||||
Doctype = "doctype"
|
||||
}
|
||||
/**
|
||||
* Tests whether an element is a tag or not.
|
||||
*
|
||||
* @param elem Element to test
|
||||
*/
|
||||
export declare function isTag(elem: {
|
||||
type: ElementType;
|
||||
}): boolean;
|
||||
/** Type for the root element of a document */
|
||||
export declare const Root = ElementType.Root;
|
||||
/** Type for Text */
|
||||
export declare const Text = ElementType.Text;
|
||||
/** Type for <? ... ?> */
|
||||
export declare const Directive = ElementType.Directive;
|
||||
/** Type for <!-- ... --> */
|
||||
export declare const Comment = ElementType.Comment;
|
||||
/** Type for <script> tags */
|
||||
export declare const Script = ElementType.Script;
|
||||
/** Type for <style> tags */
|
||||
export declare const Style = ElementType.Style;
|
||||
/** Type for Any tag */
|
||||
export declare const Tag = ElementType.Tag;
|
||||
/** Type for <![CDATA[ ... ]]> */
|
||||
export declare const CDATA = ElementType.CDATA;
|
||||
/** Type for <!doctype ...> */
|
||||
export declare const Doctype = ElementType.Doctype;
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
-48
@@ -1,48 +0,0 @@
|
||||
/** Types of elements found in htmlparser2's DOM */
|
||||
export declare enum ElementType {
|
||||
/** Type for the root element of a document */
|
||||
Root = "root",
|
||||
/** Type for Text */
|
||||
Text = "text",
|
||||
/** Type for <? ... ?> */
|
||||
Directive = "directive",
|
||||
/** Type for <!-- ... --> */
|
||||
Comment = "comment",
|
||||
/** Type for <script> tags */
|
||||
Script = "script",
|
||||
/** Type for <style> tags */
|
||||
Style = "style",
|
||||
/** Type for Any tag */
|
||||
Tag = "tag",
|
||||
/** Type for <![CDATA[ ... ]]> */
|
||||
CDATA = "cdata",
|
||||
/** Type for <!doctype ...> */
|
||||
Doctype = "doctype"
|
||||
}
|
||||
/**
|
||||
* Tests whether an element is a tag or not.
|
||||
*
|
||||
* @param elem Element to test
|
||||
*/
|
||||
export declare function isTag(elem: {
|
||||
type: ElementType;
|
||||
}): boolean;
|
||||
/** Type for the root element of a document */
|
||||
export declare const Root = ElementType.Root;
|
||||
/** Type for Text */
|
||||
export declare const Text = ElementType.Text;
|
||||
/** Type for <? ... ?> */
|
||||
export declare const Directive = ElementType.Directive;
|
||||
/** Type for <!-- ... --> */
|
||||
export declare const Comment = ElementType.Comment;
|
||||
/** Type for <script> tags */
|
||||
export declare const Script = ElementType.Script;
|
||||
/** Type for <style> tags */
|
||||
export declare const Style = ElementType.Style;
|
||||
/** Type for Any tag */
|
||||
export declare const Tag = ElementType.Tag;
|
||||
/** Type for <![CDATA[ ... ]]> */
|
||||
export declare const CDATA = ElementType.CDATA;
|
||||
/** Type for <!doctype ...> */
|
||||
export declare const Doctype = ElementType.Doctype;
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
-76
@@ -1,76 +0,0 @@
|
||||
import { ChildNode, Element, DataNode, Document, ParentNode } from "./node.js";
|
||||
export * from "./node.js";
|
||||
export interface DomHandlerOptions {
|
||||
/**
|
||||
* Add a `startIndex` property to nodes.
|
||||
* When the parser is used in a non-streaming fashion, `startIndex` is an integer
|
||||
* indicating the position of the start of the node in the document.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
withStartIndices?: boolean;
|
||||
/**
|
||||
* Add an `endIndex` property to nodes.
|
||||
* When the parser is used in a non-streaming fashion, `endIndex` is an integer
|
||||
* indicating the position of the end of the node in the document.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
withEndIndices?: boolean;
|
||||
/**
|
||||
* Treat the markup as XML.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
xmlMode?: boolean;
|
||||
}
|
||||
interface ParserInterface {
|
||||
startIndex: number | null;
|
||||
endIndex: number | null;
|
||||
}
|
||||
declare type Callback = (error: Error | null, dom: ChildNode[]) => void;
|
||||
declare type ElementCallback = (element: Element) => void;
|
||||
export declare class DomHandler {
|
||||
/** The elements of the DOM */
|
||||
dom: ChildNode[];
|
||||
/** The root element for the DOM */
|
||||
root: Document;
|
||||
/** Called once parsing has completed. */
|
||||
private readonly callback;
|
||||
/** Settings for the handler. */
|
||||
private readonly options;
|
||||
/** Callback whenever a tag is closed. */
|
||||
private readonly elementCB;
|
||||
/** Indicated whether parsing has been completed. */
|
||||
private done;
|
||||
/** Stack of open tags. */
|
||||
protected tagStack: ParentNode[];
|
||||
/** A data node that is still being written to. */
|
||||
protected lastNode: DataNode | null;
|
||||
/** Reference to the parser instance. Used for location information. */
|
||||
private parser;
|
||||
/**
|
||||
* @param callback Called once parsing has completed.
|
||||
* @param options Settings for the handler.
|
||||
* @param elementCB Callback whenever a tag is closed.
|
||||
*/
|
||||
constructor(callback?: Callback | null, options?: DomHandlerOptions | null, elementCB?: ElementCallback);
|
||||
onparserinit(parser: ParserInterface): void;
|
||||
onreset(): void;
|
||||
onend(): void;
|
||||
onerror(error: Error): void;
|
||||
onclosetag(): void;
|
||||
onopentag(name: string, attribs: {
|
||||
[key: string]: string;
|
||||
}): void;
|
||||
ontext(data: string): void;
|
||||
oncomment(data: string): void;
|
||||
oncommentend(): void;
|
||||
oncdatastart(): void;
|
||||
oncdataend(): void;
|
||||
onprocessinginstruction(name: string, data: string): void;
|
||||
protected handleCallback(error: Error | null): void;
|
||||
protected addNode(node: ChildNode): void;
|
||||
}
|
||||
export default DomHandler;
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
-245
@@ -1,245 +0,0 @@
|
||||
import { ElementType } from "domelementtype";
|
||||
interface SourceCodeLocation {
|
||||
/** One-based line index of the first character. */
|
||||
startLine: number;
|
||||
/** One-based column index of the first character. */
|
||||
startCol: number;
|
||||
/** Zero-based first character index. */
|
||||
startOffset: number;
|
||||
/** One-based line index of the last character. */
|
||||
endLine: number;
|
||||
/** One-based column index of the last character. Points directly *after* the last character. */
|
||||
endCol: number;
|
||||
/** Zero-based last character index. Points directly *after* the last character. */
|
||||
endOffset: number;
|
||||
}
|
||||
interface TagSourceCodeLocation extends SourceCodeLocation {
|
||||
startTag?: SourceCodeLocation;
|
||||
endTag?: SourceCodeLocation;
|
||||
}
|
||||
export declare type ParentNode = Document | Element | CDATA;
|
||||
export declare type ChildNode = Text | Comment | ProcessingInstruction | Element | CDATA | Document;
|
||||
export declare type AnyNode = ParentNode | ChildNode;
|
||||
/**
|
||||
* This object will be used as the prototype for Nodes when creating a
|
||||
* DOM-Level-1-compliant structure.
|
||||
*/
|
||||
export declare abstract class Node {
|
||||
/** The type of the node. */
|
||||
abstract readonly type: ElementType;
|
||||
/** Parent of the node */
|
||||
parent: ParentNode | null;
|
||||
/** Previous sibling */
|
||||
prev: ChildNode | null;
|
||||
/** Next sibling */
|
||||
next: ChildNode | null;
|
||||
/** The start index of the node. Requires `withStartIndices` on the handler to be `true. */
|
||||
startIndex: number | null;
|
||||
/** The end index of the node. Requires `withEndIndices` on the handler to be `true. */
|
||||
endIndex: number | null;
|
||||
/**
|
||||
* `parse5` source code location info.
|
||||
*
|
||||
* Available if parsing with parse5 and location info is enabled.
|
||||
*/
|
||||
sourceCodeLocation?: SourceCodeLocation | null;
|
||||
/**
|
||||
* [DOM spec](https://dom.spec.whatwg.org/#dom-node-nodetype)-compatible
|
||||
* node {@link type}.
|
||||
*/
|
||||
abstract readonly nodeType: number;
|
||||
/**
|
||||
* Same as {@link parent}.
|
||||
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
||||
*/
|
||||
get parentNode(): ParentNode | null;
|
||||
set parentNode(parent: ParentNode | null);
|
||||
/**
|
||||
* Same as {@link prev}.
|
||||
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
||||
*/
|
||||
get previousSibling(): ChildNode | null;
|
||||
set previousSibling(prev: ChildNode | null);
|
||||
/**
|
||||
* Same as {@link next}.
|
||||
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
||||
*/
|
||||
get nextSibling(): ChildNode | null;
|
||||
set nextSibling(next: ChildNode | null);
|
||||
/**
|
||||
* Clone this node, and optionally its children.
|
||||
*
|
||||
* @param recursive Clone child nodes as well.
|
||||
* @returns A clone of the node.
|
||||
*/
|
||||
cloneNode<T extends Node>(this: T, recursive?: boolean): T;
|
||||
}
|
||||
/**
|
||||
* A node that contains some data.
|
||||
*/
|
||||
export declare abstract class DataNode extends Node {
|
||||
data: string;
|
||||
/**
|
||||
* @param data The content of the data node
|
||||
*/
|
||||
constructor(data: string);
|
||||
/**
|
||||
* Same as {@link data}.
|
||||
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
||||
*/
|
||||
get nodeValue(): string;
|
||||
set nodeValue(data: string);
|
||||
}
|
||||
/**
|
||||
* Text within the document.
|
||||
*/
|
||||
export declare class Text extends DataNode {
|
||||
type: ElementType.Text;
|
||||
get nodeType(): 3;
|
||||
}
|
||||
/**
|
||||
* Comments within the document.
|
||||
*/
|
||||
export declare class Comment extends DataNode {
|
||||
type: ElementType.Comment;
|
||||
get nodeType(): 8;
|
||||
}
|
||||
/**
|
||||
* Processing instructions, including doc types.
|
||||
*/
|
||||
export declare class ProcessingInstruction extends DataNode {
|
||||
name: string;
|
||||
type: ElementType.Directive;
|
||||
constructor(name: string, data: string);
|
||||
get nodeType(): 1;
|
||||
/** If this is a doctype, the document type name (parse5 only). */
|
||||
"x-name"?: string;
|
||||
/** If this is a doctype, the document type public identifier (parse5 only). */
|
||||
"x-publicId"?: string;
|
||||
/** If this is a doctype, the document type system identifier (parse5 only). */
|
||||
"x-systemId"?: string;
|
||||
}
|
||||
/**
|
||||
* A `Node` that can have children.
|
||||
*/
|
||||
export declare abstract class NodeWithChildren extends Node {
|
||||
children: ChildNode[];
|
||||
/**
|
||||
* @param children Children of the node. Only certain node types can have children.
|
||||
*/
|
||||
constructor(children: ChildNode[]);
|
||||
/** First child of the node. */
|
||||
get firstChild(): ChildNode | null;
|
||||
/** Last child of the node. */
|
||||
get lastChild(): ChildNode | null;
|
||||
/**
|
||||
* Same as {@link children}.
|
||||
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
||||
*/
|
||||
get childNodes(): ChildNode[];
|
||||
set childNodes(children: ChildNode[]);
|
||||
}
|
||||
export declare class CDATA extends NodeWithChildren {
|
||||
type: ElementType.CDATA;
|
||||
get nodeType(): 4;
|
||||
}
|
||||
/**
|
||||
* The root node of the document.
|
||||
*/
|
||||
export declare class Document extends NodeWithChildren {
|
||||
type: ElementType.Root;
|
||||
get nodeType(): 9;
|
||||
/** [Document mode](https://dom.spec.whatwg.org/#concept-document-limited-quirks) (parse5 only). */
|
||||
"x-mode"?: "no-quirks" | "quirks" | "limited-quirks";
|
||||
}
|
||||
/**
|
||||
* The description of an individual attribute.
|
||||
*/
|
||||
interface Attribute {
|
||||
name: string;
|
||||
value: string;
|
||||
namespace?: string;
|
||||
prefix?: string;
|
||||
}
|
||||
/**
|
||||
* An element within the DOM.
|
||||
*/
|
||||
export declare class Element extends NodeWithChildren {
|
||||
name: string;
|
||||
attribs: {
|
||||
[name: string]: string;
|
||||
};
|
||||
type: ElementType.Tag | ElementType.Script | ElementType.Style;
|
||||
/**
|
||||
* @param name Name of the tag, eg. `div`, `span`.
|
||||
* @param attribs Object mapping attribute names to attribute values.
|
||||
* @param children Children of the node.
|
||||
*/
|
||||
constructor(name: string, attribs: {
|
||||
[name: string]: string;
|
||||
}, children?: ChildNode[], type?: ElementType.Tag | ElementType.Script | ElementType.Style);
|
||||
get nodeType(): 1;
|
||||
/**
|
||||
* `parse5` source code location info, with start & end tags.
|
||||
*
|
||||
* Available if parsing with parse5 and location info is enabled.
|
||||
*/
|
||||
sourceCodeLocation?: TagSourceCodeLocation | null;
|
||||
/**
|
||||
* Same as {@link name}.
|
||||
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
||||
*/
|
||||
get tagName(): string;
|
||||
set tagName(name: string);
|
||||
get attributes(): Attribute[];
|
||||
/** Element namespace (parse5 only). */
|
||||
namespace?: string;
|
||||
/** Element attribute namespaces (parse5 only). */
|
||||
"x-attribsNamespace"?: Record<string, string>;
|
||||
/** Element attribute namespace-related prefixes (parse5 only). */
|
||||
"x-attribsPrefix"?: Record<string, string>;
|
||||
}
|
||||
/**
|
||||
* @param node Node to check.
|
||||
* @returns `true` if the node is a `Element`, `false` otherwise.
|
||||
*/
|
||||
export declare function isTag(node: Node): node is Element;
|
||||
/**
|
||||
* @param node Node to check.
|
||||
* @returns `true` if the node has the type `CDATA`, `false` otherwise.
|
||||
*/
|
||||
export declare function isCDATA(node: Node): node is CDATA;
|
||||
/**
|
||||
* @param node Node to check.
|
||||
* @returns `true` if the node has the type `Text`, `false` otherwise.
|
||||
*/
|
||||
export declare function isText(node: Node): node is Text;
|
||||
/**
|
||||
* @param node Node to check.
|
||||
* @returns `true` if the node has the type `Comment`, `false` otherwise.
|
||||
*/
|
||||
export declare function isComment(node: Node): node is Comment;
|
||||
/**
|
||||
* @param node Node to check.
|
||||
* @returns `true` if the node has the type `ProcessingInstruction`, `false` otherwise.
|
||||
*/
|
||||
export declare function isDirective(node: Node): node is ProcessingInstruction;
|
||||
/**
|
||||
* @param node Node to check.
|
||||
* @returns `true` if the node has the type `ProcessingInstruction`, `false` otherwise.
|
||||
*/
|
||||
export declare function isDocument(node: Node): node is Document;
|
||||
/**
|
||||
* @param node Node to check.
|
||||
* @returns `true` if the node has children, `false` otherwise.
|
||||
*/
|
||||
export declare function hasChildren(node: Node): node is ParentNode;
|
||||
/**
|
||||
* Clone a node, and optionally its children.
|
||||
*
|
||||
* @param recursive Clone child nodes as well.
|
||||
* @returns A clone of the node.
|
||||
*/
|
||||
export declare function cloneNode<T extends Node>(node: T, recursive?: boolean): T;
|
||||
export {};
|
||||
//# sourceMappingURL=node.d.ts.map
|
||||
-76
@@ -1,76 +0,0 @@
|
||||
import { ChildNode, Element, DataNode, Document, ParentNode } from "./node.js";
|
||||
export * from "./node.js";
|
||||
export interface DomHandlerOptions {
|
||||
/**
|
||||
* Add a `startIndex` property to nodes.
|
||||
* When the parser is used in a non-streaming fashion, `startIndex` is an integer
|
||||
* indicating the position of the start of the node in the document.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
withStartIndices?: boolean;
|
||||
/**
|
||||
* Add an `endIndex` property to nodes.
|
||||
* When the parser is used in a non-streaming fashion, `endIndex` is an integer
|
||||
* indicating the position of the end of the node in the document.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
withEndIndices?: boolean;
|
||||
/**
|
||||
* Treat the markup as XML.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
xmlMode?: boolean;
|
||||
}
|
||||
interface ParserInterface {
|
||||
startIndex: number | null;
|
||||
endIndex: number | null;
|
||||
}
|
||||
declare type Callback = (error: Error | null, dom: ChildNode[]) => void;
|
||||
declare type ElementCallback = (element: Element) => void;
|
||||
export declare class DomHandler {
|
||||
/** The elements of the DOM */
|
||||
dom: ChildNode[];
|
||||
/** The root element for the DOM */
|
||||
root: Document;
|
||||
/** Called once parsing has completed. */
|
||||
private readonly callback;
|
||||
/** Settings for the handler. */
|
||||
private readonly options;
|
||||
/** Callback whenever a tag is closed. */
|
||||
private readonly elementCB;
|
||||
/** Indicated whether parsing has been completed. */
|
||||
private done;
|
||||
/** Stack of open tags. */
|
||||
protected tagStack: ParentNode[];
|
||||
/** A data node that is still being written to. */
|
||||
protected lastNode: DataNode | null;
|
||||
/** Reference to the parser instance. Used for location information. */
|
||||
private parser;
|
||||
/**
|
||||
* @param callback Called once parsing has completed.
|
||||
* @param options Settings for the handler.
|
||||
* @param elementCB Callback whenever a tag is closed.
|
||||
*/
|
||||
constructor(callback?: Callback | null, options?: DomHandlerOptions | null, elementCB?: ElementCallback);
|
||||
onparserinit(parser: ParserInterface): void;
|
||||
onreset(): void;
|
||||
onend(): void;
|
||||
onerror(error: Error): void;
|
||||
onclosetag(): void;
|
||||
onopentag(name: string, attribs: {
|
||||
[key: string]: string;
|
||||
}): void;
|
||||
ontext(data: string): void;
|
||||
oncomment(data: string): void;
|
||||
oncommentend(): void;
|
||||
oncdatastart(): void;
|
||||
oncdataend(): void;
|
||||
onprocessinginstruction(name: string, data: string): void;
|
||||
protected handleCallback(error: Error | null): void;
|
||||
protected addNode(node: ChildNode): void;
|
||||
}
|
||||
export default DomHandler;
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
-245
@@ -1,245 +0,0 @@
|
||||
import { ElementType } from "domelementtype";
|
||||
interface SourceCodeLocation {
|
||||
/** One-based line index of the first character. */
|
||||
startLine: number;
|
||||
/** One-based column index of the first character. */
|
||||
startCol: number;
|
||||
/** Zero-based first character index. */
|
||||
startOffset: number;
|
||||
/** One-based line index of the last character. */
|
||||
endLine: number;
|
||||
/** One-based column index of the last character. Points directly *after* the last character. */
|
||||
endCol: number;
|
||||
/** Zero-based last character index. Points directly *after* the last character. */
|
||||
endOffset: number;
|
||||
}
|
||||
interface TagSourceCodeLocation extends SourceCodeLocation {
|
||||
startTag?: SourceCodeLocation;
|
||||
endTag?: SourceCodeLocation;
|
||||
}
|
||||
export declare type ParentNode = Document | Element | CDATA;
|
||||
export declare type ChildNode = Text | Comment | ProcessingInstruction | Element | CDATA | Document;
|
||||
export declare type AnyNode = ParentNode | ChildNode;
|
||||
/**
|
||||
* This object will be used as the prototype for Nodes when creating a
|
||||
* DOM-Level-1-compliant structure.
|
||||
*/
|
||||
export declare abstract class Node {
|
||||
/** The type of the node. */
|
||||
abstract readonly type: ElementType;
|
||||
/** Parent of the node */
|
||||
parent: ParentNode | null;
|
||||
/** Previous sibling */
|
||||
prev: ChildNode | null;
|
||||
/** Next sibling */
|
||||
next: ChildNode | null;
|
||||
/** The start index of the node. Requires `withStartIndices` on the handler to be `true. */
|
||||
startIndex: number | null;
|
||||
/** The end index of the node. Requires `withEndIndices` on the handler to be `true. */
|
||||
endIndex: number | null;
|
||||
/**
|
||||
* `parse5` source code location info.
|
||||
*
|
||||
* Available if parsing with parse5 and location info is enabled.
|
||||
*/
|
||||
sourceCodeLocation?: SourceCodeLocation | null;
|
||||
/**
|
||||
* [DOM spec](https://dom.spec.whatwg.org/#dom-node-nodetype)-compatible
|
||||
* node {@link type}.
|
||||
*/
|
||||
abstract readonly nodeType: number;
|
||||
/**
|
||||
* Same as {@link parent}.
|
||||
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
||||
*/
|
||||
get parentNode(): ParentNode | null;
|
||||
set parentNode(parent: ParentNode | null);
|
||||
/**
|
||||
* Same as {@link prev}.
|
||||
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
||||
*/
|
||||
get previousSibling(): ChildNode | null;
|
||||
set previousSibling(prev: ChildNode | null);
|
||||
/**
|
||||
* Same as {@link next}.
|
||||
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
||||
*/
|
||||
get nextSibling(): ChildNode | null;
|
||||
set nextSibling(next: ChildNode | null);
|
||||
/**
|
||||
* Clone this node, and optionally its children.
|
||||
*
|
||||
* @param recursive Clone child nodes as well.
|
||||
* @returns A clone of the node.
|
||||
*/
|
||||
cloneNode<T extends Node>(this: T, recursive?: boolean): T;
|
||||
}
|
||||
/**
|
||||
* A node that contains some data.
|
||||
*/
|
||||
export declare abstract class DataNode extends Node {
|
||||
data: string;
|
||||
/**
|
||||
* @param data The content of the data node
|
||||
*/
|
||||
constructor(data: string);
|
||||
/**
|
||||
* Same as {@link data}.
|
||||
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
||||
*/
|
||||
get nodeValue(): string;
|
||||
set nodeValue(data: string);
|
||||
}
|
||||
/**
|
||||
* Text within the document.
|
||||
*/
|
||||
export declare class Text extends DataNode {
|
||||
type: ElementType.Text;
|
||||
get nodeType(): 3;
|
||||
}
|
||||
/**
|
||||
* Comments within the document.
|
||||
*/
|
||||
export declare class Comment extends DataNode {
|
||||
type: ElementType.Comment;
|
||||
get nodeType(): 8;
|
||||
}
|
||||
/**
|
||||
* Processing instructions, including doc types.
|
||||
*/
|
||||
export declare class ProcessingInstruction extends DataNode {
|
||||
name: string;
|
||||
type: ElementType.Directive;
|
||||
constructor(name: string, data: string);
|
||||
get nodeType(): 1;
|
||||
/** If this is a doctype, the document type name (parse5 only). */
|
||||
"x-name"?: string;
|
||||
/** If this is a doctype, the document type public identifier (parse5 only). */
|
||||
"x-publicId"?: string;
|
||||
/** If this is a doctype, the document type system identifier (parse5 only). */
|
||||
"x-systemId"?: string;
|
||||
}
|
||||
/**
|
||||
* A `Node` that can have children.
|
||||
*/
|
||||
export declare abstract class NodeWithChildren extends Node {
|
||||
children: ChildNode[];
|
||||
/**
|
||||
* @param children Children of the node. Only certain node types can have children.
|
||||
*/
|
||||
constructor(children: ChildNode[]);
|
||||
/** First child of the node. */
|
||||
get firstChild(): ChildNode | null;
|
||||
/** Last child of the node. */
|
||||
get lastChild(): ChildNode | null;
|
||||
/**
|
||||
* Same as {@link children}.
|
||||
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
||||
*/
|
||||
get childNodes(): ChildNode[];
|
||||
set childNodes(children: ChildNode[]);
|
||||
}
|
||||
export declare class CDATA extends NodeWithChildren {
|
||||
type: ElementType.CDATA;
|
||||
get nodeType(): 4;
|
||||
}
|
||||
/**
|
||||
* The root node of the document.
|
||||
*/
|
||||
export declare class Document extends NodeWithChildren {
|
||||
type: ElementType.Root;
|
||||
get nodeType(): 9;
|
||||
/** [Document mode](https://dom.spec.whatwg.org/#concept-document-limited-quirks) (parse5 only). */
|
||||
"x-mode"?: "no-quirks" | "quirks" | "limited-quirks";
|
||||
}
|
||||
/**
|
||||
* The description of an individual attribute.
|
||||
*/
|
||||
interface Attribute {
|
||||
name: string;
|
||||
value: string;
|
||||
namespace?: string;
|
||||
prefix?: string;
|
||||
}
|
||||
/**
|
||||
* An element within the DOM.
|
||||
*/
|
||||
export declare class Element extends NodeWithChildren {
|
||||
name: string;
|
||||
attribs: {
|
||||
[name: string]: string;
|
||||
};
|
||||
type: ElementType.Tag | ElementType.Script | ElementType.Style;
|
||||
/**
|
||||
* @param name Name of the tag, eg. `div`, `span`.
|
||||
* @param attribs Object mapping attribute names to attribute values.
|
||||
* @param children Children of the node.
|
||||
*/
|
||||
constructor(name: string, attribs: {
|
||||
[name: string]: string;
|
||||
}, children?: ChildNode[], type?: ElementType.Tag | ElementType.Script | ElementType.Style);
|
||||
get nodeType(): 1;
|
||||
/**
|
||||
* `parse5` source code location info, with start & end tags.
|
||||
*
|
||||
* Available if parsing with parse5 and location info is enabled.
|
||||
*/
|
||||
sourceCodeLocation?: TagSourceCodeLocation | null;
|
||||
/**
|
||||
* Same as {@link name}.
|
||||
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
||||
*/
|
||||
get tagName(): string;
|
||||
set tagName(name: string);
|
||||
get attributes(): Attribute[];
|
||||
/** Element namespace (parse5 only). */
|
||||
namespace?: string;
|
||||
/** Element attribute namespaces (parse5 only). */
|
||||
"x-attribsNamespace"?: Record<string, string>;
|
||||
/** Element attribute namespace-related prefixes (parse5 only). */
|
||||
"x-attribsPrefix"?: Record<string, string>;
|
||||
}
|
||||
/**
|
||||
* @param node Node to check.
|
||||
* @returns `true` if the node is a `Element`, `false` otherwise.
|
||||
*/
|
||||
export declare function isTag(node: Node): node is Element;
|
||||
/**
|
||||
* @param node Node to check.
|
||||
* @returns `true` if the node has the type `CDATA`, `false` otherwise.
|
||||
*/
|
||||
export declare function isCDATA(node: Node): node is CDATA;
|
||||
/**
|
||||
* @param node Node to check.
|
||||
* @returns `true` if the node has the type `Text`, `false` otherwise.
|
||||
*/
|
||||
export declare function isText(node: Node): node is Text;
|
||||
/**
|
||||
* @param node Node to check.
|
||||
* @returns `true` if the node has the type `Comment`, `false` otherwise.
|
||||
*/
|
||||
export declare function isComment(node: Node): node is Comment;
|
||||
/**
|
||||
* @param node Node to check.
|
||||
* @returns `true` if the node has the type `ProcessingInstruction`, `false` otherwise.
|
||||
*/
|
||||
export declare function isDirective(node: Node): node is ProcessingInstruction;
|
||||
/**
|
||||
* @param node Node to check.
|
||||
* @returns `true` if the node has the type `ProcessingInstruction`, `false` otherwise.
|
||||
*/
|
||||
export declare function isDocument(node: Node): node is Document;
|
||||
/**
|
||||
* @param node Node to check.
|
||||
* @returns `true` if the node has children, `false` otherwise.
|
||||
*/
|
||||
export declare function hasChildren(node: Node): node is ParentNode;
|
||||
/**
|
||||
* Clone a node, and optionally its children.
|
||||
*
|
||||
* @param recursive Clone child nodes as well.
|
||||
* @returns A clone of the node.
|
||||
*/
|
||||
export declare function cloneNode<T extends Node>(node: T, recursive?: boolean): T;
|
||||
export {};
|
||||
//# sourceMappingURL=node.d.ts.map
|
||||
-71
@@ -1,71 +0,0 @@
|
||||
import type { AnyNode } from "domhandler";
|
||||
/**
|
||||
* The medium of a media item.
|
||||
*
|
||||
* @category Feeds
|
||||
*/
|
||||
export type FeedItemMediaMedium = "image" | "audio" | "video" | "document" | "executable";
|
||||
/**
|
||||
* The type of a media item.
|
||||
*
|
||||
* @category Feeds
|
||||
*/
|
||||
export type FeedItemMediaExpression = "sample" | "full" | "nonstop";
|
||||
/**
|
||||
* A media item of a feed entry.
|
||||
*
|
||||
* @category Feeds
|
||||
*/
|
||||
export interface FeedItemMedia {
|
||||
medium: FeedItemMediaMedium | undefined;
|
||||
isDefault: boolean;
|
||||
url?: string;
|
||||
fileSize?: number;
|
||||
type?: string;
|
||||
expression?: FeedItemMediaExpression;
|
||||
bitrate?: number;
|
||||
framerate?: number;
|
||||
samplingrate?: number;
|
||||
channels?: number;
|
||||
duration?: number;
|
||||
height?: number;
|
||||
width?: number;
|
||||
lang?: string;
|
||||
}
|
||||
/**
|
||||
* An entry of a feed.
|
||||
*
|
||||
* @category Feeds
|
||||
*/
|
||||
export interface FeedItem {
|
||||
id?: string;
|
||||
title?: string;
|
||||
link?: string;
|
||||
description?: string;
|
||||
pubDate?: Date;
|
||||
media: FeedItemMedia[];
|
||||
}
|
||||
/**
|
||||
* The root of a feed.
|
||||
*
|
||||
* @category Feeds
|
||||
*/
|
||||
export interface Feed {
|
||||
type: string;
|
||||
id?: string;
|
||||
title?: string;
|
||||
link?: string;
|
||||
description?: string;
|
||||
updated?: Date;
|
||||
author?: string;
|
||||
items: FeedItem[];
|
||||
}
|
||||
/**
|
||||
* Get the feed object from the root of a DOM tree.
|
||||
*
|
||||
* @category Feeds
|
||||
* @param doc - The DOM to to extract the feed from.
|
||||
* @returns The feed.
|
||||
*/
|
||||
export declare function getFeed(doc: AnyNode[]): Feed | null;
|
||||
//# sourceMappingURL=feeds.d.ts.map
|
||||
-59
@@ -1,59 +0,0 @@
|
||||
import { AnyNode } from "domhandler";
|
||||
/**
|
||||
* Given an array of nodes, remove any member that is contained by another
|
||||
* member.
|
||||
*
|
||||
* @category Helpers
|
||||
* @param nodes Nodes to filter.
|
||||
* @returns Remaining nodes that aren't contained by other nodes.
|
||||
*/
|
||||
export declare function removeSubsets(nodes: AnyNode[]): AnyNode[];
|
||||
/**
|
||||
* @category Helpers
|
||||
* @see {@link http://dom.spec.whatwg.org/#dom-node-comparedocumentposition}
|
||||
*/
|
||||
export declare const enum DocumentPosition {
|
||||
DISCONNECTED = 1,
|
||||
PRECEDING = 2,
|
||||
FOLLOWING = 4,
|
||||
CONTAINS = 8,
|
||||
CONTAINED_BY = 16
|
||||
}
|
||||
/**
|
||||
* Compare the position of one node against another node in any other document,
|
||||
* returning a bitmask with the values from {@link DocumentPosition}.
|
||||
*
|
||||
* Document order:
|
||||
* > There is an ordering, document order, defined on all the nodes in the
|
||||
* > document corresponding to the order in which the first character of the
|
||||
* > XML representation of each node occurs in the XML representation of the
|
||||
* > document after expansion of general entities. Thus, the document element
|
||||
* > node will be the first node. Element nodes occur before their children.
|
||||
* > Thus, document order orders element nodes in order of the occurrence of
|
||||
* > their start-tag in the XML (after expansion of entities). The attribute
|
||||
* > nodes of an element occur after the element and before its children. The
|
||||
* > relative order of attribute nodes is implementation-dependent.
|
||||
*
|
||||
* Source:
|
||||
* http://www.w3.org/TR/DOM-Level-3-Core/glossary.html#dt-document-order
|
||||
*
|
||||
* @category Helpers
|
||||
* @param nodeA The first node to use in the comparison
|
||||
* @param nodeB The second node to use in the comparison
|
||||
* @returns A bitmask describing the input nodes' relative position.
|
||||
*
|
||||
* See http://dom.spec.whatwg.org/#dom-node-comparedocumentposition for
|
||||
* a description of these values.
|
||||
*/
|
||||
export declare function compareDocumentPosition(nodeA: AnyNode, nodeB: AnyNode): number;
|
||||
/**
|
||||
* Sort an array of nodes based on their relative position in the document,
|
||||
* removing any duplicate nodes. If the array contains nodes that do not belong
|
||||
* to the same document, sort order is unspecified.
|
||||
*
|
||||
* @category Helpers
|
||||
* @param nodes Array of DOM nodes.
|
||||
* @returns Collection of unique nodes, sorted in document order.
|
||||
*/
|
||||
export declare function uniqueSort<T extends AnyNode>(nodes: T[]): T[];
|
||||
//# sourceMappingURL=helpers.d.ts.map
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
export * from "./stringify.js";
|
||||
export * from "./traversal.js";
|
||||
export * from "./manipulation.js";
|
||||
export * from "./querying.js";
|
||||
export * from "./legacy.js";
|
||||
export * from "./helpers.js";
|
||||
export * from "./feeds.js";
|
||||
/** @deprecated Use these methods from `domhandler` directly. */
|
||||
export { isTag, isCDATA, isText, isComment, isDocument, hasChildren, } from "domhandler";
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
-79
@@ -1,79 +0,0 @@
|
||||
import { AnyNode, Element } from "domhandler";
|
||||
import type { ElementType } from "domelementtype";
|
||||
/**
|
||||
* An object with keys to check elements against. If a key is `tag_name`,
|
||||
* `tag_type` or `tag_contains`, it will check the value against that specific
|
||||
* value. Otherwise, it will check an attribute with the key's name.
|
||||
*
|
||||
* @category Legacy Query Functions
|
||||
*/
|
||||
export interface TestElementOpts {
|
||||
tag_name?: string | ((name: string) => boolean);
|
||||
tag_type?: string | ((name: string) => boolean);
|
||||
tag_contains?: string | ((data?: string) => boolean);
|
||||
[attributeName: string]: undefined | string | ((attributeValue: string) => boolean);
|
||||
}
|
||||
/**
|
||||
* Checks whether a node matches the description in `options`.
|
||||
*
|
||||
* @category Legacy Query Functions
|
||||
* @param options An object describing nodes to look for.
|
||||
* @param node The element to test.
|
||||
* @returns Whether the element matches the description in `options`.
|
||||
*/
|
||||
export declare function testElement(options: TestElementOpts, node: AnyNode): boolean;
|
||||
/**
|
||||
* Returns all nodes that match `options`.
|
||||
*
|
||||
* @category Legacy Query Functions
|
||||
* @param options An object describing nodes to look for.
|
||||
* @param nodes Nodes to search through.
|
||||
* @param recurse Also consider child nodes.
|
||||
* @param limit Maximum number of nodes to return.
|
||||
* @returns All nodes that match `options`.
|
||||
*/
|
||||
export declare function getElements(options: TestElementOpts, nodes: AnyNode | AnyNode[], recurse: boolean, limit?: number): AnyNode[];
|
||||
/**
|
||||
* Returns the node with the supplied ID.
|
||||
*
|
||||
* @category Legacy Query Functions
|
||||
* @param id The unique ID attribute value to look for.
|
||||
* @param nodes Nodes to search through.
|
||||
* @param recurse Also consider child nodes.
|
||||
* @returns The node with the supplied ID.
|
||||
*/
|
||||
export declare function getElementById(id: string | ((id: string) => boolean), nodes: AnyNode | AnyNode[], recurse?: boolean): Element | null;
|
||||
/**
|
||||
* Returns all nodes with the supplied `tagName`.
|
||||
*
|
||||
* @category Legacy Query Functions
|
||||
* @param tagName Tag name to search for.
|
||||
* @param nodes Nodes to search through.
|
||||
* @param recurse Also consider child nodes.
|
||||
* @param limit Maximum number of nodes to return.
|
||||
* @returns All nodes with the supplied `tagName`.
|
||||
*/
|
||||
export declare function getElementsByTagName(tagName: string | ((name: string) => boolean), nodes: AnyNode | AnyNode[], recurse?: boolean, limit?: number): Element[];
|
||||
/**
|
||||
* Returns all nodes with the supplied `className`.
|
||||
*
|
||||
* @category Legacy Query Functions
|
||||
* @param className Class name to search for.
|
||||
* @param nodes Nodes to search through.
|
||||
* @param recurse Also consider child nodes.
|
||||
* @param limit Maximum number of nodes to return.
|
||||
* @returns All nodes with the supplied `className`.
|
||||
*/
|
||||
export declare function getElementsByClassName(className: string | ((name: string) => boolean), nodes: AnyNode | AnyNode[], recurse?: boolean, limit?: number): Element[];
|
||||
/**
|
||||
* Returns all nodes with the supplied `type`.
|
||||
*
|
||||
* @category Legacy Query Functions
|
||||
* @param type Element type to look for.
|
||||
* @param nodes Nodes to search through.
|
||||
* @param recurse Also consider child nodes.
|
||||
* @param limit Maximum number of nodes to return.
|
||||
* @returns All nodes with the supplied `type`.
|
||||
*/
|
||||
export declare function getElementsByTagType(type: ElementType | ((type: ElementType) => boolean), nodes: AnyNode | AnyNode[], recurse?: boolean, limit?: number): AnyNode[];
|
||||
//# sourceMappingURL=legacy.d.ts.map
|
||||
-49
@@ -1,49 +0,0 @@
|
||||
import type { ChildNode, ParentNode } from "domhandler";
|
||||
/**
|
||||
* Remove an element from the dom
|
||||
*
|
||||
* @category Manipulation
|
||||
* @param elem The element to be removed
|
||||
*/
|
||||
export declare function removeElement(elem: ChildNode): void;
|
||||
/**
|
||||
* Replace an element in the dom
|
||||
*
|
||||
* @category Manipulation
|
||||
* @param elem The element to be replaced
|
||||
* @param replacement The element to be added
|
||||
*/
|
||||
export declare function replaceElement(elem: ChildNode, replacement: ChildNode): void;
|
||||
/**
|
||||
* Append a child to an element.
|
||||
*
|
||||
* @category Manipulation
|
||||
* @param parent The element to append to.
|
||||
* @param child The element to be added as a child.
|
||||
*/
|
||||
export declare function appendChild(parent: ParentNode, child: ChildNode): void;
|
||||
/**
|
||||
* Append an element after another.
|
||||
*
|
||||
* @category Manipulation
|
||||
* @param elem The element to append after.
|
||||
* @param next The element be added.
|
||||
*/
|
||||
export declare function append(elem: ChildNode, next: ChildNode): void;
|
||||
/**
|
||||
* Prepend a child to an element.
|
||||
*
|
||||
* @category Manipulation
|
||||
* @param parent The element to prepend before.
|
||||
* @param child The element to be added as a child.
|
||||
*/
|
||||
export declare function prependChild(parent: ParentNode, child: ChildNode): void;
|
||||
/**
|
||||
* Prepend an element before another.
|
||||
*
|
||||
* @category Manipulation
|
||||
* @param elem The element to prepend before.
|
||||
* @param prev The element be added.
|
||||
*/
|
||||
export declare function prepend(elem: ChildNode, prev: ChildNode): void;
|
||||
//# sourceMappingURL=manipulation.d.ts.map
|
||||
-64
@@ -1,64 +0,0 @@
|
||||
import { Element, AnyNode, ParentNode } from "domhandler";
|
||||
/**
|
||||
* Search a node and its children for nodes passing a test function. If `node` is not an array, it will be wrapped in one.
|
||||
*
|
||||
* @category Querying
|
||||
* @param test Function to test nodes on.
|
||||
* @param node Node to search. Will be included in the result set if it matches.
|
||||
* @param recurse Also consider child nodes.
|
||||
* @param limit Maximum number of nodes to return.
|
||||
* @returns All nodes passing `test`.
|
||||
*/
|
||||
export declare function filter(test: (elem: AnyNode) => boolean, node: AnyNode | AnyNode[], recurse?: boolean, limit?: number): AnyNode[];
|
||||
/**
|
||||
* Search an array of nodes and their children for nodes passing a test function.
|
||||
*
|
||||
* @category Querying
|
||||
* @param test Function to test nodes on.
|
||||
* @param nodes Array of nodes to search.
|
||||
* @param recurse Also consider child nodes.
|
||||
* @param limit Maximum number of nodes to return.
|
||||
* @returns All nodes passing `test`.
|
||||
*/
|
||||
export declare function find(test: (elem: AnyNode) => boolean, nodes: AnyNode[] | ParentNode, recurse: boolean, limit: number): AnyNode[];
|
||||
/**
|
||||
* Finds the first element inside of an array that matches a test function. This is an alias for `Array.prototype.find`.
|
||||
*
|
||||
* @category Querying
|
||||
* @param test Function to test nodes on.
|
||||
* @param nodes Array of nodes to search.
|
||||
* @returns The first node in the array that passes `test`.
|
||||
* @deprecated Use `Array.prototype.find` directly.
|
||||
*/
|
||||
export declare function findOneChild<T>(test: (elem: T) => boolean, nodes: T[]): T | undefined;
|
||||
/**
|
||||
* Finds one element in a tree that passes a test.
|
||||
*
|
||||
* @category Querying
|
||||
* @param test Function to test nodes on.
|
||||
* @param nodes Node or array of nodes to search.
|
||||
* @param recurse Also consider child nodes.
|
||||
* @returns The first node that passes `test`.
|
||||
*/
|
||||
export declare function findOne(test: (elem: Element) => boolean, nodes: AnyNode[] | ParentNode, recurse?: boolean): Element | null;
|
||||
/**
|
||||
* Checks if a tree of nodes contains at least one node passing a test.
|
||||
*
|
||||
* @category Querying
|
||||
* @param test Function to test nodes on.
|
||||
* @param nodes Array of nodes to search.
|
||||
* @returns Whether a tree of nodes contains at least one node passing the test.
|
||||
*/
|
||||
export declare function existsOne(test: (elem: Element) => boolean, nodes: AnyNode[] | ParentNode): boolean;
|
||||
/**
|
||||
* Search an array of nodes and their children for elements passing a test function.
|
||||
*
|
||||
* Same as `find`, but limited to elements and with less options, leading to reduced complexity.
|
||||
*
|
||||
* @category Querying
|
||||
* @param test Function to test nodes on.
|
||||
* @param nodes Array of nodes to search.
|
||||
* @returns All nodes passing `test`.
|
||||
*/
|
||||
export declare function findAll(test: (elem: Element) => boolean, nodes: AnyNode[] | ParentNode): Element[];
|
||||
//# sourceMappingURL=querying.d.ts.map
|
||||
-46
@@ -1,46 +0,0 @@
|
||||
import { AnyNode } from "domhandler";
|
||||
import { DomSerializerOptions } from "dom-serializer";
|
||||
/**
|
||||
* @category Stringify
|
||||
* @deprecated Use the `dom-serializer` module directly.
|
||||
* @param node Node to get the outer HTML of.
|
||||
* @param options Options for serialization.
|
||||
* @returns `node`'s outer HTML.
|
||||
*/
|
||||
export declare function getOuterHTML(node: AnyNode | ArrayLike<AnyNode>, options?: DomSerializerOptions): string;
|
||||
/**
|
||||
* @category Stringify
|
||||
* @deprecated Use the `dom-serializer` module directly.
|
||||
* @param node Node to get the inner HTML of.
|
||||
* @param options Options for serialization.
|
||||
* @returns `node`'s inner HTML.
|
||||
*/
|
||||
export declare function getInnerHTML(node: AnyNode, options?: DomSerializerOptions): string;
|
||||
/**
|
||||
* Get a node's inner text. Same as `textContent`, but inserts newlines for `<br>` tags. Ignores comments.
|
||||
*
|
||||
* @category Stringify
|
||||
* @deprecated Use `textContent` instead.
|
||||
* @param node Node to get the inner text of.
|
||||
* @returns `node`'s inner text.
|
||||
*/
|
||||
export declare function getText(node: AnyNode | AnyNode[]): string;
|
||||
/**
|
||||
* Get a node's text content. Ignores comments.
|
||||
*
|
||||
* @category Stringify
|
||||
* @param node Node to get the text content of.
|
||||
* @returns `node`'s text content.
|
||||
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent}
|
||||
*/
|
||||
export declare function textContent(node: AnyNode | AnyNode[]): string;
|
||||
/**
|
||||
* Get a node's inner text, ignoring `<script>` and `<style>` tags. Ignores comments.
|
||||
*
|
||||
* @category Stringify
|
||||
* @param node Node to get the inner text of.
|
||||
* @returns `node`'s inner text.
|
||||
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/innerText}
|
||||
*/
|
||||
export declare function innerText(node: AnyNode | AnyNode[]): string;
|
||||
//# sourceMappingURL=stringify.d.ts.map
|
||||
-67
@@ -1,67 +0,0 @@
|
||||
import { AnyNode, ChildNode, Element, ParentNode } from "domhandler";
|
||||
/**
|
||||
* Get a node's children.
|
||||
*
|
||||
* @category Traversal
|
||||
* @param elem Node to get the children of.
|
||||
* @returns `elem`'s children, or an empty array.
|
||||
*/
|
||||
export declare function getChildren(elem: AnyNode): ChildNode[];
|
||||
export declare function getParent(elem: AnyNode): ParentNode | null;
|
||||
/**
|
||||
* Gets an elements siblings, including the element itself.
|
||||
*
|
||||
* Attempts to get the children through the element's parent first. If we don't
|
||||
* have a parent (the element is a root node), we walk the element's `prev` &
|
||||
* `next` to get all remaining nodes.
|
||||
*
|
||||
* @category Traversal
|
||||
* @param elem Element to get the siblings of.
|
||||
* @returns `elem`'s siblings, including `elem`.
|
||||
*/
|
||||
export declare function getSiblings(elem: AnyNode): AnyNode[];
|
||||
/**
|
||||
* Gets an attribute from an element.
|
||||
*
|
||||
* @category Traversal
|
||||
* @param elem Element to check.
|
||||
* @param name Attribute name to retrieve.
|
||||
* @returns The element's attribute value, or `undefined`.
|
||||
*/
|
||||
export declare function getAttributeValue(elem: Element, name: string): string | undefined;
|
||||
/**
|
||||
* Checks whether an element has an attribute.
|
||||
*
|
||||
* @category Traversal
|
||||
* @param elem Element to check.
|
||||
* @param name Attribute name to look for.
|
||||
* @returns Returns whether `elem` has the attribute `name`.
|
||||
*/
|
||||
export declare function hasAttrib(elem: Element, name: string): boolean;
|
||||
/**
|
||||
* Get the tag name of an element.
|
||||
*
|
||||
* @category Traversal
|
||||
* @param elem The element to get the name for.
|
||||
* @returns The tag name of `elem`.
|
||||
*/
|
||||
export declare function getName(elem: Element): string;
|
||||
/**
|
||||
* Returns the next element sibling of a node.
|
||||
*
|
||||
* @category Traversal
|
||||
* @param elem The element to get the next sibling of.
|
||||
* @returns `elem`'s next sibling that is a tag, or `null` if there is no next
|
||||
* sibling.
|
||||
*/
|
||||
export declare function nextElementSibling(elem: AnyNode): Element | null;
|
||||
/**
|
||||
* Returns the previous element sibling of a node.
|
||||
*
|
||||
* @category Traversal
|
||||
* @param elem The element to get the previous sibling of.
|
||||
* @returns `elem`'s previous sibling that is a tag, or `null` if there is no
|
||||
* previous sibling.
|
||||
*/
|
||||
export declare function prevElementSibling(elem: AnyNode): Element | null;
|
||||
//# sourceMappingURL=traversal.d.ts.map
|
||||
-71
@@ -1,71 +0,0 @@
|
||||
import type { AnyNode } from "domhandler";
|
||||
/**
|
||||
* The medium of a media item.
|
||||
*
|
||||
* @category Feeds
|
||||
*/
|
||||
export type FeedItemMediaMedium = "image" | "audio" | "video" | "document" | "executable";
|
||||
/**
|
||||
* The type of a media item.
|
||||
*
|
||||
* @category Feeds
|
||||
*/
|
||||
export type FeedItemMediaExpression = "sample" | "full" | "nonstop";
|
||||
/**
|
||||
* A media item of a feed entry.
|
||||
*
|
||||
* @category Feeds
|
||||
*/
|
||||
export interface FeedItemMedia {
|
||||
medium: FeedItemMediaMedium | undefined;
|
||||
isDefault: boolean;
|
||||
url?: string;
|
||||
fileSize?: number;
|
||||
type?: string;
|
||||
expression?: FeedItemMediaExpression;
|
||||
bitrate?: number;
|
||||
framerate?: number;
|
||||
samplingrate?: number;
|
||||
channels?: number;
|
||||
duration?: number;
|
||||
height?: number;
|
||||
width?: number;
|
||||
lang?: string;
|
||||
}
|
||||
/**
|
||||
* An entry of a feed.
|
||||
*
|
||||
* @category Feeds
|
||||
*/
|
||||
export interface FeedItem {
|
||||
id?: string;
|
||||
title?: string;
|
||||
link?: string;
|
||||
description?: string;
|
||||
pubDate?: Date;
|
||||
media: FeedItemMedia[];
|
||||
}
|
||||
/**
|
||||
* The root of a feed.
|
||||
*
|
||||
* @category Feeds
|
||||
*/
|
||||
export interface Feed {
|
||||
type: string;
|
||||
id?: string;
|
||||
title?: string;
|
||||
link?: string;
|
||||
description?: string;
|
||||
updated?: Date;
|
||||
author?: string;
|
||||
items: FeedItem[];
|
||||
}
|
||||
/**
|
||||
* Get the feed object from the root of a DOM tree.
|
||||
*
|
||||
* @category Feeds
|
||||
* @param doc - The DOM to to extract the feed from.
|
||||
* @returns The feed.
|
||||
*/
|
||||
export declare function getFeed(doc: AnyNode[]): Feed | null;
|
||||
//# sourceMappingURL=feeds.d.ts.map
|
||||
-59
@@ -1,59 +0,0 @@
|
||||
import { AnyNode } from "domhandler";
|
||||
/**
|
||||
* Given an array of nodes, remove any member that is contained by another
|
||||
* member.
|
||||
*
|
||||
* @category Helpers
|
||||
* @param nodes Nodes to filter.
|
||||
* @returns Remaining nodes that aren't contained by other nodes.
|
||||
*/
|
||||
export declare function removeSubsets(nodes: AnyNode[]): AnyNode[];
|
||||
/**
|
||||
* @category Helpers
|
||||
* @see {@link http://dom.spec.whatwg.org/#dom-node-comparedocumentposition}
|
||||
*/
|
||||
export declare const enum DocumentPosition {
|
||||
DISCONNECTED = 1,
|
||||
PRECEDING = 2,
|
||||
FOLLOWING = 4,
|
||||
CONTAINS = 8,
|
||||
CONTAINED_BY = 16
|
||||
}
|
||||
/**
|
||||
* Compare the position of one node against another node in any other document,
|
||||
* returning a bitmask with the values from {@link DocumentPosition}.
|
||||
*
|
||||
* Document order:
|
||||
* > There is an ordering, document order, defined on all the nodes in the
|
||||
* > document corresponding to the order in which the first character of the
|
||||
* > XML representation of each node occurs in the XML representation of the
|
||||
* > document after expansion of general entities. Thus, the document element
|
||||
* > node will be the first node. Element nodes occur before their children.
|
||||
* > Thus, document order orders element nodes in order of the occurrence of
|
||||
* > their start-tag in the XML (after expansion of entities). The attribute
|
||||
* > nodes of an element occur after the element and before its children. The
|
||||
* > relative order of attribute nodes is implementation-dependent.
|
||||
*
|
||||
* Source:
|
||||
* http://www.w3.org/TR/DOM-Level-3-Core/glossary.html#dt-document-order
|
||||
*
|
||||
* @category Helpers
|
||||
* @param nodeA The first node to use in the comparison
|
||||
* @param nodeB The second node to use in the comparison
|
||||
* @returns A bitmask describing the input nodes' relative position.
|
||||
*
|
||||
* See http://dom.spec.whatwg.org/#dom-node-comparedocumentposition for
|
||||
* a description of these values.
|
||||
*/
|
||||
export declare function compareDocumentPosition(nodeA: AnyNode, nodeB: AnyNode): number;
|
||||
/**
|
||||
* Sort an array of nodes based on their relative position in the document,
|
||||
* removing any duplicate nodes. If the array contains nodes that do not belong
|
||||
* to the same document, sort order is unspecified.
|
||||
*
|
||||
* @category Helpers
|
||||
* @param nodes Array of DOM nodes.
|
||||
* @returns Collection of unique nodes, sorted in document order.
|
||||
*/
|
||||
export declare function uniqueSort<T extends AnyNode>(nodes: T[]): T[];
|
||||
//# sourceMappingURL=helpers.d.ts.map
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
export * from "./stringify.js";
|
||||
export * from "./traversal.js";
|
||||
export * from "./manipulation.js";
|
||||
export * from "./querying.js";
|
||||
export * from "./legacy.js";
|
||||
export * from "./helpers.js";
|
||||
export * from "./feeds.js";
|
||||
/** @deprecated Use these methods from `domhandler` directly. */
|
||||
export { isTag, isCDATA, isText, isComment, isDocument, hasChildren, } from "domhandler";
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
-79
@@ -1,79 +0,0 @@
|
||||
import { AnyNode, Element } from "domhandler";
|
||||
import type { ElementType } from "domelementtype";
|
||||
/**
|
||||
* An object with keys to check elements against. If a key is `tag_name`,
|
||||
* `tag_type` or `tag_contains`, it will check the value against that specific
|
||||
* value. Otherwise, it will check an attribute with the key's name.
|
||||
*
|
||||
* @category Legacy Query Functions
|
||||
*/
|
||||
export interface TestElementOpts {
|
||||
tag_name?: string | ((name: string) => boolean);
|
||||
tag_type?: string | ((name: string) => boolean);
|
||||
tag_contains?: string | ((data?: string) => boolean);
|
||||
[attributeName: string]: undefined | string | ((attributeValue: string) => boolean);
|
||||
}
|
||||
/**
|
||||
* Checks whether a node matches the description in `options`.
|
||||
*
|
||||
* @category Legacy Query Functions
|
||||
* @param options An object describing nodes to look for.
|
||||
* @param node The element to test.
|
||||
* @returns Whether the element matches the description in `options`.
|
||||
*/
|
||||
export declare function testElement(options: TestElementOpts, node: AnyNode): boolean;
|
||||
/**
|
||||
* Returns all nodes that match `options`.
|
||||
*
|
||||
* @category Legacy Query Functions
|
||||
* @param options An object describing nodes to look for.
|
||||
* @param nodes Nodes to search through.
|
||||
* @param recurse Also consider child nodes.
|
||||
* @param limit Maximum number of nodes to return.
|
||||
* @returns All nodes that match `options`.
|
||||
*/
|
||||
export declare function getElements(options: TestElementOpts, nodes: AnyNode | AnyNode[], recurse: boolean, limit?: number): AnyNode[];
|
||||
/**
|
||||
* Returns the node with the supplied ID.
|
||||
*
|
||||
* @category Legacy Query Functions
|
||||
* @param id The unique ID attribute value to look for.
|
||||
* @param nodes Nodes to search through.
|
||||
* @param recurse Also consider child nodes.
|
||||
* @returns The node with the supplied ID.
|
||||
*/
|
||||
export declare function getElementById(id: string | ((id: string) => boolean), nodes: AnyNode | AnyNode[], recurse?: boolean): Element | null;
|
||||
/**
|
||||
* Returns all nodes with the supplied `tagName`.
|
||||
*
|
||||
* @category Legacy Query Functions
|
||||
* @param tagName Tag name to search for.
|
||||
* @param nodes Nodes to search through.
|
||||
* @param recurse Also consider child nodes.
|
||||
* @param limit Maximum number of nodes to return.
|
||||
* @returns All nodes with the supplied `tagName`.
|
||||
*/
|
||||
export declare function getElementsByTagName(tagName: string | ((name: string) => boolean), nodes: AnyNode | AnyNode[], recurse?: boolean, limit?: number): Element[];
|
||||
/**
|
||||
* Returns all nodes with the supplied `className`.
|
||||
*
|
||||
* @category Legacy Query Functions
|
||||
* @param className Class name to search for.
|
||||
* @param nodes Nodes to search through.
|
||||
* @param recurse Also consider child nodes.
|
||||
* @param limit Maximum number of nodes to return.
|
||||
* @returns All nodes with the supplied `className`.
|
||||
*/
|
||||
export declare function getElementsByClassName(className: string | ((name: string) => boolean), nodes: AnyNode | AnyNode[], recurse?: boolean, limit?: number): Element[];
|
||||
/**
|
||||
* Returns all nodes with the supplied `type`.
|
||||
*
|
||||
* @category Legacy Query Functions
|
||||
* @param type Element type to look for.
|
||||
* @param nodes Nodes to search through.
|
||||
* @param recurse Also consider child nodes.
|
||||
* @param limit Maximum number of nodes to return.
|
||||
* @returns All nodes with the supplied `type`.
|
||||
*/
|
||||
export declare function getElementsByTagType(type: ElementType | ((type: ElementType) => boolean), nodes: AnyNode | AnyNode[], recurse?: boolean, limit?: number): AnyNode[];
|
||||
//# sourceMappingURL=legacy.d.ts.map
|
||||
-49
@@ -1,49 +0,0 @@
|
||||
import type { ChildNode, ParentNode } from "domhandler";
|
||||
/**
|
||||
* Remove an element from the dom
|
||||
*
|
||||
* @category Manipulation
|
||||
* @param elem The element to be removed
|
||||
*/
|
||||
export declare function removeElement(elem: ChildNode): void;
|
||||
/**
|
||||
* Replace an element in the dom
|
||||
*
|
||||
* @category Manipulation
|
||||
* @param elem The element to be replaced
|
||||
* @param replacement The element to be added
|
||||
*/
|
||||
export declare function replaceElement(elem: ChildNode, replacement: ChildNode): void;
|
||||
/**
|
||||
* Append a child to an element.
|
||||
*
|
||||
* @category Manipulation
|
||||
* @param parent The element to append to.
|
||||
* @param child The element to be added as a child.
|
||||
*/
|
||||
export declare function appendChild(parent: ParentNode, child: ChildNode): void;
|
||||
/**
|
||||
* Append an element after another.
|
||||
*
|
||||
* @category Manipulation
|
||||
* @param elem The element to append after.
|
||||
* @param next The element be added.
|
||||
*/
|
||||
export declare function append(elem: ChildNode, next: ChildNode): void;
|
||||
/**
|
||||
* Prepend a child to an element.
|
||||
*
|
||||
* @category Manipulation
|
||||
* @param parent The element to prepend before.
|
||||
* @param child The element to be added as a child.
|
||||
*/
|
||||
export declare function prependChild(parent: ParentNode, child: ChildNode): void;
|
||||
/**
|
||||
* Prepend an element before another.
|
||||
*
|
||||
* @category Manipulation
|
||||
* @param elem The element to prepend before.
|
||||
* @param prev The element be added.
|
||||
*/
|
||||
export declare function prepend(elem: ChildNode, prev: ChildNode): void;
|
||||
//# sourceMappingURL=manipulation.d.ts.map
|
||||
-64
@@ -1,64 +0,0 @@
|
||||
import { Element, AnyNode, ParentNode } from "domhandler";
|
||||
/**
|
||||
* Search a node and its children for nodes passing a test function. If `node` is not an array, it will be wrapped in one.
|
||||
*
|
||||
* @category Querying
|
||||
* @param test Function to test nodes on.
|
||||
* @param node Node to search. Will be included in the result set if it matches.
|
||||
* @param recurse Also consider child nodes.
|
||||
* @param limit Maximum number of nodes to return.
|
||||
* @returns All nodes passing `test`.
|
||||
*/
|
||||
export declare function filter(test: (elem: AnyNode) => boolean, node: AnyNode | AnyNode[], recurse?: boolean, limit?: number): AnyNode[];
|
||||
/**
|
||||
* Search an array of nodes and their children for nodes passing a test function.
|
||||
*
|
||||
* @category Querying
|
||||
* @param test Function to test nodes on.
|
||||
* @param nodes Array of nodes to search.
|
||||
* @param recurse Also consider child nodes.
|
||||
* @param limit Maximum number of nodes to return.
|
||||
* @returns All nodes passing `test`.
|
||||
*/
|
||||
export declare function find(test: (elem: AnyNode) => boolean, nodes: AnyNode[] | ParentNode, recurse: boolean, limit: number): AnyNode[];
|
||||
/**
|
||||
* Finds the first element inside of an array that matches a test function. This is an alias for `Array.prototype.find`.
|
||||
*
|
||||
* @category Querying
|
||||
* @param test Function to test nodes on.
|
||||
* @param nodes Array of nodes to search.
|
||||
* @returns The first node in the array that passes `test`.
|
||||
* @deprecated Use `Array.prototype.find` directly.
|
||||
*/
|
||||
export declare function findOneChild<T>(test: (elem: T) => boolean, nodes: T[]): T | undefined;
|
||||
/**
|
||||
* Finds one element in a tree that passes a test.
|
||||
*
|
||||
* @category Querying
|
||||
* @param test Function to test nodes on.
|
||||
* @param nodes Node or array of nodes to search.
|
||||
* @param recurse Also consider child nodes.
|
||||
* @returns The first node that passes `test`.
|
||||
*/
|
||||
export declare function findOne(test: (elem: Element) => boolean, nodes: AnyNode[] | ParentNode, recurse?: boolean): Element | null;
|
||||
/**
|
||||
* Checks if a tree of nodes contains at least one node passing a test.
|
||||
*
|
||||
* @category Querying
|
||||
* @param test Function to test nodes on.
|
||||
* @param nodes Array of nodes to search.
|
||||
* @returns Whether a tree of nodes contains at least one node passing the test.
|
||||
*/
|
||||
export declare function existsOne(test: (elem: Element) => boolean, nodes: AnyNode[] | ParentNode): boolean;
|
||||
/**
|
||||
* Search an array of nodes and their children for elements passing a test function.
|
||||
*
|
||||
* Same as `find`, but limited to elements and with less options, leading to reduced complexity.
|
||||
*
|
||||
* @category Querying
|
||||
* @param test Function to test nodes on.
|
||||
* @param nodes Array of nodes to search.
|
||||
* @returns All nodes passing `test`.
|
||||
*/
|
||||
export declare function findAll(test: (elem: Element) => boolean, nodes: AnyNode[] | ParentNode): Element[];
|
||||
//# sourceMappingURL=querying.d.ts.map
|
||||
-46
@@ -1,46 +0,0 @@
|
||||
import { AnyNode } from "domhandler";
|
||||
import { DomSerializerOptions } from "dom-serializer";
|
||||
/**
|
||||
* @category Stringify
|
||||
* @deprecated Use the `dom-serializer` module directly.
|
||||
* @param node Node to get the outer HTML of.
|
||||
* @param options Options for serialization.
|
||||
* @returns `node`'s outer HTML.
|
||||
*/
|
||||
export declare function getOuterHTML(node: AnyNode | ArrayLike<AnyNode>, options?: DomSerializerOptions): string;
|
||||
/**
|
||||
* @category Stringify
|
||||
* @deprecated Use the `dom-serializer` module directly.
|
||||
* @param node Node to get the inner HTML of.
|
||||
* @param options Options for serialization.
|
||||
* @returns `node`'s inner HTML.
|
||||
*/
|
||||
export declare function getInnerHTML(node: AnyNode, options?: DomSerializerOptions): string;
|
||||
/**
|
||||
* Get a node's inner text. Same as `textContent`, but inserts newlines for `<br>` tags. Ignores comments.
|
||||
*
|
||||
* @category Stringify
|
||||
* @deprecated Use `textContent` instead.
|
||||
* @param node Node to get the inner text of.
|
||||
* @returns `node`'s inner text.
|
||||
*/
|
||||
export declare function getText(node: AnyNode | AnyNode[]): string;
|
||||
/**
|
||||
* Get a node's text content. Ignores comments.
|
||||
*
|
||||
* @category Stringify
|
||||
* @param node Node to get the text content of.
|
||||
* @returns `node`'s text content.
|
||||
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent}
|
||||
*/
|
||||
export declare function textContent(node: AnyNode | AnyNode[]): string;
|
||||
/**
|
||||
* Get a node's inner text, ignoring `<script>` and `<style>` tags. Ignores comments.
|
||||
*
|
||||
* @category Stringify
|
||||
* @param node Node to get the inner text of.
|
||||
* @returns `node`'s inner text.
|
||||
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/innerText}
|
||||
*/
|
||||
export declare function innerText(node: AnyNode | AnyNode[]): string;
|
||||
//# sourceMappingURL=stringify.d.ts.map
|
||||
-67
@@ -1,67 +0,0 @@
|
||||
import { AnyNode, ChildNode, Element, ParentNode } from "domhandler";
|
||||
/**
|
||||
* Get a node's children.
|
||||
*
|
||||
* @category Traversal
|
||||
* @param elem Node to get the children of.
|
||||
* @returns `elem`'s children, or an empty array.
|
||||
*/
|
||||
export declare function getChildren(elem: AnyNode): ChildNode[];
|
||||
export declare function getParent(elem: AnyNode): ParentNode | null;
|
||||
/**
|
||||
* Gets an elements siblings, including the element itself.
|
||||
*
|
||||
* Attempts to get the children through the element's parent first. If we don't
|
||||
* have a parent (the element is a root node), we walk the element's `prev` &
|
||||
* `next` to get all remaining nodes.
|
||||
*
|
||||
* @category Traversal
|
||||
* @param elem Element to get the siblings of.
|
||||
* @returns `elem`'s siblings, including `elem`.
|
||||
*/
|
||||
export declare function getSiblings(elem: AnyNode): AnyNode[];
|
||||
/**
|
||||
* Gets an attribute from an element.
|
||||
*
|
||||
* @category Traversal
|
||||
* @param elem Element to check.
|
||||
* @param name Attribute name to retrieve.
|
||||
* @returns The element's attribute value, or `undefined`.
|
||||
*/
|
||||
export declare function getAttributeValue(elem: Element, name: string): string | undefined;
|
||||
/**
|
||||
* Checks whether an element has an attribute.
|
||||
*
|
||||
* @category Traversal
|
||||
* @param elem Element to check.
|
||||
* @param name Attribute name to look for.
|
||||
* @returns Returns whether `elem` has the attribute `name`.
|
||||
*/
|
||||
export declare function hasAttrib(elem: Element, name: string): boolean;
|
||||
/**
|
||||
* Get the tag name of an element.
|
||||
*
|
||||
* @category Traversal
|
||||
* @param elem The element to get the name for.
|
||||
* @returns The tag name of `elem`.
|
||||
*/
|
||||
export declare function getName(elem: Element): string;
|
||||
/**
|
||||
* Returns the next element sibling of a node.
|
||||
*
|
||||
* @category Traversal
|
||||
* @param elem The element to get the next sibling of.
|
||||
* @returns `elem`'s next sibling that is a tag, or `null` if there is no next
|
||||
* sibling.
|
||||
*/
|
||||
export declare function nextElementSibling(elem: AnyNode): Element | null;
|
||||
/**
|
||||
* Returns the previous element sibling of a node.
|
||||
*
|
||||
* @category Traversal
|
||||
* @param elem The element to get the previous sibling of.
|
||||
* @returns `elem`'s previous sibling that is a tag, or `null` if there is no
|
||||
* previous sibling.
|
||||
*/
|
||||
export declare function prevElementSibling(elem: AnyNode): Element | null;
|
||||
//# sourceMappingURL=traversal.d.ts.map
|
||||
-211
@@ -1,211 +0,0 @@
|
||||
import htmlDecodeTree from "./generated/decode-data-html.js";
|
||||
import xmlDecodeTree from "./generated/decode-data-xml.js";
|
||||
import decodeCodePoint from "./decode_codepoint.js";
|
||||
export { htmlDecodeTree, xmlDecodeTree, decodeCodePoint };
|
||||
export { replaceCodePoint, fromCodePoint } from "./decode_codepoint.js";
|
||||
export declare enum BinTrieFlags {
|
||||
VALUE_LENGTH = 49152,
|
||||
BRANCH_LENGTH = 16256,
|
||||
JUMP_TABLE = 127
|
||||
}
|
||||
export declare enum DecodingMode {
|
||||
/** Entities in text nodes that can end with any character. */
|
||||
Legacy = 0,
|
||||
/** Only allow entities terminated with a semicolon. */
|
||||
Strict = 1,
|
||||
/** Entities in attributes have limitations on ending characters. */
|
||||
Attribute = 2
|
||||
}
|
||||
/**
|
||||
* Producers for character reference errors as defined in the HTML spec.
|
||||
*/
|
||||
export interface EntityErrorProducer {
|
||||
missingSemicolonAfterCharacterReference(): void;
|
||||
absenceOfDigitsInNumericCharacterReference(consumedCharacters: number): void;
|
||||
validateNumericCharacterReference(code: number): void;
|
||||
}
|
||||
/**
|
||||
* Token decoder with support of writing partial entities.
|
||||
*/
|
||||
export declare class EntityDecoder {
|
||||
/** The tree used to decode entities. */
|
||||
private readonly decodeTree;
|
||||
/**
|
||||
* The function that is called when a codepoint is decoded.
|
||||
*
|
||||
* For multi-byte named entities, this will be called multiple times,
|
||||
* with the second codepoint, and the same `consumed` value.
|
||||
*
|
||||
* @param codepoint The decoded codepoint.
|
||||
* @param consumed The number of bytes consumed by the decoder.
|
||||
*/
|
||||
private readonly emitCodePoint;
|
||||
/** An object that is used to produce errors. */
|
||||
private readonly errors?;
|
||||
constructor(
|
||||
/** The tree used to decode entities. */
|
||||
decodeTree: Uint16Array,
|
||||
/**
|
||||
* The function that is called when a codepoint is decoded.
|
||||
*
|
||||
* For multi-byte named entities, this will be called multiple times,
|
||||
* with the second codepoint, and the same `consumed` value.
|
||||
*
|
||||
* @param codepoint The decoded codepoint.
|
||||
* @param consumed The number of bytes consumed by the decoder.
|
||||
*/
|
||||
emitCodePoint: (cp: number, consumed: number) => void,
|
||||
/** An object that is used to produce errors. */
|
||||
errors?: EntityErrorProducer | undefined);
|
||||
/** The current state of the decoder. */
|
||||
private state;
|
||||
/** Characters that were consumed while parsing an entity. */
|
||||
private consumed;
|
||||
/**
|
||||
* The result of the entity.
|
||||
*
|
||||
* Either the result index of a numeric entity, or the codepoint of a
|
||||
* numeric entity.
|
||||
*/
|
||||
private result;
|
||||
/** The current index in the decode tree. */
|
||||
private treeIndex;
|
||||
/** The number of characters that were consumed in excess. */
|
||||
private excess;
|
||||
/** The mode in which the decoder is operating. */
|
||||
private decodeMode;
|
||||
/** Resets the instance to make it reusable. */
|
||||
startEntity(decodeMode: DecodingMode): void;
|
||||
/**
|
||||
* Write an entity to the decoder. This can be called multiple times with partial entities.
|
||||
* If the entity is incomplete, the decoder will return -1.
|
||||
*
|
||||
* Mirrors the implementation of `getDecoder`, but with the ability to stop decoding if the
|
||||
* entity is incomplete, and resume when the next string is written.
|
||||
*
|
||||
* @param string The string containing the entity (or a continuation of the entity).
|
||||
* @param offset The offset at which the entity begins. Should be 0 if this is not the first call.
|
||||
* @returns The number of characters that were consumed, or -1 if the entity is incomplete.
|
||||
*/
|
||||
write(str: string, offset: number): number;
|
||||
/**
|
||||
* Switches between the numeric decimal and hexadecimal states.
|
||||
*
|
||||
* Equivalent to the `Numeric character reference state` in the HTML spec.
|
||||
*
|
||||
* @param str The string containing the entity (or a continuation of the entity).
|
||||
* @param offset The current offset.
|
||||
* @returns The number of characters that were consumed, or -1 if the entity is incomplete.
|
||||
*/
|
||||
private stateNumericStart;
|
||||
private addToNumericResult;
|
||||
/**
|
||||
* Parses a hexadecimal numeric entity.
|
||||
*
|
||||
* Equivalent to the `Hexademical character reference state` in the HTML spec.
|
||||
*
|
||||
* @param str The string containing the entity (or a continuation of the entity).
|
||||
* @param offset The current offset.
|
||||
* @returns The number of characters that were consumed, or -1 if the entity is incomplete.
|
||||
*/
|
||||
private stateNumericHex;
|
||||
/**
|
||||
* Parses a decimal numeric entity.
|
||||
*
|
||||
* Equivalent to the `Decimal character reference state` in the HTML spec.
|
||||
*
|
||||
* @param str The string containing the entity (or a continuation of the entity).
|
||||
* @param offset The current offset.
|
||||
* @returns The number of characters that were consumed, or -1 if the entity is incomplete.
|
||||
*/
|
||||
private stateNumericDecimal;
|
||||
/**
|
||||
* Validate and emit a numeric entity.
|
||||
*
|
||||
* Implements the logic from the `Hexademical character reference start
|
||||
* state` and `Numeric character reference end state` in the HTML spec.
|
||||
*
|
||||
* @param lastCp The last code point of the entity. Used to see if the
|
||||
* entity was terminated with a semicolon.
|
||||
* @param expectedLength The minimum number of characters that should be
|
||||
* consumed. Used to validate that at least one digit
|
||||
* was consumed.
|
||||
* @returns The number of characters that were consumed.
|
||||
*/
|
||||
private emitNumericEntity;
|
||||
/**
|
||||
* Parses a named entity.
|
||||
*
|
||||
* Equivalent to the `Named character reference state` in the HTML spec.
|
||||
*
|
||||
* @param str The string containing the entity (or a continuation of the entity).
|
||||
* @param offset The current offset.
|
||||
* @returns The number of characters that were consumed, or -1 if the entity is incomplete.
|
||||
*/
|
||||
private stateNamedEntity;
|
||||
/**
|
||||
* Emit a named entity that was not terminated with a semicolon.
|
||||
*
|
||||
* @returns The number of characters consumed.
|
||||
*/
|
||||
private emitNotTerminatedNamedEntity;
|
||||
/**
|
||||
* Emit a named entity.
|
||||
*
|
||||
* @param result The index of the entity in the decode tree.
|
||||
* @param valueLength The number of bytes in the entity.
|
||||
* @param consumed The number of characters consumed.
|
||||
*
|
||||
* @returns The number of characters consumed.
|
||||
*/
|
||||
private emitNamedEntityData;
|
||||
/**
|
||||
* Signal to the parser that the end of the input was reached.
|
||||
*
|
||||
* Remaining data will be emitted and relevant errors will be produced.
|
||||
*
|
||||
* @returns The number of characters consumed.
|
||||
*/
|
||||
end(): number;
|
||||
}
|
||||
/**
|
||||
* Determines the branch of the current node that is taken given the current
|
||||
* character. This function is used to traverse the trie.
|
||||
*
|
||||
* @param decodeTree The trie.
|
||||
* @param current The current node.
|
||||
* @param nodeIdx The index right after the current node and its value.
|
||||
* @param char The current character.
|
||||
* @returns The index of the next node, or -1 if no branch is taken.
|
||||
*/
|
||||
export declare function determineBranch(decodeTree: Uint16Array, current: number, nodeIdx: number, char: number): number;
|
||||
/**
|
||||
* Decodes an HTML string.
|
||||
*
|
||||
* @param str The string to decode.
|
||||
* @param mode The decoding mode.
|
||||
* @returns The decoded string.
|
||||
*/
|
||||
export declare function decodeHTML(str: string, mode?: DecodingMode): string;
|
||||
/**
|
||||
* Decodes an HTML string in an attribute.
|
||||
*
|
||||
* @param str The string to decode.
|
||||
* @returns The decoded string.
|
||||
*/
|
||||
export declare function decodeHTMLAttribute(str: string): string;
|
||||
/**
|
||||
* Decodes an HTML string, requiring all entities to be terminated by a semicolon.
|
||||
*
|
||||
* @param str The string to decode.
|
||||
* @returns The decoded string.
|
||||
*/
|
||||
export declare function decodeHTMLStrict(str: string): string;
|
||||
/**
|
||||
* Decodes an XML string, requiring all entities to be terminated by a semicolon.
|
||||
*
|
||||
* @param str The string to decode.
|
||||
* @returns The decoded string.
|
||||
*/
|
||||
export declare function decodeXML(str: string): string;
|
||||
//# sourceMappingURL=decode.d.ts.map
|
||||
-19
@@ -1,19 +0,0 @@
|
||||
/**
|
||||
* Polyfill for `String.fromCodePoint`. It is used to create a string from a Unicode code point.
|
||||
*/
|
||||
export declare const fromCodePoint: (...codePoints: number[]) => string;
|
||||
/**
|
||||
* Replace the given code point with a replacement character if it is a
|
||||
* surrogate or is outside the valid range. Otherwise return the code
|
||||
* point unchanged.
|
||||
*/
|
||||
export declare function replaceCodePoint(codePoint: number): number;
|
||||
/**
|
||||
* Replace the code point if relevant, then convert it to a string.
|
||||
*
|
||||
* @deprecated Use `fromCodePoint(replaceCodePoint(codePoint))` instead.
|
||||
* @param codePoint The code point to decode.
|
||||
* @returns The decoded code point.
|
||||
*/
|
||||
export default function decodeCodePoint(codePoint: number): string;
|
||||
//# sourceMappingURL=decode_codepoint.d.ts.map
|
||||
-22
@@ -1,22 +0,0 @@
|
||||
/**
|
||||
* Encodes all characters in the input using HTML entities. This includes
|
||||
* characters that are valid ASCII characters in HTML documents, such as `#`.
|
||||
*
|
||||
* To get a more compact output, consider using the `encodeNonAsciiHTML`
|
||||
* function, which will only encode characters that are not valid in HTML
|
||||
* documents, as well as non-ASCII characters.
|
||||
*
|
||||
* If a character has no equivalent entity, a numeric hexadecimal reference
|
||||
* (eg. `ü`) will be used.
|
||||
*/
|
||||
export declare function encodeHTML(data: string): string;
|
||||
/**
|
||||
* Encodes all non-ASCII characters, as well as characters not valid in HTML
|
||||
* documents using HTML entities. This function will not encode characters that
|
||||
* are valid in HTML documents, such as `#`.
|
||||
*
|
||||
* If a character has no equivalent entity, a numeric hexadecimal reference
|
||||
* (eg. `ü`) will be used.
|
||||
*/
|
||||
export declare function encodeNonAsciiHTML(data: string): string;
|
||||
//# sourceMappingURL=encode.d.ts.map
|
||||
-43
@@ -1,43 +0,0 @@
|
||||
export declare const xmlReplacer: RegExp;
|
||||
export declare const getCodePoint: (str: string, index: number) => number;
|
||||
/**
|
||||
* Encodes all non-ASCII characters, as well as characters not valid in XML
|
||||
* documents using XML entities.
|
||||
*
|
||||
* If a character has no equivalent entity, a
|
||||
* numeric hexadecimal reference (eg. `ü`) will be used.
|
||||
*/
|
||||
export declare function encodeXML(str: string): string;
|
||||
/**
|
||||
* Encodes all non-ASCII characters, as well as characters not valid in XML
|
||||
* documents using numeric hexadecimal reference (eg. `ü`).
|
||||
*
|
||||
* Have a look at `escapeUTF8` if you want a more concise output at the expense
|
||||
* of reduced transportability.
|
||||
*
|
||||
* @param data String to escape.
|
||||
*/
|
||||
export declare const escape: typeof encodeXML;
|
||||
/**
|
||||
* Encodes all characters not valid in XML documents using XML entities.
|
||||
*
|
||||
* Note that the output will be character-set dependent.
|
||||
*
|
||||
* @param data String to escape.
|
||||
*/
|
||||
export declare const escapeUTF8: (data: string) => string;
|
||||
/**
|
||||
* Encodes all characters that have to be escaped in HTML attributes,
|
||||
* following {@link https://html.spec.whatwg.org/multipage/parsing.html#escapingString}.
|
||||
*
|
||||
* @param data String to escape.
|
||||
*/
|
||||
export declare const escapeAttribute: (data: string) => string;
|
||||
/**
|
||||
* Encodes all characters that have to be escaped in HTML text,
|
||||
* following {@link https://html.spec.whatwg.org/multipage/parsing.html#escapingString}.
|
||||
*
|
||||
* @param data String to escape.
|
||||
*/
|
||||
export declare const escapeText: (data: string) => string;
|
||||
//# sourceMappingURL=escape.d.ts.map
|
||||
-211
@@ -1,211 +0,0 @@
|
||||
import htmlDecodeTree from "./generated/decode-data-html.js";
|
||||
import xmlDecodeTree from "./generated/decode-data-xml.js";
|
||||
import decodeCodePoint from "./decode_codepoint.js";
|
||||
export { htmlDecodeTree, xmlDecodeTree, decodeCodePoint };
|
||||
export { replaceCodePoint, fromCodePoint } from "./decode_codepoint.js";
|
||||
export declare enum BinTrieFlags {
|
||||
VALUE_LENGTH = 49152,
|
||||
BRANCH_LENGTH = 16256,
|
||||
JUMP_TABLE = 127
|
||||
}
|
||||
export declare enum DecodingMode {
|
||||
/** Entities in text nodes that can end with any character. */
|
||||
Legacy = 0,
|
||||
/** Only allow entities terminated with a semicolon. */
|
||||
Strict = 1,
|
||||
/** Entities in attributes have limitations on ending characters. */
|
||||
Attribute = 2
|
||||
}
|
||||
/**
|
||||
* Producers for character reference errors as defined in the HTML spec.
|
||||
*/
|
||||
export interface EntityErrorProducer {
|
||||
missingSemicolonAfterCharacterReference(): void;
|
||||
absenceOfDigitsInNumericCharacterReference(consumedCharacters: number): void;
|
||||
validateNumericCharacterReference(code: number): void;
|
||||
}
|
||||
/**
|
||||
* Token decoder with support of writing partial entities.
|
||||
*/
|
||||
export declare class EntityDecoder {
|
||||
/** The tree used to decode entities. */
|
||||
private readonly decodeTree;
|
||||
/**
|
||||
* The function that is called when a codepoint is decoded.
|
||||
*
|
||||
* For multi-byte named entities, this will be called multiple times,
|
||||
* with the second codepoint, and the same `consumed` value.
|
||||
*
|
||||
* @param codepoint The decoded codepoint.
|
||||
* @param consumed The number of bytes consumed by the decoder.
|
||||
*/
|
||||
private readonly emitCodePoint;
|
||||
/** An object that is used to produce errors. */
|
||||
private readonly errors?;
|
||||
constructor(
|
||||
/** The tree used to decode entities. */
|
||||
decodeTree: Uint16Array,
|
||||
/**
|
||||
* The function that is called when a codepoint is decoded.
|
||||
*
|
||||
* For multi-byte named entities, this will be called multiple times,
|
||||
* with the second codepoint, and the same `consumed` value.
|
||||
*
|
||||
* @param codepoint The decoded codepoint.
|
||||
* @param consumed The number of bytes consumed by the decoder.
|
||||
*/
|
||||
emitCodePoint: (cp: number, consumed: number) => void,
|
||||
/** An object that is used to produce errors. */
|
||||
errors?: EntityErrorProducer | undefined);
|
||||
/** The current state of the decoder. */
|
||||
private state;
|
||||
/** Characters that were consumed while parsing an entity. */
|
||||
private consumed;
|
||||
/**
|
||||
* The result of the entity.
|
||||
*
|
||||
* Either the result index of a numeric entity, or the codepoint of a
|
||||
* numeric entity.
|
||||
*/
|
||||
private result;
|
||||
/** The current index in the decode tree. */
|
||||
private treeIndex;
|
||||
/** The number of characters that were consumed in excess. */
|
||||
private excess;
|
||||
/** The mode in which the decoder is operating. */
|
||||
private decodeMode;
|
||||
/** Resets the instance to make it reusable. */
|
||||
startEntity(decodeMode: DecodingMode): void;
|
||||
/**
|
||||
* Write an entity to the decoder. This can be called multiple times with partial entities.
|
||||
* If the entity is incomplete, the decoder will return -1.
|
||||
*
|
||||
* Mirrors the implementation of `getDecoder`, but with the ability to stop decoding if the
|
||||
* entity is incomplete, and resume when the next string is written.
|
||||
*
|
||||
* @param string The string containing the entity (or a continuation of the entity).
|
||||
* @param offset The offset at which the entity begins. Should be 0 if this is not the first call.
|
||||
* @returns The number of characters that were consumed, or -1 if the entity is incomplete.
|
||||
*/
|
||||
write(str: string, offset: number): number;
|
||||
/**
|
||||
* Switches between the numeric decimal and hexadecimal states.
|
||||
*
|
||||
* Equivalent to the `Numeric character reference state` in the HTML spec.
|
||||
*
|
||||
* @param str The string containing the entity (or a continuation of the entity).
|
||||
* @param offset The current offset.
|
||||
* @returns The number of characters that were consumed, or -1 if the entity is incomplete.
|
||||
*/
|
||||
private stateNumericStart;
|
||||
private addToNumericResult;
|
||||
/**
|
||||
* Parses a hexadecimal numeric entity.
|
||||
*
|
||||
* Equivalent to the `Hexademical character reference state` in the HTML spec.
|
||||
*
|
||||
* @param str The string containing the entity (or a continuation of the entity).
|
||||
* @param offset The current offset.
|
||||
* @returns The number of characters that were consumed, or -1 if the entity is incomplete.
|
||||
*/
|
||||
private stateNumericHex;
|
||||
/**
|
||||
* Parses a decimal numeric entity.
|
||||
*
|
||||
* Equivalent to the `Decimal character reference state` in the HTML spec.
|
||||
*
|
||||
* @param str The string containing the entity (or a continuation of the entity).
|
||||
* @param offset The current offset.
|
||||
* @returns The number of characters that were consumed, or -1 if the entity is incomplete.
|
||||
*/
|
||||
private stateNumericDecimal;
|
||||
/**
|
||||
* Validate and emit a numeric entity.
|
||||
*
|
||||
* Implements the logic from the `Hexademical character reference start
|
||||
* state` and `Numeric character reference end state` in the HTML spec.
|
||||
*
|
||||
* @param lastCp The last code point of the entity. Used to see if the
|
||||
* entity was terminated with a semicolon.
|
||||
* @param expectedLength The minimum number of characters that should be
|
||||
* consumed. Used to validate that at least one digit
|
||||
* was consumed.
|
||||
* @returns The number of characters that were consumed.
|
||||
*/
|
||||
private emitNumericEntity;
|
||||
/**
|
||||
* Parses a named entity.
|
||||
*
|
||||
* Equivalent to the `Named character reference state` in the HTML spec.
|
||||
*
|
||||
* @param str The string containing the entity (or a continuation of the entity).
|
||||
* @param offset The current offset.
|
||||
* @returns The number of characters that were consumed, or -1 if the entity is incomplete.
|
||||
*/
|
||||
private stateNamedEntity;
|
||||
/**
|
||||
* Emit a named entity that was not terminated with a semicolon.
|
||||
*
|
||||
* @returns The number of characters consumed.
|
||||
*/
|
||||
private emitNotTerminatedNamedEntity;
|
||||
/**
|
||||
* Emit a named entity.
|
||||
*
|
||||
* @param result The index of the entity in the decode tree.
|
||||
* @param valueLength The number of bytes in the entity.
|
||||
* @param consumed The number of characters consumed.
|
||||
*
|
||||
* @returns The number of characters consumed.
|
||||
*/
|
||||
private emitNamedEntityData;
|
||||
/**
|
||||
* Signal to the parser that the end of the input was reached.
|
||||
*
|
||||
* Remaining data will be emitted and relevant errors will be produced.
|
||||
*
|
||||
* @returns The number of characters consumed.
|
||||
*/
|
||||
end(): number;
|
||||
}
|
||||
/**
|
||||
* Determines the branch of the current node that is taken given the current
|
||||
* character. This function is used to traverse the trie.
|
||||
*
|
||||
* @param decodeTree The trie.
|
||||
* @param current The current node.
|
||||
* @param nodeIdx The index right after the current node and its value.
|
||||
* @param char The current character.
|
||||
* @returns The index of the next node, or -1 if no branch is taken.
|
||||
*/
|
||||
export declare function determineBranch(decodeTree: Uint16Array, current: number, nodeIdx: number, char: number): number;
|
||||
/**
|
||||
* Decodes an HTML string.
|
||||
*
|
||||
* @param str The string to decode.
|
||||
* @param mode The decoding mode.
|
||||
* @returns The decoded string.
|
||||
*/
|
||||
export declare function decodeHTML(str: string, mode?: DecodingMode): string;
|
||||
/**
|
||||
* Decodes an HTML string in an attribute.
|
||||
*
|
||||
* @param str The string to decode.
|
||||
* @returns The decoded string.
|
||||
*/
|
||||
export declare function decodeHTMLAttribute(str: string): string;
|
||||
/**
|
||||
* Decodes an HTML string, requiring all entities to be terminated by a semicolon.
|
||||
*
|
||||
* @param str The string to decode.
|
||||
* @returns The decoded string.
|
||||
*/
|
||||
export declare function decodeHTMLStrict(str: string): string;
|
||||
/**
|
||||
* Decodes an XML string, requiring all entities to be terminated by a semicolon.
|
||||
*
|
||||
* @param str The string to decode.
|
||||
* @returns The decoded string.
|
||||
*/
|
||||
export declare function decodeXML(str: string): string;
|
||||
//# sourceMappingURL=decode.d.ts.map
|
||||
-19
@@ -1,19 +0,0 @@
|
||||
/**
|
||||
* Polyfill for `String.fromCodePoint`. It is used to create a string from a Unicode code point.
|
||||
*/
|
||||
export declare const fromCodePoint: (...codePoints: number[]) => string;
|
||||
/**
|
||||
* Replace the given code point with a replacement character if it is a
|
||||
* surrogate or is outside the valid range. Otherwise return the code
|
||||
* point unchanged.
|
||||
*/
|
||||
export declare function replaceCodePoint(codePoint: number): number;
|
||||
/**
|
||||
* Replace the code point if relevant, then convert it to a string.
|
||||
*
|
||||
* @deprecated Use `fromCodePoint(replaceCodePoint(codePoint))` instead.
|
||||
* @param codePoint The code point to decode.
|
||||
* @returns The decoded code point.
|
||||
*/
|
||||
export default function decodeCodePoint(codePoint: number): string;
|
||||
//# sourceMappingURL=decode_codepoint.d.ts.map
|
||||
-22
@@ -1,22 +0,0 @@
|
||||
/**
|
||||
* Encodes all characters in the input using HTML entities. This includes
|
||||
* characters that are valid ASCII characters in HTML documents, such as `#`.
|
||||
*
|
||||
* To get a more compact output, consider using the `encodeNonAsciiHTML`
|
||||
* function, which will only encode characters that are not valid in HTML
|
||||
* documents, as well as non-ASCII characters.
|
||||
*
|
||||
* If a character has no equivalent entity, a numeric hexadecimal reference
|
||||
* (eg. `ü`) will be used.
|
||||
*/
|
||||
export declare function encodeHTML(data: string): string;
|
||||
/**
|
||||
* Encodes all non-ASCII characters, as well as characters not valid in HTML
|
||||
* documents using HTML entities. This function will not encode characters that
|
||||
* are valid in HTML documents, such as `#`.
|
||||
*
|
||||
* If a character has no equivalent entity, a numeric hexadecimal reference
|
||||
* (eg. `ü`) will be used.
|
||||
*/
|
||||
export declare function encodeNonAsciiHTML(data: string): string;
|
||||
//# sourceMappingURL=encode.d.ts.map
|
||||
-43
@@ -1,43 +0,0 @@
|
||||
export declare const xmlReplacer: RegExp;
|
||||
export declare const getCodePoint: (str: string, index: number) => number;
|
||||
/**
|
||||
* Encodes all non-ASCII characters, as well as characters not valid in XML
|
||||
* documents using XML entities.
|
||||
*
|
||||
* If a character has no equivalent entity, a
|
||||
* numeric hexadecimal reference (eg. `ü`) will be used.
|
||||
*/
|
||||
export declare function encodeXML(str: string): string;
|
||||
/**
|
||||
* Encodes all non-ASCII characters, as well as characters not valid in XML
|
||||
* documents using numeric hexadecimal reference (eg. `ü`).
|
||||
*
|
||||
* Have a look at `escapeUTF8` if you want a more concise output at the expense
|
||||
* of reduced transportability.
|
||||
*
|
||||
* @param data String to escape.
|
||||
*/
|
||||
export declare const escape: typeof encodeXML;
|
||||
/**
|
||||
* Encodes all characters not valid in XML documents using XML entities.
|
||||
*
|
||||
* Note that the output will be character-set dependent.
|
||||
*
|
||||
* @param data String to escape.
|
||||
*/
|
||||
export declare const escapeUTF8: (data: string) => string;
|
||||
/**
|
||||
* Encodes all characters that have to be escaped in HTML attributes,
|
||||
* following {@link https://html.spec.whatwg.org/multipage/parsing.html#escapingString}.
|
||||
*
|
||||
* @param data String to escape.
|
||||
*/
|
||||
export declare const escapeAttribute: (data: string) => string;
|
||||
/**
|
||||
* Encodes all characters that have to be escaped in HTML text,
|
||||
* following {@link https://html.spec.whatwg.org/multipage/parsing.html#escapingString}.
|
||||
*
|
||||
* @param data String to escape.
|
||||
*/
|
||||
export declare const escapeText: (data: string) => string;
|
||||
//# sourceMappingURL=escape.d.ts.map
|
||||
-3
@@ -1,3 +0,0 @@
|
||||
declare const _default: Uint16Array;
|
||||
export default _default;
|
||||
//# sourceMappingURL=decode-data-html.d.ts.map
|
||||
-3
@@ -1,3 +0,0 @@
|
||||
declare const _default: Uint16Array;
|
||||
export default _default;
|
||||
//# sourceMappingURL=decode-data-xml.d.ts.map
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
type EncodeTrieNode = string | {
|
||||
v?: string;
|
||||
n: number | Map<number, EncodeTrieNode>;
|
||||
o?: string;
|
||||
};
|
||||
declare const _default: Map<number, EncodeTrieNode>;
|
||||
export default _default;
|
||||
//# sourceMappingURL=encode-html.d.ts.map
|
||||
-96
@@ -1,96 +0,0 @@
|
||||
import { DecodingMode } from "./decode.js";
|
||||
/** The level of entities to support. */
|
||||
export declare enum EntityLevel {
|
||||
/** Support only XML entities. */
|
||||
XML = 0,
|
||||
/** Support HTML entities, which are a superset of XML entities. */
|
||||
HTML = 1
|
||||
}
|
||||
export declare enum EncodingMode {
|
||||
/**
|
||||
* The output is UTF-8 encoded. Only characters that need escaping within
|
||||
* XML will be escaped.
|
||||
*/
|
||||
UTF8 = 0,
|
||||
/**
|
||||
* The output consists only of ASCII characters. Characters that need
|
||||
* escaping within HTML, and characters that aren't ASCII characters will
|
||||
* be escaped.
|
||||
*/
|
||||
ASCII = 1,
|
||||
/**
|
||||
* Encode all characters that have an equivalent entity, as well as all
|
||||
* characters that are not ASCII characters.
|
||||
*/
|
||||
Extensive = 2,
|
||||
/**
|
||||
* Encode all characters that have to be escaped in HTML attributes,
|
||||
* following {@link https://html.spec.whatwg.org/multipage/parsing.html#escapingString}.
|
||||
*/
|
||||
Attribute = 3,
|
||||
/**
|
||||
* Encode all characters that have to be escaped in HTML text,
|
||||
* following {@link https://html.spec.whatwg.org/multipage/parsing.html#escapingString}.
|
||||
*/
|
||||
Text = 4
|
||||
}
|
||||
export interface DecodingOptions {
|
||||
/**
|
||||
* The level of entities to support.
|
||||
* @default {@link EntityLevel.XML}
|
||||
*/
|
||||
level?: EntityLevel;
|
||||
/**
|
||||
* Decoding mode. If `Legacy`, will support legacy entities not terminated
|
||||
* with a semicolon (`;`).
|
||||
*
|
||||
* Always `Strict` for XML. For HTML, set this to `true` if you are parsing
|
||||
* an attribute value.
|
||||
*
|
||||
* The deprecated `decodeStrict` function defaults this to `Strict`.
|
||||
*
|
||||
* @default {@link DecodingMode.Legacy}
|
||||
*/
|
||||
mode?: DecodingMode | undefined;
|
||||
}
|
||||
/**
|
||||
* Decodes a string with entities.
|
||||
*
|
||||
* @param data String to decode.
|
||||
* @param options Decoding options.
|
||||
*/
|
||||
export declare function decode(data: string, options?: DecodingOptions | EntityLevel): string;
|
||||
/**
|
||||
* Decodes a string with entities. Does not allow missing trailing semicolons for entities.
|
||||
*
|
||||
* @param data String to decode.
|
||||
* @param options Decoding options.
|
||||
* @deprecated Use `decode` with the `mode` set to `Strict`.
|
||||
*/
|
||||
export declare function decodeStrict(data: string, options?: DecodingOptions | EntityLevel): string;
|
||||
/**
|
||||
* Options for `encode`.
|
||||
*/
|
||||
export interface EncodingOptions {
|
||||
/**
|
||||
* The level of entities to support.
|
||||
* @default {@link EntityLevel.XML}
|
||||
*/
|
||||
level?: EntityLevel;
|
||||
/**
|
||||
* Output format.
|
||||
* @default {@link EncodingMode.Extensive}
|
||||
*/
|
||||
mode?: EncodingMode;
|
||||
}
|
||||
/**
|
||||
* Encodes a string with entities.
|
||||
*
|
||||
* @param data String to encode.
|
||||
* @param options Encoding options.
|
||||
*/
|
||||
export declare function encode(data: string, options?: EncodingOptions | EntityLevel): string;
|
||||
export { encodeXML, escape, escapeUTF8, escapeAttribute, escapeText, } from "./escape.js";
|
||||
export { encodeHTML, encodeNonAsciiHTML, encodeHTML as encodeHTML4, encodeHTML as encodeHTML5, } from "./encode.js";
|
||||
export { EntityDecoder, DecodingMode, decodeXML, decodeHTML, decodeHTMLStrict, decodeHTMLAttribute, decodeHTML as decodeHTML4, decodeHTML as decodeHTML5, decodeHTMLStrict as decodeHTML4Strict, decodeHTMLStrict as decodeHTML5Strict, decodeXML as decodeXMLStrict, } from "./decode.js";
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
-3
@@ -1,3 +0,0 @@
|
||||
declare const _default: Uint16Array;
|
||||
export default _default;
|
||||
//# sourceMappingURL=decode-data-html.d.ts.map
|
||||
-3
@@ -1,3 +0,0 @@
|
||||
declare const _default: Uint16Array;
|
||||
export default _default;
|
||||
//# sourceMappingURL=decode-data-xml.d.ts.map
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
type EncodeTrieNode = string | {
|
||||
v?: string;
|
||||
n: number | Map<number, EncodeTrieNode>;
|
||||
o?: string;
|
||||
};
|
||||
declare const _default: Map<number, EncodeTrieNode>;
|
||||
export default _default;
|
||||
//# sourceMappingURL=encode-html.d.ts.map
|
||||
-96
@@ -1,96 +0,0 @@
|
||||
import { DecodingMode } from "./decode.js";
|
||||
/** The level of entities to support. */
|
||||
export declare enum EntityLevel {
|
||||
/** Support only XML entities. */
|
||||
XML = 0,
|
||||
/** Support HTML entities, which are a superset of XML entities. */
|
||||
HTML = 1
|
||||
}
|
||||
export declare enum EncodingMode {
|
||||
/**
|
||||
* The output is UTF-8 encoded. Only characters that need escaping within
|
||||
* XML will be escaped.
|
||||
*/
|
||||
UTF8 = 0,
|
||||
/**
|
||||
* The output consists only of ASCII characters. Characters that need
|
||||
* escaping within HTML, and characters that aren't ASCII characters will
|
||||
* be escaped.
|
||||
*/
|
||||
ASCII = 1,
|
||||
/**
|
||||
* Encode all characters that have an equivalent entity, as well as all
|
||||
* characters that are not ASCII characters.
|
||||
*/
|
||||
Extensive = 2,
|
||||
/**
|
||||
* Encode all characters that have to be escaped in HTML attributes,
|
||||
* following {@link https://html.spec.whatwg.org/multipage/parsing.html#escapingString}.
|
||||
*/
|
||||
Attribute = 3,
|
||||
/**
|
||||
* Encode all characters that have to be escaped in HTML text,
|
||||
* following {@link https://html.spec.whatwg.org/multipage/parsing.html#escapingString}.
|
||||
*/
|
||||
Text = 4
|
||||
}
|
||||
export interface DecodingOptions {
|
||||
/**
|
||||
* The level of entities to support.
|
||||
* @default {@link EntityLevel.XML}
|
||||
*/
|
||||
level?: EntityLevel;
|
||||
/**
|
||||
* Decoding mode. If `Legacy`, will support legacy entities not terminated
|
||||
* with a semicolon (`;`).
|
||||
*
|
||||
* Always `Strict` for XML. For HTML, set this to `true` if you are parsing
|
||||
* an attribute value.
|
||||
*
|
||||
* The deprecated `decodeStrict` function defaults this to `Strict`.
|
||||
*
|
||||
* @default {@link DecodingMode.Legacy}
|
||||
*/
|
||||
mode?: DecodingMode | undefined;
|
||||
}
|
||||
/**
|
||||
* Decodes a string with entities.
|
||||
*
|
||||
* @param data String to decode.
|
||||
* @param options Decoding options.
|
||||
*/
|
||||
export declare function decode(data: string, options?: DecodingOptions | EntityLevel): string;
|
||||
/**
|
||||
* Decodes a string with entities. Does not allow missing trailing semicolons for entities.
|
||||
*
|
||||
* @param data String to decode.
|
||||
* @param options Decoding options.
|
||||
* @deprecated Use `decode` with the `mode` set to `Strict`.
|
||||
*/
|
||||
export declare function decodeStrict(data: string, options?: DecodingOptions | EntityLevel): string;
|
||||
/**
|
||||
* Options for `encode`.
|
||||
*/
|
||||
export interface EncodingOptions {
|
||||
/**
|
||||
* The level of entities to support.
|
||||
* @default {@link EntityLevel.XML}
|
||||
*/
|
||||
level?: EntityLevel;
|
||||
/**
|
||||
* Output format.
|
||||
* @default {@link EncodingMode.Extensive}
|
||||
*/
|
||||
mode?: EncodingMode;
|
||||
}
|
||||
/**
|
||||
* Encodes a string with entities.
|
||||
*
|
||||
* @param data String to encode.
|
||||
* @param options Encoding options.
|
||||
*/
|
||||
export declare function encode(data: string, options?: EncodingOptions | EntityLevel): string;
|
||||
export { encodeXML, escape, escapeUTF8, escapeAttribute, escapeText, } from "./escape.js";
|
||||
export { encodeHTML, encodeNonAsciiHTML, encodeHTML as encodeHTML4, encodeHTML as encodeHTML5, } from "./encode.js";
|
||||
export { EntityDecoder, DecodingMode, decodeXML, decodeHTML, decodeHTMLStrict, decodeHTMLAttribute, decodeHTML as decodeHTML4, decodeHTML as decodeHTML5, decodeHTMLStrict as decodeHTML4Strict, decodeHTMLStrict as decodeHTML5Strict, decodeXML as decodeXMLStrict, } from "./decode.js";
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
-55
@@ -1,55 +0,0 @@
|
||||
/**
|
||||
* Returns a function that checks if an elements index matches the given rule
|
||||
* highly optimized to return the fastest solution.
|
||||
*
|
||||
* @param parsed A tuple [a, b], as returned by `parse`.
|
||||
* @returns A highly optimized function that returns whether an index matches the nth-check.
|
||||
* @example
|
||||
*
|
||||
* ```js
|
||||
* const check = nthCheck.compile([2, 3]);
|
||||
*
|
||||
* check(0); // `false`
|
||||
* check(1); // `false`
|
||||
* check(2); // `true`
|
||||
* check(3); // `false`
|
||||
* check(4); // `true`
|
||||
* check(5); // `false`
|
||||
* check(6); // `true`
|
||||
* ```
|
||||
*/
|
||||
export declare function compile(parsed: [a: number, b: number]): (index: number) => boolean;
|
||||
/**
|
||||
* Returns a function that produces a monotonously increasing sequence of indices.
|
||||
*
|
||||
* If the sequence has an end, the returned function will return `null` after
|
||||
* the last index in the sequence.
|
||||
*
|
||||
* @param parsed A tuple [a, b], as returned by `parse`.
|
||||
* @returns A function that produces a sequence of indices.
|
||||
* @example <caption>Always increasing (2n+3)</caption>
|
||||
*
|
||||
* ```js
|
||||
* const gen = nthCheck.generate([2, 3])
|
||||
*
|
||||
* gen() // `1`
|
||||
* gen() // `3`
|
||||
* gen() // `5`
|
||||
* gen() // `8`
|
||||
* gen() // `11`
|
||||
* ```
|
||||
*
|
||||
* @example <caption>With end value (-2n+10)</caption>
|
||||
*
|
||||
* ```js
|
||||
*
|
||||
* const gen = nthCheck.generate([-2, 5]);
|
||||
*
|
||||
* gen() // 0
|
||||
* gen() // 2
|
||||
* gen() // 4
|
||||
* gen() // null
|
||||
* ```
|
||||
*/
|
||||
export declare function generate(parsed: [a: number, b: number]): () => number | null;
|
||||
//# sourceMappingURL=compile.d.ts.map
|
||||
-55
@@ -1,55 +0,0 @@
|
||||
/**
|
||||
* Returns a function that checks if an elements index matches the given rule
|
||||
* highly optimized to return the fastest solution.
|
||||
*
|
||||
* @param parsed A tuple [a, b], as returned by `parse`.
|
||||
* @returns A highly optimized function that returns whether an index matches the nth-check.
|
||||
* @example
|
||||
*
|
||||
* ```js
|
||||
* const check = nthCheck.compile([2, 3]);
|
||||
*
|
||||
* check(0); // `false`
|
||||
* check(1); // `false`
|
||||
* check(2); // `true`
|
||||
* check(3); // `false`
|
||||
* check(4); // `true`
|
||||
* check(5); // `false`
|
||||
* check(6); // `true`
|
||||
* ```
|
||||
*/
|
||||
export declare function compile(parsed: [a: number, b: number]): (index: number) => boolean;
|
||||
/**
|
||||
* Returns a function that produces a monotonously increasing sequence of indices.
|
||||
*
|
||||
* If the sequence has an end, the returned function will return `null` after
|
||||
* the last index in the sequence.
|
||||
*
|
||||
* @param parsed A tuple [a, b], as returned by `parse`.
|
||||
* @returns A function that produces a sequence of indices.
|
||||
* @example <caption>Always increasing (2n+3)</caption>
|
||||
*
|
||||
* ```js
|
||||
* const gen = nthCheck.generate([2, 3])
|
||||
*
|
||||
* gen() // `1`
|
||||
* gen() // `3`
|
||||
* gen() // `5`
|
||||
* gen() // `8`
|
||||
* gen() // `11`
|
||||
* ```
|
||||
*
|
||||
* @example <caption>With end value (-2n+10)</caption>
|
||||
*
|
||||
* ```js
|
||||
*
|
||||
* const gen = nthCheck.generate([-2, 5]);
|
||||
*
|
||||
* gen() // 0
|
||||
* gen() // 2
|
||||
* gen() // 4
|
||||
* gen() // null
|
||||
* ```
|
||||
*/
|
||||
export declare function generate(parsed: [a: number, b: number]): () => number | null;
|
||||
//# sourceMappingURL=compile.d.ts.map
|
||||
-59
@@ -1,59 +0,0 @@
|
||||
import { parse } from "./parse.js";
|
||||
import { compile, generate } from "./compile.js";
|
||||
export { parse, compile, generate };
|
||||
/**
|
||||
* Parses and compiles a formula to a highly optimized function.
|
||||
* Combination of {@link parse} and {@link compile}.
|
||||
*
|
||||
* If the formula doesn't match any elements,
|
||||
* it returns [`boolbase`](https://github.com/fb55/boolbase)'s `falseFunc`.
|
||||
* Otherwise, a function accepting an _index_ is returned, which returns
|
||||
* whether or not the passed _index_ matches the formula.
|
||||
*
|
||||
* Note: The nth-rule starts counting at `1`, the returned function at `0`.
|
||||
*
|
||||
* @param formula The formula to compile.
|
||||
* @example
|
||||
* const check = nthCheck("2n+3");
|
||||
*
|
||||
* check(0); // `false`
|
||||
* check(1); // `false`
|
||||
* check(2); // `true`
|
||||
* check(3); // `false`
|
||||
* check(4); // `true`
|
||||
* check(5); // `false`
|
||||
* check(6); // `true`
|
||||
*/
|
||||
export default function nthCheck(formula: string): (index: number) => boolean;
|
||||
/**
|
||||
* Parses and compiles a formula to a generator that produces a sequence of indices.
|
||||
* Combination of {@link parse} and {@link generate}.
|
||||
*
|
||||
* @param formula The formula to compile.
|
||||
* @returns A function that produces a sequence of indices.
|
||||
* @example <caption>Always increasing</caption>
|
||||
*
|
||||
* ```js
|
||||
* const gen = nthCheck.sequence('2n+3')
|
||||
*
|
||||
* gen() // `1`
|
||||
* gen() // `3`
|
||||
* gen() // `5`
|
||||
* gen() // `8`
|
||||
* gen() // `11`
|
||||
* ```
|
||||
*
|
||||
* @example <caption>With end value</caption>
|
||||
*
|
||||
* ```js
|
||||
*
|
||||
* const gen = nthCheck.sequence('-2n+5');
|
||||
*
|
||||
* gen() // 0
|
||||
* gen() // 2
|
||||
* gen() // 4
|
||||
* gen() // null
|
||||
* ```
|
||||
*/
|
||||
export declare function sequence(formula: string): () => number | null;
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
/**
|
||||
* Parses an expression.
|
||||
*
|
||||
* @throws An `Error` if parsing fails.
|
||||
* @returns An array containing the integer step size and the integer offset of the nth rule.
|
||||
* @example nthCheck.parse("2n+3"); // returns [2, 3]
|
||||
*/
|
||||
export declare function parse(formula: string): [a: number, b: number];
|
||||
//# sourceMappingURL=parse.d.ts.map
|
||||
-59
@@ -1,59 +0,0 @@
|
||||
import { parse } from "./parse.js";
|
||||
import { compile, generate } from "./compile.js";
|
||||
export { parse, compile, generate };
|
||||
/**
|
||||
* Parses and compiles a formula to a highly optimized function.
|
||||
* Combination of {@link parse} and {@link compile}.
|
||||
*
|
||||
* If the formula doesn't match any elements,
|
||||
* it returns [`boolbase`](https://github.com/fb55/boolbase)'s `falseFunc`.
|
||||
* Otherwise, a function accepting an _index_ is returned, which returns
|
||||
* whether or not the passed _index_ matches the formula.
|
||||
*
|
||||
* Note: The nth-rule starts counting at `1`, the returned function at `0`.
|
||||
*
|
||||
* @param formula The formula to compile.
|
||||
* @example
|
||||
* const check = nthCheck("2n+3");
|
||||
*
|
||||
* check(0); // `false`
|
||||
* check(1); // `false`
|
||||
* check(2); // `true`
|
||||
* check(3); // `false`
|
||||
* check(4); // `true`
|
||||
* check(5); // `false`
|
||||
* check(6); // `true`
|
||||
*/
|
||||
export default function nthCheck(formula: string): (index: number) => boolean;
|
||||
/**
|
||||
* Parses and compiles a formula to a generator that produces a sequence of indices.
|
||||
* Combination of {@link parse} and {@link generate}.
|
||||
*
|
||||
* @param formula The formula to compile.
|
||||
* @returns A function that produces a sequence of indices.
|
||||
* @example <caption>Always increasing</caption>
|
||||
*
|
||||
* ```js
|
||||
* const gen = nthCheck.sequence('2n+3')
|
||||
*
|
||||
* gen() // `1`
|
||||
* gen() // `3`
|
||||
* gen() // `5`
|
||||
* gen() // `8`
|
||||
* gen() // `11`
|
||||
* ```
|
||||
*
|
||||
* @example <caption>With end value</caption>
|
||||
*
|
||||
* ```js
|
||||
*
|
||||
* const gen = nthCheck.sequence('-2n+5');
|
||||
*
|
||||
* gen() // 0
|
||||
* gen() // 2
|
||||
* gen() // 4
|
||||
* gen() // null
|
||||
* ```
|
||||
*/
|
||||
export declare function sequence(formula: string): () => number | null;
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
/**
|
||||
* Parses an expression.
|
||||
*
|
||||
* @throws An `Error` if parsing fails.
|
||||
* @returns An array containing the integer step size and the integer offset of the nth rule.
|
||||
* @example nthCheck.parse("2n+3"); // returns [2, 3]
|
||||
*/
|
||||
export declare function parse(formula: string): [a: number, b: number];
|
||||
//# sourceMappingURL=parse.d.ts.map
|
||||
-5
@@ -1,5 +0,0 @@
|
||||
import { Colors } from "./types"
|
||||
|
||||
declare const picocolors: Colors & { createColors: (enabled?: boolean) => Colors }
|
||||
|
||||
export = picocolors
|
||||
-51
@@ -1,51 +0,0 @@
|
||||
export type Formatter = (input: string | number | null | undefined) => string
|
||||
|
||||
export interface Colors {
|
||||
isColorSupported: boolean
|
||||
|
||||
reset: Formatter
|
||||
bold: Formatter
|
||||
dim: Formatter
|
||||
italic: Formatter
|
||||
underline: Formatter
|
||||
inverse: Formatter
|
||||
hidden: Formatter
|
||||
strikethrough: Formatter
|
||||
|
||||
black: Formatter
|
||||
red: Formatter
|
||||
green: Formatter
|
||||
yellow: Formatter
|
||||
blue: Formatter
|
||||
magenta: Formatter
|
||||
cyan: Formatter
|
||||
white: Formatter
|
||||
gray: Formatter
|
||||
|
||||
bgBlack: Formatter
|
||||
bgRed: Formatter
|
||||
bgGreen: Formatter
|
||||
bgYellow: Formatter
|
||||
bgBlue: Formatter
|
||||
bgMagenta: Formatter
|
||||
bgCyan: Formatter
|
||||
bgWhite: Formatter
|
||||
|
||||
blackBright: Formatter
|
||||
redBright: Formatter
|
||||
greenBright: Formatter
|
||||
yellowBright: Formatter
|
||||
blueBright: Formatter
|
||||
magentaBright: Formatter
|
||||
cyanBright: Formatter
|
||||
whiteBright: Formatter
|
||||
|
||||
bgBlackBright: Formatter
|
||||
bgRedBright: Formatter
|
||||
bgGreenBright: Formatter
|
||||
bgYellowBright: Formatter
|
||||
bgBlueBright: Formatter
|
||||
bgMagentaBright: Formatter
|
||||
bgCyanBright: Formatter
|
||||
bgWhiteBright: Formatter
|
||||
}
|
||||
-1
@@ -1 +0,0 @@
|
||||
export { SourceMapConsumer } from '..';
|
||||
-1
@@ -1 +0,0 @@
|
||||
export { SourceMapGenerator } from '..';
|
||||
-1
@@ -1 +0,0 @@
|
||||
export { SourceNode } from '..';
|
||||
-104
@@ -1,104 +0,0 @@
|
||||
export interface StartOfSourceMap {
|
||||
file?: string;
|
||||
sourceRoot?: string;
|
||||
}
|
||||
|
||||
export interface RawSourceMap extends StartOfSourceMap {
|
||||
version: string;
|
||||
sources: string[];
|
||||
names: string[];
|
||||
sourcesContent?: string[];
|
||||
mappings: string;
|
||||
}
|
||||
|
||||
export interface Position {
|
||||
line: number;
|
||||
column: number;
|
||||
}
|
||||
|
||||
export interface LineRange extends Position {
|
||||
lastColumn: number;
|
||||
}
|
||||
|
||||
export interface FindPosition extends Position {
|
||||
// SourceMapConsumer.GREATEST_LOWER_BOUND or SourceMapConsumer.LEAST_UPPER_BOUND
|
||||
bias?: number;
|
||||
}
|
||||
|
||||
export interface SourceFindPosition extends FindPosition {
|
||||
source: string;
|
||||
}
|
||||
|
||||
export interface MappedPosition extends Position {
|
||||
source: string;
|
||||
name?: string;
|
||||
}
|
||||
|
||||
export interface MappingItem {
|
||||
source: string | null;
|
||||
generatedLine: number;
|
||||
generatedColumn: number;
|
||||
originalLine: number | null;
|
||||
originalColumn: number | null;
|
||||
name: string | null;
|
||||
}
|
||||
|
||||
export class SourceMapConsumer {
|
||||
static GENERATED_ORDER: number;
|
||||
static ORIGINAL_ORDER: number;
|
||||
|
||||
static GREATEST_LOWER_BOUND: number;
|
||||
static LEAST_UPPER_BOUND: number;
|
||||
|
||||
constructor(rawSourceMap: RawSourceMap);
|
||||
readonly file: string | undefined | null;
|
||||
readonly sourceRoot: string | undefined | null;
|
||||
readonly sourcesContent: readonly string[] | null | undefined;
|
||||
readonly sources: readonly string[]
|
||||
|
||||
computeColumnSpans(): void;
|
||||
originalPositionFor(generatedPosition: FindPosition): MappedPosition;
|
||||
generatedPositionFor(originalPosition: SourceFindPosition): LineRange;
|
||||
allGeneratedPositionsFor(originalPosition: MappedPosition): Position[];
|
||||
hasContentsOfAllSources(): boolean;
|
||||
sourceContentFor(source: string, returnNullOnMissing?: boolean): string | null;
|
||||
eachMapping(callback: (mapping: MappingItem) => void, context?: any, order?: number): void;
|
||||
}
|
||||
|
||||
export interface Mapping {
|
||||
generated: Position;
|
||||
original?: Position | null;
|
||||
source?: string | null;
|
||||
name?: string | null;
|
||||
}
|
||||
|
||||
export class SourceMapGenerator {
|
||||
constructor(startOfSourceMap?: StartOfSourceMap);
|
||||
static fromSourceMap(sourceMapConsumer: SourceMapConsumer, startOfSourceMap?: StartOfSourceMap): SourceMapGenerator;
|
||||
addMapping(mapping: Mapping): void;
|
||||
setSourceContent(sourceFile: string, sourceContent: string | null | undefined): void;
|
||||
applySourceMap(sourceMapConsumer: SourceMapConsumer, sourceFile?: string, sourceMapPath?: string): void;
|
||||
toString(): string;
|
||||
toJSON(): RawSourceMap;
|
||||
}
|
||||
|
||||
export interface CodeWithSourceMap {
|
||||
code: string;
|
||||
map: SourceMapGenerator;
|
||||
}
|
||||
|
||||
export class SourceNode {
|
||||
constructor();
|
||||
constructor(line: number, column: number, source: string);
|
||||
constructor(line: number, column: number, source: string, chunk?: string, name?: string);
|
||||
static fromStringWithSourceMap(code: string, sourceMapConsumer: SourceMapConsumer, relativePath?: string): SourceNode;
|
||||
add(chunk: string): void;
|
||||
prepend(chunk: string): void;
|
||||
setSourceContent(sourceFile: string, sourceContent: string): void;
|
||||
walk(fn: (chunk: string, mapping: MappedPosition) => void): void;
|
||||
walkSourceContents(fn: (file: string, content: string) => void): void;
|
||||
join(sep: string): SourceNode;
|
||||
replaceRight(pattern: string, replacement: string): SourceNode;
|
||||
toString(): string;
|
||||
toStringWithSourceMap(startOfSourceMap?: StartOfSourceMap): CodeWithSourceMap;
|
||||
}
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
/**
|
||||
* Plugins that are bundled with SVGO. This includes plugin presets, and plugins
|
||||
* that are not enabled by default.
|
||||
*
|
||||
* @type {ReadonlyArray<{[Name in keyof import('./types.js').PluginsParams]: import('./types.js').BuiltinPluginOrPreset<Name, import('./types.js').PluginsParams[Name]>;}[keyof import('./types.js').PluginsParams]>}
|
||||
*/
|
||||
export const builtinPlugins: ReadonlyArray<{ [Name in keyof import("./types.js").PluginsParams]: import("./types.js").BuiltinPluginOrPreset<Name, import("./types.js").PluginsParams[Name]>; }[keyof import("./types.js").PluginsParams]>;
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
export class SvgoParserError extends Error {
|
||||
/**
|
||||
* @param {string} message
|
||||
* @param {number} line
|
||||
* @param {number} column
|
||||
* @param {string} source
|
||||
* @param {string=} file
|
||||
*/
|
||||
constructor(message: string, line: number, column: number, source: string, file?: string | undefined);
|
||||
reason: string;
|
||||
line: number;
|
||||
column: number;
|
||||
source: string;
|
||||
}
|
||||
export function parseSvg(data: string, from?: string | undefined): import("./types.js").XastRoot;
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
export function parsePathData(string: string): import("./types.js").PathDataItem[];
|
||||
export function stringifyPathData({ pathData, precision, disableSpaceAfterFlags, }: StringifyPathDataOptions): string;
|
||||
export type ReadNumberState = "none" | "sign" | "whole" | "decimal_point" | "decimal" | "e" | "exponent_sign" | "exponent";
|
||||
export type StringifyPathDataOptions = {
|
||||
pathData: ReadonlyArray<import("./types.js").PathDataItem>;
|
||||
precision?: number | undefined;
|
||||
disableSpaceAfterFlags?: boolean | undefined;
|
||||
};
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
export function stringifySvg(data: import("./types.js").XastRoot, userOptions?: import("./types.js").StringifyOptions | undefined): string;
|
||||
export type Options = Required<import("./types.js").StringifyOptions>;
|
||||
export type State = {
|
||||
indent: string;
|
||||
textContext: import("./types.js").XastElement | null;
|
||||
indentLevel: number;
|
||||
};
|
||||
-5
@@ -1,5 +0,0 @@
|
||||
export function compareSpecificity(a: import("./types.js").Specificity, b: import("./types.js").Specificity): number;
|
||||
export function collectStylesheet(root: import("./types.js").XastRoot): import("./types.js").Stylesheet;
|
||||
export function computeStyle(stylesheet: import("./types.js").Stylesheet, node: import("./types.js").XastElement): import("./types.js").ComputedStyles;
|
||||
export function includesAttrSelector(selector: csstree.ListItem<csstree.CssNode> | string, name: string, value?: string | null, traversed?: boolean): boolean;
|
||||
import * as csstree from 'css-tree';
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
export * from "./svgo.js";
|
||||
/**
|
||||
* If you write a tool on top of svgo you might need a way to load svgo config.
|
||||
* You can also specify relative or absolute path and customize current working
|
||||
* directory.
|
||||
*
|
||||
* @type {<T extends string | null>(configFile?: T, cwd?: string) => Promise<T extends string ? import('./svgo.js').Config : import('./svgo.js').Config | null>}
|
||||
*/
|
||||
export const loadConfig: <T extends string | null>(configFile?: T, cwd?: string) => Promise<T extends string ? import("./svgo.js").Config : import("./svgo.js").Config | null>;
|
||||
export function optimize(input: string, config?: import("./svgo.js").Config | undefined): import("./svgo.js").Output;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user