@umijs/utils 3.5.17 → 4.0.0-beta.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.
Files changed (208) hide show
  1. package/README.md +2 -0
  2. package/compiled/address/index.js +1 -0
  3. package/compiled/address/lib/address.d.ts +28 -0
  4. package/compiled/address/package.json +1 -0
  5. package/compiled/axios/LICENSE +19 -0
  6. package/compiled/axios/index.d.ts +206 -0
  7. package/compiled/axios/index.js +1 -0
  8. package/compiled/axios/package.json +1 -0
  9. package/compiled/chalk/LICENSE +9 -0
  10. package/compiled/chalk/index.d.ts +415 -0
  11. package/compiled/chalk/index.js +1 -0
  12. package/compiled/chalk/package.json +1 -0
  13. package/compiled/cheerio/LICENSE +21 -0
  14. package/compiled/cheerio/domelementtype/lib/index.d.ts +48 -0
  15. package/compiled/cheerio/domhandler/lib/index.d.ts +85 -0
  16. package/compiled/cheerio/domhandler/lib/node.d.ts +169 -0
  17. package/compiled/cheerio/htmlparser2/lib/Parser.d.ts +159 -0
  18. package/compiled/cheerio/htmlparser2/lib/Tokenizer.d.ts +182 -0
  19. package/compiled/cheerio/htmlparser2/lib/index.d.ts +39 -0
  20. package/compiled/cheerio/index.js +16 -0
  21. package/compiled/cheerio/lib/api/attributes.d.ts +317 -0
  22. package/compiled/cheerio/lib/api/css.d.ts +41 -0
  23. package/compiled/cheerio/lib/api/forms.d.ts +31 -0
  24. package/compiled/cheerio/lib/api/manipulation.d.ts +496 -0
  25. package/compiled/cheerio/lib/api/traversing.d.ts +644 -0
  26. package/compiled/cheerio/lib/cheerio.d.ts +53 -0
  27. package/compiled/cheerio/lib/index.d.ts +91 -0
  28. package/compiled/cheerio/lib/load.d.ts +73 -0
  29. package/compiled/cheerio/lib/options.d.ts +31 -0
  30. package/compiled/cheerio/lib/static.d.ts +88 -0
  31. package/compiled/cheerio/lib/types.d.ts +20 -0
  32. package/compiled/cheerio/package.json +1 -0
  33. package/compiled/color/LICENSE +21 -0
  34. package/compiled/color/color-convert/conversions.d.ts +149 -0
  35. package/compiled/color/color-convert/index.d.ts +113 -0
  36. package/compiled/color/color-convert/route.d.ts +294 -0
  37. package/compiled/color/color-name/index.d.ts +161 -0
  38. package/compiled/color/index.d.ts +142 -0
  39. package/compiled/color/index.js +1 -0
  40. package/compiled/color/package.json +4 -0
  41. package/compiled/cross-spawn/LICENSE +21 -0
  42. package/compiled/cross-spawn/index.d.ts +36 -0
  43. package/compiled/cross-spawn/index.js +1 -0
  44. package/compiled/cross-spawn/package.json +1 -0
  45. package/compiled/debug/LICENSE +19 -0
  46. package/compiled/debug/index.d.ts +54 -0
  47. package/compiled/debug/index.js +1 -0
  48. package/compiled/debug/ms/index.d.ts +25 -0
  49. package/compiled/debug/package.json +1 -0
  50. package/compiled/fs-extra/LICENSE +15 -0
  51. package/compiled/fs-extra/index.d.ts +332 -0
  52. package/compiled/fs-extra/index.js +1 -0
  53. package/compiled/fs-extra/package.json +1 -0
  54. package/compiled/glob/LICENSE +21 -0
  55. package/compiled/glob/index.d.ts +89 -0
  56. package/compiled/glob/index.js +1 -0
  57. package/compiled/glob/minimatch/index.d.ts +204 -0
  58. package/compiled/glob/package.json +1 -0
  59. package/compiled/import-lazy/LICENSE +9 -0
  60. package/compiled/import-lazy/index.d.ts +26 -0
  61. package/compiled/import-lazy/index.js +1 -0
  62. package/compiled/import-lazy/package.json +1 -0
  63. package/compiled/lodash/LICENSE +47 -0
  64. package/compiled/lodash/common/array.d.ts +2126 -0
  65. package/compiled/lodash/common/collection.d.ts +1930 -0
  66. package/compiled/lodash/common/common.d.ts +280 -0
  67. package/compiled/lodash/common/date.d.ts +23 -0
  68. package/compiled/lodash/common/function.d.ts +1430 -0
  69. package/compiled/lodash/common/lang.d.ts +1692 -0
  70. package/compiled/lodash/common/math.d.ts +405 -0
  71. package/compiled/lodash/common/number.d.ts +131 -0
  72. package/compiled/lodash/common/object.d.ts +2519 -0
  73. package/compiled/lodash/common/seq.d.ts +210 -0
  74. package/compiled/lodash/common/string.d.ts +788 -0
  75. package/compiled/lodash/common/util.d.ts +1219 -0
  76. package/compiled/lodash/index.d.ts +46 -0
  77. package/compiled/lodash/index.js +9 -0
  78. package/compiled/lodash/package.json +1 -0
  79. package/compiled/mustache/LICENSE +11 -0
  80. package/compiled/mustache/index.d.ts +437 -0
  81. package/compiled/mustache/index.js +5 -0
  82. package/compiled/mustache/package.json +1 -0
  83. package/compiled/pkg-up/LICENSE +9 -0
  84. package/compiled/pkg-up/index.d.ts +48 -0
  85. package/compiled/pkg-up/index.js +1 -0
  86. package/compiled/pkg-up/package.json +1 -0
  87. package/compiled/portfinder/LICENSE +22 -0
  88. package/compiled/portfinder/index.js +1 -0
  89. package/compiled/portfinder/lib/portfinder.d.ts +47 -0
  90. package/compiled/portfinder/package.json +1 -0
  91. package/compiled/prettier/LICENSE +7 -0
  92. package/compiled/prettier/index.d.ts +867 -0
  93. package/compiled/prettier/index.js +475 -0
  94. package/compiled/prettier/package.json +5 -0
  95. package/compiled/prompts/LICENSE +21 -0
  96. package/compiled/prompts/index.d.ts +120 -0
  97. package/compiled/prompts/index.js +1 -0
  98. package/compiled/prompts/package.json +1 -0
  99. package/compiled/resolve/LICENSE +21 -0
  100. package/compiled/resolve/index.d.ts +166 -0
  101. package/compiled/resolve/index.js +1 -0
  102. package/compiled/resolve/package.json +1 -0
  103. package/compiled/rimraf/LICENSE +15 -0
  104. package/compiled/rimraf/glob/index.d.ts +89 -0
  105. package/compiled/rimraf/index.d.ts +49 -0
  106. package/compiled/rimraf/index.js +1 -0
  107. package/compiled/rimraf/minimatch/index.d.ts +204 -0
  108. package/compiled/rimraf/package.json +1 -0
  109. package/compiled/semver/LICENSE +15 -0
  110. package/compiled/semver/classes/comparator.d.ts +17 -0
  111. package/compiled/semver/classes/range.d.ts +21 -0
  112. package/compiled/semver/classes/semver.d.ts +62 -0
  113. package/compiled/semver/functions/clean.d.ts +8 -0
  114. package/compiled/semver/functions/cmp.d.ts +16 -0
  115. package/compiled/semver/functions/coerce.d.ts +12 -0
  116. package/compiled/semver/functions/compare-build.d.ts +16 -0
  117. package/compiled/semver/functions/compare-loose.d.ts +5 -0
  118. package/compiled/semver/functions/compare.d.ts +20 -0
  119. package/compiled/semver/functions/diff.d.ts +13 -0
  120. package/compiled/semver/functions/eq.d.ts +9 -0
  121. package/compiled/semver/functions/gt.d.ts +9 -0
  122. package/compiled/semver/functions/gte.d.ts +9 -0
  123. package/compiled/semver/functions/inc.d.ts +15 -0
  124. package/compiled/semver/functions/lt.d.ts +9 -0
  125. package/compiled/semver/functions/lte.d.ts +8 -0
  126. package/compiled/semver/functions/major.d.ts +9 -0
  127. package/compiled/semver/functions/minor.d.ts +9 -0
  128. package/compiled/semver/functions/neq.d.ts +9 -0
  129. package/compiled/semver/functions/parse.d.ts +12 -0
  130. package/compiled/semver/functions/patch.d.ts +9 -0
  131. package/compiled/semver/functions/prerelease.d.ts +12 -0
  132. package/compiled/semver/functions/rcompare.d.ts +15 -0
  133. package/compiled/semver/functions/rsort.d.ts +9 -0
  134. package/compiled/semver/functions/satisfies.d.ts +14 -0
  135. package/compiled/semver/functions/sort.d.ts +9 -0
  136. package/compiled/semver/functions/valid.d.ts +11 -0
  137. package/compiled/semver/index.d.ts +133 -0
  138. package/compiled/semver/index.js +1 -0
  139. package/compiled/semver/internals/identifiers.d.ts +13 -0
  140. package/compiled/semver/package.json +1 -0
  141. package/compiled/semver/ranges/gtr.d.ts +14 -0
  142. package/compiled/semver/ranges/intersects.d.ts +13 -0
  143. package/compiled/semver/ranges/ltr.d.ts +14 -0
  144. package/compiled/semver/ranges/max-satisfying.d.ts +14 -0
  145. package/compiled/semver/ranges/min-satisfying.d.ts +14 -0
  146. package/compiled/semver/ranges/min-version.d.ts +10 -0
  147. package/compiled/semver/ranges/outside.d.ts +15 -0
  148. package/compiled/semver/ranges/simplify.d.ts +14 -0
  149. package/compiled/semver/ranges/subset.d.ts +13 -0
  150. package/compiled/semver/ranges/to-comparators.d.ts +9 -0
  151. package/compiled/semver/ranges/valid.d.ts +12 -0
  152. package/compiled/strip-ansi/LICENSE +9 -0
  153. package/compiled/strip-ansi/index.d.ts +17 -0
  154. package/compiled/strip-ansi/index.js +1 -0
  155. package/compiled/strip-ansi/package.json +1 -0
  156. package/compiled/yargs-parser/index.d.ts +112 -0
  157. package/compiled/yargs-parser/index.js +1 -0
  158. package/compiled/yargs-parser/package.json +1 -0
  159. package/dist/BaseGenerator/BaseGenerator.d.ts +18 -0
  160. package/dist/BaseGenerator/BaseGenerator.js +58 -0
  161. package/{lib → dist}/Generator/Generator.d.ts +3 -3
  162. package/dist/Generator/Generator.js +74 -0
  163. package/dist/importLazy.d.ts +6 -0
  164. package/dist/importLazy.js +17 -0
  165. package/dist/index.d.ts +28 -0
  166. package/dist/index.js +79 -0
  167. package/dist/logger.d.ts +14 -0
  168. package/dist/logger.js +39 -0
  169. package/dist/randomColor/randomColor.d.ts +6 -0
  170. package/dist/randomColor/randomColor.js +19 -0
  171. package/dist/register.d.ts +6 -0
  172. package/dist/register.js +47 -0
  173. package/dist/winPath.d.ts +1 -0
  174. package/dist/winPath.js +11 -0
  175. package/package.json +92 -12
  176. package/lib/BabelRegister/BabelRegister.d.ts +0 -9
  177. package/lib/BabelRegister/BabelRegister.js +0 -66
  178. package/lib/Generator/Generator.js +0 -120
  179. package/lib/cheerio/cheerio.d.ts +0 -2
  180. package/lib/cheerio/cheerio.js +0 -37
  181. package/lib/cleanRequireCache/cleanRequireCache.d.ts +0 -1
  182. package/lib/cleanRequireCache/cleanRequireCache.js +0 -40
  183. package/lib/compatESModuleRequire/compatESModuleRequire.d.ts +0 -7
  184. package/lib/compatESModuleRequire/compatESModuleRequire.js +0 -22
  185. package/lib/delay/delay.d.ts +0 -1
  186. package/lib/delay/delay.js +0 -22
  187. package/lib/getFile/getFile.d.ts +0 -22
  188. package/lib/getFile/getFile.js +0 -85
  189. package/lib/index.d.ts +0 -66
  190. package/lib/index.js +0 -619
  191. package/lib/isLernaPackage/isLernaPackage.d.ts +0 -1
  192. package/lib/isLernaPackage/isLernaPackage.js +0 -42
  193. package/lib/mergeConfig/mergeConfig.d.ts +0 -8
  194. package/lib/mergeConfig/mergeConfig.js +0 -42
  195. package/lib/parseRequireDeps/parseRequireDeps.d.ts +0 -1
  196. package/lib/parseRequireDeps/parseRequireDeps.js +0 -98
  197. package/lib/randomColor/randomColor.d.ts +0 -6
  198. package/lib/randomColor/randomColor.js +0 -42
  199. package/lib/routes.d.ts +0 -11
  200. package/lib/routes.js +0 -53
  201. package/lib/ssr.d.ts +0 -12
  202. package/lib/ssr.js +0 -41
  203. package/lib/types.d.ts +0 -7
  204. package/lib/types.js +0 -17
  205. package/lib/winEOL/winEOL.d.ts +0 -7
  206. package/lib/winEOL/winEOL.js +0 -39
  207. package/lib/winPath/winPath.d.ts +0 -1
  208. package/lib/winPath/winPath.js +0 -28
