wikiparser-node 0.11.0 → 1.0.0-beta.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.
Files changed (251) hide show
  1. package/dist/index.d.ts +59 -113
  2. package/dist/index.js +307 -0
  3. package/dist/lib/element.d.ts +122 -108
  4. package/dist/lib/element.js +656 -0
  5. package/dist/lib/node.d.ts +115 -221
  6. package/dist/lib/node.js +473 -0
  7. package/dist/lib/ranges.d.ts +27 -26
  8. package/dist/lib/ranges.js +130 -0
  9. package/dist/lib/text.d.ts +36 -28
  10. package/dist/lib/text.js +215 -0
  11. package/dist/lib/title.d.ts +25 -12
  12. package/dist/lib/title.js +100 -0
  13. package/dist/mixin/attributesParent.js +90 -0
  14. package/dist/mixin/fixed.js +29 -0
  15. package/dist/mixin/hidden.js +19 -0
  16. package/dist/mixin/singleLine.js +23 -0
  17. package/dist/mixin/sol.js +41 -0
  18. package/dist/parser/brackets.js +117 -0
  19. package/dist/parser/commentAndExt.js +48 -0
  20. package/dist/parser/converter.js +31 -0
  21. package/dist/parser/externalLinks.js +22 -0
  22. package/dist/parser/hrAndDoubleUnderscore.js +33 -0
  23. package/dist/parser/html.js +29 -0
  24. package/dist/parser/links.js +86 -0
  25. package/dist/parser/list.js +51 -0
  26. package/dist/parser/magicLinks.js +32 -0
  27. package/dist/parser/quotes.js +57 -0
  28. package/dist/parser/selector.js +158 -0
  29. package/dist/parser/table.js +108 -0
  30. package/dist/src/arg.d.ts +47 -23
  31. package/dist/src/arg.js +196 -0
  32. package/dist/src/atom.d.ts +12 -0
  33. package/dist/src/atom.js +22 -0
  34. package/dist/src/attribute.d.ts +74 -33
  35. package/dist/src/attribute.js +433 -0
  36. package/dist/src/attributes.d.ts +61 -55
  37. package/dist/src/attributes.js +371 -0
  38. package/dist/src/converter.d.ts +45 -71
  39. package/dist/src/converter.js +135 -0
  40. package/dist/src/converterFlags.d.ts +64 -39
  41. package/dist/src/converterFlags.js +235 -0
  42. package/dist/src/converterRule.d.ts +49 -27
  43. package/dist/src/converterRule.js +255 -0
  44. package/dist/src/extLink.d.ts +41 -38
  45. package/dist/src/extLink.js +154 -0
  46. package/dist/src/gallery.d.ts +59 -18
  47. package/dist/src/gallery.js +132 -0
  48. package/dist/src/heading.d.ts +60 -22
  49. package/dist/src/heading.js +135 -0
  50. package/dist/src/hidden.d.ts +20 -0
  51. package/dist/src/hidden.js +24 -0
  52. package/dist/src/html.d.ts +83 -29
  53. package/dist/src/html.js +242 -0
  54. package/dist/src/imageParameter.d.ts +59 -40
  55. package/dist/src/imageParameter.js +251 -0
  56. package/dist/src/imagemap.d.ts +65 -21
  57. package/dist/src/imagemap.js +164 -0
  58. package/dist/src/imagemapLink.d.ts +46 -14
  59. package/dist/src/imagemapLink.js +38 -0
  60. package/dist/src/index.d.ts +71 -105
  61. package/dist/src/index.js +826 -0
  62. package/dist/src/link/base.d.ts +71 -0
  63. package/dist/src/link/base.js +225 -0
  64. package/dist/src/link/category.d.ts +10 -11
  65. package/dist/src/link/category.js +26 -0
  66. package/dist/src/link/file.d.ts +61 -39
  67. package/dist/src/link/file.js +242 -0
  68. package/dist/src/link/galleryImage.d.ts +34 -12
  69. package/dist/src/link/galleryImage.js +98 -0
  70. package/dist/src/link/index.d.ts +25 -63
  71. package/dist/src/link/index.js +136 -0
  72. package/dist/src/magicLink.d.ts +22 -15
  73. package/dist/src/magicLink.js +126 -0
  74. package/dist/src/nested.d.ts +47 -0
  75. package/dist/src/nested.js +84 -0
  76. package/dist/src/nowiki/base.d.ts +39 -0
  77. package/dist/src/nowiki/base.js +29 -0
  78. package/dist/src/nowiki/comment.d.ts +31 -20
  79. package/dist/src/nowiki/comment.js +61 -0
  80. package/dist/src/nowiki/dd.d.ts +17 -11
  81. package/dist/src/nowiki/dd.js +50 -0
  82. package/dist/src/nowiki/doubleUnderscore.d.ts +28 -13
  83. package/dist/src/nowiki/doubleUnderscore.js +45 -0
  84. package/dist/src/nowiki/hr.d.ts +28 -10
  85. package/dist/src/nowiki/hr.js +33 -0
  86. package/dist/src/nowiki/index.d.ts +17 -23
  87. package/dist/src/nowiki/index.js +21 -0
  88. package/dist/src/nowiki/list.d.ts +15 -7
  89. package/dist/src/nowiki/list.js +11 -0
  90. package/dist/src/nowiki/noinclude.d.ts +20 -7
  91. package/dist/src/nowiki/noinclude.js +22 -0
  92. package/dist/src/nowiki/quote.d.ts +25 -10
  93. package/dist/src/nowiki/quote.js +55 -0
  94. package/dist/src/onlyinclude.d.ts +28 -12
  95. package/dist/src/onlyinclude.js +64 -0
  96. package/dist/src/paramTag/index.d.ts +40 -17
  97. package/dist/src/paramTag/index.js +76 -0
  98. package/dist/src/paramTag/inputbox.d.ts +8 -7
  99. package/dist/src/paramTag/inputbox.js +19 -0
  100. package/dist/src/parameter.d.ts +62 -41
  101. package/dist/src/parameter.js +201 -0
  102. package/dist/src/pre.d.ts +32 -0
  103. package/dist/src/pre.js +39 -0
  104. package/dist/src/syntax.d.ts +17 -14
  105. package/dist/src/syntax.js +65 -0
  106. package/dist/src/table/base.d.ts +55 -0
  107. package/dist/src/table/base.js +77 -0
  108. package/dist/src/table/index.d.ts +123 -156
  109. package/dist/src/table/index.js +811 -0
  110. package/dist/src/table/td.d.ts +90 -67
  111. package/dist/src/table/td.js +276 -0
  112. package/dist/src/table/tr.d.ts +30 -85
  113. package/dist/src/table/tr.js +48 -0
  114. package/dist/src/table/trBase.d.ts +72 -0
  115. package/dist/src/table/trBase.js +153 -0
  116. package/dist/src/tagPair/ext.d.ts +47 -11
  117. package/dist/src/tagPair/ext.js +127 -0
  118. package/dist/src/tagPair/include.d.ts +32 -13
  119. package/dist/src/tagPair/include.js +40 -0
  120. package/dist/src/tagPair/index.d.ts +44 -29
  121. package/dist/src/tagPair/index.js +111 -0
  122. package/dist/src/transclude.d.ts +88 -85
  123. package/dist/src/transclude.js +739 -0
  124. package/dist/util/base.js +26 -0
  125. package/dist/util/debug.js +52 -0
  126. package/dist/util/diff.js +69 -0
  127. package/dist/util/lint.js +38 -0
  128. package/dist/util/string.js +103 -0
  129. package/errors/README +1 -0
  130. package/i18n/zh-hans.json +1 -0
  131. package/i18n/zh-hant.json +1 -0
  132. package/package.json +11 -14
  133. package/printed/README +1 -0
  134. package/dist/mixin/attributeParent.d.ts +0 -9
  135. package/dist/mixin/fixedToken.d.ts +0 -8
  136. package/dist/mixin/hidden.d.ts +0 -8
  137. package/dist/mixin/singleLine.d.ts +0 -8
  138. package/dist/mixin/sol.d.ts +0 -8
  139. package/dist/parser/brackets.d.ts +0 -12
  140. package/dist/parser/commentAndExt.d.ts +0 -8
  141. package/dist/parser/converter.d.ts +0 -7
  142. package/dist/parser/externalLinks.d.ts +0 -7
  143. package/dist/parser/hrAndDoubleUnderscore.d.ts +0 -11
  144. package/dist/parser/html.d.ts +0 -7
  145. package/dist/parser/links.d.ts +0 -7
  146. package/dist/parser/list.d.ts +0 -7
  147. package/dist/parser/magicLinks.d.ts +0 -7
  148. package/dist/parser/quotes.d.ts +0 -7
  149. package/dist/parser/selector.d.ts +0 -12
  150. package/dist/parser/table.d.ts +0 -11
  151. package/dist/src/atom/hidden.d.ts +0 -5
  152. package/dist/src/atom/index.d.ts +0 -15
  153. package/dist/src/charinsert.d.ts +0 -32
  154. package/dist/src/hasNowiki/index.d.ts +0 -14
  155. package/dist/src/hasNowiki/pre.d.ts +0 -13
  156. package/dist/src/nested/choose.d.ts +0 -13
  157. package/dist/src/nested/combobox.d.ts +0 -13
  158. package/dist/src/nested/index.d.ts +0 -18
  159. package/dist/src/nested/references.d.ts +0 -13
  160. package/dist/tool/index.d.ts +0 -420
  161. package/dist/util/base.d.ts +0 -10
  162. package/dist/util/debug.d.ts +0 -20
  163. package/dist/util/diff.d.ts +0 -8
  164. package/dist/util/lint.d.ts +0 -28
  165. package/dist/util/string.d.ts +0 -55
  166. package/index.js +0 -333
  167. package/lib/element.js +0 -618
  168. package/lib/node.js +0 -730
  169. package/lib/ranges.js +0 -130
  170. package/lib/text.js +0 -265
  171. package/lib/title.js +0 -83
  172. package/mixin/attributeParent.js +0 -117
  173. package/mixin/fixedToken.js +0 -40
  174. package/mixin/hidden.js +0 -21
  175. package/mixin/singleLine.js +0 -31
  176. package/mixin/sol.js +0 -54
  177. package/parser/brackets.js +0 -128
  178. package/parser/commentAndExt.js +0 -62
  179. package/parser/converter.js +0 -46
  180. package/parser/externalLinks.js +0 -33
  181. package/parser/hrAndDoubleUnderscore.js +0 -49
  182. package/parser/html.js +0 -42
  183. package/parser/links.js +0 -94
  184. package/parser/list.js +0 -59
  185. package/parser/magicLinks.js +0 -41
  186. package/parser/quotes.js +0 -64
  187. package/parser/selector.js +0 -180
  188. package/parser/table.js +0 -114
  189. package/src/arg.js +0 -207
  190. package/src/atom/hidden.js +0 -13
  191. package/src/atom/index.js +0 -43
  192. package/src/attribute.js +0 -472
  193. package/src/attributes.js +0 -453
  194. package/src/charinsert.js +0 -97
  195. package/src/converter.js +0 -176
  196. package/src/converterFlags.js +0 -284
  197. package/src/converterRule.js +0 -256
  198. package/src/extLink.js +0 -180
  199. package/src/gallery.js +0 -149
  200. package/src/hasNowiki/index.js +0 -44
  201. package/src/hasNowiki/pre.js +0 -40
  202. package/src/heading.js +0 -134
  203. package/src/html.js +0 -254
  204. package/src/imageParameter.js +0 -303
  205. package/src/imagemap.js +0 -199
  206. package/src/imagemapLink.js +0 -41
  207. package/src/index.js +0 -938
  208. package/src/link/category.js +0 -44
  209. package/src/link/file.js +0 -287
  210. package/src/link/galleryImage.js +0 -120
  211. package/src/link/index.js +0 -388
  212. package/src/magicLink.js +0 -151
  213. package/src/nested/choose.js +0 -24
  214. package/src/nested/combobox.js +0 -23
  215. package/src/nested/index.js +0 -96
  216. package/src/nested/references.js +0 -23
  217. package/src/nowiki/comment.js +0 -71
  218. package/src/nowiki/dd.js +0 -59
  219. package/src/nowiki/doubleUnderscore.js +0 -56
  220. package/src/nowiki/hr.js +0 -41
  221. package/src/nowiki/index.js +0 -56
  222. package/src/nowiki/list.js +0 -16
  223. package/src/nowiki/noinclude.js +0 -28
  224. package/src/nowiki/quote.js +0 -69
  225. package/src/onlyinclude.js +0 -64
  226. package/src/paramTag/index.js +0 -89
  227. package/src/paramTag/inputbox.js +0 -35
  228. package/src/parameter.js +0 -239
  229. package/src/syntax.js +0 -91
  230. package/src/table/index.js +0 -985
  231. package/src/table/td.js +0 -343
  232. package/src/table/tr.js +0 -319
  233. package/src/tagPair/ext.js +0 -146
  234. package/src/tagPair/include.js +0 -50
  235. package/src/tagPair/index.js +0 -131
  236. package/src/transclude.js +0 -843
  237. package/tool/index.js +0 -1209
  238. package/typings/api.d.ts +0 -9
  239. package/typings/array.d.ts +0 -29
  240. package/typings/event.d.ts +0 -22
  241. package/typings/index.d.ts +0 -118
  242. package/typings/node.d.ts +0 -35
  243. package/typings/parser.d.ts +0 -12
  244. package/typings/table.d.ts +0 -10
  245. package/typings/token.d.ts +0 -31
  246. package/typings/tool.d.ts +0 -6
  247. package/util/base.js +0 -17
  248. package/util/debug.js +0 -73
  249. package/util/diff.js +0 -76
  250. package/util/lint.js +0 -57
  251. package/util/string.js +0 -126
