wikiparser-node 0.11.0 → 1.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 (252) hide show
  1. package/config/.schema.json +26 -0
  2. package/dist/index.d.ts +61 -113
  3. package/dist/index.js +314 -0
  4. package/dist/lib/element.d.ts +122 -108
  5. package/dist/lib/element.js +656 -0
  6. package/dist/lib/node.d.ts +115 -221
  7. package/dist/lib/node.js +473 -0
  8. package/dist/lib/ranges.d.ts +27 -26
  9. package/dist/lib/ranges.js +130 -0
  10. package/dist/lib/text.d.ts +36 -28
  11. package/dist/lib/text.js +215 -0
  12. package/dist/lib/title.d.ts +26 -12
  13. package/dist/lib/title.js +108 -0
  14. package/dist/mixin/attributesParent.js +90 -0
  15. package/dist/mixin/fixed.js +29 -0
  16. package/dist/mixin/hidden.js +19 -0
  17. package/dist/mixin/singleLine.js +23 -0
  18. package/dist/mixin/sol.js +41 -0
  19. package/dist/parser/brackets.js +118 -0
  20. package/dist/parser/commentAndExt.js +48 -0
  21. package/dist/parser/converter.js +31 -0
  22. package/dist/parser/externalLinks.js +22 -0
  23. package/dist/parser/hrAndDoubleUnderscore.js +35 -0
  24. package/dist/parser/html.js +29 -0
  25. package/dist/parser/links.js +86 -0
  26. package/dist/parser/list.js +51 -0
  27. package/dist/parser/magicLinks.js +32 -0
  28. package/dist/parser/quotes.js +57 -0
  29. package/dist/parser/selector.js +158 -0
  30. package/dist/parser/table.js +108 -0
  31. package/dist/src/arg.d.ts +47 -23
  32. package/dist/src/arg.js +196 -0
  33. package/dist/src/atom.d.ts +12 -0
  34. package/dist/src/atom.js +22 -0
  35. package/dist/src/attribute.d.ts +74 -33
  36. package/dist/src/attribute.js +433 -0
  37. package/dist/src/attributes.d.ts +61 -55
  38. package/dist/src/attributes.js +371 -0
  39. package/dist/src/converter.d.ts +45 -71
  40. package/dist/src/converter.js +135 -0
  41. package/dist/src/converterFlags.d.ts +64 -39
  42. package/dist/src/converterFlags.js +235 -0
  43. package/dist/src/converterRule.d.ts +49 -27
  44. package/dist/src/converterRule.js +255 -0
  45. package/dist/src/extLink.d.ts +41 -38
  46. package/dist/src/extLink.js +154 -0
  47. package/dist/src/gallery.d.ts +59 -18
  48. package/dist/src/gallery.js +132 -0
  49. package/dist/src/heading.d.ts +60 -22
  50. package/dist/src/heading.js +135 -0
  51. package/dist/src/hidden.d.ts +20 -0
  52. package/dist/src/hidden.js +24 -0
  53. package/dist/src/html.d.ts +83 -29
  54. package/dist/src/html.js +242 -0
  55. package/dist/src/imageParameter.d.ts +59 -40
  56. package/dist/src/imageParameter.js +251 -0
  57. package/dist/src/imagemap.d.ts +65 -21
  58. package/dist/src/imagemap.js +169 -0
  59. package/dist/src/imagemapLink.d.ts +46 -14
  60. package/dist/src/imagemapLink.js +38 -0
  61. package/dist/src/index.d.ts +71 -105
  62. package/dist/src/index.js +826 -0
  63. package/dist/src/link/base.d.ts +71 -0
  64. package/dist/src/link/base.js +225 -0
  65. package/dist/src/link/category.d.ts +10 -11
  66. package/dist/src/link/category.js +26 -0
  67. package/dist/src/link/file.d.ts +61 -39
  68. package/dist/src/link/file.js +242 -0
  69. package/dist/src/link/galleryImage.d.ts +34 -12
  70. package/dist/src/link/galleryImage.js +98 -0
  71. package/dist/src/link/index.d.ts +25 -63
  72. package/dist/src/link/index.js +136 -0
  73. package/dist/src/magicLink.d.ts +22 -15
  74. package/dist/src/magicLink.js +126 -0
  75. package/dist/src/nested.d.ts +47 -0
  76. package/dist/src/nested.js +84 -0
  77. package/dist/src/nowiki/base.d.ts +39 -0
  78. package/dist/src/nowiki/base.js +29 -0
  79. package/dist/src/nowiki/comment.d.ts +31 -20
  80. package/dist/src/nowiki/comment.js +61 -0
  81. package/dist/src/nowiki/dd.d.ts +17 -11
  82. package/dist/src/nowiki/dd.js +50 -0
  83. package/dist/src/nowiki/doubleUnderscore.d.ts +28 -13
  84. package/dist/src/nowiki/doubleUnderscore.js +45 -0
  85. package/dist/src/nowiki/hr.d.ts +28 -10
  86. package/dist/src/nowiki/hr.js +33 -0
  87. package/dist/src/nowiki/index.d.ts +17 -23
  88. package/dist/src/nowiki/index.js +21 -0
  89. package/dist/src/nowiki/list.d.ts +15 -7
  90. package/dist/src/nowiki/list.js +11 -0
  91. package/dist/src/nowiki/noinclude.d.ts +20 -7
  92. package/dist/src/nowiki/noinclude.js +22 -0
  93. package/dist/src/nowiki/quote.d.ts +25 -10
  94. package/dist/src/nowiki/quote.js +55 -0
  95. package/dist/src/onlyinclude.d.ts +28 -12
  96. package/dist/src/onlyinclude.js +64 -0
  97. package/dist/src/paramTag/index.d.ts +40 -17
  98. package/dist/src/paramTag/index.js +76 -0
  99. package/dist/src/paramTag/inputbox.d.ts +8 -7
  100. package/dist/src/paramTag/inputbox.js +19 -0
  101. package/dist/src/parameter.d.ts +62 -41
  102. package/dist/src/parameter.js +201 -0
  103. package/dist/src/pre.d.ts +32 -0
  104. package/dist/src/pre.js +39 -0
  105. package/dist/src/syntax.d.ts +17 -14
  106. package/dist/src/syntax.js +65 -0
  107. package/dist/src/table/base.d.ts +55 -0
  108. package/dist/src/table/base.js +77 -0
  109. package/dist/src/table/index.d.ts +123 -156
  110. package/dist/src/table/index.js +811 -0
  111. package/dist/src/table/td.d.ts +90 -67
  112. package/dist/src/table/td.js +276 -0
  113. package/dist/src/table/tr.d.ts +30 -85
  114. package/dist/src/table/tr.js +48 -0
  115. package/dist/src/table/trBase.d.ts +72 -0
  116. package/dist/src/table/trBase.js +153 -0
  117. package/dist/src/tagPair/ext.d.ts +47 -11
  118. package/dist/src/tagPair/ext.js +127 -0
  119. package/dist/src/tagPair/include.d.ts +32 -13
  120. package/dist/src/tagPair/include.js +40 -0
  121. package/dist/src/tagPair/index.d.ts +44 -29
  122. package/dist/src/tagPair/index.js +111 -0
  123. package/dist/src/transclude.d.ts +88 -85
  124. package/dist/src/transclude.js +739 -0
  125. package/dist/util/base.js +26 -0
  126. package/dist/util/debug.js +52 -0
  127. package/dist/util/diff.js +69 -0
  128. package/dist/util/lint.js +38 -0
  129. package/dist/util/string.js +103 -0
  130. package/errors/README +1 -0
  131. package/i18n/zh-hans.json +1 -0
  132. package/i18n/zh-hant.json +1 -0
  133. package/package.json +21 -24
  134. package/printed/README +1 -0
  135. package/dist/mixin/attributeParent.d.ts +0 -9
  136. package/dist/mixin/fixedToken.d.ts +0 -8
  137. package/dist/mixin/hidden.d.ts +0 -8
  138. package/dist/mixin/singleLine.d.ts +0 -8
  139. package/dist/mixin/sol.d.ts +0 -8
  140. package/dist/parser/brackets.d.ts +0 -12
  141. package/dist/parser/commentAndExt.d.ts +0 -8
  142. package/dist/parser/converter.d.ts +0 -7
  143. package/dist/parser/externalLinks.d.ts +0 -7
  144. package/dist/parser/hrAndDoubleUnderscore.d.ts +0 -11
  145. package/dist/parser/html.d.ts +0 -7
  146. package/dist/parser/links.d.ts +0 -7
  147. package/dist/parser/list.d.ts +0 -7
  148. package/dist/parser/magicLinks.d.ts +0 -7
  149. package/dist/parser/quotes.d.ts +0 -7
  150. package/dist/parser/selector.d.ts +0 -12
  151. package/dist/parser/table.d.ts +0 -11
  152. package/dist/src/atom/hidden.d.ts +0 -5
  153. package/dist/src/atom/index.d.ts +0 -15
  154. package/dist/src/charinsert.d.ts +0 -32
  155. package/dist/src/hasNowiki/index.d.ts +0 -14
  156. package/dist/src/hasNowiki/pre.d.ts +0 -13
  157. package/dist/src/nested/choose.d.ts +0 -13
  158. package/dist/src/nested/combobox.d.ts +0 -13
  159. package/dist/src/nested/index.d.ts +0 -18
  160. package/dist/src/nested/references.d.ts +0 -13
  161. package/dist/tool/index.d.ts +0 -420
  162. package/dist/util/base.d.ts +0 -10
  163. package/dist/util/debug.d.ts +0 -20
  164. package/dist/util/diff.d.ts +0 -8
  165. package/dist/util/lint.d.ts +0 -28
  166. package/dist/util/string.d.ts +0 -55
  167. package/index.js +0 -333
  168. package/lib/element.js +0 -618
  169. package/lib/node.js +0 -730
  170. package/lib/ranges.js +0 -130
  171. package/lib/text.js +0 -265
  172. package/lib/title.js +0 -83
  173. package/mixin/attributeParent.js +0 -117
  174. package/mixin/fixedToken.js +0 -40
  175. package/mixin/hidden.js +0 -21
  176. package/mixin/singleLine.js +0 -31
  177. package/mixin/sol.js +0 -54
  178. package/parser/brackets.js +0 -128
  179. package/parser/commentAndExt.js +0 -62
  180. package/parser/converter.js +0 -46
  181. package/parser/externalLinks.js +0 -33
  182. package/parser/hrAndDoubleUnderscore.js +0 -49
  183. package/parser/html.js +0 -42
  184. package/parser/links.js +0 -94
  185. package/parser/list.js +0 -59
  186. package/parser/magicLinks.js +0 -41
  187. package/parser/quotes.js +0 -64
  188. package/parser/selector.js +0 -180
  189. package/parser/table.js +0 -114
  190. package/src/arg.js +0 -207
  191. package/src/atom/hidden.js +0 -13
  192. package/src/atom/index.js +0 -43
  193. package/src/attribute.js +0 -472
  194. package/src/attributes.js +0 -453
  195. package/src/charinsert.js +0 -97
  196. package/src/converter.js +0 -176
  197. package/src/converterFlags.js +0 -284
  198. package/src/converterRule.js +0 -256
  199. package/src/extLink.js +0 -180
  200. package/src/gallery.js +0 -149
  201. package/src/hasNowiki/index.js +0 -44
  202. package/src/hasNowiki/pre.js +0 -40
  203. package/src/heading.js +0 -134
  204. package/src/html.js +0 -254
  205. package/src/imageParameter.js +0 -303
  206. package/src/imagemap.js +0 -199
  207. package/src/imagemapLink.js +0 -41
  208. package/src/index.js +0 -938
  209. package/src/link/category.js +0 -44
  210. package/src/link/file.js +0 -287
  211. package/src/link/galleryImage.js +0 -120
  212. package/src/link/index.js +0 -388
  213. package/src/magicLink.js +0 -151
  214. package/src/nested/choose.js +0 -24
  215. package/src/nested/combobox.js +0 -23
  216. package/src/nested/index.js +0 -96
  217. package/src/nested/references.js +0 -23
  218. package/src/nowiki/comment.js +0 -71
  219. package/src/nowiki/dd.js +0 -59
  220. package/src/nowiki/doubleUnderscore.js +0 -56
  221. package/src/nowiki/hr.js +0 -41
  222. package/src/nowiki/index.js +0 -56
  223. package/src/nowiki/list.js +0 -16
  224. package/src/nowiki/noinclude.js +0 -28
  225. package/src/nowiki/quote.js +0 -69
  226. package/src/onlyinclude.js +0 -64
  227. package/src/paramTag/index.js +0 -89
  228. package/src/paramTag/inputbox.js +0 -35
  229. package/src/parameter.js +0 -239
  230. package/src/syntax.js +0 -91
  231. package/src/table/index.js +0 -985
  232. package/src/table/td.js +0 -343
  233. package/src/table/tr.js +0 -319
  234. package/src/tagPair/ext.js +0 -146
  235. package/src/tagPair/include.js +0 -50
  236. package/src/tagPair/index.js +0 -131
  237. package/src/transclude.js +0 -843
  238. package/tool/index.js +0 -1209
  239. package/typings/api.d.ts +0 -9
  240. package/typings/array.d.ts +0 -29
  241. package/typings/event.d.ts +0 -22
  242. package/typings/index.d.ts +0 -118
  243. package/typings/node.d.ts +0 -35
  244. package/typings/parser.d.ts +0 -12
  245. package/typings/table.d.ts +0 -10
  246. package/typings/token.d.ts +0 -31
  247. package/typings/tool.d.ts +0 -6
  248. package/util/base.js +0 -17
  249. package/util/debug.js +0 -73
  250. package/util/diff.js +0 -76
  251. package/util/lint.js +0 -57
  252. package/util/string.js +0 -126
