wikiparser-node 1.3.3-b → 1.3.3

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/config/.schema.json +172 -0
  2. package/config/llwiki.json +35 -1
  3. package/config/moegirl.json +44 -1
  4. package/config/zhwiki.json +466 -1
  5. package/dist/addon/table.d.ts +6 -0
  6. package/dist/addon/table.js +564 -0
  7. package/dist/base.d.ts +45 -0
  8. package/dist/bin/toc.js +18 -0
  9. package/dist/index.d.ts +31 -0
  10. package/dist/index.js +209 -0
  11. package/dist/internal.d.ts +44 -0
  12. package/dist/lib/element.d.ts +155 -0
  13. package/dist/lib/element.js +634 -0
  14. package/dist/lib/node.d.ts +146 -0
  15. package/dist/lib/node.js +419 -0
  16. package/dist/lib/range.d.ts +104 -0
  17. package/dist/lib/range.js +385 -0
  18. package/dist/lib/ranges.d.ts +26 -0
  19. package/dist/lib/ranges.js +117 -0
  20. package/dist/lib/text.d.ts +62 -0
  21. package/dist/lib/text.js +248 -0
  22. package/dist/lib/title.d.ts +38 -0
  23. package/dist/lib/title.js +162 -0
  24. package/dist/mixin/attributesParent.js +94 -0
  25. package/dist/mixin/fixed.js +32 -0
  26. package/dist/mixin/flagsParent.js +70 -0
  27. package/dist/mixin/hidden.js +26 -0
  28. package/dist/mixin/magicLinkParent.js +41 -0
  29. package/dist/mixin/singleLine.js +25 -0
  30. package/dist/mixin/sol.js +43 -0
  31. package/dist/mixin/syntax.js +56 -0
  32. package/dist/parser/braces.js +121 -0
  33. package/dist/parser/commentAndExt.js +69 -0
  34. package/dist/parser/converter.js +40 -0
  35. package/dist/parser/externalLinks.js +28 -0
  36. package/dist/parser/hrAndDoubleUnderscore.js +38 -0
  37. package/dist/parser/html.js +36 -0
  38. package/dist/parser/links.js +94 -0
  39. package/dist/parser/list.js +59 -0
  40. package/dist/parser/magicLinks.js +40 -0
  41. package/dist/parser/quotes.js +67 -0
  42. package/dist/parser/selector.js +162 -0
  43. package/dist/parser/table.js +112 -0
  44. package/dist/src/arg.d.ts +58 -0
  45. package/dist/src/arg.js +189 -0
  46. package/dist/src/atom.d.ts +12 -0
  47. package/dist/src/atom.js +27 -0
  48. package/dist/src/attribute.d.ts +87 -0
  49. package/dist/src/attribute.js +392 -0
  50. package/dist/src/attributes.d.ts +107 -0
  51. package/dist/src/attributes.js +341 -0
  52. package/dist/src/converter.d.ts +52 -0
  53. package/dist/src/converter.js +79 -0
  54. package/dist/src/converterFlags.d.ts +87 -0
  55. package/dist/src/converterFlags.js +224 -0
  56. package/dist/src/converterRule.d.ts +81 -0
  57. package/dist/src/converterRule.js +212 -0
  58. package/dist/src/extLink.d.ts +54 -0
  59. package/dist/src/extLink.js +122 -0
  60. package/dist/src/gallery.d.ts +55 -0
  61. package/dist/src/gallery.js +122 -0
  62. package/dist/src/heading.d.ts +74 -0
  63. package/dist/src/heading.js +127 -0
  64. package/dist/src/hidden.d.ts +22 -0
  65. package/dist/src/hidden.js +23 -0
  66. package/dist/src/html.d.ts +101 -0
  67. package/dist/src/html.js +227 -0
  68. package/dist/src/imageParameter.d.ts +66 -0
  69. package/dist/src/imageParameter.js +247 -0
  70. package/dist/src/imagemap.d.ts +57 -0
  71. package/dist/src/imagemap.js +148 -0
  72. package/dist/src/imagemapLink.d.ts +59 -0
  73. package/dist/src/imagemapLink.js +40 -0
  74. package/dist/src/index.d.ts +146 -0
  75. package/dist/src/index.js +777 -0
  76. package/dist/src/link/base.d.ts +52 -0
  77. package/dist/src/link/base.js +209 -0
  78. package/dist/src/link/category.d.ts +13 -0
  79. package/dist/src/link/category.js +29 -0
  80. package/dist/src/link/file.d.ts +96 -0
  81. package/dist/src/link/file.js +255 -0
  82. package/dist/src/link/galleryImage.d.ts +44 -0
  83. package/dist/src/link/galleryImage.js +106 -0
  84. package/dist/src/link/index.d.ts +53 -0
  85. package/dist/src/link/index.js +123 -0
  86. package/dist/src/magicLink.d.ts +70 -0
  87. package/dist/src/magicLink.js +147 -0
  88. package/dist/src/nested.d.ts +44 -0
  89. package/dist/src/nested.js +87 -0
  90. package/dist/src/nowiki/base.d.ts +47 -0
  91. package/dist/src/nowiki/base.js +42 -0
  92. package/dist/src/nowiki/comment.d.ts +40 -0
  93. package/dist/src/nowiki/comment.js +67 -0
  94. package/dist/src/nowiki/dd.d.ts +8 -0
  95. package/dist/src/nowiki/dd.js +25 -0
  96. package/dist/src/nowiki/doubleUnderscore.d.ts +45 -0
  97. package/dist/src/nowiki/doubleUnderscore.js +50 -0
  98. package/dist/src/nowiki/hr.d.ts +31 -0
  99. package/dist/src/nowiki/hr.js +14 -0
  100. package/dist/src/nowiki/index.d.ts +16 -0
  101. package/dist/src/nowiki/index.js +21 -0
  102. package/dist/src/nowiki/list.d.ts +30 -0
  103. package/dist/src/nowiki/list.js +48 -0
  104. package/dist/src/nowiki/listBase.d.ts +19 -0
  105. package/dist/src/nowiki/listBase.js +12 -0
  106. package/dist/src/nowiki/noinclude.d.ts +26 -0
  107. package/dist/src/nowiki/noinclude.js +25 -0
  108. package/dist/src/nowiki/quote.d.ts +23 -0
  109. package/dist/src/nowiki/quote.js +45 -0
  110. package/dist/src/onlyinclude.d.ts +16 -0
  111. package/dist/src/onlyinclude.js +57 -0
  112. package/dist/src/paramTag/index.d.ts +37 -0
  113. package/dist/src/paramTag/index.js +68 -0
  114. package/dist/src/paramTag/inputbox.d.ts +8 -0
  115. package/dist/src/paramTag/inputbox.js +23 -0
  116. package/dist/src/parameter.d.ts +85 -0
  117. package/dist/src/parameter.js +205 -0
  118. package/dist/src/pre.d.ts +28 -0
  119. package/dist/src/pre.js +51 -0
  120. package/dist/src/syntax.d.ts +28 -0
  121. package/dist/src/syntax.js +34 -0
  122. package/dist/src/table/base.d.ts +53 -0
  123. package/dist/src/table/base.js +78 -0
  124. package/dist/src/table/index.d.ts +229 -0
  125. package/dist/src/table/index.js +379 -0
  126. package/dist/src/table/td.d.ts +104 -0
  127. package/dist/src/table/td.js +261 -0
  128. package/dist/src/table/tr.d.ts +32 -0
  129. package/dist/src/table/tr.js +56 -0
  130. package/dist/src/table/trBase.d.ts +54 -0
  131. package/dist/src/table/trBase.js +159 -0
  132. package/dist/src/tagPair/ext.d.ts +56 -0
  133. package/dist/src/tagPair/ext.js +142 -0
  134. package/dist/src/tagPair/include.d.ts +53 -0
  135. package/dist/src/tagPair/include.js +63 -0
  136. package/dist/src/tagPair/index.d.ts +48 -0
  137. package/dist/src/tagPair/index.js +93 -0
  138. package/dist/src/transclude.d.ts +167 -0
  139. package/dist/src/transclude.js +690 -0
  140. package/dist/util/constants.js +108 -0
  141. package/dist/util/debug.js +64 -0
  142. package/dist/util/diff.js +72 -0
  143. package/dist/util/lint.js +46 -0
  144. package/dist/util/string.js +61 -0
  145. package/errors/README +1 -0
  146. package/package.json +12 -32
  147. package/printed/README +1 -0
  148. package/bundle/bundle.min.js +0 -36
  149. package/extensions/dist/base.js +0 -68
  150. package/extensions/dist/editor.js +0 -159
  151. package/extensions/dist/highlight.js +0 -30
  152. package/extensions/dist/lint.js +0 -48
  153. package/extensions/editor.css +0 -63
  154. package/extensions/ui.css +0 -114