@@ -0,0 +1,169 @@
1
+ import { ElementType } from '../../domelementtype';
2
+ /**
3
+ * This object will be used as the prototype for Nodes when creating a
4
+ * DOM-Level-1-compliant structure.
5
+ */
6
+ export declare class Node {
7
+ type: ElementType;
8
+ /** Parent of the node */
9
+ parent: NodeWithChildren | null;
10
+ /** Previous sibling */
11
+ prev: Node | null;
12
+ /** Next sibling */
13
+ next: Node | null;
14
+ /** The start index of the node. Requires `withStartIndices` on the handler to be `true. */
15
+ startIndex: number | null;
16
+ /** The end index of the node. Requires `withEndIndices` on the handler to be `true. */
17
+ endIndex: number | null;
18
+ /**
19
+ *
20
+ * @param type The type of the node.
21
+ */
22
+ constructor(type: ElementType);
23
+ get nodeType(): number;
24
+ get parentNode(): NodeWithChildren | null;
25
+ set parentNode(parent: NodeWithChildren | null);
26
+ get previousSibling(): Node | null;
27
+ set previousSibling(prev: Node | null);
28
+ get nextSibling(): Node | null;
29
+ set nextSibling(next: Node | null);
30
+ /**
31
+ * Clone this node, and optionally its children.
32
+ *
33
+ * @param recursive Clone child nodes as well.
34
+ * @returns A clone of the node.
35
+ */
36
+ cloneNode<T extends Node>(this: T, recursive?: boolean): T;
37
+ }
38
+ /**
39
+ * A node that contains some data.
40
+ */
41
+ export declare class DataNode extends Node {
42
+ data: string;
43
+ /**
44
+ * @param type The type of the node
45
+ * @param data The content of the data node
46
+ */
47
+ constructor(type: ElementType.Comment | ElementType.Text | ElementType.Directive, data: string);
48
+ get nodeValue(): string;
49
+ set nodeValue(data: string);
50
+ }
51
+ /**
52
+ * Text within the document.
53
+ */
54
+ export declare class Text extends DataNode {
55
+ constructor(data: string);
56
+ }
57
+ /**
58
+ * Comments within the document.
59
+ */
60
+ export declare class Comment extends DataNode {
61
+ constructor(data: string);
62
+ }
63
+ /**
64
+ * Processing instructions, including doc types.
65
+ */
66
+ export declare class ProcessingInstruction extends DataNode {
67
+ name: string;
68
+ constructor(name: string, data: string);
69
+ "x-name"?: string;
70
+ "x-publicId"?: string;
71
+ "x-systemId"?: string;
72
+ }
73
+ /**
74
+ * A `Node` that can have children.
75
+ */
76
+ export declare class NodeWithChildren extends Node {
77
+ children: Node[];
78
+ /**
79
+ * @param type Type of the node.
80
+ * @param children Children of the node. Only certain node types can have children.
81
+ */
82
+ constructor(type: ElementType.Root | ElementType.CDATA | ElementType.Script | ElementType.Style | ElementType.Tag, children: Node[]);
83
+ get firstChild(): Node | null;
84
+ get lastChild(): Node | null;
85
+ get childNodes(): Node[];
86
+ set childNodes(children: Node[]);
87
+ }
88
+ /**
89
+ * The root node of the document.
90
+ */
91
+ export declare class Document extends NodeWithChildren {
92
+ constructor(children: Node[]);
93
+ "x-mode"?: "no-quirks" | "quirks" | "limited-quirks";
94
+ }
95
+ /**
96
+ * The description of an individual attribute.
97
+ */
98
+ interface Attribute {
99
+ name: string;
100
+ value: string;
101
+ namespace?: string;
102
+ prefix?: string;
103
+ }
104
+ /**
105
+ * An element within the DOM.
106
+ */
107
+ export declare class Element extends NodeWithChildren {
108
+ name: string;
109
+ attribs: {
110
+ [name: string]: string;
111
+ };
112
+ /**
113
+ * @param name Name of the tag, eg. `div`, `span`.
114
+ * @param attribs Object mapping attribute names to attribute values.
115
+ * @param children Children of the node.
116
+ */
117
+ constructor(name: string, attribs: {
118
+ [name: string]: string;
119
+ }, children?: Node[], type?: ElementType.Tag | ElementType.Script | ElementType.Style);
120
+ get tagName(): string;
121
+ set tagName(name: string);
122
+ get attributes(): Attribute[];
123
+ "x-attribsNamespace"?: Record<string, string>;
124
+ "x-attribsPrefix"?: Record<string, string>;
125
+ }
126
+ /**
127
+ * @param node Node to check.
128
+ * @returns `true` if the node is a `Element`, `false` otherwise.
129
+ */
130
+ export declare function isTag(node: Node): node is Element;
131
+ /**
132
+ * @param node Node to check.
133
+ * @returns `true` if the node has the type `CDATA`, `false` otherwise.
134
+ */
135
+ export declare function isCDATA(node: Node): node is NodeWithChildren;
136
+ /**
137
+ * @param node Node to check.
138
+ * @returns `true` if the node has the type `Text`, `false` otherwise.
139
+ */
140
+ export declare function isText(node: Node): node is Text;
141
+ /**
142
+ * @param node Node to check.
143
+ * @returns `true` if the node has the type `Comment`, `false` otherwise.
144
+ */
145
+ export declare function isComment(node: Node): node is DataNode;
146
+ /**
147
+ * @param node Node to check.
148
+ * @returns `true` if the node has the type `ProcessingInstruction`, `false` otherwise.
149
+ */
150
+ export declare function isDirective(node: Node): node is ProcessingInstruction;
151
+ /**
152
+ * @param node Node to check.
153
+ * @returns `true` if the node has the type `ProcessingInstruction`, `false` otherwise.
154
+ */
155
+ export declare function isDocument(node: Node): node is Document;
156
+ /**
157
+ * @param node Node to check.
158
+ * @returns `true` if the node is a `NodeWithChildren` (has children), `false` otherwise.
159
+ */
160
+ export declare function hasChildren(node: Node): node is NodeWithChildren;
161
+ /**
162
+ * Clone a node, and optionally its children.
163
+ *
164
+ * @param recursive Clone child nodes as well.
165
+ * @returns A clone of the node.
166
+ */
167
+ export declare function cloneNode<T extends Node>(node: T, recursive?: boolean): T;
168
+ export {};
169
+ //# sourceMappingURL=node.d.ts.map
@@ -0,0 +1,159 @@
1
+ import Tokenizer from './Tokenizer';
2
+ export interface ParserOptions {
3
+ /**
4
+ * Indicates whether special tags (`<script>`, `<style>`, and `<title>`) should get special treatment
5
+ * and if "empty" tags (eg. `<br>`) can have children. If `false`, the content of special tags
6
+ * will be text only. For feeds and other XML content (documents that don't consist of HTML),
7
+ * set this to `true`.
8
+ *
9
+ * @default false
10
+ */
11
+ xmlMode?: boolean;
12
+ /**
13
+ * Decode entities within the document.
14
+ *
15
+ * @default true
16
+ */
17
+ decodeEntities?: boolean;
18
+ /**
19
+ * If set to true, all tags will be lowercased.
20
+ *
21
+ * @default !xmlMode
22
+ */
23
+ lowerCaseTags?: boolean;
24
+ /**
25
+ * If set to `true`, all attribute names will be lowercased. This has noticeable impact on speed.
26
+ *
27
+ * @default !xmlMode
28
+ */
29
+ lowerCaseAttributeNames?: boolean;
30
+ /**
31
+ * If set to true, CDATA sections will be recognized as text even if the xmlMode option is not enabled.
32
+ * NOTE: If xmlMode is set to `true` then CDATA sections will always be recognized as text.
33
+ *
34
+ * @default xmlMode
35
+ */
36
+ recognizeCDATA?: boolean;
37
+ /**
38
+ * If set to `true`, self-closing tags will trigger the onclosetag event even if xmlMode is not set to `true`.
39
+ * NOTE: If xmlMode is set to `true` then self-closing tags will always be recognized.
40
+ *
41
+ * @default xmlMode
42
+ */
43
+ recognizeSelfClosing?: boolean;
44
+ /**
45
+ * Allows the default tokenizer to be overwritten.
46
+ */
47
+ Tokenizer?: typeof Tokenizer;
48
+ }
49
+ export interface Handler {
50
+ onparserinit(parser: Parser): void;
51
+ /**
52
+ * Resets the handler back to starting state
53
+ */
54
+ onreset(): void;
55
+ /**
56
+ * Signals the handler that parsing is done
57
+ */
58
+ onend(): void;
59
+ onerror(error: Error): void;
60
+ onclosetag(name: string): void;
61
+ onopentagname(name: string): void;
62
+ /**
63
+ *
64
+ * @param name Name of the attribute
65
+ * @param value Value of the attribute.
66
+ * @param quote Quotes used around the attribute. `null` if the attribute has no quotes around the value, `undefined` if the attribute has no value.
67
+ */
68
+ onattribute(name: string, value: string, quote?: string | undefined | null): void;
69
+ onopentag(name: string, attribs: {
70
+ [s: string]: string;
71
+ }): void;
72
+ ontext(data: string): void;
73
+ oncomment(data: string): void;
74
+ oncdatastart(): void;
75
+ oncdataend(): void;
76
+ oncommentend(): void;
77
+ onprocessinginstruction(name: string, data: string): void;
78
+ }
79
+ export declare class Parser {
80
+ /** The start index of the last event. */
81
+ startIndex: number;
82
+ /** The end index of the last event. */
83
+ endIndex: number | null;
84
+ private tagname;
85
+ private attribname;
86
+ private attribvalue;
87
+ private attribs;
88
+ private stack;
89
+ private readonly foreignContext;
90
+ private readonly cbs;
91
+ private readonly options;
92
+ private readonly lowerCaseTagNames;
93
+ private readonly lowerCaseAttributeNames;
94
+ private readonly tokenizer;
95
+ constructor(cbs: Partial<Handler> | null, options?: ParserOptions);
96
+ private updatePosition;
97
+ ontext(data: string): void;
98
+ onopentagname(name: string): void;
99
+ onopentagend(): void;
100
+ onclosetag(name: string): void;
101
+ onselfclosingtag(): void;
102
+ private closeCurrentTag;
103
+ onattribname(name: string): void;
104
+ onattribdata(value: string): void;
105
+ onattribend(quote: string | undefined | null): void;
106
+ private getInstructionName;
107
+ ondeclaration(value: string): void;
108
+ onprocessinginstruction(value: string): void;
109
+ oncomment(value: string): void;
110
+ oncdata(value: string): void;
111
+ onerror(err: Error): void;
112
+ onend(): void;
113
+ /**
114
+ * Resets the parser to a blank state, ready to parse a new HTML document
115
+ */
116
+ reset(): void;
117
+ /**
118
+ * Resets the parser, then parses a complete document and
119
+ * pushes it to the handler.
120
+ *
121
+ * @param data Document to parse.
122
+ */
123
+ parseComplete(data: string): void;
124
+ /**
125
+ * Parses a chunk of data and calls the corresponding callbacks.
126
+ *
127
+ * @param chunk Chunk to parse.
128
+ */
129
+ write(chunk: string): void;
130
+ /**
131
+ * Parses the end of the buffer and clears the stack, calls onend.
132
+ *
133
+ * @param chunk Optional final chunk to parse.
134
+ */
135
+ end(chunk?: string): void;
136
+ /**
137
+ * Pauses parsing. The parser won't emit events until `resume` is called.
138
+ */
139
+ pause(): void;
140
+ /**
141
+ * Resumes parsing after `pause` was called.
142
+ */
143
+ resume(): void;
144
+ /**
145
+ * Alias of `write`, for backwards compatibility.
146
+ *
147
+ * @param chunk Chunk to parse.
148
+ * @deprecated
149
+ */
150
+ parseChunk(chunk: string): void;
151
+ /**
152
+ * Alias of `end`, for backwards compatibility.
153
+ *
154
+ * @param chunk Optional final chunk to parse.
155
+ * @deprecated
156
+ */
157
+ done(chunk?: string): void;
158
+ }
159
+ //# sourceMappingURL=Parser.d.ts.map
@@ -0,0 +1,182 @@
1
+ /** All the states the tokenizer can be in. */
2
+ declare const enum State {
3
+ Text = 1,
4
+ BeforeTagName = 2,
5
+ InTagName = 3,
6
+ InSelfClosingTag = 4,
7
+ BeforeClosingTagName = 5,
8
+ InClosingTagName = 6,
9
+ AfterClosingTagName = 7,
10
+ BeforeAttributeName = 8,
11
+ InAttributeName = 9,
12
+ AfterAttributeName = 10,
13
+ BeforeAttributeValue = 11,
14
+ InAttributeValueDq = 12,
15
+ InAttributeValueSq = 13,
16
+ InAttributeValueNq = 14,
17
+ BeforeDeclaration = 15,
18
+ InDeclaration = 16,
19
+ InProcessingInstruction = 17,
20
+ BeforeComment = 18,
21
+ InComment = 19,
22
+ InSpecialComment = 20,
23
+ AfterComment1 = 21,
24
+ AfterComment2 = 22,
25
+ BeforeCdata1 = 23,
26
+ BeforeCdata2 = 24,
27
+ BeforeCdata3 = 25,
28
+ BeforeCdata4 = 26,
29
+ BeforeCdata5 = 27,
30
+ BeforeCdata6 = 28,
31
+ InCdata = 29,
32
+ AfterCdata1 = 30,
33
+ AfterCdata2 = 31,
34
+ BeforeSpecialS = 32,
35
+ BeforeSpecialSEnd = 33,
36
+ BeforeScript1 = 34,
37
+ BeforeScript2 = 35,
38
+ BeforeScript3 = 36,
39
+ BeforeScript4 = 37,
40
+ BeforeScript5 = 38,
41
+ AfterScript1 = 39,
42
+ AfterScript2 = 40,
43
+ AfterScript3 = 41,
44
+ AfterScript4 = 42,
45
+ AfterScript5 = 43,
46
+ BeforeStyle1 = 44,
47
+ BeforeStyle2 = 45,
48
+ BeforeStyle3 = 46,
49
+ BeforeStyle4 = 47,
50
+ AfterStyle1 = 48,
51
+ AfterStyle2 = 49,
52
+ AfterStyle3 = 50,
53
+ AfterStyle4 = 51,
54
+ BeforeSpecialT = 52,
55
+ BeforeSpecialTEnd = 53,
56
+ BeforeTitle1 = 54,
57
+ BeforeTitle2 = 55,
58
+ BeforeTitle3 = 56,
59
+ BeforeTitle4 = 57,
60
+ AfterTitle1 = 58,
61
+ AfterTitle2 = 59,
62
+ AfterTitle3 = 60,
63
+ AfterTitle4 = 61,
64
+ BeforeEntity = 62,
65
+ BeforeNumericEntity = 63,
66
+ InNamedEntity = 64,
67
+ InNumericEntity = 65,
68
+ InHexEntity = 66
69
+ }
70
+ export interface Callbacks {
71
+ onattribdata(value: string): void;
72
+ onattribend(quote: string | undefined | null): void;
73
+ onattribname(name: string): void;
74
+ oncdata(data: string): void;
75
+ onclosetag(name: string): void;
76
+ oncomment(data: string): void;
77
+ ondeclaration(content: string): void;
78
+ onend(): void;
79
+ onerror(error: Error, state?: State): void;
80
+ onopentagend(): void;
81
+ onopentagname(name: string): void;
82
+ onprocessinginstruction(instruction: string): void;
83
+ onselfclosingtag(): void;
84
+ ontext(value: string): void;
85
+ }
86
+ export default class Tokenizer {
87
+ /** The current state the tokenizer is in. */
88
+ _state: State;
89
+ /** The read buffer. */
90
+ private buffer;
91
+ /** The beginning of the section that is currently being read. */
92
+ sectionStart: number;
93
+ /** The index within the buffer that we are currently looking at. */
94
+ _index: number;
95
+ /**
96
+ * Data that has already been processed will be removed from the buffer occasionally.
97
+ * `_bufferOffset` keeps track of how many characters have been removed, to make sure position information is accurate.
98
+ */
99
+ private bufferOffset;
100
+ /** Some behavior, eg. when decoding entities, is done while we are in another state. This keeps track of the other state type. */
101
+ private baseState;
102
+ /** For special parsing behavior inside of script and style tags. */
103
+ private special;
104
+ /** Indicates whether the tokenizer has been paused. */
105
+ private running;
106
+ /** Indicates whether the tokenizer has finished running / `.end` has been called. */
107
+ private ended;
108
+ private readonly cbs;
109
+ private readonly xmlMode;
110
+ private readonly decodeEntities;
111
+ constructor(options: {
112
+ xmlMode?: boolean;
113
+ decodeEntities?: boolean;
114
+ } | null, cbs: Callbacks);
115
+ reset(): void;
116
+ write(chunk: string): void;
117
+ end(chunk?: string): void;
118
+ pause(): void;
119
+ resume(): void;
120
+ /**
121
+ * The current index within all of the written data.
122
+ */
123
+ getAbsoluteIndex(): number;
124
+ private stateText;
125
+ /**
126
+ * HTML only allows ASCII alpha characters (a-z and A-Z) at the beginning of a tag name.
127
+ *
128
+ * XML allows a lot more characters here (@see https://www.w3.org/TR/REC-xml/#NT-NameStartChar).
129
+ * We allow anything that wouldn't end the tag.
130
+ */
131
+ private isTagStartChar;
132
+ private stateBeforeTagName;
133
+ private stateInTagName;
134
+ private stateBeforeClosingTagName;
135
+ private stateInClosingTagName;
136
+ private stateAfterClosingTagName;
137
+ private stateBeforeAttributeName;
138
+ private stateInSelfClosingTag;
139
+ private stateInAttributeName;
140
+ private stateAfterAttributeName;
141
+ private stateBeforeAttributeValue;
142
+ private handleInAttributeValue;
143
+ private stateInAttributeValueDoubleQuotes;
144
+ private stateInAttributeValueSingleQuotes;
145
+ private stateInAttributeValueNoQuotes;
146
+ private stateBeforeDeclaration;
147
+ private stateInDeclaration;
148
+ private stateInProcessingInstruction;
149
+ private stateBeforeComment;
150
+ private stateInComment;
151
+ private stateInSpecialComment;
152
+ private stateAfterComment1;
153
+ private stateAfterComment2;
154
+ private stateBeforeCdata6;
155
+ private stateInCdata;
156
+ private stateAfterCdata1;
157
+ private stateAfterCdata2;
158
+ private stateBeforeSpecialS;
159
+ private stateBeforeSpecialSEnd;
160
+ private stateBeforeSpecialLast;
161
+ private stateAfterSpecialLast;
162
+ private parseFixedEntity;
163
+ private parseLegacyEntity;
164
+ private stateInNamedEntity;
165
+ private decodeNumericEntity;
166
+ private stateInNumericEntity;
167
+ private stateInHexEntity;
168
+ private cleanup;
169
+ /**
170
+ * Iterates through the buffer, calling the function corresponding to the current state.
171
+ *
172
+ * States that are more likely to be hit are higher up, as a performance improvement.
173
+ */
174
+ private parse;
175
+ private finish;
176
+ private handleTrailingData;
177
+ private getSection;
178
+ private emitToken;
179
+ private emitPartial;
180
+ }
181
+ export {};
182
+ //# sourceMappingURL=Tokenizer.d.ts.map
@@ -0,0 +1,39 @@
1
+ import { Parser, ParserOptions } from './Parser';
2
+ export { Parser, ParserOptions };
3
+ import { DomHandler, DomHandlerOptions, Node, Element, Document } from '../../domhandler';
4
+ export { DomHandler, DomHandlerOptions };
5
+ declare type Options = ParserOptions & DomHandlerOptions;
6
+ /**
7
+ * Parses the data, returns the resulting document.
8
+ *
9
+ * @param data The data that should be parsed.
10
+ * @param options Optional options for the parser and DOM builder.
11
+ */
12
+ export declare function parseDocument(data: string, options?: Options): Document;
13
+ /**
14
+ * Parses data, returns an array of the root nodes.
15
+ *
16
+ * Note that the root nodes still have a `Document` node as their parent.
17
+ * Use `parseDocument` to get the `Document` node instead.
18
+ *
19
+ * @param data The data that should be parsed.
20
+ * @param options Optional options for the parser and DOM builder.
21
+ * @deprecated Use `parseDocument` instead.
22
+ */
23
+ export declare function parseDOM(data: string, options?: Options): Node[];
24
+ /**
25
+ * Creates a parser instance, with an attached DOM handler.
26
+ *
27
+ * @param cb A callback that will be called once parsing has been completed.
28
+ * @param options Optional options for the parser and DOM builder.
29
+ * @param elementCb An optional callback that will be called every time a tag has been completed inside of the DOM.
30
+ */
31
+ export declare function createDomStream(cb: (error: Error | null, dom: Node[]) => void, options?: Options, elementCb?: (element: Element) => void): Parser;
32
+ export { default as Tokenizer, Callbacks as TokenizerCallbacks, } from "./Tokenizer";
33
+ import * as ElementType from '../../domelementtype';
34
+ export { ElementType };
35
+ export * from "./FeedHandler";
36
+ export * as DomUtils from "domutils";
37
+ export { DomHandler as DefaultHandler };
38
+ export { FeedHandler as RssHandler } from "./FeedHandler";
39
+ //# sourceMappingURL=index.d.ts.map