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