wikiparser-node 1.5.2-b → 1.5.2

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 (163) hide show
  1. package/config/.schema.json +172 -0
  2. package/config/enwiki.json +814 -1
  3. package/config/llwiki.json +35 -1
  4. package/config/moegirl.json +44 -1
  5. package/config/zhwiki.json +466 -1
  6. package/dist/addon/table.d.ts +6 -0
  7. package/dist/addon/table.js +564 -0
  8. package/dist/base.d.ts +72 -0
  9. package/dist/base.js +38 -0
  10. package/dist/index.d.ts +30 -0
  11. package/dist/index.js +214 -0
  12. package/dist/internal.d.ts +44 -0
  13. package/dist/lib/element.d.ts +150 -0
  14. package/dist/lib/element.js +613 -0
  15. package/dist/lib/node.d.ts +146 -0
  16. package/dist/lib/node.js +428 -0
  17. package/dist/lib/range.d.ts +104 -0
  18. package/dist/lib/range.js +385 -0
  19. package/dist/lib/ranges.d.ts +26 -0
  20. package/dist/lib/ranges.js +118 -0
  21. package/dist/lib/text.d.ts +62 -0
  22. package/dist/lib/text.js +361 -0
  23. package/dist/lib/title.d.ts +38 -0
  24. package/dist/lib/title.js +166 -0
  25. package/dist/mixin/attributesParent.d.ts +50 -0
  26. package/dist/mixin/attributesParent.js +78 -0
  27. package/dist/mixin/fixed.d.ts +6 -0
  28. package/dist/mixin/fixed.js +30 -0
  29. package/dist/mixin/flagsParent.d.ts +72 -0
  30. package/dist/mixin/flagsParent.js +59 -0
  31. package/dist/mixin/hidden.d.ts +5 -0
  32. package/dist/mixin/hidden.js +24 -0
  33. package/dist/mixin/magicLinkParent.d.ts +40 -0
  34. package/dist/mixin/magicLinkParent.js +42 -0
  35. package/dist/mixin/singleLine.d.ts +6 -0
  36. package/dist/mixin/singleLine.js +26 -0
  37. package/dist/mixin/sol.d.ts +6 -0
  38. package/dist/mixin/sol.js +43 -0
  39. package/dist/mixin/syntax.d.ts +9 -0
  40. package/dist/mixin/syntax.js +50 -0
  41. package/dist/parser/braces.js +131 -0
  42. package/dist/parser/commentAndExt.js +90 -0
  43. package/dist/parser/converter.js +41 -0
  44. package/dist/parser/externalLinks.js +32 -0
  45. package/dist/parser/hrAndDoubleUnderscore.js +41 -0
  46. package/dist/parser/html.js +39 -0
  47. package/dist/parser/links.js +95 -0
  48. package/dist/parser/list.js +98 -0
  49. package/dist/parser/magicLinks.js +43 -0
  50. package/dist/parser/quotes.js +68 -0
  51. package/dist/parser/selector.js +162 -0
  52. package/dist/parser/table.js +124 -0
  53. package/dist/src/arg.d.ts +58 -0
  54. package/dist/src/arg.js +214 -0
  55. package/dist/src/atom.d.ts +12 -0
  56. package/dist/src/atom.js +27 -0
  57. package/dist/src/attribute.d.ts +71 -0
  58. package/dist/src/attribute.js +502 -0
  59. package/dist/src/attributes.d.ts +109 -0
  60. package/dist/src/attributes.js +356 -0
  61. package/dist/src/converter.d.ts +33 -0
  62. package/dist/src/converter.js +134 -0
  63. package/dist/src/converterFlags.d.ts +87 -0
  64. package/dist/src/converterFlags.js +242 -0
  65. package/dist/src/converterRule.d.ts +77 -0
  66. package/dist/src/converterRule.js +209 -0
  67. package/dist/src/extLink.d.ts +43 -0
  68. package/dist/src/extLink.js +186 -0
  69. package/dist/src/gallery.d.ts +54 -0
  70. package/dist/src/gallery.js +139 -0
  71. package/dist/src/heading.d.ts +47 -0
  72. package/dist/src/heading.js +190 -0
  73. package/dist/src/hidden.d.ts +7 -0
  74. package/dist/src/hidden.js +23 -0
  75. package/dist/src/html.d.ts +65 -0
  76. package/dist/src/html.js +358 -0
  77. package/dist/src/imageParameter.d.ts +65 -0
  78. package/dist/src/imageParameter.js +257 -0
  79. package/dist/src/imagemap.d.ts +56 -0
  80. package/dist/src/imagemap.js +150 -0
  81. package/dist/src/imagemapLink.d.ts +31 -0
  82. package/dist/src/imagemapLink.js +93 -0
  83. package/dist/src/index.d.ts +143 -0
  84. package/dist/src/index.js +813 -0
  85. package/dist/src/link/base.d.ts +52 -0
  86. package/dist/src/link/base.js +229 -0
  87. package/dist/src/link/category.d.ts +13 -0
  88. package/dist/src/link/category.js +28 -0
  89. package/dist/src/link/file.d.ts +98 -0
  90. package/dist/src/link/file.js +272 -0
  91. package/dist/src/link/galleryImage.d.ts +32 -0
  92. package/dist/src/link/galleryImage.js +157 -0
  93. package/dist/src/link/index.d.ts +56 -0
  94. package/dist/src/link/index.js +133 -0
  95. package/dist/src/magicLink.d.ts +59 -0
  96. package/dist/src/magicLink.js +223 -0
  97. package/dist/src/nested.d.ts +43 -0
  98. package/dist/src/nested.js +105 -0
  99. package/dist/src/nowiki/base.d.ts +31 -0
  100. package/dist/src/nowiki/base.js +93 -0
  101. package/dist/src/nowiki/comment.d.ts +25 -0
  102. package/dist/src/nowiki/comment.js +76 -0
  103. package/dist/src/nowiki/dd.d.ts +8 -0
  104. package/dist/src/nowiki/dd.js +24 -0
  105. package/dist/src/nowiki/doubleUnderscore.d.ts +18 -0
  106. package/dist/src/nowiki/doubleUnderscore.js +101 -0
  107. package/dist/src/nowiki/hr.d.ts +5 -0
  108. package/dist/src/nowiki/hr.js +63 -0
  109. package/dist/src/nowiki/index.d.ts +16 -0
  110. package/dist/src/nowiki/index.js +27 -0
  111. package/dist/src/nowiki/list.d.ts +16 -0
  112. package/dist/src/nowiki/list.js +97 -0
  113. package/dist/src/nowiki/listBase.d.ts +5 -0
  114. package/dist/src/nowiki/listBase.js +61 -0
  115. package/dist/src/nowiki/noinclude.d.ts +10 -0
  116. package/dist/src/nowiki/noinclude.js +23 -0
  117. package/dist/src/nowiki/quote.d.ts +14 -0
  118. package/dist/src/nowiki/quote.js +131 -0
  119. package/dist/src/onlyinclude.d.ts +16 -0
  120. package/dist/src/onlyinclude.js +57 -0
  121. package/dist/src/paramTag/index.d.ts +37 -0
  122. package/dist/src/paramTag/index.js +77 -0
  123. package/dist/src/paramTag/inputbox.d.ts +8 -0
  124. package/dist/src/paramTag/inputbox.js +22 -0
  125. package/dist/src/parameter.d.ts +70 -0
  126. package/dist/src/parameter.js +264 -0
  127. package/dist/src/pre.d.ts +28 -0
  128. package/dist/src/pre.js +55 -0
  129. package/dist/src/syntax.d.ts +20 -0
  130. package/dist/src/syntax.js +86 -0
  131. package/dist/src/table/base.d.ts +30 -0
  132. package/dist/src/table/base.js +132 -0
  133. package/dist/src/table/index.d.ts +233 -0
  134. package/dist/src/table/index.js +396 -0
  135. package/dist/src/table/td.d.ts +86 -0
  136. package/dist/src/table/td.js +350 -0
  137. package/dist/src/table/tr.d.ts +32 -0
  138. package/dist/src/table/tr.js +58 -0
  139. package/dist/src/table/trBase.d.ts +53 -0
  140. package/dist/src/table/trBase.js +152 -0
  141. package/dist/src/tagPair/ext.d.ts +32 -0
  142. package/dist/src/tagPair/ext.js +203 -0
  143. package/dist/src/tagPair/include.d.ts +35 -0
  144. package/dist/src/tagPair/include.js +74 -0
  145. package/dist/src/tagPair/index.d.ts +27 -0
  146. package/dist/src/tagPair/index.js +128 -0
  147. package/dist/src/transclude.d.ts +167 -0
  148. package/dist/src/transclude.js +717 -0
  149. package/dist/util/constants.js +28 -0
  150. package/dist/util/debug.js +88 -0
  151. package/dist/util/diff.js +83 -0
  152. package/dist/util/lint.js +31 -0
  153. package/dist/util/string.js +54 -0
  154. package/errors/README +1 -0
  155. package/package.json +14 -27
  156. package/printed/README +1 -0
  157. package/bundle/bundle.min.js +0 -37
  158. package/extensions/dist/base.js +0 -64
  159. package/extensions/dist/editor.js +0 -159
  160. package/extensions/dist/highlight.js +0 -59
  161. package/extensions/dist/lint.js +0 -60
  162. package/extensions/editor.css +0 -63
  163. package/extensions/ui.css +0 -141
