@mptool/all 0.6.1 → 0.6.2
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 +262 -1
- package/lib/index.d.ts +262 -1
- package/lib/index.js +11 -4
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +11 -4
- package/lib/index.mjs.map +1 -1
- package/package.json +5 -5
package/lib/index.d.mts
CHANGED
|
@@ -1497,4 +1497,265 @@ interface RequestFactory {
|
|
|
1497
1497
|
*/
|
|
1498
1498
|
declare const createRequest: ({ cookieStore, server, responseHandler, errorHandler, ...defaultOptions }?: RequestInitOptions) => RequestFactory;
|
|
1499
1499
|
|
|
1500
|
-
|
|
1500
|
+
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";
|
|
1501
|
+
declare const ALLOWED_TAGS: [
|
|
1502
|
+
tag: AllowTag | "big" | "center" | "font",
|
|
1503
|
+
allowedAttrs?: string[]
|
|
1504
|
+
][];
|
|
1505
|
+
|
|
1506
|
+
/** Types of elements found in htmlparser2's DOM */
|
|
1507
|
+
declare enum ElementType {
|
|
1508
|
+
/** Type for the root element of a document */
|
|
1509
|
+
Root = "root",
|
|
1510
|
+
/** Type for Text */
|
|
1511
|
+
Text = "text",
|
|
1512
|
+
/** Type for <? ... ?> */
|
|
1513
|
+
Directive = "directive",
|
|
1514
|
+
/** Type for <!-- ... --> */
|
|
1515
|
+
Comment = "comment",
|
|
1516
|
+
/** Type for <script> tags */
|
|
1517
|
+
Script = "script",
|
|
1518
|
+
/** Type for <style> tags */
|
|
1519
|
+
Style = "style",
|
|
1520
|
+
/** Type for Any tag */
|
|
1521
|
+
Tag = "tag",
|
|
1522
|
+
/** Type for <![CDATA[ ... ]]> */
|
|
1523
|
+
CDATA = "cdata",
|
|
1524
|
+
/** Type for <!doctype ...> */
|
|
1525
|
+
Doctype = "doctype"
|
|
1526
|
+
}
|
|
1527
|
+
|
|
1528
|
+
interface SourceCodeLocation {
|
|
1529
|
+
/** One-based line index of the first character. */
|
|
1530
|
+
startLine: number;
|
|
1531
|
+
/** One-based column index of the first character. */
|
|
1532
|
+
startCol: number;
|
|
1533
|
+
/** Zero-based first character index. */
|
|
1534
|
+
startOffset: number;
|
|
1535
|
+
/** One-based line index of the last character. */
|
|
1536
|
+
endLine: number;
|
|
1537
|
+
/** One-based column index of the last character. Points directly *after* the last character. */
|
|
1538
|
+
endCol: number;
|
|
1539
|
+
/** Zero-based last character index. Points directly *after* the last character. */
|
|
1540
|
+
endOffset: number;
|
|
1541
|
+
}
|
|
1542
|
+
interface TagSourceCodeLocation extends SourceCodeLocation {
|
|
1543
|
+
startTag?: SourceCodeLocation;
|
|
1544
|
+
endTag?: SourceCodeLocation;
|
|
1545
|
+
}
|
|
1546
|
+
declare type ParentNode = Document | Element | CDATA;
|
|
1547
|
+
declare type ChildNode = Text | Comment | ProcessingInstruction | Element | CDATA | Document;
|
|
1548
|
+
declare type AnyNode = ParentNode | ChildNode;
|
|
1549
|
+
/**
|
|
1550
|
+
* This object will be used as the prototype for Nodes when creating a
|
|
1551
|
+
* DOM-Level-1-compliant structure.
|
|
1552
|
+
*/
|
|
1553
|
+
declare abstract class Node {
|
|
1554
|
+
/** The type of the node. */
|
|
1555
|
+
abstract readonly type: ElementType;
|
|
1556
|
+
/** Parent of the node */
|
|
1557
|
+
parent: ParentNode | null;
|
|
1558
|
+
/** Previous sibling */
|
|
1559
|
+
prev: ChildNode | null;
|
|
1560
|
+
/** Next sibling */
|
|
1561
|
+
next: ChildNode | null;
|
|
1562
|
+
/** The start index of the node. Requires `withStartIndices` on the handler to be `true. */
|
|
1563
|
+
startIndex: number | null;
|
|
1564
|
+
/** The end index of the node. Requires `withEndIndices` on the handler to be `true. */
|
|
1565
|
+
endIndex: number | null;
|
|
1566
|
+
/**
|
|
1567
|
+
* `parse5` source code location info.
|
|
1568
|
+
*
|
|
1569
|
+
* Available if parsing with parse5 and location info is enabled.
|
|
1570
|
+
*/
|
|
1571
|
+
sourceCodeLocation?: SourceCodeLocation | null;
|
|
1572
|
+
/**
|
|
1573
|
+
* [DOM spec](https://dom.spec.whatwg.org/#dom-node-nodetype)-compatible
|
|
1574
|
+
* node {@link type}.
|
|
1575
|
+
*/
|
|
1576
|
+
abstract readonly nodeType: number;
|
|
1577
|
+
/**
|
|
1578
|
+
* Same as {@link parent}.
|
|
1579
|
+
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
|
1580
|
+
*/
|
|
1581
|
+
get parentNode(): ParentNode | null;
|
|
1582
|
+
set parentNode(parent: ParentNode | null);
|
|
1583
|
+
/**
|
|
1584
|
+
* Same as {@link prev}.
|
|
1585
|
+
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
|
1586
|
+
*/
|
|
1587
|
+
get previousSibling(): ChildNode | null;
|
|
1588
|
+
set previousSibling(prev: ChildNode | null);
|
|
1589
|
+
/**
|
|
1590
|
+
* Same as {@link next}.
|
|
1591
|
+
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
|
1592
|
+
*/
|
|
1593
|
+
get nextSibling(): ChildNode | null;
|
|
1594
|
+
set nextSibling(next: ChildNode | null);
|
|
1595
|
+
/**
|
|
1596
|
+
* Clone this node, and optionally its children.
|
|
1597
|
+
*
|
|
1598
|
+
* @param recursive Clone child nodes as well.
|
|
1599
|
+
* @returns A clone of the node.
|
|
1600
|
+
*/
|
|
1601
|
+
cloneNode<T extends Node>(this: T, recursive?: boolean): T;
|
|
1602
|
+
}
|
|
1603
|
+
/**
|
|
1604
|
+
* A node that contains some data.
|
|
1605
|
+
*/
|
|
1606
|
+
declare abstract class DataNode extends Node {
|
|
1607
|
+
data: string;
|
|
1608
|
+
/**
|
|
1609
|
+
* @param data The content of the data node
|
|
1610
|
+
*/
|
|
1611
|
+
constructor(data: string);
|
|
1612
|
+
/**
|
|
1613
|
+
* Same as {@link data}.
|
|
1614
|
+
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
|
1615
|
+
*/
|
|
1616
|
+
get nodeValue(): string;
|
|
1617
|
+
set nodeValue(data: string);
|
|
1618
|
+
}
|
|
1619
|
+
/**
|
|
1620
|
+
* Text within the document.
|
|
1621
|
+
*/
|
|
1622
|
+
declare class Text extends DataNode {
|
|
1623
|
+
type: ElementType.Text;
|
|
1624
|
+
get nodeType(): 3;
|
|
1625
|
+
}
|
|
1626
|
+
/**
|
|
1627
|
+
* Comments within the document.
|
|
1628
|
+
*/
|
|
1629
|
+
declare class Comment extends DataNode {
|
|
1630
|
+
type: ElementType.Comment;
|
|
1631
|
+
get nodeType(): 8;
|
|
1632
|
+
}
|
|
1633
|
+
/**
|
|
1634
|
+
* Processing instructions, including doc types.
|
|
1635
|
+
*/
|
|
1636
|
+
declare class ProcessingInstruction extends DataNode {
|
|
1637
|
+
name: string;
|
|
1638
|
+
type: ElementType.Directive;
|
|
1639
|
+
constructor(name: string, data: string);
|
|
1640
|
+
get nodeType(): 1;
|
|
1641
|
+
/** If this is a doctype, the document type name (parse5 only). */
|
|
1642
|
+
"x-name"?: string;
|
|
1643
|
+
/** If this is a doctype, the document type public identifier (parse5 only). */
|
|
1644
|
+
"x-publicId"?: string;
|
|
1645
|
+
/** If this is a doctype, the document type system identifier (parse5 only). */
|
|
1646
|
+
"x-systemId"?: string;
|
|
1647
|
+
}
|
|
1648
|
+
/**
|
|
1649
|
+
* A `Node` that can have children.
|
|
1650
|
+
*/
|
|
1651
|
+
declare abstract class NodeWithChildren extends Node {
|
|
1652
|
+
children: ChildNode[];
|
|
1653
|
+
/**
|
|
1654
|
+
* @param children Children of the node. Only certain node types can have children.
|
|
1655
|
+
*/
|
|
1656
|
+
constructor(children: ChildNode[]);
|
|
1657
|
+
/** First child of the node. */
|
|
1658
|
+
get firstChild(): ChildNode | null;
|
|
1659
|
+
/** Last child of the node. */
|
|
1660
|
+
get lastChild(): ChildNode | null;
|
|
1661
|
+
/**
|
|
1662
|
+
* Same as {@link children}.
|
|
1663
|
+
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
|
1664
|
+
*/
|
|
1665
|
+
get childNodes(): ChildNode[];
|
|
1666
|
+
set childNodes(children: ChildNode[]);
|
|
1667
|
+
}
|
|
1668
|
+
declare class CDATA extends NodeWithChildren {
|
|
1669
|
+
type: ElementType.CDATA;
|
|
1670
|
+
get nodeType(): 4;
|
|
1671
|
+
}
|
|
1672
|
+
/**
|
|
1673
|
+
* The root node of the document.
|
|
1674
|
+
*/
|
|
1675
|
+
declare class Document extends NodeWithChildren {
|
|
1676
|
+
type: ElementType.Root;
|
|
1677
|
+
get nodeType(): 9;
|
|
1678
|
+
/** [Document mode](https://dom.spec.whatwg.org/#concept-document-limited-quirks) (parse5 only). */
|
|
1679
|
+
"x-mode"?: "no-quirks" | "quirks" | "limited-quirks";
|
|
1680
|
+
}
|
|
1681
|
+
/**
|
|
1682
|
+
* The description of an individual attribute.
|
|
1683
|
+
*/
|
|
1684
|
+
interface Attribute {
|
|
1685
|
+
name: string;
|
|
1686
|
+
value: string;
|
|
1687
|
+
namespace?: string;
|
|
1688
|
+
prefix?: string;
|
|
1689
|
+
}
|
|
1690
|
+
/**
|
|
1691
|
+
* An element within the DOM.
|
|
1692
|
+
*/
|
|
1693
|
+
declare class Element extends NodeWithChildren {
|
|
1694
|
+
name: string;
|
|
1695
|
+
attribs: {
|
|
1696
|
+
[name: string]: string;
|
|
1697
|
+
};
|
|
1698
|
+
type: ElementType.Tag | ElementType.Script | ElementType.Style;
|
|
1699
|
+
/**
|
|
1700
|
+
* @param name Name of the tag, eg. `div`, `span`.
|
|
1701
|
+
* @param attribs Object mapping attribute names to attribute values.
|
|
1702
|
+
* @param children Children of the node.
|
|
1703
|
+
*/
|
|
1704
|
+
constructor(name: string, attribs: {
|
|
1705
|
+
[name: string]: string;
|
|
1706
|
+
}, children?: ChildNode[], type?: ElementType.Tag | ElementType.Script | ElementType.Style);
|
|
1707
|
+
get nodeType(): 1;
|
|
1708
|
+
/**
|
|
1709
|
+
* `parse5` source code location info, with start & end tags.
|
|
1710
|
+
*
|
|
1711
|
+
* Available if parsing with parse5 and location info is enabled.
|
|
1712
|
+
*/
|
|
1713
|
+
sourceCodeLocation?: TagSourceCodeLocation | null;
|
|
1714
|
+
/**
|
|
1715
|
+
* Same as {@link name}.
|
|
1716
|
+
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
|
1717
|
+
*/
|
|
1718
|
+
get tagName(): string;
|
|
1719
|
+
set tagName(name: string);
|
|
1720
|
+
get attributes(): Attribute[];
|
|
1721
|
+
/** Element namespace (parse5 only). */
|
|
1722
|
+
namespace?: string;
|
|
1723
|
+
/** Element attribute namespaces (parse5 only). */
|
|
1724
|
+
"x-attribsNamespace"?: Record<string, string>;
|
|
1725
|
+
/** Element attribute namespace-related prefixes (parse5 only). */
|
|
1726
|
+
"x-attribsPrefix"?: Record<string, string>;
|
|
1727
|
+
}
|
|
1728
|
+
|
|
1729
|
+
declare const parseHTML: (content: string) => AnyNode[];
|
|
1730
|
+
|
|
1731
|
+
interface ElementNode {
|
|
1732
|
+
type: "node";
|
|
1733
|
+
name: string;
|
|
1734
|
+
attrs?: Record<string, string>;
|
|
1735
|
+
children?: RichTextNode[];
|
|
1736
|
+
}
|
|
1737
|
+
interface TextNode {
|
|
1738
|
+
type: "text";
|
|
1739
|
+
text: string;
|
|
1740
|
+
}
|
|
1741
|
+
type RichTextNode = ElementNode | TextNode;
|
|
1742
|
+
|
|
1743
|
+
type NodeHandler = (node: ElementNode) => ElementNode | null | Promise<ElementNode | null>;
|
|
1744
|
+
interface ParserOptions {
|
|
1745
|
+
/**
|
|
1746
|
+
* 是否附加标签名到 class
|
|
1747
|
+
*
|
|
1748
|
+
* @default true
|
|
1749
|
+
*/
|
|
1750
|
+
appendClass?: boolean;
|
|
1751
|
+
/**
|
|
1752
|
+
* 处理 Tag
|
|
1753
|
+
*/
|
|
1754
|
+
transform?: Partial<Record<AllowTag, NodeHandler>>;
|
|
1755
|
+
}
|
|
1756
|
+
|
|
1757
|
+
declare const getRichTextNodes: (content: string | AnyNode[], { appendClass, transform }?: ParserOptions) => Promise<RichTextNode[]>;
|
|
1758
|
+
|
|
1759
|
+
declare const getText: (content: string | AnyNode[]) => string;
|
|
1760
|
+
|
|
1761
|
+
export { $App, $Component, $Config, $Page, ALLOWED_TAGS, type AllowTag, type AppConfig, type AppConstructor, type AppInstance, type AppOptions, type ComponentConstructor, type ComponentInstance, type ComponentLifetimes, type ComponentOptions, 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 ExtendsAppOptions, type Handler, Headers, type HeadersInit, type PageConstructor, type PageInstance, type PageOptions, type PageQuery, type PageState, type PropType, Queue, type RefMap, type RequestBody, type RequestError, type RequestFactory, type RequestInitOptions, type RequestOptions, type RequestResponse, type RequestType, type RichTextNode, type SetCookieOptions, type StorageData, type Task, type TextNode, type TrivialComponentInstance, type TrivialComponentOptions, type TrivialPageInstance, type TrivialPageOptions, URLSearchParams, type UrlInfo, type WildCardEventHandlerList, type WildcardHandler, check, checkAsync, createRequest, decode as decodeBase64, dirname, userEmitter as emitter, encode as encodeBase64, exists, funcQueue, get, getAsync, getCookieOptions, getCookieScopeDomain, getDomain, getRichTextNodes, getText, isDir, isFile, isMp, isQQ, isWx, lock, logger, ls, mkdir, normalizeDomain, once, parseCookieHeader, parseHTML, parseUrl, put, query, readFile, readJSON, remove, removeAsync, request, requestCookieStore, rm, saveFile, saveOnlineFile, set, setAsync, storage, take, type, unzip, wrapFunction, writeFile, writeJSON };
|
package/lib/index.d.ts
CHANGED
|
@@ -1497,4 +1497,265 @@ interface RequestFactory {
|
|
|
1497
1497
|
*/
|
|
1498
1498
|
declare const createRequest: ({ cookieStore, server, responseHandler, errorHandler, ...defaultOptions }?: RequestInitOptions) => RequestFactory;
|
|
1499
1499
|
|
|
1500
|
-
|
|
1500
|
+
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";
|
|
1501
|
+
declare const ALLOWED_TAGS: [
|
|
1502
|
+
tag: AllowTag | "big" | "center" | "font",
|
|
1503
|
+
allowedAttrs?: string[]
|
|
1504
|
+
][];
|
|
1505
|
+
|
|
1506
|
+
/** Types of elements found in htmlparser2's DOM */
|
|
1507
|
+
declare enum ElementType {
|
|
1508
|
+
/** Type for the root element of a document */
|
|
1509
|
+
Root = "root",
|
|
1510
|
+
/** Type for Text */
|
|
1511
|
+
Text = "text",
|
|
1512
|
+
/** Type for <? ... ?> */
|
|
1513
|
+
Directive = "directive",
|
|
1514
|
+
/** Type for <!-- ... --> */
|
|
1515
|
+
Comment = "comment",
|
|
1516
|
+
/** Type for <script> tags */
|
|
1517
|
+
Script = "script",
|
|
1518
|
+
/** Type for <style> tags */
|
|
1519
|
+
Style = "style",
|
|
1520
|
+
/** Type for Any tag */
|
|
1521
|
+
Tag = "tag",
|
|
1522
|
+
/** Type for <![CDATA[ ... ]]> */
|
|
1523
|
+
CDATA = "cdata",
|
|
1524
|
+
/** Type for <!doctype ...> */
|
|
1525
|
+
Doctype = "doctype"
|
|
1526
|
+
}
|
|
1527
|
+
|
|
1528
|
+
interface SourceCodeLocation {
|
|
1529
|
+
/** One-based line index of the first character. */
|
|
1530
|
+
startLine: number;
|
|
1531
|
+
/** One-based column index of the first character. */
|
|
1532
|
+
startCol: number;
|
|
1533
|
+
/** Zero-based first character index. */
|
|
1534
|
+
startOffset: number;
|
|
1535
|
+
/** One-based line index of the last character. */
|
|
1536
|
+
endLine: number;
|
|
1537
|
+
/** One-based column index of the last character. Points directly *after* the last character. */
|
|
1538
|
+
endCol: number;
|
|
1539
|
+
/** Zero-based last character index. Points directly *after* the last character. */
|
|
1540
|
+
endOffset: number;
|
|
1541
|
+
}
|
|
1542
|
+
interface TagSourceCodeLocation extends SourceCodeLocation {
|
|
1543
|
+
startTag?: SourceCodeLocation;
|
|
1544
|
+
endTag?: SourceCodeLocation;
|
|
1545
|
+
}
|
|
1546
|
+
declare type ParentNode = Document | Element | CDATA;
|
|
1547
|
+
declare type ChildNode = Text | Comment | ProcessingInstruction | Element | CDATA | Document;
|
|
1548
|
+
declare type AnyNode = ParentNode | ChildNode;
|
|
1549
|
+
/**
|
|
1550
|
+
* This object will be used as the prototype for Nodes when creating a
|
|
1551
|
+
* DOM-Level-1-compliant structure.
|
|
1552
|
+
*/
|
|
1553
|
+
declare abstract class Node {
|
|
1554
|
+
/** The type of the node. */
|
|
1555
|
+
abstract readonly type: ElementType;
|
|
1556
|
+
/** Parent of the node */
|
|
1557
|
+
parent: ParentNode | null;
|
|
1558
|
+
/** Previous sibling */
|
|
1559
|
+
prev: ChildNode | null;
|
|
1560
|
+
/** Next sibling */
|
|
1561
|
+
next: ChildNode | null;
|
|
1562
|
+
/** The start index of the node. Requires `withStartIndices` on the handler to be `true. */
|
|
1563
|
+
startIndex: number | null;
|
|
1564
|
+
/** The end index of the node. Requires `withEndIndices` on the handler to be `true. */
|
|
1565
|
+
endIndex: number | null;
|
|
1566
|
+
/**
|
|
1567
|
+
* `parse5` source code location info.
|
|
1568
|
+
*
|
|
1569
|
+
* Available if parsing with parse5 and location info is enabled.
|
|
1570
|
+
*/
|
|
1571
|
+
sourceCodeLocation?: SourceCodeLocation | null;
|
|
1572
|
+
/**
|
|
1573
|
+
* [DOM spec](https://dom.spec.whatwg.org/#dom-node-nodetype)-compatible
|
|
1574
|
+
* node {@link type}.
|
|
1575
|
+
*/
|
|
1576
|
+
abstract readonly nodeType: number;
|
|
1577
|
+
/**
|
|
1578
|
+
* Same as {@link parent}.
|
|
1579
|
+
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
|
1580
|
+
*/
|
|
1581
|
+
get parentNode(): ParentNode | null;
|
|
1582
|
+
set parentNode(parent: ParentNode | null);
|
|
1583
|
+
/**
|
|
1584
|
+
* Same as {@link prev}.
|
|
1585
|
+
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
|
1586
|
+
*/
|
|
1587
|
+
get previousSibling(): ChildNode | null;
|
|
1588
|
+
set previousSibling(prev: ChildNode | null);
|
|
1589
|
+
/**
|
|
1590
|
+
* Same as {@link next}.
|
|
1591
|
+
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
|
1592
|
+
*/
|
|
1593
|
+
get nextSibling(): ChildNode | null;
|
|
1594
|
+
set nextSibling(next: ChildNode | null);
|
|
1595
|
+
/**
|
|
1596
|
+
* Clone this node, and optionally its children.
|
|
1597
|
+
*
|
|
1598
|
+
* @param recursive Clone child nodes as well.
|
|
1599
|
+
* @returns A clone of the node.
|
|
1600
|
+
*/
|
|
1601
|
+
cloneNode<T extends Node>(this: T, recursive?: boolean): T;
|
|
1602
|
+
}
|
|
1603
|
+
/**
|
|
1604
|
+
* A node that contains some data.
|
|
1605
|
+
*/
|
|
1606
|
+
declare abstract class DataNode extends Node {
|
|
1607
|
+
data: string;
|
|
1608
|
+
/**
|
|
1609
|
+
* @param data The content of the data node
|
|
1610
|
+
*/
|
|
1611
|
+
constructor(data: string);
|
|
1612
|
+
/**
|
|
1613
|
+
* Same as {@link data}.
|
|
1614
|
+
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
|
1615
|
+
*/
|
|
1616
|
+
get nodeValue(): string;
|
|
1617
|
+
set nodeValue(data: string);
|
|
1618
|
+
}
|
|
1619
|
+
/**
|
|
1620
|
+
* Text within the document.
|
|
1621
|
+
*/
|
|
1622
|
+
declare class Text extends DataNode {
|
|
1623
|
+
type: ElementType.Text;
|
|
1624
|
+
get nodeType(): 3;
|
|
1625
|
+
}
|
|
1626
|
+
/**
|
|
1627
|
+
* Comments within the document.
|
|
1628
|
+
*/
|
|
1629
|
+
declare class Comment extends DataNode {
|
|
1630
|
+
type: ElementType.Comment;
|
|
1631
|
+
get nodeType(): 8;
|
|
1632
|
+
}
|
|
1633
|
+
/**
|
|
1634
|
+
* Processing instructions, including doc types.
|
|
1635
|
+
*/
|
|
1636
|
+
declare class ProcessingInstruction extends DataNode {
|
|
1637
|
+
name: string;
|
|
1638
|
+
type: ElementType.Directive;
|
|
1639
|
+
constructor(name: string, data: string);
|
|
1640
|
+
get nodeType(): 1;
|
|
1641
|
+
/** If this is a doctype, the document type name (parse5 only). */
|
|
1642
|
+
"x-name"?: string;
|
|
1643
|
+
/** If this is a doctype, the document type public identifier (parse5 only). */
|
|
1644
|
+
"x-publicId"?: string;
|
|
1645
|
+
/** If this is a doctype, the document type system identifier (parse5 only). */
|
|
1646
|
+
"x-systemId"?: string;
|
|
1647
|
+
}
|
|
1648
|
+
/**
|
|
1649
|
+
* A `Node` that can have children.
|
|
1650
|
+
*/
|
|
1651
|
+
declare abstract class NodeWithChildren extends Node {
|
|
1652
|
+
children: ChildNode[];
|
|
1653
|
+
/**
|
|
1654
|
+
* @param children Children of the node. Only certain node types can have children.
|
|
1655
|
+
*/
|
|
1656
|
+
constructor(children: ChildNode[]);
|
|
1657
|
+
/** First child of the node. */
|
|
1658
|
+
get firstChild(): ChildNode | null;
|
|
1659
|
+
/** Last child of the node. */
|
|
1660
|
+
get lastChild(): ChildNode | null;
|
|
1661
|
+
/**
|
|
1662
|
+
* Same as {@link children}.
|
|
1663
|
+
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
|
1664
|
+
*/
|
|
1665
|
+
get childNodes(): ChildNode[];
|
|
1666
|
+
set childNodes(children: ChildNode[]);
|
|
1667
|
+
}
|
|
1668
|
+
declare class CDATA extends NodeWithChildren {
|
|
1669
|
+
type: ElementType.CDATA;
|
|
1670
|
+
get nodeType(): 4;
|
|
1671
|
+
}
|
|
1672
|
+
/**
|
|
1673
|
+
* The root node of the document.
|
|
1674
|
+
*/
|
|
1675
|
+
declare class Document extends NodeWithChildren {
|
|
1676
|
+
type: ElementType.Root;
|
|
1677
|
+
get nodeType(): 9;
|
|
1678
|
+
/** [Document mode](https://dom.spec.whatwg.org/#concept-document-limited-quirks) (parse5 only). */
|
|
1679
|
+
"x-mode"?: "no-quirks" | "quirks" | "limited-quirks";
|
|
1680
|
+
}
|
|
1681
|
+
/**
|
|
1682
|
+
* The description of an individual attribute.
|
|
1683
|
+
*/
|
|
1684
|
+
interface Attribute {
|
|
1685
|
+
name: string;
|
|
1686
|
+
value: string;
|
|
1687
|
+
namespace?: string;
|
|
1688
|
+
prefix?: string;
|
|
1689
|
+
}
|
|
1690
|
+
/**
|
|
1691
|
+
* An element within the DOM.
|
|
1692
|
+
*/
|
|
1693
|
+
declare class Element extends NodeWithChildren {
|
|
1694
|
+
name: string;
|
|
1695
|
+
attribs: {
|
|
1696
|
+
[name: string]: string;
|
|
1697
|
+
};
|
|
1698
|
+
type: ElementType.Tag | ElementType.Script | ElementType.Style;
|
|
1699
|
+
/**
|
|
1700
|
+
* @param name Name of the tag, eg. `div`, `span`.
|
|
1701
|
+
* @param attribs Object mapping attribute names to attribute values.
|
|
1702
|
+
* @param children Children of the node.
|
|
1703
|
+
*/
|
|
1704
|
+
constructor(name: string, attribs: {
|
|
1705
|
+
[name: string]: string;
|
|
1706
|
+
}, children?: ChildNode[], type?: ElementType.Tag | ElementType.Script | ElementType.Style);
|
|
1707
|
+
get nodeType(): 1;
|
|
1708
|
+
/**
|
|
1709
|
+
* `parse5` source code location info, with start & end tags.
|
|
1710
|
+
*
|
|
1711
|
+
* Available if parsing with parse5 and location info is enabled.
|
|
1712
|
+
*/
|
|
1713
|
+
sourceCodeLocation?: TagSourceCodeLocation | null;
|
|
1714
|
+
/**
|
|
1715
|
+
* Same as {@link name}.
|
|
1716
|
+
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
|
1717
|
+
*/
|
|
1718
|
+
get tagName(): string;
|
|
1719
|
+
set tagName(name: string);
|
|
1720
|
+
get attributes(): Attribute[];
|
|
1721
|
+
/** Element namespace (parse5 only). */
|
|
1722
|
+
namespace?: string;
|
|
1723
|
+
/** Element attribute namespaces (parse5 only). */
|
|
1724
|
+
"x-attribsNamespace"?: Record<string, string>;
|
|
1725
|
+
/** Element attribute namespace-related prefixes (parse5 only). */
|
|
1726
|
+
"x-attribsPrefix"?: Record<string, string>;
|
|
1727
|
+
}
|
|
1728
|
+
|
|
1729
|
+
declare const parseHTML: (content: string) => AnyNode[];
|
|
1730
|
+
|
|
1731
|
+
interface ElementNode {
|
|
1732
|
+
type: "node";
|
|
1733
|
+
name: string;
|
|
1734
|
+
attrs?: Record<string, string>;
|
|
1735
|
+
children?: RichTextNode[];
|
|
1736
|
+
}
|
|
1737
|
+
interface TextNode {
|
|
1738
|
+
type: "text";
|
|
1739
|
+
text: string;
|
|
1740
|
+
}
|
|
1741
|
+
type RichTextNode = ElementNode | TextNode;
|
|
1742
|
+
|
|
1743
|
+
type NodeHandler = (node: ElementNode) => ElementNode | null | Promise<ElementNode | null>;
|
|
1744
|
+
interface ParserOptions {
|
|
1745
|
+
/**
|
|
1746
|
+
* 是否附加标签名到 class
|
|
1747
|
+
*
|
|
1748
|
+
* @default true
|
|
1749
|
+
*/
|
|
1750
|
+
appendClass?: boolean;
|
|
1751
|
+
/**
|
|
1752
|
+
* 处理 Tag
|
|
1753
|
+
*/
|
|
1754
|
+
transform?: Partial<Record<AllowTag, NodeHandler>>;
|
|
1755
|
+
}
|
|
1756
|
+
|
|
1757
|
+
declare const getRichTextNodes: (content: string | AnyNode[], { appendClass, transform }?: ParserOptions) => Promise<RichTextNode[]>;
|
|
1758
|
+
|
|
1759
|
+
declare const getText: (content: string | AnyNode[]) => string;
|
|
1760
|
+
|
|
1761
|
+
export { $App, $Component, $Config, $Page, ALLOWED_TAGS, type AllowTag, type AppConfig, type AppConstructor, type AppInstance, type AppOptions, type ComponentConstructor, type ComponentInstance, type ComponentLifetimes, type ComponentOptions, 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 ExtendsAppOptions, type Handler, Headers, type HeadersInit, type PageConstructor, type PageInstance, type PageOptions, type PageQuery, type PageState, type PropType, Queue, type RefMap, type RequestBody, type RequestError, type RequestFactory, type RequestInitOptions, type RequestOptions, type RequestResponse, type RequestType, type RichTextNode, type SetCookieOptions, type StorageData, type Task, type TextNode, type TrivialComponentInstance, type TrivialComponentOptions, type TrivialPageInstance, type TrivialPageOptions, URLSearchParams, type UrlInfo, type WildCardEventHandlerList, type WildcardHandler, check, checkAsync, createRequest, decode as decodeBase64, dirname, userEmitter as emitter, encode as encodeBase64, exists, funcQueue, get, getAsync, getCookieOptions, getCookieScopeDomain, getDomain, getRichTextNodes, getText, isDir, isFile, isMp, isQQ, isWx, lock, logger, ls, mkdir, normalizeDomain, once, parseCookieHeader, parseHTML, parseUrl, put, query, readFile, readJSON, remove, removeAsync, request, requestCookieStore, rm, saveFile, saveOnlineFile, set, setAsync, storage, take, type, unzip, wrapFunction, writeFile, writeJSON };
|