wikiparser-node 1.16.3 → 1.16.5

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 (154) hide show
  1. package/README.md +1 -1
  2. package/bundle/bundle.es7.js +28 -28
  3. package/bundle/bundle.lsp.js +30 -30
  4. package/bundle/bundle.min.js +29 -29
  5. package/coverage/badge.svg +1 -1
  6. package/data/signatures.json +43 -0
  7. package/dist/addon/table.js +7 -4
  8. package/dist/addon/token.js +119 -113
  9. package/dist/addon/transclude.js +7 -5
  10. package/dist/base.d.mts +99 -30
  11. package/dist/base.d.ts +99 -30
  12. package/dist/index.d.ts +10 -4
  13. package/dist/index.js +59 -14
  14. package/dist/lib/attributes.js +2 -2
  15. package/dist/lib/element.d.ts +128 -29
  16. package/dist/lib/element.js +178 -32
  17. package/dist/lib/lsp.d.ts +62 -27
  18. package/dist/lib/lsp.js +395 -304
  19. package/dist/lib/node.d.ts +123 -54
  20. package/dist/lib/node.js +216 -87
  21. package/dist/lib/range.d.ts +83 -31
  22. package/dist/lib/range.js +83 -31
  23. package/dist/lib/ranges.d.ts +1 -1
  24. package/dist/lib/ranges.js +3 -2
  25. package/dist/lib/text.d.ts +40 -14
  26. package/dist/lib/text.js +47 -19
  27. package/dist/lib/title.d.ts +54 -17
  28. package/dist/lib/title.js +101 -47
  29. package/dist/mixin/attributesParent.d.ts +37 -21
  30. package/dist/mixin/attributesParent.js +18 -20
  31. package/dist/mixin/flagsParent.d.ts +38 -12
  32. package/dist/mixin/hidden.d.ts +0 -2
  33. package/dist/mixin/hidden.js +0 -2
  34. package/dist/mixin/magicLinkParent.d.ts +11 -5
  35. package/dist/mixin/singleLine.d.ts +0 -2
  36. package/dist/mixin/singleLine.js +3 -3
  37. package/dist/mixin/sol.d.ts +0 -2
  38. package/dist/mixin/sol.js +2 -3
  39. package/dist/mixin/syntax.d.ts +0 -2
  40. package/dist/mixin/syntax.js +0 -2
  41. package/dist/parser/braces.js +4 -2
  42. package/dist/parser/links.js +13 -7
  43. package/dist/parser/list.js +3 -1
  44. package/dist/parser/quotes.js +22 -2
  45. package/dist/parser/redirect.js +4 -1
  46. package/dist/parser/selector.js +1 -1
  47. package/dist/src/arg.d.ts +19 -9
  48. package/dist/src/arg.js +34 -15
  49. package/dist/src/atom.d.ts +5 -1
  50. package/dist/src/atom.js +5 -1
  51. package/dist/src/attribute.d.ts +26 -8
  52. package/dist/src/attribute.js +30 -11
  53. package/dist/src/attributes.d.ts +50 -22
  54. package/dist/src/attributes.js +54 -26
  55. package/dist/src/converter.d.ts +4 -2
  56. package/dist/src/converter.js +12 -9
  57. package/dist/src/converterFlags.d.ts +45 -15
  58. package/dist/src/converterFlags.js +45 -15
  59. package/dist/src/converterRule.d.ts +30 -11
  60. package/dist/src/converterRule.js +46 -16
  61. package/dist/src/extLink.d.ts +6 -2
  62. package/dist/src/extLink.js +14 -11
  63. package/dist/src/gallery.d.ts +13 -9
  64. package/dist/src/gallery.js +35 -21
  65. package/dist/src/heading.d.ts +13 -7
  66. package/dist/src/heading.js +28 -18
  67. package/dist/src/hidden.d.ts +5 -1
  68. package/dist/src/hidden.js +7 -3
  69. package/dist/src/html.d.ts +12 -10
  70. package/dist/src/html.js +17 -12
  71. package/dist/src/imageParameter.d.ts +27 -12
  72. package/dist/src/imageParameter.js +27 -12
  73. package/dist/src/imagemap.d.ts +4 -4
  74. package/dist/src/imagemap.js +9 -5
  75. package/dist/src/imagemapLink.d.ts +3 -1
  76. package/dist/src/imagemapLink.js +3 -1
  77. package/dist/src/index.d.ts +65 -64
  78. package/dist/src/index.js +111 -132
  79. package/dist/src/link/base.d.ts +14 -6
  80. package/dist/src/link/base.js +45 -21
  81. package/dist/src/link/category.d.ts +9 -4
  82. package/dist/src/link/category.js +20 -4
  83. package/dist/src/link/file.d.ts +71 -23
  84. package/dist/src/link/file.js +100 -36
  85. package/dist/src/link/galleryImage.d.ts +8 -4
  86. package/dist/src/link/galleryImage.js +15 -8
  87. package/dist/src/link/index.d.ts +14 -6
  88. package/dist/src/link/index.js +15 -5
  89. package/dist/src/link/redirectTarget.d.ts +4 -3
  90. package/dist/src/link/redirectTarget.js +5 -3
  91. package/dist/src/magicLink.d.ts +28 -12
  92. package/dist/src/magicLink.js +56 -34
  93. package/dist/src/nested.d.ts +5 -3
  94. package/dist/src/nested.js +9 -6
  95. package/dist/src/nowiki/base.d.ts +4 -2
  96. package/dist/src/nowiki/base.js +6 -5
  97. package/dist/src/nowiki/comment.d.ts +6 -2
  98. package/dist/src/nowiki/comment.js +8 -3
  99. package/dist/src/nowiki/dd.d.ts +0 -3
  100. package/dist/src/nowiki/dd.js +0 -8
  101. package/dist/src/nowiki/doubleUnderscore.d.ts +5 -1
  102. package/dist/src/nowiki/doubleUnderscore.js +5 -1
  103. package/dist/src/nowiki/index.d.ts +5 -1
  104. package/dist/src/nowiki/index.js +5 -1
  105. package/dist/src/nowiki/list.d.ts +5 -1
  106. package/dist/src/nowiki/list.js +5 -1
  107. package/dist/src/nowiki/listBase.d.ts +15 -5
  108. package/dist/src/nowiki/listBase.js +41 -10
  109. package/dist/src/nowiki/noinclude.d.ts +5 -1
  110. package/dist/src/nowiki/noinclude.js +5 -1
  111. package/dist/src/nowiki/quote.d.ts +15 -8
  112. package/dist/src/nowiki/quote.js +32 -12
  113. package/dist/src/onlyinclude.d.ts +4 -2
  114. package/dist/src/onlyinclude.js +4 -2
  115. package/dist/src/paramTag/index.d.ts +1 -1
  116. package/dist/src/paramTag/index.js +1 -1
  117. package/dist/src/parameter.d.ts +24 -12
  118. package/dist/src/parameter.js +45 -27
  119. package/dist/src/pre.d.ts +1 -1
  120. package/dist/src/pre.js +1 -1
  121. package/dist/src/redirect.d.ts +2 -0
  122. package/dist/src/redirect.js +2 -0
  123. package/dist/src/syntax.d.ts +5 -1
  124. package/dist/src/syntax.js +5 -1
  125. package/dist/src/table/base.d.ts +5 -1
  126. package/dist/src/table/base.js +11 -4
  127. package/dist/src/table/index.d.ts +134 -66
  128. package/dist/src/table/index.js +149 -81
  129. package/dist/src/table/td.d.ts +18 -10
  130. package/dist/src/table/td.js +23 -15
  131. package/dist/src/table/tr.d.ts +13 -3
  132. package/dist/src/table/tr.js +14 -6
  133. package/dist/src/table/trBase.d.ts +28 -12
  134. package/dist/src/table/trBase.js +28 -18
  135. package/dist/src/tagPair/ext.d.ts +3 -1
  136. package/dist/src/tagPair/ext.js +11 -10
  137. package/dist/src/tagPair/include.d.ts +8 -2
  138. package/dist/src/tagPair/include.js +8 -2
  139. package/dist/src/tagPair/index.d.ts +6 -2
  140. package/dist/src/tagPair/index.js +6 -2
  141. package/dist/src/transclude.d.ts +107 -33
  142. package/dist/src/transclude.js +139 -45
  143. package/dist/util/debug.js +2 -7
  144. package/dist/util/html.js +1 -14
  145. package/dist/util/string.js +7 -1
  146. package/extensions/dist/base.js +25 -8
  147. package/extensions/dist/codejar.js +2 -1
  148. package/extensions/dist/lsp.js +5 -10
  149. package/extensions/es7/base.js +25 -8
  150. package/extensions/ui.css +1 -162
  151. package/i18n/zh-hans.json +1 -1
  152. package/i18n/zh-hant.json +1 -1
  153. package/package.json +3 -3
  154. package/extensions/dist/test-page.js +0 -89