@@ -0,0 +1,30 @@
1
+ import type { log } from './util/diff';
2
+ import type { Config, LintError, Parser as ParserBase } from './base';
3
+ import type { Title } from './lib/title';
4
+ import type { Token } from './internal';
5
+ declare interface Parser extends ParserBase {
6
+ conversionTable: Map<string, string>;
7
+ redirects: Map<string, string>;
8
+ warning: boolean;
9
+ debugging: boolean;
10
+ /**
11
+ * 规范化页面标题
12
+ * @param title 标题(含或不含命名空间前缀)
13
+ * @param defaultNs 命名空间
14
+ * @param include 是否嵌入
15
+ * @param halfParsed 是否是半解析状态
16
+ * @param decode 是否需要解码
17
+ * @param selfLink 是否允许selfLink
18
+ */
19
+ normalizeTitle(title: string, defaultNs?: number, include?: boolean, config?: Config, halfParsed?: boolean, decode?: boolean, selfLink?: boolean): Title;
20
+ parse(wikitext: string, include?: boolean, maxStage?: number, config?: Config): Token;
21
+ /**
22
+ * 是否是跨维基链接
23
+ * @param title 链接标题
24
+ */
25
+ isInterwiki(title: string, config?: Config): RegExpExecArray | null;
26
+ }
27
+ declare const Parser: Parser;
28
+ export = Parser;
29
+ export type { Config, LintError };
30
+ export type * from './internal';
package/dist/index.js ADDED
@@ -0,0 +1,214 @@
1
+ "use strict";
2
+ /* eslint n/exports-style: 0 */
3
+ const fs = require("fs");
4
+ const path = require("path");
5
+ const chalk = require("chalk");
6
+ const base_1 = require("./base");
7
+ const debug_1 = require("./util/debug");
8
+ const constants_1 = require("./util/constants");
9
+ const string_1 = require("./util/string");
10
+ const diff_1 = require("./util/diff");
11
+ /**
12
+ * 从根路径require
13
+ * @param file 文件名
14
+ * @param dir 子路径
15
+ */
16
+ const rootRequire = (file, dir) => require(file.startsWith('/') ? file : `../${file.includes('/') ? '' : dir}${file}`);
17
+ // eslint-disable-next-line @typescript-eslint/no-redeclare
18
+ const Parser = {
19
+ config: 'default',
20
+ i18n: undefined,
21
+ rules: base_1.rules,
22
+ /* NOT FOR BROWSER */
23
+ conversionTable: new Map(),
24
+ redirects: new Map(),
25
+ warning: true,
26
+ debugging: false,
27
+ /* NOT FOR BROWSER END */
28
+ /** @implements */
29
+ getConfig() {
30
+ if (typeof this.config === 'string') {
31
+ this.config = rootRequire(this.config, 'config/');
32
+ /* NOT FOR BROWSER */
33
+ const { config: { conversionTable, redirects } } = this;
34
+ if (conversionTable) {
35
+ this.conversionTable = new Map(conversionTable);
36
+ }
37
+ if (redirects) {
38
+ this.redirects = new Map(redirects);
39
+ }
40
+ /* NOT FOR BROWSER END */
41
+ return this.getConfig();
42
+ }
43
+ return {
44
+ ...this.config,
45
+ excludes: [],
46
+ };
47
+ },
48
+ /** @implements */
49
+ msg(msg, arg = '') {
50
+ if (typeof this.i18n === 'string') {
51
+ this.i18n = rootRequire(this.i18n, 'i18n/');
52
+ return this.msg(msg, arg);
53
+ }
54
+ return msg && (this.i18n?.[msg] ?? msg).replace('$1', this.msg(arg));
55
+ },
56
+ /** @implements */
57
+ normalizeTitle(title, defaultNs = 0, include = false, config = Parser.getConfig(), halfParsed = false, decode = false, selfLink = false) {
58
+ const { Title } = require('./lib/title');
59
+ if (halfParsed) {
60
+ return new Title(title, defaultNs, config, decode, selfLink);
61
+ }
62
+ const { Token } = require('./src/index');
63
+ const token = debug_1.Shadow.run(() => new Token(title, config).parseOnce(0, include).parseOnce()), titleObj = new Title(String(token), defaultNs, config, decode, selfLink);
64
+ /* NOT FOR BROWSER */
65
+ debug_1.Shadow.run(() => {
66
+ for (const key of ['main', 'fragment']) {
67
+ const str = titleObj[key];
68
+ if (str?.includes('\0')) {
69
+ titleObj[key] = token.buildFromStr(str, constants_1.BuildMethod.Text);
70
+ }
71
+ }
72
+ });
73
+ titleObj.conversionTable = this.conversionTable;
74
+ titleObj.redirects = this.redirects;
75
+ /* NOT FOR BROWSER END */
76
+ return titleObj;
77
+ },
78
+ /** @implements */
79
+ parse(wikitext, include, maxStage = constants_1.MAX_STAGE, config = Parser.getConfig()) {
80
+ wikitext = (0, string_1.tidy)(wikitext);
81
+ const { Token } = require('./src/index');
82
+ const root = debug_1.Shadow.run(() => {
83
+ const token = new Token(wikitext, config);
84
+ try {
85
+ return token.parse(maxStage, include);
86
+ }
87
+ catch (e) {
88
+ if (e instanceof Error) {
89
+ const file = path.join(__dirname, '..', 'errors', new Date().toISOString()), stage = token.getAttribute('stage');
90
+ fs.writeFileSync(file, stage === constants_1.MAX_STAGE ? wikitext : String(token));
91
+ fs.writeFileSync(`${file}.err`, e.stack);
92
+ fs.writeFileSync(`${file}.json`, JSON.stringify({
93
+ stage, include: token.getAttribute('include'), config: this.config,
94
+ }, null, '\t'));
95
+ }
96
+ throw e;
97
+ }
98
+ });
99
+ /* NOT FOR BROWSER */
100
+ if (this.debugging) {
101
+ let restored = String(root), process = '解析';
102
+ if (restored === wikitext) {
103
+ const entities = { lt: '<', gt: '>', amp: '&' };
104
+ restored = root.print().replace(/<[^<]+?>|&([lg]t|amp);/gu, (_, s) => s ? entities[s] : '');
105
+ process = '渲染HTML';
106
+ }
107
+ if (restored !== wikitext) {
108
+ const { diff } = require('./util/diff');
109
+ const { 0: cur, length } = constants_1.promises;
110
+ constants_1.promises.unshift((async () => {
111
+ await cur;
112
+ this.error(`${process}过程中不可逆地修改了原始文本!`);
113
+ return diff(wikitext, restored, length);
114
+ })());
115
+ }
116
+ }
117
+ /* NOT FOR BROWSER END */
118
+ return root;
119
+ },
120
+ /* NOT FOR BROWSER */
121
+ /** @implements */
122
+ warn(msg, ...args) {
123
+ if (this.warning) {
124
+ console.warn(chalk.yellow(msg), ...args);
125
+ }
126
+ },
127
+ /** @implements */
128
+ debug(msg, ...args) {
129
+ if (this.debugging) {
130
+ console.debug(chalk.blue(msg), ...args);
131
+ }
132
+ },
133
+ error: diff_1.error,
134
+ info: diff_1.info,
135
+ /** @implements */
136
+ log(f) {
137
+ if (typeof f === 'function') {
138
+ console.log(String(f));
139
+ }
140
+ },
141
+ /** @implements */
142
+ async clearCache() {
143
+ const promise = (0, diff_1.cmd)('npm', ['run', 'build']), entries = [
144
+ ...Object.entries(constants_1.classes),
145
+ ...Object.entries(constants_1.mixins),
146
+ ...Object.entries(constants_1.parsers),
147
+ ];
148
+ for (const [, filePath] of entries) {
149
+ try {
150
+ delete require.cache[require.resolve(filePath)];
151
+ }
152
+ catch { }
153
+ }
154
+ await promise;
155
+ for (const [name, filePath] of entries) {
156
+ if (name in global) {
157
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
158
+ Object.assign(global, { [name]: require(filePath)[name] });
159
+ }
160
+ }
161
+ this.info('已重新加载Parser');
162
+ },
163
+ /** @implements */
164
+ isInterwiki(title, { interwiki } = Parser.getConfig()) {
165
+ return interwiki.length > 0
166
+ ? new RegExp(`^(${interwiki.join('|')})\\s*:`, 'diu')
167
+ .exec(title.replace(/_/gu, ' ').replace(/^\s*:?\s*/u, ''))
168
+ : null;
169
+ },
170
+ /** @implements */
171
+ reparse(date) {
172
+ const main = fs.readdirSync(path.join(__dirname, '..', 'errors'))
173
+ .find(name => name.startsWith(date) && name.endsWith('Z'));
174
+ if (!main) {
175
+ throw new RangeError(`找不到对应时间戳的错误记录:${date}`);
176
+ }
177
+ const file = path.join(__dirname, '..', 'errors', main), wikitext = fs.readFileSync(file, 'utf8');
178
+ const { stage, include, config } = require(`${file}.json`), { Token } = require('./src');
179
+ this.config = config;
180
+ return debug_1.Shadow.run(() => {
181
+ const halfParsed = stage < constants_1.MAX_STAGE, token = new Token(halfParsed ? wikitext : (0, string_1.tidy)(wikitext), this.getConfig());
182
+ if (halfParsed) {
183
+ token.setAttribute('stage', stage);
184
+ token.parseOnce(stage, include);
185
+ }
186
+ else {
187
+ token.parse(undefined, include);
188
+ }
189
+ fs.unlinkSync(file);
190
+ fs.unlinkSync(`${file}.err`);
191
+ fs.unlinkSync(`${file}.json`);
192
+ return token;
193
+ });
194
+ },
195
+ };
196
+ const def = {
197
+ default: { value: Parser },
198
+ }, enumerable = new Set([
199
+ 'normalizeTitle',
200
+ 'parse',
201
+ /* NOT FOR BROWSER */
202
+ 'conversionTable',
203
+ 'redirects',
204
+ 'warning',
205
+ 'debugging',
206
+ 'isInterwiki',
207
+ ]);
208
+ for (const key in Parser) {
209
+ if (!enumerable.has(key)) {
210
+ def[key] = { enumerable: false };
211
+ }
212
+ }
213
+ Object.defineProperties(Parser, def);
214
+ module.exports = Parser;
@@ -0,0 +1,44 @@
1
+ export type { AstNodes, } from './lib/node';
2
+ export type * from './lib/text';
3
+ export type * from './src/index';
4
+ export type * from './src/onlyinclude';
5
+ export type * from './src/nowiki/noinclude';
6
+ export type * from './src/tagPair/include';
7
+ export type * from './src/nowiki/comment';
8
+ export type * from './src/atom';
9
+ export type { AttributeToken } from './src/attribute';
10
+ export type * from './src/attributes';
11
+ export type * from './src/tagPair/ext';
12
+ export type * from './src/hidden';
13
+ export type * from './src/arg';
14
+ export type * from './src/syntax';
15
+ export type * from './src/parameter';
16
+ export type * from './src/transclude';
17
+ export type * from './src/heading';
18
+ export type * from './src/html';
19
+ export type { TdToken } from './src/table/td';
20
+ export type * from './src/table/tr';
21
+ export type { TableToken } from './src/table/index';
22
+ export type * from './src/nowiki/hr';
23
+ export type * from './src/nowiki/doubleUnderscore';
24
+ export type * from './src/link/index';
25
+ export type * from './src/link/category';
26
+ export type { ImageParameterToken } from './src/imageParameter';
27
+ export type * from './src/link/file';
28
+ export type * from './src/link/galleryImage';
29
+ export type * from './src/nowiki/quote';
30
+ export type * from './src/magicLink';
31
+ export type * from './src/extLink';
32
+ export type * from './src/nowiki/dd';
33
+ export type * from './src/nowiki/list';
34
+ export type * from './src/converterFlags';
35
+ export type * from './src/converterRule';
36
+ export type * from './src/converter';
37
+ export type * from './src/nowiki/index';
38
+ export type * from './src/pre';
39
+ export type * from './src/paramTag/index';
40
+ export type * from './src/paramTag/inputbox';
41
+ export type * from './src/nested';
42
+ export type * from './src/gallery';
43
+ export type * from './src/imagemapLink';
44
+ export type * from './src/imagemap';
@@ -0,0 +1,150 @@
1
+ import { AstNode } from './node';
2
+ import type { LintError, AST } from '../base';
3
+ import type { AstNodes, AstText, Token } from '../internal';
4
+ /** 类似HTMLElement */
5
+ export declare abstract class AstElement extends AstNode {
6
+ #private;
7
+ readonly name?: string;
8
+ readonly data: undefined;
9
+ /** 子节点总数 */
10
+ get length(): number;
11
+ /** 全部非文本子节点 */
12
+ get children(): Token[];
13
+ /** 首位非文本子节点 */
14
+ get firstElementChild(): Token | undefined;
15
+ /** 末位非文本子节点 */
16
+ get lastElementChild(): Token | undefined;
17
+ /** 非文本子节点总数 */
18
+ get childElementCount(): number;
19
+ /** 父节点 */
20
+ get parentElement(): Token | undefined;
21
+ /** AstElement.prototype.text()的getter写法 */
22
+ get outerText(): string;
23
+ /** 不可见 */
24
+ get hidden(): boolean;
25
+ /** 后一个可见的兄弟节点 */
26
+ get nextVisibleSibling(): AstNodes | undefined;
27
+ /** 前一个可见的兄弟节点 */
28
+ get previousVisibleSibling(): AstNodes | undefined;
29
+ /** 内部高度 */
30
+ get clientHeight(): number | undefined;
31
+ /** 内部宽度 */
32
+ get clientWidth(): number | undefined;
33
+ constructor();
34
+ /**
35
+ * 可见部分
36
+ * @param separator 子节点间的连接符
37
+ */
38
+ text(separator?: string): string;
39
+ /** 合并相邻的文本子节点 */
40
+ normalize(): void;
41
+ /**
42
+ * 移除子节点
43
+ * @param i 移除位置
44
+ */
45
+ removeAt(i: number): AstNodes;
46
+ /**
47
+ * 插入子节点
48
+ * @param node 待插入的子节点
49
+ * @param i 插入位置
50
+ * @throws `RangeError` 不能插入祖先或子节点
51
+ */
52
+ insertAt<T extends AstNodes>(node: T, i?: number): T;
53
+ /**
54
+ * 最近的祖先节点
55
+ * @param selector 选择器
56
+ */
57
+ closest<T = Token>(selector: string): T | undefined;
58
+ /**
59
+ * 在末尾批量插入子节点
60
+ * @param elements 插入节点
61
+ */
62
+ append(...elements: (AstNodes | string)[]): void;
63
+ /**
64
+ * 批量替换子节点
65
+ * @param elements 新的子节点
66
+ */
67
+ replaceChildren(...elements: (AstNodes | string)[]): void;
68
+ /**
69
+ * 修改文本子节点
70
+ * @param str 新文本
71
+ * @param i 子节点位置
72
+ * @throws `RangeError` 对应位置的子节点不是文本节点
73
+ */
74
+ setText(str: string, i?: number): string;
75
+ /**
76
+ * @override
77
+ * @param start
78
+ */
79
+ lint(start?: number): LintError[];
80
+ /**
81
+ * @override
82
+ * @param opt 选项
83
+ */
84
+ print(opt?: PrintOpt): string;
85
+ /**
86
+ * 保存为JSON
87
+ * @param file 文件名
88
+ * @param start
89
+ */
90
+ json(file?: string, start?: number): AST;
91
+ /** 销毁 */
92
+ destroy(): void;
93
+ /**
94
+ * 检查是否符合选择器
95
+ * @param selector 选择器
96
+ */
97
+ matches<T>(selector?: string): this is T;
98
+ /**
99
+ * 符合选择器的第一个后代节点
100
+ * @param selector 选择器
101
+ */
102
+ querySelector<T = Token>(selector: string): T | undefined;
103
+ /**
104
+ * 类型选择器
105
+ * @param types
106
+ */
107
+ getElementByTypes<T = Token>(types: string): T | undefined;
108
+ /**
109
+ * id选择器
110
+ * @param id id名
111
+ */
112
+ getElementById<T = Token>(id: string): T | undefined;
113
+ /**
114
+ * 符合选择器的所有后代节点
115
+ * @param selector 选择器
116
+ */
117
+ querySelectorAll<T = Token>(selector: string): T[];
118
+ /**
119
+ * 类选择器
120
+ * @param className 类名之一
121
+ */
122
+ getElementsByClassName<T = Token>(className: string): T[];
123
+ /**
124
+ * 标签名选择器
125
+ * @param tag 标签名
126
+ */
127
+ getElementsByTagName<T = Token>(tag: string): T[];
128
+ /**
129
+ * 获取某一行的wikitext
130
+ * @param n 行号
131
+ */
132
+ getLine(n: number): string | undefined;
133
+ /**
134
+ * 在开头批量插入子节点
135
+ * @param elements 插入节点
136
+ */
137
+ prepend(...elements: (AstNodes | string)[]): void;
138
+ /**
139
+ * 移除子节点
140
+ * @param node 子节点
141
+ */
142
+ removeChild<T extends AstNodes>(node: T): T;
143
+ /**
144
+ * 在指定位置前插入子节点
145
+ * @param child 插入节点
146
+ * @param reference 指定位置处的子节点
147
+ */
148
+ insertBefore(child: string, reference?: AstNodes): AstText;
149
+ insertBefore<T extends AstNodes>(child: T, reference?: AstNodes): T;
150
+ }