@@ -1,13 +0,0 @@
1
- export = ChooseToken;
2
- /**
3
- * `<choose>`
4
- * @classdesc `{childNodes: [...ExtToken|NoincludeToken]}`
5
- */
6
- declare class ChooseToken extends NestedToken {
7
- /**
8
- * @param {string|undefined} wikitext wikitext
9
- * @param {import('../../../typings/token').accum} accum
10
- */
11
- constructor(wikitext: string | undefined, config?: import("../../../typings/token").ParserConfig, accum?: import('../../../typings/token').accum);
12
- }
13
- import NestedToken = require(".");
@@ -1,13 +0,0 @@
1
- export = ComboboxToken;
2
- /**
3
- * `<combobox>`
4
- * @classdesc `{childNodes: [...ExtToken|NoincludeToken]}`
5
- */
6
- declare class ComboboxToken extends NestedToken {
7
- /**
8
- * @param {string|undefined} wikitext wikitext
9
- * @param {import('../../../typings/token').accum} accum
10
- */
11
- constructor(wikitext: string | undefined, config?: import("../../../typings/token").ParserConfig, accum?: import('../../../typings/token').accum);
12
- }
13
- import NestedToken = require(".");
@@ -1,18 +0,0 @@
1
- export = NestedToken;
2
- /**
3
- * 嵌套式的扩展标签
4
- * @classdesc `{childNodes: [...ExtToken|NoincludeToken|CommentToken]}`
5
- */
6
- declare class NestedToken extends Token {
7
- /**
8
- * @param {string|undefined} wikitext wikitext
9
- * @param {RegExp} regex 内层正则
10
- * @param {string[]} tags 内层标签名
11
- * @param {import('../../../typings/token').accum} accum
12
- */
13
- constructor(wikitext: string | undefined, regex: RegExp, tags: string[], config?: import("../../../typings/token").ParserConfig, accum?: import('../../../typings/token').accum);
14
- /** @override */
15
- override cloneNode(): any;
16
- #private;
17
- }
18
- import Token = require("..");
@@ -1,13 +0,0 @@
1
- export = ReferencesToken;
2
- /**
3
- * `<references>`
4
- * @classdesc `{childNodes: [...ExtToken|NoincludeToken|CommentToken]}`
5
- */
6
- declare class ReferencesToken extends NestedToken {
7
- /**
8
- * @param {string|undefined} wikitext wikitext
9
- * @param {import('../../../typings/token').accum} accum
10
- */
11
- constructor(wikitext: string | undefined, config?: import("../../../typings/token").ParserConfig, accum?: import('../../../typings/token').accum);
12
- }
13
- import NestedToken = require(".");
@@ -1,420 +0,0 @@
1
- export = $;
2
- /**
3
- * 代替TokenCollection构造器
4
- * @param {AstNode|Iterable<AstNode>} arr 节点数组
5
- */
6
- declare function $(arr: AstNode | Iterable<AstNode>): TokenCollection;
7
- declare namespace $ {
8
- export { hasData, data, removeData, cache, CollectionCallback, AstListener };
9
- }
10
- import AstNode = require("../lib/node");
11
- /** Token集合 */
12
- declare class TokenCollection {
13
- /**
14
- * 生成匹配函数
15
- * @param {string} method
16
- * @param {string|AstNode|Iterable<AstNode>} selector
17
- * @returns {(token: AstNode) => boolean}
18
- */
19
- static "__#22@#matchesGenerator": (method: string, selector: string | AstNode | Iterable<AstNode>) => (token: AstNode) => boolean;
20
- /**
21
- * @param {Iterable<AstNode>} arr 节点数组
22
- * @param {TokenCollection} prevObject 前身
23
- */
24
- constructor(arr: Iterable<AstNode>, prevObject: TokenCollection);
25
- /** @type {AstNode[]} */ array: AstNode[];
26
- /** @type {TokenCollection} */ prevObject: TokenCollection;
27
- /** 数组长度 */
28
- get length(): number;
29
- /** 数组长度 */
30
- size(): number;
31
- /**
32
- * 抛出TypeError
33
- * @param {string} method
34
- * @param {...string} types 可接受的参数类型
35
- */
36
- typeError(method: string, ...types: string[]): never;
37
- /** 转换为数组 */
38
- toArray(): AstNode[];
39
- /**
40
- * 提取第n个元素
41
- * @template {unknown} T
42
- * @param {T} n 序号
43
- * @returns {T extends number ? AstNode : AstNode[]}
44
- */
45
- get<T extends unknown>(n: T): T extends number ? AstNode : AstNode[];
46
- /**
47
- * 循环
48
- * @param {CollectionCallback<void, AstNode>} callback
49
- */
50
- each(callback: CollectionCallback<void, AstNode>): TokenCollection;
51
- /**
52
- * map方法
53
- * @param {CollectionCallback<*, AstNode>} callback
54
- */
55
- map(callback: CollectionCallback<any, AstNode>): any[] | TokenCollection;
56
- /**
57
- * 子序列
58
- * @param {number} start 起点
59
- * @param {number} end 终点
60
- */
61
- slice(start: number, end: number): TokenCollection;
62
- /** 第一个元素 */
63
- first(): TokenCollection;
64
- /** 最后一个元素 */
65
- last(): TokenCollection;
66
- /**
67
- * 任一元素
68
- * @param {number} i 序号
69
- */
70
- eq(i: number): TokenCollection;
71
- /** 使用空字符串join */
72
- toString(): string;
73
- /**
74
- * 输出有效部分或设置文本
75
- * @template {unknown} T
76
- * @param {T} str 新文本
77
- * @returns {T extends string|CollectionCallback<string, string> ? this : string}
78
- */
79
- text<T_1 extends unknown>(str: T_1): T_1 extends string | import("../../typings/tool").CollectionCallback<string, string> ? TokenCollection : string;
80
- /**
81
- * 判断是否存在元素满足选择器
82
- * @param {string|AstNode|Iterable<AstNode>|CollectionCallback<boolean, AstNode>} selector
83
- */
84
- is(selector: string | AstNode | Iterable<AstNode> | CollectionCallback<boolean, AstNode>): boolean;
85
- /**
86
- * 筛选满足选择器的元素
87
- * @param {string|AstNode|Iterable<AstNode>|CollectionCallback<boolean, AstNode>} selector
88
- */
89
- filter(selector: string | AstNode | Iterable<AstNode> | CollectionCallback<boolean, AstNode>): TokenCollection;
90
- /**
91
- * 筛选不满足选择器的元素
92
- * @param {string|AstNode|Iterable<AstNode>|CollectionCallback<boolean, AstNode>} selector
93
- */
94
- not(selector: string | AstNode | Iterable<AstNode> | CollectionCallback<boolean, AstNode>): TokenCollection;
95
- /**
96
- * 搜索满足选择器的子节点
97
- * @param {string|AstNode|Iterable<AstNode>} selector
98
- */
99
- find(selector: string | AstNode | Iterable<AstNode>): TokenCollection;
100
- /**
101
- * 是否存在满足条件的后代节点
102
- * @param {string|AstNode} selector
103
- */
104
- has(selector: string | AstNode): boolean;
105
- /**
106
- * 最近的祖先
107
- * @param {string} selector
108
- */
109
- closest(selector: string): TokenCollection;
110
- /** 第一个Token节点在父容器中的序号 */
111
- index(): number;
112
- /**
113
- * 添加元素
114
- * @param {AstNode|Iterable<AstNode>} elements 新增的元素
115
- */
116
- add(elements: AstNode | Iterable<AstNode>): TokenCollection;
117
- /**
118
- * 添加prevObject
119
- * @param {string} selector
120
- */
121
- addBack(selector: string): TokenCollection;
122
- /**
123
- * 父元素
124
- * @param {string} selector
125
- */
126
- parent(selector: string): TokenCollection;
127
- /**
128
- * 祖先
129
- * @param {string} selector
130
- */
131
- parents(selector: string): TokenCollection;
132
- /**
133
- * nextElementSibling
134
- * @param {string} selector
135
- */
136
- next(selector: string): TokenCollection;
137
- /**
138
- * previousElementSibling
139
- * @param {string} selector
140
- */
141
- prev(selector: string): TokenCollection;
142
- /**
143
- * 所有在后的兄弟
144
- * @param {string} selector
145
- */
146
- nextAll(selector: string): TokenCollection;
147
- /**
148
- * 所有在前的兄弟
149
- * @param {string} selector
150
- */
151
- prevAll(selector: string): TokenCollection;
152
- /**
153
- * 所有在后的兄弟
154
- * @param {string} selector
155
- */
156
- siblings(selector: string): TokenCollection;
157
- /**
158
- * 直到选择器被满足的祖先
159
- * @param {string|Token|Iterable<Token>} selector
160
- * @param {string} filter 额外的筛选选择器
161
- */
162
- parentsUntil(selector: string | Token | Iterable<Token>, filter: string): TokenCollection;
163
- /**
164
- * 直到选择器被满足的后方兄弟
165
- * @param {string|Token|Iterable<Token>} selector
166
- * @param {string} filter 额外的筛选选择器
167
- */
168
- nextUntil(selector: string | Token | Iterable<Token>, filter: string): TokenCollection;
169
- /**
170
- * 直到选择器被满足的前方兄弟
171
- * @param {string|Token|Iterable<Token>} selector
172
- * @param {string} filter 额外的筛选选择器
173
- */
174
- prevUntil(selector: string | Token | Iterable<Token>, filter: string): TokenCollection;
175
- /**
176
- * Token子节点
177
- * @param {string} selector
178
- */
179
- children(selector: string): TokenCollection;
180
- /** 所有子节点 */
181
- contents(): TokenCollection;
182
- /**
183
- * 存取数据
184
- * @param {string|Record<string, *>} key 键
185
- * @param {*} value 值
186
- */
187
- data(key: string | Record<string, any>, value: any): any;
188
- /**
189
- * 删除数据
190
- * @param {string|string[]} name 键
191
- */
192
- removeData(name: string | string[]): TokenCollection;
193
- /**
194
- * 添加事件监听
195
- * @param {string|Record<string, AstListener>} events 事件名
196
- * @param {string|AstListener} selector
197
- * @param {AstListener} handler 事件处理
198
- */
199
- on(events: string | Record<string, AstListener>, selector: string | AstListener, handler: AstListener): TokenCollection;
200
- /**
201
- * 添加一次性事件监听
202
- * @param {string|Record<string, AstListener>} events 事件名
203
- * @param {string|AstListener} selector
204
- * @param {AstListener} handler 事件处理
205
- */
206
- one(events: string | Record<string, AstListener>, selector: string | AstListener, handler: AstListener): TokenCollection;
207
- /**
208
- * 移除事件监听
209
- * @param {string|Record<string, AstListener|undefined>|undefined} events 事件名
210
- * @param {string|AstListener} selector
211
- * @param {AstListener} handler 事件处理
212
- */
213
- off(events: string | Record<string, AstListener | undefined> | undefined, selector: string | AstListener, handler: AstListener): TokenCollection;
214
- /**
215
- * 触发事件
216
- * @param {string|Event} event 事件名
217
- * @param {*} data 事件数据
218
- */
219
- trigger(event: string | Event, data: any): TokenCollection;
220
- /**
221
- * 伪装触发事件
222
- * @param {string|Event} event 事件名
223
- * @param {*} data 事件数据
224
- */
225
- triggerHandler(event: string | Event, data: any): unknown;
226
- /**
227
- * 在末尾插入
228
- * @param {AstNode|Iterable<AstNode>|CollectionCallback<AstNode|Iterable<AstNode>, string>} content 插入内容
229
- * @param {...AstNode|Iterable<AstNode>} additional 更多插入内容
230
- */
231
- append(content: AstNode | Iterable<AstNode> | CollectionCallback<AstNode | Iterable<AstNode>, string>, ...additional: (AstNode | Iterable<AstNode>)[]): TokenCollection;
232
- /**
233
- * 在开头插入
234
- * @param {AstNode|Iterable<AstNode>|CollectionCallback<AstNode|Iterable<AstNode>, string>} content 插入内容
235
- * @param {...AstNode|Iterable<AstNode>} additional 更多插入内容
236
- */
237
- prepend(content: AstNode | Iterable<AstNode> | CollectionCallback<AstNode | Iterable<AstNode>, string>, ...additional: (AstNode | Iterable<AstNode>)[]): TokenCollection;
238
- /**
239
- * 在后方插入
240
- * @param {AstNode|Iterable<AstNode>|CollectionCallback<AstNode|Iterable<AstNode>, string>} content 插入内容
241
- * @param {...AstNode|Iterable<AstNode>} additional 更多插入内容
242
- */
243
- before(content: AstNode | Iterable<AstNode> | CollectionCallback<AstNode | Iterable<AstNode>, string>, ...additional: (AstNode | Iterable<AstNode>)[]): TokenCollection;
244
- /**
245
- * 在前方插入
246
- * @param {AstNode|Iterable<AstNode>|CollectionCallback<AstNode|Iterable<AstNode>, string>} content 插入内容
247
- * @param {...AstNode|Iterable<AstNode>} additional 更多插入内容
248
- */
249
- after(content: AstNode | Iterable<AstNode> | CollectionCallback<AstNode | Iterable<AstNode>, string>, ...additional: (AstNode | Iterable<AstNode>)[]): TokenCollection;
250
- /**
251
- * 替换所有子节点
252
- * @param {AstNode|Iterable<AstNode>|CollectionCallback<AstNode|Iterable<AstNode>, string>} content 插入内容
253
- * @param {...AstNode|Iterable<AstNode>} additional 更多插入内容
254
- */
255
- html(content: AstNode | Iterable<AstNode> | CollectionCallback<AstNode | Iterable<AstNode>, string>): string | TokenCollection;
256
- /**
257
- * 替换自身
258
- * @param {AstNode|Iterable<AstNode>|CollectionCallback<AstNode|Iterable<AstNode>, string>} content 插入内容
259
- * @param {...AstNode|Iterable<AstNode>} additional 更多插入内容
260
- */
261
- replaceWith(content: AstNode | Iterable<AstNode> | CollectionCallback<AstNode | Iterable<AstNode>, string>): TokenCollection;
262
- /**
263
- * 移除自身
264
- * @param {string} selector
265
- */
266
- remove(selector: string): TokenCollection;
267
- /**
268
- * 移除自身
269
- * @param {string} selector
270
- */
271
- detach(selector: string): TokenCollection;
272
- /** 清空子节点 */
273
- empty(): TokenCollection;
274
- /**
275
- * 深拷贝
276
- * @param {boolean} withData 是否复制数据
277
- */
278
- clone(withData: boolean): TokenCollection;
279
- /**
280
- * 插入到末尾
281
- * @param {Token|Iterable<Token>} target 目标位置
282
- */
283
- appendTo(target: Token | Iterable<Token>): TokenCollection;
284
- /**
285
- * 插入到开头
286
- * @param {Token|Iterable<Token>} target 目标位置
287
- */
288
- prependTo(target: Token | Iterable<Token>): TokenCollection;
289
- /**
290
- * 插入到前方
291
- * @param {Token|Iterable<Token>} target 目标位置
292
- */
293
- insertBefore(target: Token | Iterable<Token>): TokenCollection;
294
- /**
295
- * 插入到后方
296
- * @param {Token|Iterable<Token>} target 目标位置
297
- */
298
- insertAfter(target: Token | Iterable<Token>): TokenCollection;
299
- /**
300
- * 替换全部
301
- * @param {Token|Iterable<Token>} target 目标位置
302
- */
303
- replaceAll(target: Token | Iterable<Token>): TokenCollection;
304
- /**
305
- * 获取几何属性
306
- * @param {string|string[]} key 属性键
307
- */
308
- css(key: string | string[]): number | {
309
- [k: string]: number;
310
- };
311
- /**
312
- * 查询或修改值
313
- * @param {string|boolean|(string|boolean)[]|CollectionCallback<string, string|boolean>} value 值
314
- */
315
- val(value: string | boolean | (string | boolean)[] | CollectionCallback<string, string | boolean>): any;
316
- /**
317
- * 标签属性
318
- * @param {string|Record<string, string|boolean>} name 属性名
319
- * @param {string|boolean|CollectionCallback<string|boolean, string|boolean>} value 属性值
320
- */
321
- attr(name: string | Record<string, string | boolean>, value: string | boolean | CollectionCallback<string | boolean, string | boolean>): any;
322
- /**
323
- * 节点属性
324
- * @param {string|Record<string, string|boolean>} name 属性名
325
- * @param {string|boolean|CollectionCallback<string|boolean, string|boolean>} value 属性值
326
- */
327
- prop(name: string | Record<string, string | boolean>, value: string | boolean | CollectionCallback<string | boolean, string | boolean>): any;
328
- /**
329
- * 标签属性
330
- * @param {string} name 属性名
331
- */
332
- removeAttr(name: string): TokenCollection;
333
- /**
334
- * 节点属性
335
- * @param {string} name 属性名
336
- */
337
- removeProp(name: string): TokenCollection;
338
- /**
339
- * 添加class
340
- * @this {TokenCollection & {array: AttributesToken[]}}
341
- * @param {string|string[]|CollectionCallback<string|string[], string>} className 类名
342
- */
343
- addClass(this: TokenCollection & {
344
- array: AttributesToken[];
345
- }, className: string | string[] | CollectionCallback<string | string[], string>): TokenCollection & {
346
- array: AttributesToken[];
347
- };
348
- /**
349
- * 移除class
350
- * @this {TokenCollection & {array: AttributesToken[]}}
351
- * @param {undefined|string|string[]|CollectionCallback<undefined|string|string[], string>} className 类名
352
- */
353
- removeClass(this: TokenCollection & {
354
- array: AttributesToken[];
355
- }, className: undefined | string | string[] | CollectionCallback<undefined | string | string[], string>): TokenCollection & {
356
- array: AttributesToken[];
357
- };
358
- /**
359
- * 增减class
360
- * @this {TokenCollection & {array: AttributesToken[]}}
361
- * @param {string|string[]|CollectionCallback<string|string[], string>} className 类名
362
- * @param {boolean} state 是否增删
363
- */
364
- toggleClass(this: TokenCollection & {
365
- array: AttributesToken[];
366
- }, className: string | string[] | CollectionCallback<string | string[], string>, state: boolean): any;
367
- /**
368
- * 是否带有某class
369
- * @this {{array: AttributesToken[]}}
370
- * @param {string} className 类名
371
- */
372
- hasClass(this: {
373
- array: AttributesToken[];
374
- }, className: string): boolean;
375
- /**
376
- * 全包围
377
- * @param {string[]|CollectionCallback<string[], undefined>} wrapper 包裹
378
- * @throws `Error` 不是连续的兄弟节点
379
- */
380
- wrapAll(wrapper: string[] | CollectionCallback<string[], undefined>): TokenCollection;
381
- /**
382
- * 包裹内部
383
- * @param {string[]|CollectionCallback<string[], undefined>} wrapper 包裹
384
- */
385
- wrapInner(wrapper: string[] | CollectionCallback<string[], undefined>): TokenCollection;
386
- /**
387
- * 包裹自身
388
- * @param {string[]|CollectionCallback<string[], undefined>} wrapper 包裹
389
- */
390
- wrap(wrapper: string[] | CollectionCallback<string[], undefined>): TokenCollection;
391
- /** 相对于文档的位置 */
392
- offset(): {
393
- top: any;
394
- left: any;
395
- };
396
- /** 相对于父容器的位置 */
397
- position(): {
398
- top: number;
399
- left: number;
400
- };
401
- /** 高度 */
402
- height(): number;
403
- /** 宽度 */
404
- width(): number;
405
- /** 内部高度 */
406
- innerHeight(): number;
407
- /** 内部宽度 */
408
- innerWidth(): number;
409
- /** @ignore */
410
- [Symbol.iterator](): IterableIterator<AstNode>;
411
- #private;
412
- }
413
- declare function hasData(element: Token): boolean;
414
- declare function data(arg0: Token, arg1: string, arg2: any): any;
415
- declare function removeData(arg0: Token, arg1: string): void;
416
- declare var cache: WeakMap<Token, Record<string, any>>;
417
- type CollectionCallback<T, S> = import('../../typings/tool').CollectionCallback<T, S>;
418
- type AstListener = import('../../typings/event').AstListener;
419
- import Token = require("../src");
420
- import AttributesToken = require("../src/attributes");
@@ -1,10 +0,0 @@
1
- /**
2
- * 是否是普通对象
3
- * @param {*} obj 对象
4
- */
5
- export function isPlainObject(obj: any): boolean;
6
- /**
7
- * 延时
8
- * @param {number} t 秒数
9
- */
10
- export function sleep(t: number): Promise<any>;
@@ -1,20 +0,0 @@
1
- /**
2
- * 定制TypeError消息
3
- * @param {Function} constructor 类
4
- * @param {string} method
5
- * @param {...string} args 可接受的参数类型
6
- * @throws `TypeError`
7
- */
8
- export function typeError({ name }: Function, method: string, ...args: string[]): never;
9
- /**
10
- * 不是被构造器或原型方法调用
11
- * @param {string} name 方法名称
12
- */
13
- export function externalUse(name: string): boolean;
14
- /**
15
- * 撤销最近一次Mutation
16
- * @param {import('../../typings/event').AstEvent} e 事件
17
- * @param {import('../../typings/event').AstEventData} data 事件数据
18
- * @throws `RangeError` 无法撤销的事件类型
19
- */
20
- export function undo(e: import('../../typings/event').AstEvent, data: import('../../typings/event').AstEventData): void;
@@ -1,8 +0,0 @@
1
- export = diff;
2
- /**
3
- * 比较两个文件
4
- * @param {string} oldStr 旧文本
5
- * @param {string} newStr 新文本
6
- * @param {string} uid 唯一标识
7
- */
8
- declare function diff(oldStr: string, newStr: string, uid?: string): Promise<void>;
@@ -1,28 +0,0 @@
1
- export type LintError = import('../../typings/token').LintError;
2
- /**
3
- * 生成对于子节点的LintError对象
4
- * @param {Token} child 子节点
5
- * @param {{top: number, left: number, start: number}} boundingRect 父节点的绝对定位
6
- * @param {string} msg 错误信息
7
- * @param {'error'|'warning'} severity 严重程度
8
- * @returns {LintError}
9
- */
10
- export function generateForChild(child: Token, boundingRect: {
11
- top: number;
12
- left: number;
13
- start: number;
14
- }, msg: string, severity?: 'error' | 'warning'): LintError;
15
- /**
16
- * 生成对于自己的LintError对象
17
- * @param {Token} token 节点
18
- * @param {{top: number, left: number, start: number}} boundingRect 绝对定位
19
- * @param {string} msg 错误信息
20
- * @param {'error'|'warning'} severity 严重程度
21
- * @returns {LintError}
22
- */
23
- export function generateForSelf(token: Token, boundingRect: {
24
- top: number;
25
- left: number;
26
- start: number;
27
- }, msg: string, severity?: 'error' | 'warning'): LintError;
28
- import Token = require("../src");
@@ -1,55 +0,0 @@
1
- export const extUrlCharFirst: "(?:\\[[\\da-f:.]+\\]|[^[\\]<>\"\\0-\\x1F\\x7F\\p{Zs}\\uFFFD])";
2
- export const extUrlChar: "(?:[^[\\]<>\"\\0-\\x1F\\x7F\\p{Zs}\\uFFFD]|\\0\\d+c\\x7F)*";
3
- /**
4
- * remove half-parsed comment-like tokens
5
- * @param {string} str 原字符串
6
- */
7
- export function removeComment(str: string): string;
8
- /**
9
- * 以HTML格式打印
10
- * @param {(AstText|AstElement)[]} childNodes 子节点
11
- * @param {import('../../typings/node').printOpt} opt 选项
12
- */
13
- export function print(childNodes: (import("../lib/text") | import("../lib/element"))[], opt?: import('../../typings/node').printOpt): string;
14
- /**
15
- * escape special chars for RegExp constructor
16
- * @param {string} str RegExp source
17
- */
18
- export function escapeRegExp(str: string): string;
19
- /**
20
- * a more sophisticated string-explode function
21
- * @param {string} start start syntax of a nested AST node
22
- * @param {string} end end syntax of a nested AST node
23
- * @param {string} separator syntax for explosion
24
- * @param {string} str string to be exploded
25
- */
26
- export function explode(start: string, end: string, separator: string, str: string): string[];
27
- /**
28
- * extract effective wikitext
29
- * @param {(string|AstNode)[]} childNodes a Token's contents
30
- * @param {string} separator delimiter between nodes
31
- */
32
- export function text(childNodes: (string | import("../lib/node"))[], separator?: string): string;
33
- /**
34
- * decode HTML entities
35
- * @param {string} str 原字符串
36
- */
37
- export function decodeHtml(str: string): string;
38
- /**
39
- * optionally convert to lower cases
40
- * @param {string} val 属性值
41
- * @param {string|undefined} i 是否对大小写不敏感
42
- */
43
- export function toCase(val: string, i: string | undefined): string;
44
- /**
45
- * escape newlines
46
- * @param {string} str 原字符串
47
- */
48
- export function noWrap(str: string): string;
49
- /**
50
- * convert newline in text nodes to single whitespace
51
- * @param {Token & {childNodes: AstText[]}} token 父节点
52
- */
53
- export function normalizeSpace(token: import("../src") & {
54
- childNodes: import("../lib/text")[];
55
- }): void;