From 7a52ddeba2a68388b544f529d2d92104420f77b0 Mon Sep 17 00:00:00 2001 From: Shipwreckt Date: Fri, 31 Oct 2025 20:02:14 +0000 Subject: Changed from static to 11ty! --- node_modules/posthtml/types/posthtml.d.ts | 108 ++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 node_modules/posthtml/types/posthtml.d.ts (limited to 'node_modules/posthtml/types') diff --git a/node_modules/posthtml/types/posthtml.d.ts b/node_modules/posthtml/types/posthtml.d.ts new file mode 100644 index 0000000..0088dd2 --- /dev/null +++ b/node_modules/posthtml/types/posthtml.d.ts @@ -0,0 +1,108 @@ +type Maybe = void | T; +type MaybeArray = T | T[]; + +declare namespace PostHTML { + type StringMatcher = string | RegExp; + type AttrMatcher = Record; + type ContentMatcher = + | StringMatcher[] + | { + tag?: StringMatcher; + attrs?: AttrMatcher; + content?: ContentMatcher[]; + }; + + export type Matcher< + TTag extends StringMatcher, + TAttrs extends Maybe + > = + | StringMatcher + | { + tag?: TTag; + attrs?: TAttrs; + content?: ContentMatcher[]; + }; + + export type Expression< + TTag extends StringMatcher, + TAttrs extends Maybe + > = MaybeArray>; + + export type NodeCallback< + TTag extends Maybe = Maybe, + TAttrs extends Maybe = Maybe + > = (node: Node) => MaybeArray; + + export type NodeAttributes = Record>; + + interface NodeAPI { + walk: (cb: NodeCallback) => Node; + match: < + TTag extends StringMatcher, + TAttrs extends Maybe, + TTagResult extends Maybe = TTag extends string + ? TTag + : TTag extends void + ? Maybe + : string, + TAttrResult extends Maybe = TAttrs extends void + ? Maybe + : { + [P in keyof TAttrs]: string; + } & + NodeAttributes + >( + expression: Expression, + cb: NodeCallback + ) => Node[]; + } + + export interface RawNode< + TTag extends Maybe = Maybe, + TAttrs extends Maybe = Maybe + > { + tag: TTag; + attrs: TAttrs; + content?: Array; + } + + export interface Node< + TTag extends Maybe = Maybe, + TAttrs extends Maybe = Maybe + > extends NodeAPI, RawNode { + content?: Array; + options?: Options; + } + + export interface Options { + sync?: boolean; + parser?: Function; + render?: Function; + skipParse?: boolean; + } + + export type Plugin = ( + tree: Node + ) => void | Node | RawNode | ThisType; + + export interface Result { + html: string; + tree: Node; + messages: TMessage[]; + } + + export interface PostHTML { + version: string; + name: ""; + plugins: Plugin[]; + messages: TMessage[]; + use(plugins: MaybeArray>): this; + process(html: string, options?: Options): Promise>; + } +} + +declare function PostHTML( + plugins?: PostHTML.Plugin[] +): PostHTML.PostHTML; + +export = PostHTML; -- cgit v1.2.3