package/dist/index.js ADDED
@@ -0,0 +1,209 @@
1
+ "use strict";
2
+ /* eslint n/exports-style: 0 */
3
+ const fs = require("fs");
4
+ const path = require("path");
5
+ const diff_1 = require("./util/diff");
6
+ const debug_1 = require("./util/debug");
7
+ const constants_1 = require("./util/constants");
8
+ /**
9
+ * 从根路径require
10
+ * @param file 文件名
11
+ * @param dir 子路径
12
+ */
13
+ const rootRequire = (file, dir) => require(file.startsWith('/') ? file : `../${file.includes('/') ? '' : dir}${file}`);
14
+ /**
15
+ * 清理解析专用的不可见字符
16
+ * @param text 源文本
17
+ */
18
+ const tidy = (text) => text.replace(/[\0\x7F]/gu, '');
19
+ // eslint-disable-next-line @typescript-eslint/no-redeclare
20
+ const Parser = {
21
+ config: 'default',
22
+ i18n: undefined,
23
+ /* NOT FOR BROWSER */
24
+ Shadow: debug_1.Shadow,
25
+ conversionTable: new Map(),
26
+ redirects: new Map(),
27
+ warning: true,
28
+ debugging: false,
29
+ /* NOT FOR BROWSER END */
30
+ /** @implements */
31
+ getConfig() {
32
+ if (typeof this.config === 'string') {
33
+ this.config = rootRequire(this.config, 'config/');
34
+ const { config: { conversionTable, redirects } } = this;
35
+ if (conversionTable) {
36
+ this.conversionTable = new Map(conversionTable);
37
+ }
38
+ if (redirects) {
39
+ this.redirects = new Map(redirects);
40
+ }
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
+ debug_1.Shadow.run(() => {
65
+ for (const key of ['main', 'fragment']) {
66
+ if (titleObj[key]?.includes('\0')) {
67
+ titleObj[key] = token.buildFromStr(titleObj[key], 'text');
68
+ }
69
+ }
70
+ });
71
+ titleObj.conversionTable = this.conversionTable;
72
+ titleObj.redirects = this.redirects;
73
+ return titleObj;
74
+ },
75
+ /** @implements */
76
+ parse(wikitext, include, maxStage = constants_1.MAX_STAGE, config = Parser.getConfig()) {
77
+ const { Token } = require('./src/index');
78
+ const root = debug_1.Shadow.run(() => {
79
+ const token = new Token(tidy(wikitext), config);
80
+ try {
81
+ return token.parse(maxStage, include);
82
+ }
83
+ catch (e) {
84
+ if (e instanceof Error) {
85
+ const file = path.join(__dirname, '..', 'errors', new Date().toISOString()), stage = token.getAttribute('stage');
86
+ fs.writeFileSync(file, stage === constants_1.MAX_STAGE ? wikitext : String(token));
87
+ fs.writeFileSync(`${file}.err`, e.stack);
88
+ fs.writeFileSync(`${file}.json`, JSON.stringify({
89
+ stage, include: token.getAttribute('include'), config: this.config,
90
+ }, null, '\t'));
91
+ }
92
+ throw e;
93
+ }
94
+ });
95
+ if (this.debugging) {
96
+ let restored = String(root), process = '解析';
97
+ if (restored === wikitext) {
98
+ const entities = { lt: '<', gt: '>', amp: '&' };
99
+ restored = root.print().replace(/<[^<]+?>|&([lg]t|amp);/gu, (_, s) => s ? entities[s] : '');
100
+ process = '渲染HTML';
101
+ }
102
+ if (restored !== wikitext) {
103
+ const { diff } = require('./util/diff');
104
+ const { 0: cur, length } = constants_1.promises;
105
+ constants_1.promises.unshift((async () => {
106
+ await cur;
107
+ this.error(`${process}过程中不可逆地修改了原始文本!`);
108
+ return diff(wikitext, restored, length);
109
+ })());
110
+ }
111
+ }
112
+ return root;
113
+ },
114
+ /* NOT FOR BROWSER */
115
+ /** @implements */
116
+ warn(msg, ...args) {
117
+ if (this.warning) {
118
+ console.warn('\x1B[33m%s\x1B[0m', msg, ...args);
119
+ }
120
+ },
121
+ /** @implements */
122
+ debug(msg, ...args) {
123
+ if (this.debugging) {
124
+ console.debug('\x1B[34m%s\x1B[0m', msg, ...args);
125
+ }
126
+ },
127
+ /** @implements */
128
+ error(msg, ...args) {
129
+ console.error('\x1B[31m%s\x1B[0m', msg, ...args);
130
+ },
131
+ /** @implements */
132
+ info(msg, ...args) {
133
+ console.info('\x1B[32m%s\x1B[0m', msg, ...args);
134
+ },
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 new RegExp(`^(${interwiki.join('|')})\\s*:`, 'diu')
166
+ .exec(title.replaceAll('_', ' ').replace(/^\s*:?\s*/u, ''));
167
+ },
168
+ /** @implements */
169
+ reparse(date) {
170
+ const main = fs.readdirSync(path.join(__dirname, '..', 'errors'))
171
+ .find(name => name.startsWith(date) && name.endsWith('Z'));
172
+ if (!main) {
173
+ throw new RangeError(`找不到对应时间戳的错误记录:${date}`);
174
+ }
175
+ const file = path.join(__dirname, '..', 'errors', main), wikitext = fs.readFileSync(file, 'utf8');
176
+ const { stage, include, config } = require(`${file}.json`), { Token } = require('./src');
177
+ this.config = config;
178
+ return debug_1.Shadow.run(() => {
179
+ const halfParsed = stage < constants_1.MAX_STAGE, token = new Token(halfParsed ? wikitext : tidy(wikitext), this.getConfig());
180
+ if (halfParsed) {
181
+ token.setAttribute('stage', stage);
182
+ token.parseOnce(stage, include);
183
+ }
184
+ else {
185
+ token.parse(undefined, include);
186
+ }
187
+ fs.unlinkSync(file);
188
+ fs.unlinkSync(`${file}.err`);
189
+ fs.unlinkSync(`${file}.json`);
190
+ return token;
191
+ });
192
+ },
193
+ };
194
+ const def = {}, enumerable = new Set([
195
+ 'conversionTable',
196
+ 'redirects',
197
+ 'warning',
198
+ 'debugging',
199
+ 'normalizeTitle',
200
+ 'parse',
201
+ 'isInterwiki',
202
+ ]);
203
+ for (const key in Parser) {
204
+ if (!enumerable.has(key)) {
205
+ def[key] = { enumerable: false };
206
+ }
207
+ }
208
+ Object.defineProperties(Parser, def);
209
+ 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,155 @@
1
+ import { AstNode } from './node';
2
+ import type { LintError } from '../base';
3
+ import type { AstNodes, AstText, Token, HtmlToken, ExtToken } 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(): readonly 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 extends 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
+ */
89
+ json(file?: string): unknown;
90
+ /** 销毁 */
91
+ destroy(): void;
92
+ /**
93
+ * 检查是否符合选择器
94
+ * @param selector 选择器
95
+ */
96
+ matches(selector?: string): boolean;
97
+ /**
98
+ * 符合选择器的第一个后代节点
99
+ * @param selector 选择器
100
+ */
101
+ querySelector<T extends Token>(selector: string): T | undefined;
102
+ /**
103
+ * 类型选择器
104
+ * @param types
105
+ */
106
+ getElementByTypes<T extends Token>(types: string): T | undefined;
107
+ /**
108
+ * id选择器
109
+ * @param id id名
110
+ */
111
+ getElementById(id: string): Token | undefined;
112
+ /**
113
+ * 符合选择器的所有后代节点
114
+ * @param selector 选择器
115
+ */
116
+ querySelectorAll<T extends Token>(selector: string): readonly T[];
117
+ /**
118
+ * 类选择器
119
+ * @param className 类名之一
120
+ */
121
+ getElementsByClassName(className: string): readonly Token[];
122
+ /**
123
+ * 标签名选择器
124
+ * @param tag 标签名
125
+ */
126
+ getElementsByTagName(tag: string): readonly (HtmlToken | ExtToken)[];
127
+ /**
128
+ * 获取某一行的wikitext
129
+ * @param n 行号
130
+ */
131
+ getLine(n: number): string | undefined;
132
+ /**
133
+ * 在开头批量插入子节点
134
+ * @param elements 插入节点
135
+ */
136
+ prepend(...elements: (AstNodes | string)[]): void;
137
+ /**
138
+ * 移除子节点
139
+ * @param node 子节点
140
+ */
141
+ removeChild<T extends AstNodes>(node: T): T;
142
+ /**
143
+ * 在指定位置前插入子节点
144
+ * @param child 插入节点
145
+ * @param reference 指定位置处的子节点
146
+ */
147
+ insertBefore(child: string, reference?: AstNodes): AstText;
148
+ /** @ignore */
149
+ insertBefore<T extends AstNodes>(child: T, reference?: AstNodes): T;
150
+ /**
151
+ * 输出AST
152
+ * @param depth 当前深度
153
+ */
154
+ echo(depth?: number): void;
155
+ }