@mptool/all 0.8.0 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.d.mts CHANGED
@@ -1093,7 +1093,6 @@ interface CookieType {
1093
1093
  sameSite?: boolean | "lax" | "strict" | "none" | undefined;
1094
1094
  }
1095
1095
 
1096
- declare const getCookieScopeDomain: (domain?: string) => string[];
1097
1096
  /**
1098
1097
  * Cookie 类
1099
1098
  */
@@ -1131,18 +1130,19 @@ declare class Cookie {
1131
1130
  * @see RFC 6265
1132
1131
  */
1133
1132
  declare const normalizeDomain: (domain?: string) => string;
1133
+ declare const getDomain: (domainOrURL: string) => string;
1134
+ declare const getCookieScopeDomain: (domain?: string) => string[];
1134
1135
  interface UrlInfo {
1135
1136
  domain: string;
1136
1137
  path: string;
1137
1138
  }
1138
- declare const getDomain: (domainOrURL: string) => string;
1139
1139
  declare const parseUrl: (url: string) => UrlInfo;
1140
- type CookieOptions = string | {
1140
+ type Url = string;
1141
+ type CookieOptions = Url | {
1141
1142
  domain?: string;
1142
1143
  path?: string;
1143
1144
  };
1144
- declare const getCookieOptions: (options: CookieOptions) => UrlInfo;
1145
- declare const parseCookieHeader: (setCookieHeader: string, domain: string) => Cookie[];
1145
+ declare const getUrlInfo: (options: CookieOptions) => UrlInfo;
1146
1146
 
1147
1147
  type CookieMap = Map<string, Cookie>;
1148
1148
  type CookieStoreType = Map<string, CookieMap>;
@@ -1159,6 +1159,7 @@ interface SetCookieOptions {
1159
1159
  * CookieStore 类
1160
1160
  */
1161
1161
  declare class CookieStore {
1162
+ #private;
1162
1163
  /** 存储键值 */
1163
1164
  private key;
1164
1165
  private store;
@@ -1234,7 +1235,7 @@ declare class CookieStore {
1234
1235
  *
1235
1236
  * @param domain 指定域名
1236
1237
  */
1237
- clear(domain?: string): void;
1238
+ clear(domain?: string, exact?: boolean): void;
1238
1239
  /**
1239
1240
  * 应用 header cookies
1240
1241
  *
@@ -1256,16 +1257,9 @@ declare class CookieStore {
1256
1257
  * @return request cookie header
1257
1258
  */
1258
1259
  getHeader(options: CookieOptions): string;
1259
- /**
1260
- * 从 Storage 读取 cookies
1261
- */
1262
- private init;
1263
- /**
1264
- * 将 cookies 保存到 Storage
1265
- */
1266
- private save;
1267
1260
  }
1268
1261
 
1262
+ declare const parseCookieHeader: (setCookieHeader: string, domain: string) => Cookie[];
1269
1263
  type HeadersInit = [string, string][] | Record<string, string> | Headers;
1270
1264
  declare class Headers {
1271
1265
  private headers;
@@ -1516,4 +1510,265 @@ interface RequestFactory {
1516
1510
  */
1517
1511
  declare const createRequest: ({ cookieStore, server, responseHandler, errorHandler, ...defaultOptions }?: RequestInitOptions) => RequestFactory;
1518
1512
 
1519
- export { $App, $Component, $Config, $Page, type AppConfigCommonOptions, type AppConfigOptions, type AppConstructor, type AppInstance, type AppOptions, type ComponentConstructor, type ComponentInstance, type ComponentLifetimes, type ComponentOptions, type Config, Cookie, type CookieMap, type CookieOptions, CookieStore, type CookieStoreType, type CookieType, Emitter, type EmitterInstance, type EventHandlerList, type EventHandlerMap, type EventType, type ExtendedAppMethods, type ExtendedComponentMethods, type ExtendedComponentProperty, type ExtendedPageLifeCycles, type ExtendedPageMethods, type ExtendedPageProperties, type ExtendsAppOptions, type Handler, Headers, type HeadersInit, type InferFromType, type InferPropType, type InferPropTypes, type PageConstructor, type PageInstance, type PageOptions, type PageQuery, type PageState, type PropItem, type PropOption, type PropType, type Props, type PropsOptions, Queue, type RefMap, type RequestBody, type RequestError, type RequestFactory, type RequestInitOptions, type RequestOptions, type RequestResponse, type RequestType, type RouteCustomConfig, type RoutePathConfig, type SetCookieOptions, type StorageData, type Task, type TrivialComponentInstance, type TrivialComponentOptions, type TrivialPageInstance, type TrivialPageOptions, URLSearchParams, type UrlInfo, type WildCardEventHandlerList, type WildcardHandler, appState, check, checkAsync, createRequest, decode as decodeBase64, dirname, userEmitter as emitter, encode as encodeBase64, exists, funcQueue, get, getAsync, getConfig, getCookieOptions, getCookieScopeDomain, getDomain, getRef, handleProperties, isDir, isFile, isFunction, isMp, isQQ, isWx, lock, logger, ls, mkdir, normalizeDomain, once, parseCookieHeader, parseUrl, put, query, readFile, readJSON, remove, removeAsync, removeRef, request, requestCookieStore, rm, saveFile, saveOnlineFile, set, setAsync, setRef, storage, take, type, unzip, wrapFunction, writeFile, writeJSON };
1513
+ type AllowTag = "a" | "abbr" | "address" | "article" | "aside" | "b" | "bdi" | "bdo" | "blockquote" | "br" | "caption" | "cite" | "code" | "col" | "colgroup" | "dd" | "del" | "div" | "dl" | "dt" | "em" | "fieldset" | "footer" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "header" | "hr" | "i" | "img" | "ins" | "label" | "legend" | "li" | "mark" | "nav" | "ol" | "p" | "pre" | "q" | "rt" | "ruby" | "s" | "section" | "small" | "span" | "strong" | "sub" | "sup" | "table" | "tbody" | "td" | "tfoot" | "th" | "thead" | "tr" | "tt" | "u" | "ul";
1514
+ declare const ALLOWED_TAGS: [
1515
+ tag: AllowTag | "big" | "center" | "font",
1516
+ allowedAttrs?: string[]
1517
+ ][];
1518
+
1519
+ /** Types of elements found in htmlparser2's DOM */
1520
+ declare enum ElementType {
1521
+ /** Type for the root element of a document */
1522
+ Root = "root",
1523
+ /** Type for Text */
1524
+ Text = "text",
1525
+ /** Type for <? ... ?> */
1526
+ Directive = "directive",
1527
+ /** Type for <!-- ... --> */
1528
+ Comment = "comment",
1529
+ /** Type for <script> tags */
1530
+ Script = "script",
1531
+ /** Type for <style> tags */
1532
+ Style = "style",
1533
+ /** Type for Any tag */
1534
+ Tag = "tag",
1535
+ /** Type for <![CDATA[ ... ]]> */
1536
+ CDATA = "cdata",
1537
+ /** Type for <!doctype ...> */
1538
+ Doctype = "doctype"
1539
+ }
1540
+
1541
+ interface SourceCodeLocation {
1542
+ /** One-based line index of the first character. */
1543
+ startLine: number;
1544
+ /** One-based column index of the first character. */
1545
+ startCol: number;
1546
+ /** Zero-based first character index. */
1547
+ startOffset: number;
1548
+ /** One-based line index of the last character. */
1549
+ endLine: number;
1550
+ /** One-based column index of the last character. Points directly *after* the last character. */
1551
+ endCol: number;
1552
+ /** Zero-based last character index. Points directly *after* the last character. */
1553
+ endOffset: number;
1554
+ }
1555
+ interface TagSourceCodeLocation extends SourceCodeLocation {
1556
+ startTag?: SourceCodeLocation;
1557
+ endTag?: SourceCodeLocation;
1558
+ }
1559
+ declare type ParentNode = Document | Element | CDATA;
1560
+ declare type ChildNode = Text | Comment | ProcessingInstruction | Element | CDATA | Document;
1561
+ declare type AnyNode = ParentNode | ChildNode;
1562
+ /**
1563
+ * This object will be used as the prototype for Nodes when creating a
1564
+ * DOM-Level-1-compliant structure.
1565
+ */
1566
+ declare abstract class Node {
1567
+ /** The type of the node. */
1568
+ abstract readonly type: ElementType;
1569
+ /** Parent of the node */
1570
+ parent: ParentNode | null;
1571
+ /** Previous sibling */
1572
+ prev: ChildNode | null;
1573
+ /** Next sibling */
1574
+ next: ChildNode | null;
1575
+ /** The start index of the node. Requires `withStartIndices` on the handler to be `true. */
1576
+ startIndex: number | null;
1577
+ /** The end index of the node. Requires `withEndIndices` on the handler to be `true. */
1578
+ endIndex: number | null;
1579
+ /**
1580
+ * `parse5` source code location info.
1581
+ *
1582
+ * Available if parsing with parse5 and location info is enabled.
1583
+ */
1584
+ sourceCodeLocation?: SourceCodeLocation | null;
1585
+ /**
1586
+ * [DOM spec](https://dom.spec.whatwg.org/#dom-node-nodetype)-compatible
1587
+ * node {@link type}.
1588
+ */
1589
+ abstract readonly nodeType: number;
1590
+ /**
1591
+ * Same as {@link parent}.
1592
+ * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
1593
+ */
1594
+ get parentNode(): ParentNode | null;
1595
+ set parentNode(parent: ParentNode | null);
1596
+ /**
1597
+ * Same as {@link prev}.
1598
+ * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
1599
+ */
1600
+ get previousSibling(): ChildNode | null;
1601
+ set previousSibling(prev: ChildNode | null);
1602
+ /**
1603
+ * Same as {@link next}.
1604
+ * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
1605
+ */
1606
+ get nextSibling(): ChildNode | null;
1607
+ set nextSibling(next: ChildNode | null);
1608
+ /**
1609
+ * Clone this node, and optionally its children.
1610
+ *
1611
+ * @param recursive Clone child nodes as well.
1612
+ * @returns A clone of the node.
1613
+ */
1614
+ cloneNode<T extends Node>(this: T, recursive?: boolean): T;
1615
+ }
1616
+ /**
1617
+ * A node that contains some data.
1618
+ */
1619
+ declare abstract class DataNode extends Node {
1620
+ data: string;
1621
+ /**
1622
+ * @param data The content of the data node
1623
+ */
1624
+ constructor(data: string);
1625
+ /**
1626
+ * Same as {@link data}.
1627
+ * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
1628
+ */
1629
+ get nodeValue(): string;
1630
+ set nodeValue(data: string);
1631
+ }
1632
+ /**
1633
+ * Text within the document.
1634
+ */
1635
+ declare class Text extends DataNode {
1636
+ type: ElementType.Text;
1637
+ get nodeType(): 3;
1638
+ }
1639
+ /**
1640
+ * Comments within the document.
1641
+ */
1642
+ declare class Comment extends DataNode {
1643
+ type: ElementType.Comment;
1644
+ get nodeType(): 8;
1645
+ }
1646
+ /**
1647
+ * Processing instructions, including doc types.
1648
+ */
1649
+ declare class ProcessingInstruction extends DataNode {
1650
+ name: string;
1651
+ type: ElementType.Directive;
1652
+ constructor(name: string, data: string);
1653
+ get nodeType(): 1;
1654
+ /** If this is a doctype, the document type name (parse5 only). */
1655
+ "x-name"?: string;
1656
+ /** If this is a doctype, the document type public identifier (parse5 only). */
1657
+ "x-publicId"?: string;
1658
+ /** If this is a doctype, the document type system identifier (parse5 only). */
1659
+ "x-systemId"?: string;
1660
+ }
1661
+ /**
1662
+ * A `Node` that can have children.
1663
+ */
1664
+ declare abstract class NodeWithChildren extends Node {
1665
+ children: ChildNode[];
1666
+ /**
1667
+ * @param children Children of the node. Only certain node types can have children.
1668
+ */
1669
+ constructor(children: ChildNode[]);
1670
+ /** First child of the node. */
1671
+ get firstChild(): ChildNode | null;
1672
+ /** Last child of the node. */
1673
+ get lastChild(): ChildNode | null;
1674
+ /**
1675
+ * Same as {@link children}.
1676
+ * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
1677
+ */
1678
+ get childNodes(): ChildNode[];
1679
+ set childNodes(children: ChildNode[]);
1680
+ }
1681
+ declare class CDATA extends NodeWithChildren {
1682
+ type: ElementType.CDATA;
1683
+ get nodeType(): 4;
1684
+ }
1685
+ /**
1686
+ * The root node of the document.
1687
+ */
1688
+ declare class Document extends NodeWithChildren {
1689
+ type: ElementType.Root;
1690
+ get nodeType(): 9;
1691
+ /** [Document mode](https://dom.spec.whatwg.org/#concept-document-limited-quirks) (parse5 only). */
1692
+ "x-mode"?: "no-quirks" | "quirks" | "limited-quirks";
1693
+ }
1694
+ /**
1695
+ * The description of an individual attribute.
1696
+ */
1697
+ interface Attribute {
1698
+ name: string;
1699
+ value: string;
1700
+ namespace?: string;
1701
+ prefix?: string;
1702
+ }
1703
+ /**
1704
+ * An element within the DOM.
1705
+ */
1706
+ declare class Element extends NodeWithChildren {
1707
+ name: string;
1708
+ attribs: {
1709
+ [name: string]: string;
1710
+ };
1711
+ type: ElementType.Tag | ElementType.Script | ElementType.Style;
1712
+ /**
1713
+ * @param name Name of the tag, eg. `div`, `span`.
1714
+ * @param attribs Object mapping attribute names to attribute values.
1715
+ * @param children Children of the node.
1716
+ */
1717
+ constructor(name: string, attribs: {
1718
+ [name: string]: string;
1719
+ }, children?: ChildNode[], type?: ElementType.Tag | ElementType.Script | ElementType.Style);
1720
+ get nodeType(): 1;
1721
+ /**
1722
+ * `parse5` source code location info, with start & end tags.
1723
+ *
1724
+ * Available if parsing with parse5 and location info is enabled.
1725
+ */
1726
+ sourceCodeLocation?: TagSourceCodeLocation | null;
1727
+ /**
1728
+ * Same as {@link name}.
1729
+ * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
1730
+ */
1731
+ get tagName(): string;
1732
+ set tagName(name: string);
1733
+ get attributes(): Attribute[];
1734
+ /** Element namespace (parse5 only). */
1735
+ namespace?: string;
1736
+ /** Element attribute namespaces (parse5 only). */
1737
+ "x-attribsNamespace"?: Record<string, string>;
1738
+ /** Element attribute namespace-related prefixes (parse5 only). */
1739
+ "x-attribsPrefix"?: Record<string, string>;
1740
+ }
1741
+
1742
+ declare const parseHTML: (content: string) => AnyNode[];
1743
+
1744
+ interface ElementNode {
1745
+ type: "node";
1746
+ name: string;
1747
+ attrs?: Record<string, string>;
1748
+ children?: RichTextNode[];
1749
+ }
1750
+ interface TextNode {
1751
+ type: "text";
1752
+ text: string;
1753
+ }
1754
+ type RichTextNode = ElementNode | TextNode;
1755
+
1756
+ type NodeHandler = (node: ElementNode) => ElementNode | null | Promise<ElementNode | null>;
1757
+ interface ParserOptions {
1758
+ /**
1759
+ * 是否附加标签名到 class
1760
+ *
1761
+ * @default true
1762
+ */
1763
+ appendClass?: boolean;
1764
+ /**
1765
+ * 处理 Tag
1766
+ */
1767
+ transform?: Partial<Record<AllowTag, NodeHandler>>;
1768
+ }
1769
+
1770
+ declare const getRichTextNodes: (content: string | AnyNode[], { appendClass, transform }?: ParserOptions) => Promise<RichTextNode[]>;
1771
+
1772
+ declare const getText: (content: string | AnyNode[]) => string;
1773
+
1774
+ export { $App, $Component, $Config, $Page, ALLOWED_TAGS, type AllowTag, type AppConfigCommonOptions, type AppConfigOptions, type AppConstructor, type AppInstance, type AppOptions, type ComponentConstructor, type ComponentInstance, type ComponentLifetimes, type ComponentOptions, type Config, Cookie, type CookieMap, type CookieOptions, CookieStore, type CookieStoreType, type CookieType, type ElementNode, Emitter, type EmitterInstance, type EventHandlerList, type EventHandlerMap, type EventType, type ExtendedAppMethods, type ExtendedComponentMethods, type ExtendedComponentProperty, type ExtendedPageLifeCycles, type ExtendedPageMethods, type ExtendedPageProperties, type ExtendsAppOptions, type Handler, Headers, type HeadersInit, type InferFromType, type InferPropType, type InferPropTypes, type PageConstructor, type PageInstance, type PageOptions, type PageQuery, type PageState, type PropItem, type PropOption, type PropType, type Props, type PropsOptions, Queue, type RefMap, type RequestBody, type RequestError, type RequestFactory, type RequestInitOptions, type RequestOptions, type RequestResponse, type RequestType, type RichTextNode, type RouteCustomConfig, type RoutePathConfig, type SetCookieOptions, type StorageData, type Task, type TextNode, type TrivialComponentInstance, type TrivialComponentOptions, type TrivialPageInstance, type TrivialPageOptions, URLSearchParams, type UrlInfo, type WildCardEventHandlerList, type WildcardHandler, appState, check, checkAsync, createRequest, decode as decodeBase64, dirname, userEmitter as emitter, encode as encodeBase64, exists, funcQueue, get, getAsync, getConfig, getCookieScopeDomain, getDomain, getRef, getRichTextNodes, getText, getUrlInfo, handleProperties, isDir, isFile, isFunction, isMp, isQQ, isWx, lock, logger, ls, mkdir, normalizeDomain, once, parseCookieHeader, parseHTML, parseUrl, put, query, readFile, readJSON, remove, removeAsync, removeRef, request, requestCookieStore, rm, saveFile, saveOnlineFile, set, setAsync, setRef, storage, take, type, unzip, wrapFunction, writeFile, writeJSON };
package/lib/index.d.ts CHANGED
@@ -1093,7 +1093,6 @@ interface CookieType {
1093
1093
  sameSite?: boolean | "lax" | "strict" | "none" | undefined;
1094
1094
  }
1095
1095
 
1096
- declare const getCookieScopeDomain: (domain?: string) => string[];
1097
1096
  /**
1098
1097
  * Cookie 类
1099
1098
  */
@@ -1131,18 +1130,19 @@ declare class Cookie {
1131
1130
  * @see RFC 6265
1132
1131
  */
1133
1132
  declare const normalizeDomain: (domain?: string) => string;
1133
+ declare const getDomain: (domainOrURL: string) => string;
1134
+ declare const getCookieScopeDomain: (domain?: string) => string[];
1134
1135
  interface UrlInfo {
1135
1136
  domain: string;
1136
1137
  path: string;
1137
1138
  }
1138
- declare const getDomain: (domainOrURL: string) => string;
1139
1139
  declare const parseUrl: (url: string) => UrlInfo;
1140
- type CookieOptions = string | {
1140
+ type Url = string;
1141
+ type CookieOptions = Url | {
1141
1142
  domain?: string;
1142
1143
  path?: string;
1143
1144
  };
1144
- declare const getCookieOptions: (options: CookieOptions) => UrlInfo;
1145
- declare const parseCookieHeader: (setCookieHeader: string, domain: string) => Cookie[];
1145
+ declare const getUrlInfo: (options: CookieOptions) => UrlInfo;
1146
1146
 
1147
1147
  type CookieMap = Map<string, Cookie>;
1148
1148
  type CookieStoreType = Map<string, CookieMap>;
@@ -1159,6 +1159,7 @@ interface SetCookieOptions {
1159
1159
  * CookieStore 类
1160
1160
  */
1161
1161
  declare class CookieStore {
1162
+ #private;
1162
1163
  /** 存储键值 */
1163
1164
  private key;
1164
1165
  private store;
@@ -1234,7 +1235,7 @@ declare class CookieStore {
1234
1235
  *
1235
1236
  * @param domain 指定域名
1236
1237
  */
1237
- clear(domain?: string): void;
1238
+ clear(domain?: string, exact?: boolean): void;
1238
1239
  /**
1239
1240
  * 应用 header cookies
1240
1241
  *
@@ -1256,16 +1257,9 @@ declare class CookieStore {
1256
1257
  * @return request cookie header
1257
1258
  */
1258
1259
  getHeader(options: CookieOptions): string;
1259
- /**
1260
- * 从 Storage 读取 cookies
1261
- */
1262
- private init;
1263
- /**
1264
- * 将 cookies 保存到 Storage
1265
- */
1266
- private save;
1267
1260
  }
1268
1261
 
1262
+ declare const parseCookieHeader: (setCookieHeader: string, domain: string) => Cookie[];
1269
1263
  type HeadersInit = [string, string][] | Record<string, string> | Headers;
1270
1264
  declare class Headers {
1271
1265
  private headers;
@@ -1516,4 +1510,265 @@ interface RequestFactory {
1516
1510
  */
1517
1511
  declare const createRequest: ({ cookieStore, server, responseHandler, errorHandler, ...defaultOptions }?: RequestInitOptions) => RequestFactory;
1518
1512
 
1519
- export { $App, $Component, $Config, $Page, type AppConfigCommonOptions, type AppConfigOptions, type AppConstructor, type AppInstance, type AppOptions, type ComponentConstructor, type ComponentInstance, type ComponentLifetimes, type ComponentOptions, type Config, Cookie, type CookieMap, type CookieOptions, CookieStore, type CookieStoreType, type CookieType, Emitter, type EmitterInstance, type EventHandlerList, type EventHandlerMap, type EventType, type ExtendedAppMethods, type ExtendedComponentMethods, type ExtendedComponentProperty, type ExtendedPageLifeCycles, type ExtendedPageMethods, type ExtendedPageProperties, type ExtendsAppOptions, type Handler, Headers, type HeadersInit, type InferFromType, type InferPropType, type InferPropTypes, type PageConstructor, type PageInstance, type PageOptions, type PageQuery, type PageState, type PropItem, type PropOption, type PropType, type Props, type PropsOptions, Queue, type RefMap, type RequestBody, type RequestError, type RequestFactory, type RequestInitOptions, type RequestOptions, type RequestResponse, type RequestType, type RouteCustomConfig, type RoutePathConfig, type SetCookieOptions, type StorageData, type Task, type TrivialComponentInstance, type TrivialComponentOptions, type TrivialPageInstance, type TrivialPageOptions, URLSearchParams, type UrlInfo, type WildCardEventHandlerList, type WildcardHandler, appState, check, checkAsync, createRequest, decode as decodeBase64, dirname, userEmitter as emitter, encode as encodeBase64, exists, funcQueue, get, getAsync, getConfig, getCookieOptions, getCookieScopeDomain, getDomain, getRef, handleProperties, isDir, isFile, isFunction, isMp, isQQ, isWx, lock, logger, ls, mkdir, normalizeDomain, once, parseCookieHeader, parseUrl, put, query, readFile, readJSON, remove, removeAsync, removeRef, request, requestCookieStore, rm, saveFile, saveOnlineFile, set, setAsync, setRef, storage, take, type, unzip, wrapFunction, writeFile, writeJSON };
1513
+ type AllowTag = "a" | "abbr" | "address" | "article" | "aside" | "b" | "bdi" | "bdo" | "blockquote" | "br" | "caption" | "cite" | "code" | "col" | "colgroup" | "dd" | "del" | "div" | "dl" | "dt" | "em" | "fieldset" | "footer" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "header" | "hr" | "i" | "img" | "ins" | "label" | "legend" | "li" | "mark" | "nav" | "ol" | "p" | "pre" | "q" | "rt" | "ruby" | "s" | "section" | "small" | "span" | "strong" | "sub" | "sup" | "table" | "tbody" | "td" | "tfoot" | "th" | "thead" | "tr" | "tt" | "u" | "ul";
1514
+ declare const ALLOWED_TAGS: [
1515
+ tag: AllowTag | "big" | "center" | "font",
1516
+ allowedAttrs?: string[]
1517
+ ][];
1518
+
1519
+ /** Types of elements found in htmlparser2's DOM */
1520
+ declare enum ElementType {
1521
+ /** Type for the root element of a document */
1522
+ Root = "root",
1523
+ /** Type for Text */
1524
+ Text = "text",
1525
+ /** Type for <? ... ?> */
1526
+ Directive = "directive",
1527
+ /** Type for <!-- ... --> */
1528
+ Comment = "comment",
1529
+ /** Type for <script> tags */
1530
+ Script = "script",
1531
+ /** Type for <style> tags */
1532
+ Style = "style",
1533
+ /** Type for Any tag */
1534
+ Tag = "tag",
1535
+ /** Type for <![CDATA[ ... ]]> */
1536
+ CDATA = "cdata",
1537
+ /** Type for <!doctype ...> */
1538
+ Doctype = "doctype"
1539
+ }
1540
+
1541
+ interface SourceCodeLocation {
1542
+ /** One-based line index of the first character. */
1543
+ startLine: number;
1544
+ /** One-based column index of the first character. */
1545
+ startCol: number;
1546
+ /** Zero-based first character index. */
1547
+ startOffset: number;
1548
+ /** One-based line index of the last character. */
1549
+ endLine: number;
1550
+ /** One-based column index of the last character. Points directly *after* the last character. */
1551
+ endCol: number;
1552
+ /** Zero-based last character index. Points directly *after* the last character. */
1553
+ endOffset: number;
1554
+ }
1555
+ interface TagSourceCodeLocation extends SourceCodeLocation {
1556
+ startTag?: SourceCodeLocation;
1557
+ endTag?: SourceCodeLocation;
1558
+ }
1559
+ declare type ParentNode = Document | Element | CDATA;
1560
+ declare type ChildNode = Text | Comment | ProcessingInstruction | Element | CDATA | Document;
1561
+ declare type AnyNode = ParentNode | ChildNode;
1562
+ /**
1563
+ * This object will be used as the prototype for Nodes when creating a
1564
+ * DOM-Level-1-compliant structure.
1565
+ */
1566
+ declare abstract class Node {
1567
+ /** The type of the node. */
1568
+ abstract readonly type: ElementType;
1569
+ /** Parent of the node */
1570
+ parent: ParentNode | null;
1571
+ /** Previous sibling */
1572
+ prev: ChildNode | null;
1573
+ /** Next sibling */
1574
+ next: ChildNode | null;
1575
+ /** The start index of the node. Requires `withStartIndices` on the handler to be `true. */
1576
+ startIndex: number | null;
1577
+ /** The end index of the node. Requires `withEndIndices` on the handler to be `true. */
1578
+ endIndex: number | null;
1579
+ /**
1580
+ * `parse5` source code location info.
1581
+ *
1582
+ * Available if parsing with parse5 and location info is enabled.
1583
+ */
1584
+ sourceCodeLocation?: SourceCodeLocation | null;
1585
+ /**
1586
+ * [DOM spec](https://dom.spec.whatwg.org/#dom-node-nodetype)-compatible
1587
+ * node {@link type}.
1588
+ */
1589
+ abstract readonly nodeType: number;
1590
+ /**
1591
+ * Same as {@link parent}.
1592
+ * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
1593
+ */
1594
+ get parentNode(): ParentNode | null;
1595
+ set parentNode(parent: ParentNode | null);
1596
+ /**
1597
+ * Same as {@link prev}.
1598
+ * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
1599
+ */
1600
+ get previousSibling(): ChildNode | null;
1601
+ set previousSibling(prev: ChildNode | null);
1602
+ /**
1603
+ * Same as {@link next}.
1604
+ * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
1605
+ */
1606
+ get nextSibling(): ChildNode | null;
1607
+ set nextSibling(next: ChildNode | null);
1608
+ /**
1609
+ * Clone this node, and optionally its children.
1610
+ *
1611
+ * @param recursive Clone child nodes as well.
1612
+ * @returns A clone of the node.
1613
+ */
1614
+ cloneNode<T extends Node>(this: T, recursive?: boolean): T;
1615
+ }
1616
+ /**
1617
+ * A node that contains some data.
1618
+ */
1619
+ declare abstract class DataNode extends Node {
1620
+ data: string;
1621
+ /**
1622
+ * @param data The content of the data node
1623
+ */
1624
+ constructor(data: string);
1625
+ /**
1626
+ * Same as {@link data}.
1627
+ * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
1628
+ */
1629
+ get nodeValue(): string;
1630
+ set nodeValue(data: string);
1631
+ }
1632
+ /**
1633
+ * Text within the document.
1634
+ */
1635
+ declare class Text extends DataNode {
1636
+ type: ElementType.Text;
1637
+ get nodeType(): 3;
1638
+ }
1639
+ /**
1640
+ * Comments within the document.
1641
+ */
1642
+ declare class Comment extends DataNode {
1643
+ type: ElementType.Comment;
1644
+ get nodeType(): 8;
1645
+ }
1646
+ /**
1647
+ * Processing instructions, including doc types.
1648
+ */
1649
+ declare class ProcessingInstruction extends DataNode {
1650
+ name: string;
1651
+ type: ElementType.Directive;
1652
+ constructor(name: string, data: string);
1653
+ get nodeType(): 1;
1654
+ /** If this is a doctype, the document type name (parse5 only). */
1655
+ "x-name"?: string;
1656
+ /** If this is a doctype, the document type public identifier (parse5 only). */
1657
+ "x-publicId"?: string;
1658
+ /** If this is a doctype, the document type system identifier (parse5 only). */
1659
+ "x-systemId"?: string;
1660
+ }
1661
+ /**
1662
+ * A `Node` that can have children.
1663
+ */
1664
+ declare abstract class NodeWithChildren extends Node {
1665
+ children: ChildNode[];
1666
+ /**
1667
+ * @param children Children of the node. Only certain node types can have children.
1668
+ */
1669
+ constructor(children: ChildNode[]);
1670
+ /** First child of the node. */
1671
+ get firstChild(): ChildNode | null;
1672
+ /** Last child of the node. */
1673
+ get lastChild(): ChildNode | null;
1674
+ /**
1675
+ * Same as {@link children}.
1676
+ * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
1677
+ */
1678
+ get childNodes(): ChildNode[];
1679
+ set childNodes(children: ChildNode[]);
1680
+ }
1681
+ declare class CDATA extends NodeWithChildren {
1682
+ type: ElementType.CDATA;
1683
+ get nodeType(): 4;
1684
+ }
1685
+ /**
1686
+ * The root node of the document.
1687
+ */
1688
+ declare class Document extends NodeWithChildren {
1689
+ type: ElementType.Root;
1690
+ get nodeType(): 9;
1691
+ /** [Document mode](https://dom.spec.whatwg.org/#concept-document-limited-quirks) (parse5 only). */
1692
+ "x-mode"?: "no-quirks" | "quirks" | "limited-quirks";
1693
+ }
1694
+ /**
1695
+ * The description of an individual attribute.
1696
+ */
1697
+ interface Attribute {
1698
+ name: string;
1699
+ value: string;
1700
+ namespace?: string;
1701
+ prefix?: string;
1702
+ }
1703
+ /**
1704
+ * An element within the DOM.
1705
+ */
1706
+ declare class Element extends NodeWithChildren {
1707
+ name: string;
1708
+ attribs: {
1709
+ [name: string]: string;
1710
+ };
1711
+ type: ElementType.Tag | ElementType.Script | ElementType.Style;
1712
+ /**
1713
+ * @param name Name of the tag, eg. `div`, `span`.
1714
+ * @param attribs Object mapping attribute names to attribute values.
1715
+ * @param children Children of the node.
1716
+ */
1717
+ constructor(name: string, attribs: {
1718
+ [name: string]: string;
1719
+ }, children?: ChildNode[], type?: ElementType.Tag | ElementType.Script | ElementType.Style);
1720
+ get nodeType(): 1;
1721
+ /**
1722
+ * `parse5` source code location info, with start & end tags.
1723
+ *
1724
+ * Available if parsing with parse5 and location info is enabled.
1725
+ */
1726
+ sourceCodeLocation?: TagSourceCodeLocation | null;
1727
+ /**
1728
+ * Same as {@link name}.
1729
+ * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
1730
+ */
1731
+ get tagName(): string;
1732
+ set tagName(name: string);
1733
+ get attributes(): Attribute[];
1734
+ /** Element namespace (parse5 only). */
1735
+ namespace?: string;
1736
+ /** Element attribute namespaces (parse5 only). */
1737
+ "x-attribsNamespace"?: Record<string, string>;
1738
+ /** Element attribute namespace-related prefixes (parse5 only). */
1739
+ "x-attribsPrefix"?: Record<string, string>;
1740
+ }
1741
+
1742
+ declare const parseHTML: (content: string) => AnyNode[];
1743
+
1744
+ interface ElementNode {
1745
+ type: "node";
1746
+ name: string;
1747
+ attrs?: Record<string, string>;
1748
+ children?: RichTextNode[];
1749
+ }
1750
+ interface TextNode {
1751
+ type: "text";
1752
+ text: string;
1753
+ }
1754
+ type RichTextNode = ElementNode | TextNode;
1755
+
1756
+ type NodeHandler = (node: ElementNode) => ElementNode | null | Promise<ElementNode | null>;
1757
+ interface ParserOptions {
1758
+ /**
1759
+ * 是否附加标签名到 class
1760
+ *
1761
+ * @default true
1762
+ */
1763
+ appendClass?: boolean;
1764
+ /**
1765
+ * 处理 Tag
1766
+ */
1767
+ transform?: Partial<Record<AllowTag, NodeHandler>>;
1768
+ }
1769
+
1770
+ declare const getRichTextNodes: (content: string | AnyNode[], { appendClass, transform }?: ParserOptions) => Promise<RichTextNode[]>;
1771
+
1772
+ declare const getText: (content: string | AnyNode[]) => string;
1773
+
1774
+ export { $App, $Component, $Config, $Page, ALLOWED_TAGS, type AllowTag, type AppConfigCommonOptions, type AppConfigOptions, type AppConstructor, type AppInstance, type AppOptions, type ComponentConstructor, type ComponentInstance, type ComponentLifetimes, type ComponentOptions, type Config, Cookie, type CookieMap, type CookieOptions, CookieStore, type CookieStoreType, type CookieType, type ElementNode, Emitter, type EmitterInstance, type EventHandlerList, type EventHandlerMap, type EventType, type ExtendedAppMethods, type ExtendedComponentMethods, type ExtendedComponentProperty, type ExtendedPageLifeCycles, type ExtendedPageMethods, type ExtendedPageProperties, type ExtendsAppOptions, type Handler, Headers, type HeadersInit, type InferFromType, type InferPropType, type InferPropTypes, type PageConstructor, type PageInstance, type PageOptions, type PageQuery, type PageState, type PropItem, type PropOption, type PropType, type Props, type PropsOptions, Queue, type RefMap, type RequestBody, type RequestError, type RequestFactory, type RequestInitOptions, type RequestOptions, type RequestResponse, type RequestType, type RichTextNode, type RouteCustomConfig, type RoutePathConfig, type SetCookieOptions, type StorageData, type Task, type TextNode, type TrivialComponentInstance, type TrivialComponentOptions, type TrivialPageInstance, type TrivialPageOptions, URLSearchParams, type UrlInfo, type WildCardEventHandlerList, type WildcardHandler, appState, check, checkAsync, createRequest, decode as decodeBase64, dirname, userEmitter as emitter, encode as encodeBase64, exists, funcQueue, get, getAsync, getConfig, getCookieScopeDomain, getDomain, getRef, getRichTextNodes, getText, getUrlInfo, handleProperties, isDir, isFile, isFunction, isMp, isQQ, isWx, lock, logger, ls, mkdir, normalizeDomain, once, parseCookieHeader, parseHTML, parseUrl, put, query, readFile, readJSON, remove, removeAsync, removeRef, request, requestCookieStore, rm, saveFile, saveOnlineFile, set, setAsync, setRef, storage, take, type, unzip, wrapFunction, writeFile, writeJSON };