@@ -1,291 +1,185 @@
1
- export = AstNode;
1
+ import * as Parser from '../index';
2
+ import type * as Ranges from './ranges';
3
+ declare type AstNodeTypes = import('./text') | import('../src');
4
+ declare type TokenAttribute<T extends string> = T extends 'stage' ? number : T extends 'config' ? Parser.Config : T extends 'accum' ? import('../src')[] : T extends 'parentNode' ? import('../src') | undefined : T extends 'childNodes' ? AstNodeTypes[] : T extends 'bracket' | 'include' ? boolean : T extends 'pattern' ? RegExp : T extends 'tags' | 'flags' ? string[] : T extends 'quotes' ? [string?, string?] : T extends 'optional' | 'keys' ? Set<string> : T extends 'args' ? Record<string, Set<import('../src/parameter')>> : T extends 'protectedChildren' ? Ranges : string;
5
+ declare type TokenAttributeGetter<T extends string> = T extends 'acceptable' ? Record<string, Ranges> | undefined : TokenAttribute<T>;
6
+ declare type TokenAttributeSetter<T extends string> = T extends 'acceptable' ? Acceptable | undefined : TokenAttribute<T> | undefined;
7
+ declare interface Dimension {
8
+ height: number;
9
+ width: number;
10
+ }
11
+ declare interface Position {
12
+ top: number;
13
+ left: number;
14
+ }
15
+ declare interface CaretPosition {
16
+ offsetNode: AstNodeTypes;
17
+ offset: number;
18
+ }
2
19
  /** 类似Node */