@@ -1,5 +1,9 @@
1
1
  import type { LintError, AstNode as AstNodeBase, TokenTypes } from '../base';
2
2
  import type { AstText, Token } from '../internal';
3
+ export interface Font {
4
+ bold: boolean;
5
+ italic: boolean;
6
+ }
3
7
  export type AstNodes = AstText | Token;
4
8
  export interface Dimension {
5
9
  readonly height: number;
@@ -13,163 +17,228 @@ export interface CaretPosition {
13
17
  readonly offsetNode: AstNodes;
14
18
  readonly offset: number;
15
19
  }
16
- /** 类似Node */
20
+ /**
21
+ * Node-like
22
+ *
23
+ * 类似Node
24
+ */
17
25
  export declare abstract class AstNode implements AstNodeBase {
18
26
  #private;
19
27
  data?: string | undefined;
20
28
  readonly childNodes: readonly AstNodes[];
21
29
  abstract get type(): TokenTypes | 'text';
22
30
  abstract set type(value: TokenTypes | "text");
23
- /** 可见部分 */
31
+ /**
32
+ * Get the visible text
33
+ *
34
+ * 可见部分
35
+ */
24
36
  text(): string;
25
37
  lint(): LintError[];
26
38
  print(): string;
27
- /** 首位子节点 */
39
+ /** first child node / 首位子节点 */
28
40
  get firstChild(): AstNodes | undefined;
29
- /** 末位子节点 */
41
+ /** last child node / 末位子节点 */
30
42
  get lastChild(): AstNodes | undefined;
31
- /** 父节点 */
43
+ /** parent node / 父节点 */
32
44
  get parentNode(): Token | undefined;
33
- /** 后一个兄弟节点 */
45
+ /** next sibling node / 后一个兄弟节点 */
34
46
  get nextSibling(): AstNodes | undefined;
35
- /** 前一个兄弟节点 */
47
+ /** previous sibling node / 前一个兄弟节点 */
36
48
  get previousSibling(): AstNodes | undefined;
37
- /** 行数 */
49
+ /** number of lines / 行数 */
38
50
  get offsetHeight(): number;
39
- /** 最后一行的列数 */
51
+ /** number of columns of the last line / 最后一行的列数 */
40
52
  get offsetWidth(): number;
41
- /** 后一个非文本兄弟节点 */
53
+ /** next sibling element / 后一个非文本兄弟节点 */
42
54
  get nextElementSibling(): Token | undefined;
43
- /** 前一个非文本兄弟节点 */
55
+ /** previous sibling element / 前一个非文本兄弟节点 */
44
56
  get previousElementSibling(): Token | undefined;
45
- /** 后一个可见的兄弟节点 */
57
+ /** next visibling sibling node / 后一个可见的兄弟节点 */
46
58
  get nextVisibleSibling(): AstNodes | undefined;
47
- /** 前一个可见的兄弟节点 */
59
+ /** previous visible sibling node / 前一个可见的兄弟节点 */
48
60
  get previousVisibleSibling(): AstNodes | undefined;
49
- /** 是否具有根节点 */
61
+ /** whether to be connected to a root token / 是否具有根节点 */
50
62
  get isConnected(): boolean;
51
- /** 后方是否还有其他节点(不含后代) */
63
+ /** whether to be the end of a document / 后方是否还有其他节点(不含后代) */
52
64
  get eof(): boolean | undefined;
53
- /** 相对于父容器的行号 */
65
+ /** line number relative to its parent / 相对于父容器的行号 */
54
66
  get offsetTop(): number;
55
- /** 相对于父容器的列号 */
67
+ /** column number of the last line relative to its parent / 相对于父容器的列号 */
56
68
  get offsetLeft(): number;
57
- /** 位置、大小和padding */
69
+ /** position, dimension and paddings / 位置、大小和padding */
58
70
  get style(): Position & Dimension & {
59
71
  padding: number;
60
72
  };
61
- /** 字体样式 */
62
- get font(): {
63
- bold: boolean;
64
- italic: boolean;
65
- };
66
- /** 是否粗体 */
73
+ /** font weigth and style / 字体样式 */
74
+ get font(): Font;
75
+ /** whether to be bold / 是否粗体 */
67
76
  get bold(): boolean;
68
- /** 是否斜体 */
77
+ /** whether to be italic / 是否斜体 */
69
78
  get italic(): boolean;
70
79
  constructor();
71
- /** 获取根节点 */
80
+ /**
81
+ * Get the root node
82
+ *
83
+ * 获取根节点
84
+ */
72
85
  getRootNode(): Token | this;
73
86
  /**
87
+ * Convert the position to the character index
88
+ *
74
89
  * 将行列号转换为字符位置
75
- * @param top 行号
76
- * @param left 列号
90
+ * @param top line number / 行号
91
+ * @param left column number / 列号
77
92
  */
78
93
  indexFromPos(top: number, left: number): number | undefined;
79
94
  /**
95
+ * Convert the character indenx to the position
96
+ *
80
97
  * 将字符位置转换为行列号
81
- * @param index 字符位置
98
+ * @param index character index / 字符位置
82
99
  */
83
100
  posFromIndex(index: number): Position | undefined;
84
101
  /**
102
+ * Get the relative character index of the current node, or its `j`-th child node
103
+ *
85
104
  * 获取当前节点的相对字符位置,或其第`j`个子节点的相对字符位置
86
- * @param j 子节点序号
105
+ * @param j rank of the child node / 子节点序号
87
106
  */
88
107
  getRelativeIndex(j?: number): number;
89
- /** 获取当前节点的绝对位置 */
108
+ /**
109
+ * Get the absolute character index of the current node
110
+ *
111
+ * 获取当前节点的绝对位置
112
+ */
90
113
  getAbsoluteIndex(): number;
91
- /** 获取当前节点的行列位置和大小 */
114
+ /**
115
+ * Get the position and dimension of the current node
116
+ *
117
+ * 获取当前节点的行列位置和大小
118
+ */
92
119
  getBoundingClientRect(): Dimension & Position;
93
120
  /**
121
+ * Whether to be of a certain type
122
+ *
94
123
  * 是否是某种类型的节点
95
- * @param type 节点类型
124
+ * @param type token type / 节点类型
125
+ */
126
+ is<T extends Token>(type: TokenTypes): this is T;
127
+ /**
128
+ * Get the text and the start/end positions of all lines
129
+ *
130
+ * 获取所有行的wikitext和起止位置
96
131
  */
97
- is<T extends Token>(type: string): this is T;
98
- /** 获取所有行的wikitext和起止位置 */
99
132
  getLines(): [string, number, number][];
100
133
  /**
134
+ * Check if the node is identical
135
+ *
101
136
  * 是否是全同节点
102
- * @param node 待比较的节点
137
+ * @param node node to be compared to / 待比较的节点
103
138
  * @throws `assert.AssertionError`
104
139
  */
105
140
  isEqualNode(node: AstNode): boolean;
106
141
  /**
142
+ * Insert a batch of sibling nodes after the current node
143
+ *
107
144
  * 在后方批量插入兄弟节点
108
- * @param nodes 插入节点
145
+ * @param nodes nodes to be inserted / 插入节点
109
146
  */
110
147
  after(...nodes: (AstNodes | string)[]): void;
111
148
  /**
149
+ * Insert a batch of sibling nodes before the current node
150
+ *
112
151
  * 在前方批量插入兄弟节点
113
- * @param nodes 插入节点
152
+ * @param nodes nodes to be inserted / 插入节点
114
153
  */
115
154
  before(...nodes: (AstNodes | string)[]): void;
116
- /** 移除当前节点 */
155
+ /**
156
+ * Remove the current node
157
+ *
158
+ * 移除当前节点
159
+ */
117
160
  remove(): void;
118
161
  /**
162
+ * Replace the current node with new nodes
163
+ *
119
164
  * 将当前节点批量替换为新的节点
120
- * @param nodes 插入节点
165
+ * @param nodes nodes to be inserted / 插入节点
121
166
  */
122
167
  replaceWith(...nodes: (AstNodes | string)[]): void;
123
168
  /**
169
+ * Check if the node is a descendant
170
+ *
124
171
  * 是自身或后代节点
125
- * @param node 待检测节点
172
+ * @param node node to be compared to / 待检测节点
126
173
  */
127
174
  contains(node: AstNode): boolean;
128
175
  /**
176
+ * Add an event listener
177
+ *
129
178
  * 添加事件监听
130
- * @param types 事件类型
131
- * @param listener 监听函数
179
+ * @param types event type / 事件类型
180
+ * @param listener listener function / 监听函数
132
181
  * @param options 选项
133
- * @param options.once 仅执行一次
182
+ * @param options.once to be executed only once / 仅执行一次
134
183
  */
135
184
  addEventListener(types: string | string[], listener: (...args: any[]) => void, options?: {
136
185
  once?: boolean;
137
186
  }): void;
138
187
  /**
188
+ * Remove an event listener
189
+ *
139
190
  * 移除事件监听
140
- * @param types 事件类型
141
- * @param listener 监听函数
191
+ * @param types event type / 事件类型
192
+ * @param listener listener function / 监听函数
142
193
  */
143
194
  removeEventListener(types: string | string[], listener: (...args: any[]) => void): void;
144
195
  /**
196
+ * Remove all event listeners
197
+ *
145
198
  * 移除事件的所有监听
146
- * @param types 事件类型
199
+ * @param types event type / 事件类型
147
200
  */
148
201
  removeAllEventListeners(types: string | string[]): void;
149
202
  /**
203
+ * List all event listeners
204
+ *
150
205
  * 列举事件监听
151
- * @param type 事件类型
206
+ * @param type event type / 事件类型
152
207
  */
153
208
  listEventListeners(type: string): Function[];
154
209
  /**
210
+ * Dispatch an event
211
+ *
155
212
  * 触发事件
156
- * @param e 事件对象
157
- * @param data 事件数据
213
+ * @param e event object / 事件对象
214
+ * @param data event data / 事件数据
158
215
  */
159
216
  dispatchEvent(e: Event, data: unknown): void;
160
- /** 获取所有祖先节点 */
217
+ /**
218
+ * Get all the ancestor nodes
219
+ *
220
+ * 获取所有祖先节点
221
+ */
161
222
  getAncestors(): Token[];
162
223
  /**
224
+ * Compare the relative position with another node
225
+ *
163
226
  * 比较和另一个节点的相对位置
164
- * @param other 待比较的节点
227
+ * @param other node to be compared with / 待比较的节点
165
228
  * @throws `RangeError` 不在同一个语法树
166
229
  */
167
230
  compareDocumentPosition(other: AstNodes): number;
168
- /** 销毁 */
231
+ /**
232
+ * Destroy the instance
233
+ *
234
+ * 销毁
235
+ */
169
236
  destroy(): void;
170
237
  /**
238
+ * Get the wikitext of a line
239
+ *
171
240
  * 获取某一行的wikitext
172
- * @param n 行号
241
+ * @param n line number / 行号
173
242
  */
174
243
  getLine(n: number): string | undefined;
175
244
  }