@mptool/all 0.7.2 → 0.8.0
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 +21 -296
- package/lib/index.d.ts +21 -296
- package/lib/index.js +4 -11
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +4 -11
- package/lib/index.mjs.map +1 -1
- package/package.json +4 -5
package/lib/index.d.mts
CHANGED
|
@@ -648,12 +648,6 @@ interface ExtendedPageMethods<Data extends WechatMiniprogram.IAnyObject, Custom
|
|
|
648
648
|
* 获取当前页面实例。
|
|
649
649
|
*/
|
|
650
650
|
$currentPage(): PageInstance<Data, Custom>;
|
|
651
|
-
/**
|
|
652
|
-
* 获得页面简称
|
|
653
|
-
*
|
|
654
|
-
* @param url 页面地址
|
|
655
|
-
*/
|
|
656
|
-
$getName(url: string): string;
|
|
657
651
|
/**
|
|
658
652
|
* 获得页面路径
|
|
659
653
|
*
|
|
@@ -807,6 +801,17 @@ interface AppConfigCommonOptions {
|
|
|
807
801
|
injectPage?(name: string, options: TrivialPageOptions): void;
|
|
808
802
|
}
|
|
809
803
|
interface RoutePathConfig {
|
|
804
|
+
/**
|
|
805
|
+
* 当你给出的页面路径或简称无法通过 routeMap 解析时,会回退到此路径
|
|
806
|
+
*
|
|
807
|
+
* 填入小程序路径模式,小程序路径模式是一个路径字符串,用 `$name` 表示小程序简称的位置
|
|
808
|
+
*
|
|
809
|
+
* 例子: 你可以填入 `/pages/$name/$name` 来表达:
|
|
810
|
+
*
|
|
811
|
+
* - `main': '/pages/main/main`
|
|
812
|
+
* - `user': '/pages/user/user`
|
|
813
|
+
*/
|
|
814
|
+
defaultPage: string;
|
|
810
815
|
/**
|
|
811
816
|
* 你可以直接以对象形式表示简称到路径的映射。如:
|
|
812
817
|
*
|
|
@@ -850,48 +855,29 @@ interface RoutePathConfig {
|
|
|
850
855
|
* }
|
|
851
856
|
* ```
|
|
852
857
|
*
|
|
853
|
-
* @description 无法解析的路径会回退到 `
|
|
858
|
+
* @description 无法解析的路径会回退到 `defaultPage`
|
|
854
859
|
*/
|
|
855
|
-
|
|
856
|
-
/**
|
|
857
|
-
* 当你给出的页面路径或简称无法通过 routeMap 解析时,会回退到此路径
|
|
858
|
-
*
|
|
859
|
-
* 填入小程序路径模式,小程序路径模式是一个路径字符串,用 `$name` 表示小程序简称的位置
|
|
860
|
-
*
|
|
861
|
-
* 例子: 你可以填入 `/pages/$name/$name` 来表达:
|
|
862
|
-
*
|
|
863
|
-
* - `main': '/pages/main/main`
|
|
864
|
-
* - `user': '/pages/user/user`
|
|
865
|
-
*/
|
|
866
|
-
defaultRoute: string;
|
|
860
|
+
pages?: Record<string, string> | [string | string[], string][];
|
|
867
861
|
}
|
|
868
862
|
interface RouteCustomConfig {
|
|
869
|
-
/**
|
|
870
|
-
* 获得页面简称
|
|
871
|
-
*
|
|
872
|
-
* @param url 页面路径
|
|
873
|
-
* @returns 页面名称
|
|
874
|
-
*/
|
|
875
|
-
getName: (url: string) => string;
|
|
876
863
|
/**
|
|
877
864
|
* 获得页面路径
|
|
878
865
|
*
|
|
879
866
|
* @param pageName 页面简称
|
|
880
867
|
* @returns 页面路径
|
|
881
868
|
*/
|
|
882
|
-
|
|
869
|
+
getPath: (pageName: string) => string;
|
|
883
870
|
}
|
|
884
871
|
type AppConfigOptions = AppConfigCommonOptions & (RoutePathConfig | RouteCustomConfig);
|
|
885
872
|
|
|
886
|
-
interface Config extends Omit<AppConfigOptions, "
|
|
873
|
+
interface Config extends Omit<AppConfigOptions, "defaultPage" | "pages"> {
|
|
887
874
|
/**
|
|
888
|
-
*
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
* @returns route
|
|
875
|
+
* 获得页面路径
|
|
876
|
+
*
|
|
877
|
+
* @param pageName 页面简称
|
|
878
|
+
* @returns 页面路径
|
|
893
879
|
*/
|
|
894
|
-
|
|
880
|
+
getPath: (pageName: string) => string;
|
|
895
881
|
}
|
|
896
882
|
declare const $Config: (config: AppConfigOptions) => void;
|
|
897
883
|
declare const getConfig: () => Config;
|
|
@@ -1530,265 +1516,4 @@ interface RequestFactory {
|
|
|
1530
1516
|
*/
|
|
1531
1517
|
declare const createRequest: ({ cookieStore, server, responseHandler, errorHandler, ...defaultOptions }?: RequestInitOptions) => RequestFactory;
|
|
1532
1518
|
|
|
1533
|
-
type
|
|
1534
|
-
declare const ALLOWED_TAGS: [
|
|
1535
|
-
tag: AllowTag | "big" | "center" | "font",
|
|
1536
|
-
allowedAttrs?: string[]
|
|
1537
|
-
][];
|
|
1538
|
-
|
|
1539
|
-
/** Types of elements found in htmlparser2's DOM */
|
|
1540
|
-
declare enum ElementType {
|
|
1541
|
-
/** Type for the root element of a document */
|
|
1542
|
-
Root = "root",
|
|
1543
|
-
/** Type for Text */
|
|
1544
|
-
Text = "text",
|
|
1545
|
-
/** Type for <? ... ?> */
|
|
1546
|
-
Directive = "directive",
|
|
1547
|
-
/** Type for <!-- ... --> */
|
|
1548
|
-
Comment = "comment",
|
|
1549
|
-
/** Type for <script> tags */
|
|
1550
|
-
Script = "script",
|
|
1551
|
-
/** Type for <style> tags */
|
|
1552
|
-
Style = "style",
|
|
1553
|
-
/** Type for Any tag */
|
|
1554
|
-
Tag = "tag",
|
|
1555
|
-
/** Type for <![CDATA[ ... ]]> */
|
|
1556
|
-
CDATA = "cdata",
|
|
1557
|
-
/** Type for <!doctype ...> */
|
|
1558
|
-
Doctype = "doctype"
|
|
1559
|
-
}
|
|
1560
|
-
|
|
1561
|
-
interface SourceCodeLocation {
|
|
1562
|
-
/** One-based line index of the first character. */
|
|
1563
|
-
startLine: number;
|
|
1564
|
-
/** One-based column index of the first character. */
|
|
1565
|
-
startCol: number;
|
|
1566
|
-
/** Zero-based first character index. */
|
|
1567
|
-
startOffset: number;
|
|
1568
|
-
/** One-based line index of the last character. */
|
|
1569
|
-
endLine: number;
|
|
1570
|
-
/** One-based column index of the last character. Points directly *after* the last character. */
|
|
1571
|
-
endCol: number;
|
|
1572
|
-
/** Zero-based last character index. Points directly *after* the last character. */
|
|
1573
|
-
endOffset: number;
|
|
1574
|
-
}
|
|
1575
|
-
interface TagSourceCodeLocation extends SourceCodeLocation {
|
|
1576
|
-
startTag?: SourceCodeLocation;
|
|
1577
|
-
endTag?: SourceCodeLocation;
|
|
1578
|
-
}
|
|
1579
|
-
declare type ParentNode = Document | Element | CDATA;
|
|
1580
|
-
declare type ChildNode = Text | Comment | ProcessingInstruction | Element | CDATA | Document;
|
|
1581
|
-
declare type AnyNode = ParentNode | ChildNode;
|
|
1582
|
-
/**
|
|
1583
|
-
* This object will be used as the prototype for Nodes when creating a
|
|
1584
|
-
* DOM-Level-1-compliant structure.
|
|
1585
|
-
*/
|
|
1586
|
-
declare abstract class Node {
|
|
1587
|
-
/** The type of the node. */
|
|
1588
|
-
abstract readonly type: ElementType;
|
|
1589
|
-
/** Parent of the node */
|
|
1590
|
-
parent: ParentNode | null;
|
|
1591
|
-
/** Previous sibling */
|
|
1592
|
-
prev: ChildNode | null;
|
|
1593
|
-
/** Next sibling */
|
|
1594
|
-
next: ChildNode | null;
|
|
1595
|
-
/** The start index of the node. Requires `withStartIndices` on the handler to be `true. */
|
|
1596
|
-
startIndex: number | null;
|
|
1597
|
-
/** The end index of the node. Requires `withEndIndices` on the handler to be `true. */
|
|
1598
|
-
endIndex: number | null;
|
|
1599
|
-
/**
|
|
1600
|
-
* `parse5` source code location info.
|
|
1601
|
-
*
|
|
1602
|
-
* Available if parsing with parse5 and location info is enabled.
|
|
1603
|
-
*/
|
|
1604
|
-
sourceCodeLocation?: SourceCodeLocation | null;
|
|
1605
|
-
/**
|
|
1606
|
-
* [DOM spec](https://dom.spec.whatwg.org/#dom-node-nodetype)-compatible
|
|
1607
|
-
* node {@link type}.
|
|
1608
|
-
*/
|
|
1609
|
-
abstract readonly nodeType: number;
|
|
1610
|
-
/**
|
|
1611
|
-
* Same as {@link parent}.
|
|
1612
|
-
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
|
1613
|
-
*/
|
|
1614
|
-
get parentNode(): ParentNode | null;
|
|
1615
|
-
set parentNode(parent: ParentNode | null);
|
|
1616
|
-
/**
|
|
1617
|
-
* Same as {@link prev}.
|
|
1618
|
-
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
|
1619
|
-
*/
|
|
1620
|
-
get previousSibling(): ChildNode | null;
|
|
1621
|
-
set previousSibling(prev: ChildNode | null);
|
|
1622
|
-
/**
|
|
1623
|
-
* Same as {@link next}.
|
|
1624
|
-
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
|
1625
|
-
*/
|
|
1626
|
-
get nextSibling(): ChildNode | null;
|
|
1627
|
-
set nextSibling(next: ChildNode | null);
|
|
1628
|
-
/**
|
|
1629
|
-
* Clone this node, and optionally its children.
|
|
1630
|
-
*
|
|
1631
|
-
* @param recursive Clone child nodes as well.
|
|
1632
|
-
* @returns A clone of the node.
|
|
1633
|
-
*/
|
|
1634
|
-
cloneNode<T extends Node>(this: T, recursive?: boolean): T;
|
|
1635
|
-
}
|
|
1636
|
-
/**
|
|
1637
|
-
* A node that contains some data.
|
|
1638
|
-
*/
|
|
1639
|
-
declare abstract class DataNode extends Node {
|
|
1640
|
-
data: string;
|
|
1641
|
-
/**
|
|
1642
|
-
* @param data The content of the data node
|
|
1643
|
-
*/
|
|
1644
|
-
constructor(data: string);
|
|
1645
|
-
/**
|
|
1646
|
-
* Same as {@link data}.
|
|
1647
|
-
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
|
1648
|
-
*/
|
|
1649
|
-
get nodeValue(): string;
|
|
1650
|
-
set nodeValue(data: string);
|
|
1651
|
-
}
|
|
1652
|
-
/**
|
|
1653
|
-
* Text within the document.
|
|
1654
|
-
*/
|
|
1655
|
-
declare class Text extends DataNode {
|
|
1656
|
-
type: ElementType.Text;
|
|
1657
|
-
get nodeType(): 3;
|
|
1658
|
-
}
|
|
1659
|
-
/**
|
|
1660
|
-
* Comments within the document.
|
|
1661
|
-
*/
|
|
1662
|
-
declare class Comment extends DataNode {
|
|
1663
|
-
type: ElementType.Comment;
|
|
1664
|
-
get nodeType(): 8;
|
|
1665
|
-
}
|
|
1666
|
-
/**
|
|
1667
|
-
* Processing instructions, including doc types.
|
|
1668
|
-
*/
|
|
1669
|
-
declare class ProcessingInstruction extends DataNode {
|
|
1670
|
-
name: string;
|
|
1671
|
-
type: ElementType.Directive;
|
|
1672
|
-
constructor(name: string, data: string);
|
|
1673
|
-
get nodeType(): 1;
|
|
1674
|
-
/** If this is a doctype, the document type name (parse5 only). */
|
|
1675
|
-
"x-name"?: string;
|
|
1676
|
-
/** If this is a doctype, the document type public identifier (parse5 only). */
|
|
1677
|
-
"x-publicId"?: string;
|
|
1678
|
-
/** If this is a doctype, the document type system identifier (parse5 only). */
|
|
1679
|
-
"x-systemId"?: string;
|
|
1680
|
-
}
|
|
1681
|
-
/**
|
|
1682
|
-
* A `Node` that can have children.
|
|
1683
|
-
*/
|
|
1684
|
-
declare abstract class NodeWithChildren extends Node {
|
|
1685
|
-
children: ChildNode[];
|
|
1686
|
-
/**
|
|
1687
|
-
* @param children Children of the node. Only certain node types can have children.
|
|
1688
|
-
*/
|
|
1689
|
-
constructor(children: ChildNode[]);
|
|
1690
|
-
/** First child of the node. */
|
|
1691
|
-
get firstChild(): ChildNode | null;
|
|
1692
|
-
/** Last child of the node. */
|
|
1693
|
-
get lastChild(): ChildNode | null;
|
|
1694
|
-
/**
|
|
1695
|
-
* Same as {@link children}.
|
|
1696
|
-
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
|
1697
|
-
*/
|
|
1698
|
-
get childNodes(): ChildNode[];
|
|
1699
|
-
set childNodes(children: ChildNode[]);
|
|
1700
|
-
}
|
|
1701
|
-
declare class CDATA extends NodeWithChildren {
|
|
1702
|
-
type: ElementType.CDATA;
|
|
1703
|
-
get nodeType(): 4;
|
|
1704
|
-
}
|
|
1705
|
-
/**
|
|
1706
|
-
* The root node of the document.
|
|
1707
|
-
*/
|
|
1708
|
-
declare class Document extends NodeWithChildren {
|
|
1709
|
-
type: ElementType.Root;
|
|
1710
|
-
get nodeType(): 9;
|
|
1711
|
-
/** [Document mode](https://dom.spec.whatwg.org/#concept-document-limited-quirks) (parse5 only). */
|
|
1712
|
-
"x-mode"?: "no-quirks" | "quirks" | "limited-quirks";
|
|
1713
|
-
}
|
|
1714
|
-
/**
|
|
1715
|
-
* The description of an individual attribute.
|
|
1716
|
-
*/
|
|
1717
|
-
interface Attribute {
|
|
1718
|
-
name: string;
|
|
1719
|
-
value: string;
|
|
1720
|
-
namespace?: string;
|
|
1721
|
-
prefix?: string;
|
|
1722
|
-
}
|
|
1723
|
-
/**
|
|
1724
|
-
* An element within the DOM.
|
|
1725
|
-
*/
|
|
1726
|
-
declare class Element extends NodeWithChildren {
|
|
1727
|
-
name: string;
|
|
1728
|
-
attribs: {
|
|
1729
|
-
[name: string]: string;
|
|
1730
|
-
};
|
|
1731
|
-
type: ElementType.Tag | ElementType.Script | ElementType.Style;
|
|
1732
|
-
/**
|
|
1733
|
-
* @param name Name of the tag, eg. `div`, `span`.
|
|
1734
|
-
* @param attribs Object mapping attribute names to attribute values.
|
|
1735
|
-
* @param children Children of the node.
|
|
1736
|
-
*/
|
|
1737
|
-
constructor(name: string, attribs: {
|
|
1738
|
-
[name: string]: string;
|
|
1739
|
-
}, children?: ChildNode[], type?: ElementType.Tag | ElementType.Script | ElementType.Style);
|
|
1740
|
-
get nodeType(): 1;
|
|
1741
|
-
/**
|
|
1742
|
-
* `parse5` source code location info, with start & end tags.
|
|
1743
|
-
*
|
|
1744
|
-
* Available if parsing with parse5 and location info is enabled.
|
|
1745
|
-
*/
|
|
1746
|
-
sourceCodeLocation?: TagSourceCodeLocation | null;
|
|
1747
|
-
/**
|
|
1748
|
-
* Same as {@link name}.
|
|
1749
|
-
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
|
1750
|
-
*/
|
|
1751
|
-
get tagName(): string;
|
|
1752
|
-
set tagName(name: string);
|
|
1753
|
-
get attributes(): Attribute[];
|
|
1754
|
-
/** Element namespace (parse5 only). */
|
|
1755
|
-
namespace?: string;
|
|
1756
|
-
/** Element attribute namespaces (parse5 only). */
|
|
1757
|
-
"x-attribsNamespace"?: Record<string, string>;
|
|
1758
|
-
/** Element attribute namespace-related prefixes (parse5 only). */
|
|
1759
|
-
"x-attribsPrefix"?: Record<string, string>;
|
|
1760
|
-
}
|
|
1761
|
-
|
|
1762
|
-
declare const parseHTML: (content: string) => AnyNode[];
|
|
1763
|
-
|
|
1764
|
-
interface ElementNode {
|
|
1765
|
-
type: "node";
|
|
1766
|
-
name: string;
|
|
1767
|
-
attrs?: Record<string, string>;
|
|
1768
|
-
children?: RichTextNode[];
|
|
1769
|
-
}
|
|
1770
|
-
interface TextNode {
|
|
1771
|
-
type: "text";
|
|
1772
|
-
text: string;
|
|
1773
|
-
}
|
|
1774
|
-
type RichTextNode = ElementNode | TextNode;
|
|
1775
|
-
|
|
1776
|
-
type NodeHandler = (node: ElementNode) => ElementNode | null | Promise<ElementNode | null>;
|
|
1777
|
-
interface ParserOptions {
|
|
1778
|
-
/**
|
|
1779
|
-
* 是否附加标签名到 class
|
|
1780
|
-
*
|
|
1781
|
-
* @default true
|
|
1782
|
-
*/
|
|
1783
|
-
appendClass?: boolean;
|
|
1784
|
-
/**
|
|
1785
|
-
* 处理 Tag
|
|
1786
|
-
*/
|
|
1787
|
-
transform?: Partial<Record<AllowTag, NodeHandler>>;
|
|
1788
|
-
}
|
|
1789
|
-
|
|
1790
|
-
declare const getRichTextNodes: (content: string | AnyNode[], { appendClass, transform }?: ParserOptions) => Promise<RichTextNode[]>;
|
|
1791
|
-
|
|
1792
|
-
declare const getText: (content: string | AnyNode[]) => string;
|
|
1793
|
-
|
|
1794
|
-
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, getCookieOptions, getCookieScopeDomain, getDomain, getRef, getRichTextNodes, getText, 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 };
|
|
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 };
|