3
- declare class AstNode {
4
- /** @type {string} */ type: string;
5
- /** @type {this[]} */ childNodes: this[];
6
- /** 首位子节点 */
7
- get firstChild(): this;
8
- /** 末位子节点 */
9
- get lastChild(): this;
10
- /** 父节点 */
11
- get parentNode(): this;
12
- /**
13
- * 后一个兄弟节点
14
- * @complexity `n`
15
- */
16
- get nextSibling(): this;
17
- /**
18
- * 前一个兄弟节点
19
- * @complexity `n`
20
- */
21
- get previousSibling(): this;
22
- /**
23
- * 后一个非文本兄弟节点
24
- * @complexity `n`
25
- * @returns {this}
26
- */
27
- get nextElementSibling(): this;
28
- /**
29
- * 前一个非文本兄弟节点
30
- * @complexity `n`
31
- * @returns {this}
32
- */
33
- get previousElementSibling(): this;
34
- /** 是否具有根节点 */
35
- get isConnected(): any;
36
- /** 不是自身的根节点 */
37
- get ownerDocument(): any;
38
- /**
39
- * 后方是否还有其他节点(不含后代)
40
- * @returns {boolean}
41
- * @complexity `n`
42
- */
43
- get eof(): boolean;
44
- /**
45
- * 标记仅用于代码调试的方法
46
- * @param {string} method
47
- * @throws `Error`
48
- */
49
- debugOnly(method?: string): void;
50
- /**
51
- * 抛出`TypeError`
52
- * @param {string} method
53
- * @param {...string} types 可接受的参数类型
54
- */
55
- typeError(method: string, ...types: string[]): never;
20
+ declare abstract class AstNode {
21
+ #private;
22
+ /** @browser */
23
+ type: string;
24
+ /** @browser */
25
+ readonly childNodes: AstNodeTypes[];
56
26
  /**
57
- * 冻结部分属性
58
- * @param {string|string[]} keys 属性键
59
- * @param {boolean} permanent 是否永久
27
+ * 首位子节点
28
+ * @browser
60
29
  */
61
- seal(keys: string | string[], permanent: boolean): void;
30
+ get firstChild(): AstNodeTypes | undefined;
62
31
  /**
63
- * 是否是全同节点
64
- * @param {this} node 待比较的节点
65
- * @throws `assert.AssertionError`
32
+ * 末位子节点
33
+ * @browser
66
34
  */
67
- isEqualNode(node: this): boolean;
35
+ get lastChild(): AstNodeTypes | undefined;
68
36
  /**
69
- * 是否具有某属性
70
- * @param {PropertyKey} key 属性键
37
+ * 父节点
38
+ * @browser
71
39
  */
72
- hasAttribute(key: PropertyKey): boolean;
40
+ get parentNode(): import('../src') | undefined;
73
41
  /**
74
- * 获取属性值。除非用于私有属性,否则总是返回字符串。
75
- * @template {string} T
76
- * @param {T} key 属性键
77
- * @returns {TokenAttribute<T>}
42
+ * 后一个兄弟节点
43
+ * @browser
78
44
  */
79
- getAttribute<T extends string>(key: T): import("../../typings/node").TokenAttribute<T>;
45
+ get nextSibling(): AstNodeTypes | undefined;
80
46
  /**
81
- * 设置属性
82
- * @template {string} T
83
- * @param {T} key 属性键
84
- * @param {TokenAttribute<T>} value 属性值
47
+ * 前一个兄弟节点
48
+ * @browser
85
49
  */
86
- setAttribute<T_1 extends string>(key: T_1, value: import("../../typings/node").TokenAttribute<T_1>): this;
50
+ get previousSibling(): AstNodeTypes | undefined;
87
51
  /**
88
- * 可见部分
89
- * @param {string} separator 子节点间的连接符
90
- * @returns {string}
91
- * @complexity `n`
52
+ * 行数
53
+ * @browser
92
54
  */
93
- text(separator?: string): string;
55
+ get offsetHeight(): number;
94
56
  /**
95
- * 移除子节点
96
- * @param {number} i 移除位置
57
+ * 最后一行的列数
58
+ * @browser
97
59
  */
98
- removeAt(i: number): this;
60
+ get offsetWidth(): number;
61
+ /** 后一个非文本兄弟节点 */
62
+ get nextElementSibling(): import('../src') | undefined;
63
+ /** 前一个非文本兄弟节点 */
64
+ get previousElementSibling(): import('../src') | undefined;
65
+ /** 是否具有根节点 */
66
+ get isConnected(): boolean;
67
+ /** 不是自身的根节点 */
68
+ get ownerDocument(): import('../src') | undefined;
69
+ /** 后方是否还有其他节点(不含后代) */
70
+ get eof(): boolean | undefined;
71
+ /** 相对于父容器的行号 */
72
+ get offsetTop(): number;
73
+ /** 相对于父容器的列号 */
74
+ get offsetLeft(): number;
75
+ /** 位置、大小和padding */
76
+ get style(): Position & Dimension & {
77
+ padding: number;
78
+ };
79
+ constructor();
99
80
  /**
100
- * 插入子节点
101
- * @template {this} T
102
- * @param {T} node 待插入的子节点
103
- * @param {number} i 插入位置
104
- * @complexity `n`
105
- * @throws `RangeError` 不能插入祖先节点
81
+ * 获取根节点
82
+ * @browser
106
83
  */
107
- insertAt<T_2 extends AstNode>(node: T_2, i?: number): T_2;
84
+ getRootNode(): import('../src') | this;
108
85
  /**
109
- * 移除子节点
110
- * @template {this} T
111
- * @param {T} node 子节点
112
- * @complexity `n`
86
+ * 将字符位置转换为行列号
87
+ * @browser
88
+ * @param index 字符位置
113
89
  */
114
- removeChild<T_3 extends AstNode>(node: T_3): T_3;
90
+ posFromIndex(index: number): Position | undefined;
115
91
  /**
116
- * 在末尾插入子节点
117
- * @template {this} T
118
- * @param {T} node 插入节点
119
- * @complexity `n`
92
+ * 获取当前节点的相对字符位置,或其第`j`个子节点的相对字符位置
93
+ * @browser
94
+ * @param j 子节点序号
120
95
  */
121
- appendChild<T_4 extends AstNode>(node: T_4): T_4;
96
+ getRelativeIndex(j?: number): number;
122
97
  /**
123
- * 在指定位置前插入子节点
124
- * @template {this} T
125
- * @param {T} child 插入节点
126
- * @param {this} reference 指定位置处的子节点
127
- * @complexity `n`
98
+ * 获取当前节点的绝对位置
99
+ * @browser
128
100
  */
129
- insertBefore<T_5 extends AstNode>(child: T_5, reference: AstNode): T_5;
101
+ getAbsoluteIndex(): number;
130
102
  /**
131
- * 替换子节点
132
- * @template {this} T
133
- * @param {this} newChild 新子节点
134
- * @param {T} oldChild 原子节点
135
- * @complexity `n`
103
+ * 是否是全同节点
104
+ * @param node 待比较的节点
105
+ * @throws `assert.AssertionError`
136
106
  */
137
- replaceChild<T_6 extends AstNode>(newChild: AstNode, oldChild: T_6): T_6;
107
+ isEqualNode(node: AstNode): boolean;
138
108
  /**
139
109
  * 在后方批量插入兄弟节点
140
- * @param {...this} nodes 插入节点
141
- * @complexity `n`
110
+ * @param nodes 插入节点
142
111
  */
143
- after(...nodes: AstNode[]): void;
112
+ after(...nodes: (AstNodeTypes | string)[]): void;
144
113
  /**
145
114
  * 在前方批量插入兄弟节点
146
- * @param {...this} nodes 插入节点
147
- * @complexity `n`
115
+ * @param nodes 插入节点
148
116
  */
149
- before(...nodes: AstNode[]): void;
117
+ before(...nodes: (AstNodeTypes | string)[]): void;
150
118
  /**
151
119
  * 移除当前节点
152
- * @complexity `n`
153
120
  * @throws `Error` 不存在父节点
154
121
  */
155
122
  remove(): void;
156
123
  /**
157
124
  * 将当前节点批量替换为新的节点
158
- * @param {...this} nodes 插入节点
159
- * @complexity `n`
125
+ * @param nodes 插入节点
160
126
  */
161
- replaceWith(...nodes: AstNode[]): void;
127
+ replaceWith(...nodes: (AstNodeTypes | string)[]): void;
162
128
  /**
163
129
  * 是自身或后代节点
164
- * @param {this} node 待检测节点
165
- * @returns {boolean}
166
- * @complexity `n`
130
+ * @param node 待检测节点
167
131
  */
168
132
  contains(node: AstNode): boolean;
169
133
  /**
170
134
  * 添加事件监听
171
- * @param {string|string[]} types 事件类型
172
- * @param {AstListener} listener 监听函数
173
- * @param {{once: boolean}} options 选项
135
+ * @param types 事件类型
136
+ * @param listener 监听函数
137
+ * @param options 选项
138
+ * @param options.once 仅执行一次
174
139
  */
175
- addEventListener(types: string | string[], listener: AstListener, options: {
176
- once: boolean;
140
+ addEventListener(types: AstEventType | AstEventType[], listener: AstListener, options?: {
141
+ once?: boolean;
177
142
  }): void;
178
143
  /**
179
144
  * 移除事件监听
180
- * @param {string|string[]} types 事件类型
181
- * @param {AstListener} listener 监听函数
145
+ * @param types 事件类型
146
+ * @param listener 监听函数
182
147
  */
183
- removeEventListener(types: string | string[], listener: AstListener): void;
148
+ removeEventListener(types: AstEventType | AstEventType[], listener: AstListener): void;
184
149
  /**
185
150
  * 移除事件的所有监听
186
- * @param {string|string[]} types 事件类型
151
+ * @param types 事件类型
187
152
  */
188
- removeAllEventListeners(types: string | string[]): void;
153
+ removeAllEventListeners(types?: AstEventType | AstEventType[]): void;
189
154
  /**
190
155
  * 列举事件监听
191
- * @param {string} type 事件类型
192
- * @returns {AstListener[]}
156
+ * @param type 事件类型
193
157
  */
194
- listEventListeners(type: string): AstListener[];
158
+ listEventListeners(type: AstEventType): Function[];
195
159
  /**
196
160
  * 触发事件
197
- * @param {import('../../typings/event').AstEvent} e 事件对象
198
- * @param {*} data 事件数据
161
+ * @param e 事件对象
162
+ * @param data 事件数据
199
163
  */
200
- dispatchEvent(e: import('../../typings/event').AstEvent, data: any): void;
164
+ dispatchEvent(e: Event, data: AstEventData): void;
201
165
  /** 获取所有祖先节点 */
202
- getAncestors(): AstNode[];
166
+ getAncestors(): import('../src')[];
203
167
  /**
204
168
  * 比较和另一个节点的相对位置
205
- * @param {this} other 待比较的节点
206
- * @complexity `n`
169
+ * @param other 待比较的节点
207
170
  * @throws `Error` 不在同一个语法树
208
171
  */
209
- compareDocumentPosition(other: AstNode): number;
210
- /**
211
- * 合并相邻的文本子节点
212
- * @complexity `n`
213
- */
214
- normalize(): void;
215
- /** 获取根节点 */
216
- getRootNode(): any;
217
- /**
218
- * 将字符位置转换为行列号
219
- * @param {number} index 字符位置
220
- * @complexity `n`
221
- */
222
- posFromIndex(index: number): {
223
- top: number;
224
- left: number;
225
- };
172
+ compareDocumentPosition(other: AstNodeTypes): number;
226
173
  /**
227
174
  * 将行列号转换为字符位置
228
- * @param {number} top 行号
229
- * @param {number} left 列号
230
- * @complexity `n`
175
+ * @param top 行号
176
+ * @param left 列号
231
177
  */
232
- indexFromPos(top: number, left: number): number;
233
- /** 第一个子节点前的间距 */
234
- getPadding(): number;
235
- /** 子节点间距 */
236
- getGaps(): number;
237
- /**
238
- * 获取当前节点的相对字符位置,或其第`j`个子节点的相对字符位置
239
- * @param {number|undefined} j 子节点序号
240
- * @complexity `n`
241
- */
242
- getRelativeIndex(j: number | undefined): number;
243
- /**
244
- * 获取当前节点的绝对位置
245
- * @returns {number}
246
- * @complexity `n`
247
- */
248
- getAbsoluteIndex(): number;
249
- /**
250
- * 获取当前节点的行列位置和大小
251
- * @complexity `n`
252
- */
253
- getBoundingClientRect(): any;
254
- /**
255
- * 行数
256
- * @complexity `n`
257
- */
258
- get offsetHeight(): number;
259
- /**
260
- * 最后一行的列数
261
- * @complexity `n`
262
- */
263
- get offsetWidth(): number;
264
- /**
265
- * 相对于父容器的行号
266
- * @complexity `n`
267
- */
268
- get offsetTop(): number;
269
- /**
270
- * 相对于父容器的列号
271
- * @complexity `n`
272
- */
273
- get offsetLeft(): number;
274
- /**
275
- * 位置、大小和padding
276
- * @complexity `n`
277
- */
278
- get style(): {
279
- padding: number;
280
- height: number;
281
- width: number;
282
- top: number;
283
- left: number;
284
- };
285
- #private;
178
+ indexFromPos(top: number, left: number): number | undefined;
179
+ /** 获取当前节点的行列位置和大小 */
180
+ getBoundingClientRect(): Dimension & Position;
286
181
  }
287
182
  declare namespace AstNode {
288
- export { TokenAttribute, AstListener };
183
+ export type { AstNodeTypes, TokenAttributeGetter, TokenAttributeSetter, Dimension, Position, CaretPosition, };
289
184
  }
290
- type AstListener = import('../../typings/event').AstListener;
291
- type TokenAttribute<T> = import('../../typings/node').TokenAttribute<T>;
185
+ export = AstNode;