wikiparser-node 1.12.4 → 1.12.5-b

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 (175) hide show
  1. package/bundle/bundle.min.js +37 -0
  2. package/config/default.json +29 -30
  3. package/config/enwiki.json +15 -829
  4. package/config/llwiki.json +21 -56
  5. package/config/minimum.json +6 -1
  6. package/config/moegirl.json +21 -65
  7. package/config/zhwiki.json +28 -494
  8. package/extensions/dist/base.js +163 -0
  9. package/extensions/dist/codejar.js +52 -0
  10. package/extensions/dist/editor.js +159 -0
  11. package/extensions/dist/highlight.js +30 -0
  12. package/extensions/dist/lint.js +72 -0
  13. package/extensions/editor.css +59 -0
  14. package/extensions/ui.css +162 -0
  15. package/package.json +28 -21
  16. package/config/.schema.json +0 -203
  17. package/dist/addon/table.js +0 -494
  18. package/dist/addon/token.js +0 -392
  19. package/dist/addon/transclude.js +0 -184
  20. package/dist/base.d.ts +0 -81
  21. package/dist/base.js +0 -40
  22. package/dist/index.d.ts +0 -33
  23. package/dist/index.js +0 -275
  24. package/dist/internal.d.ts +0 -47
  25. package/dist/lib/element.d.ts +0 -125
  26. package/dist/lib/element.js +0 -377
  27. package/dist/lib/node.d.ts +0 -173
  28. package/dist/lib/node.js +0 -478
  29. package/dist/lib/range.d.ts +0 -105
  30. package/dist/lib/range.js +0 -406
  31. package/dist/lib/ranges.d.ts +0 -28
  32. package/dist/lib/ranges.js +0 -126
  33. package/dist/lib/rect.d.ts +0 -18
  34. package/dist/lib/rect.js +0 -36
  35. package/dist/lib/text.d.ts +0 -58
  36. package/dist/lib/text.js +0 -414
  37. package/dist/lib/title.d.ts +0 -49
  38. package/dist/lib/title.js +0 -253
  39. package/dist/mixin/attributesParent.d.ts +0 -49
  40. package/dist/mixin/attributesParent.js +0 -80
  41. package/dist/mixin/fixed.d.ts +0 -5
  42. package/dist/mixin/fixed.js +0 -32
  43. package/dist/mixin/flagsParent.d.ts +0 -43
  44. package/dist/mixin/flagsParent.js +0 -64
  45. package/dist/mixin/hidden.d.ts +0 -7
  46. package/dist/mixin/hidden.js +0 -39
  47. package/dist/mixin/magicLinkParent.d.ts +0 -19
  48. package/dist/mixin/magicLinkParent.js +0 -43
  49. package/dist/mixin/singleLine.d.ts +0 -5
  50. package/dist/mixin/singleLine.js +0 -25
  51. package/dist/mixin/sol.d.ts +0 -6
  52. package/dist/mixin/sol.js +0 -45
  53. package/dist/mixin/syntax.d.ts +0 -8
  54. package/dist/mixin/syntax.js +0 -46
  55. package/dist/parser/braces.js +0 -152
  56. package/dist/parser/commentAndExt.js +0 -84
  57. package/dist/parser/converter.js +0 -41
  58. package/dist/parser/externalLinks.js +0 -39
  59. package/dist/parser/hrAndDoubleUnderscore.js +0 -44
  60. package/dist/parser/html.js +0 -40
  61. package/dist/parser/links.js +0 -103
  62. package/dist/parser/list.js +0 -116
  63. package/dist/parser/magicLinks.js +0 -55
  64. package/dist/parser/quotes.js +0 -69
  65. package/dist/parser/redirect.js +0 -28
  66. package/dist/parser/selector.js +0 -393
  67. package/dist/parser/table.js +0 -125
  68. package/dist/src/arg.d.ts +0 -49
  69. package/dist/src/arg.js +0 -219
  70. package/dist/src/atom.d.ts +0 -14
  71. package/dist/src/atom.js +0 -54
  72. package/dist/src/attribute.d.ts +0 -64
  73. package/dist/src/attribute.js +0 -478
  74. package/dist/src/attributes.d.ts +0 -103
  75. package/dist/src/attributes.js +0 -380
  76. package/dist/src/converter.d.ts +0 -28
  77. package/dist/src/converter.js +0 -153
  78. package/dist/src/converterFlags.d.ts +0 -80
  79. package/dist/src/converterFlags.js +0 -241
  80. package/dist/src/converterRule.d.ts +0 -71
  81. package/dist/src/converterRule.js +0 -218
  82. package/dist/src/extLink.d.ts +0 -36
  83. package/dist/src/extLink.js +0 -223
  84. package/dist/src/gallery.d.ts +0 -47
  85. package/dist/src/gallery.js +0 -145
  86. package/dist/src/heading.d.ts +0 -44
  87. package/dist/src/heading.js +0 -222
  88. package/dist/src/hidden.d.ts +0 -9
  89. package/dist/src/hidden.js +0 -82
  90. package/dist/src/html.d.ts +0 -61
  91. package/dist/src/html.js +0 -344
  92. package/dist/src/imageParameter.d.ts +0 -60
  93. package/dist/src/imageParameter.js +0 -262
  94. package/dist/src/imagemap.d.ts +0 -47
  95. package/dist/src/imagemap.js +0 -148
  96. package/dist/src/imagemapLink.d.ts +0 -35
  97. package/dist/src/imagemapLink.js +0 -99
  98. package/dist/src/index.d.ts +0 -136
  99. package/dist/src/index.js +0 -790
  100. package/dist/src/link/base.d.ts +0 -52
  101. package/dist/src/link/base.js +0 -258
  102. package/dist/src/link/category.d.ts +0 -22
  103. package/dist/src/link/category.js +0 -36
  104. package/dist/src/link/file.d.ts +0 -102
  105. package/dist/src/link/file.js +0 -335
  106. package/dist/src/link/galleryImage.d.ts +0 -29
  107. package/dist/src/link/galleryImage.js +0 -133
  108. package/dist/src/link/index.d.ts +0 -39
  109. package/dist/src/link/index.js +0 -100
  110. package/dist/src/link/redirectTarget.d.ts +0 -27
  111. package/dist/src/link/redirectTarget.js +0 -71
  112. package/dist/src/magicLink.d.ts +0 -57
  113. package/dist/src/magicLink.js +0 -261
  114. package/dist/src/nested.d.ts +0 -40
  115. package/dist/src/nested.js +0 -108
  116. package/dist/src/nowiki/base.d.ts +0 -28
  117. package/dist/src/nowiki/base.js +0 -90
  118. package/dist/src/nowiki/comment.d.ts +0 -14
  119. package/dist/src/nowiki/comment.js +0 -123
  120. package/dist/src/nowiki/dd.d.ts +0 -8
  121. package/dist/src/nowiki/dd.js +0 -74
  122. package/dist/src/nowiki/doubleUnderscore.d.ts +0 -15
  123. package/dist/src/nowiki/doubleUnderscore.js +0 -101
  124. package/dist/src/nowiki/hr.d.ts +0 -5
  125. package/dist/src/nowiki/hr.js +0 -72
  126. package/dist/src/nowiki/index.d.ts +0 -14
  127. package/dist/src/nowiki/index.js +0 -30
  128. package/dist/src/nowiki/list.d.ts +0 -5
  129. package/dist/src/nowiki/list.js +0 -67
  130. package/dist/src/nowiki/listBase.d.ts +0 -23
  131. package/dist/src/nowiki/listBase.js +0 -100
  132. package/dist/src/nowiki/noinclude.d.ts +0 -6
  133. package/dist/src/nowiki/noinclude.js +0 -77
  134. package/dist/src/nowiki/quote.d.ts +0 -14
  135. package/dist/src/nowiki/quote.js +0 -149
  136. package/dist/src/onlyinclude.d.ts +0 -13
  137. package/dist/src/onlyinclude.js +0 -60
  138. package/dist/src/paramTag/index.d.ts +0 -28
  139. package/dist/src/paramTag/index.js +0 -80
  140. package/dist/src/paramTag/inputbox.d.ts +0 -8
  141. package/dist/src/paramTag/inputbox.js +0 -24
  142. package/dist/src/parameter.d.ts +0 -60
  143. package/dist/src/parameter.js +0 -267
  144. package/dist/src/pre.d.ts +0 -28
  145. package/dist/src/pre.js +0 -62
  146. package/dist/src/redirect.d.ts +0 -30
  147. package/dist/src/redirect.js +0 -128
  148. package/dist/src/syntax.d.ts +0 -15
  149. package/dist/src/syntax.js +0 -87
  150. package/dist/src/table/base.d.ts +0 -28
  151. package/dist/src/table/base.js +0 -81
  152. package/dist/src/table/index.d.ts +0 -230
  153. package/dist/src/table/index.js +0 -506
  154. package/dist/src/table/td.d.ts +0 -72
  155. package/dist/src/table/td.js +0 -375
  156. package/dist/src/table/tr.d.ts +0 -30
  157. package/dist/src/table/tr.js +0 -61
  158. package/dist/src/table/trBase.d.ts +0 -49
  159. package/dist/src/table/trBase.js +0 -165
  160. package/dist/src/tagPair/ext.d.ts +0 -29
  161. package/dist/src/tagPair/ext.js +0 -217
  162. package/dist/src/tagPair/include.d.ts +0 -33
  163. package/dist/src/tagPair/include.js +0 -132
  164. package/dist/src/tagPair/index.d.ts +0 -23
  165. package/dist/src/tagPair/index.js +0 -130
  166. package/dist/src/transclude.d.ts +0 -159
  167. package/dist/src/transclude.js +0 -598
  168. package/dist/util/constants.js +0 -26
  169. package/dist/util/debug.js +0 -95
  170. package/dist/util/diff.js +0 -83
  171. package/dist/util/html.js +0 -146
  172. package/dist/util/lint.js +0 -32
  173. package/dist/util/string.js +0 -107
  174. package/errors/README +0 -3
  175. package/printed/README +0 -3
package/dist/base.js DELETED
@@ -1,40 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.rules = void 0;
4
- exports.rules = [
5
- 'bold-header',
6
- 'format-leakage',
7
- 'fostered-content',
8
- 'h1',
9
- 'illegal-attr',
10
- 'insecure-style',
11
- 'invalid-gallery',
12
- 'invalid-imagemap',
13
- 'invalid-invoke',
14
- 'invalid-isbn',
15
- 'lonely-apos',
16
- 'lonely-bracket',
17
- 'lonely-http',
18
- 'nested-link',
19
- 'no-arg',
20
- 'no-duplicate',
21
- 'no-ignored',
22
- 'obsolete-attr',
23
- 'obsolete-tag',
24
- 'parsing-order',
25
- 'pipe-like',
26
- 'table-layout',
27
- 'tag-like',
28
- 'unbalanced-header',
29
- 'unclosed-comment',
30
- 'unclosed-quote',
31
- 'unclosed-table',
32
- 'unescaped',
33
- 'unknown-page',
34
- 'unmatched-tag',
35
- 'unterminated-url',
36
- 'url-encoding',
37
- 'var-anchor',
38
- 'void-ext',
39
- ];
40
- Object.freeze(exports.rules);
package/dist/index.d.ts DELETED
@@ -1,33 +0,0 @@
1
- import type { Config, LintError, Parser as ParserBase } from './base';
2
- import type { Title } from './lib/title';
3
- import type { Token } from './internal';
4
- declare interface Parser extends ParserBase {
5
- rules: readonly LintError.Rule[];
6
- viewOnly: boolean;
7
- conversionTable: Map<string, string>;
8
- redirects: Map<string, string>;
9
- templateDir?: string;
10
- templates: Map<string, string>;
11
- warning: boolean;
12
- debugging: boolean;
13
- /**
14
- * 规范化页面标题
15
- * @param title 标题(含或不含命名空间前缀)
16
- * @param defaultNs 命名空间
17
- * @param include 是否嵌入
18
- */
19
- normalizeTitle(title: string, defaultNs?: number, include?: boolean, config?: Config): 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
- // @ts-expect-error mixed export styles
29
- export = Parser;
30
- export default Parser;
31
- export type { Config, LintError };
32
- export type * from './internal';
33
- declare global { type Acceptable = unknown; }
package/dist/index.js DELETED
@@ -1,275 +0,0 @@
1
- "use strict";
2
- /* eslint n/exports-style: 0 */
3
- const fs = require("fs");
4
- const path = require("path");
5
- const base_1 = require("./base");
6
- const debug_1 = require("./util/debug");
7
- const constants_1 = require("./util/constants");
8
- const string_1 = require("./util/string");
9
- /* NOT FOR BROWSER */
10
- const chalk = require("chalk");
11
- const diff_1 = require("./util/diff");
12
- /**
13
- * 从根路径require
14
- * @param file 文件名
15
- * @param dir 子路径
16
- */
17
- const rootRequire = (file, dir) => require(path.isAbsolute(file) ? file : path.join('..', file.includes('/') ? '' : dir, file));
18
- /* NOT FOR BROWSER */
19
- /**
20
- * 快速规范化页面标题
21
- * @param title 标题
22
- */
23
- const normalizeTitle = (title) => String(Parser.normalizeTitle(title));
24
- /** 重定向列表 */
25
- class RedirectMap extends Map {
26
- /** @ignore */
27
- constructor(entries) {
28
- super();
29
- if (entries) {
30
- for (const [k, v] of entries) {
31
- this.set(k, v);
32
- }
33
- }
34
- }
35
- set(key, value) {
36
- return super.set(normalizeTitle(key), normalizeTitle(value));
37
- }
38
- }
39
- const promises = [Promise.resolve()];
40
- let viewOnly = false, redirectMap = new RedirectMap();
41
- /* NOT FOR BROWSER END */
42
- const Parser = {
43
- config: 'default',
44
- i18n: undefined,
45
- rules: base_1.rules,
46
- /* NOT FOR BROWSER */
47
- /** @implements */
48
- get viewOnly() {
49
- return viewOnly;
50
- },
51
- set viewOnly(value) {
52
- if (viewOnly && !value) {
53
- debug_1.Shadow.rev++;
54
- }
55
- viewOnly = value;
56
- },
57
- /** @implements */
58
- get redirects() {
59
- return redirectMap;
60
- },
61
- set redirects(redirects) {
62
- redirectMap = new RedirectMap(redirects);
63
- },
64
- conversionTable: new Map(),
65
- templates: new Map(),
66
- warning: true,
67
- debugging: false,
68
- /* NOT FOR BROWSER END */
69
- /** @implements */
70
- getConfig() {
71
- if (typeof this.config === 'string') {
72
- this.config = rootRequire(this.config, 'config');
73
- /* NOT FOR BROWSER */
74
- const { config: { conversionTable, redirects } } = this;
75
- if (conversionTable) {
76
- this.conversionTable = new Map(conversionTable);
77
- }
78
- if (redirects) {
79
- this.redirects = new Map(redirects);
80
- }
81
- /* NOT FOR BROWSER END */
82
- return this.getConfig();
83
- }
84
- const { doubleUnderscore } = this.config;
85
- if (doubleUnderscore.length === 2) {
86
- (0, diff_1.error)(`The schema (${path.resolve(__dirname, '..', 'config', '.schema.json')}) of parser configuration is updated.`);
87
- }
88
- else if (doubleUnderscore[0].length === 0) {
89
- doubleUnderscore[0] = Object.keys(doubleUnderscore[2]);
90
- }
91
- return {
92
- ...this.config,
93
- excludes: [],
94
- };
95
- },
96
- /** @implements */
97
- msg(msg, arg = '') {
98
- if (typeof this.i18n === 'string') {
99
- this.i18n = rootRequire(this.i18n, 'i18n');
100
- return this.msg(msg, arg);
101
- }
102
- return msg && (this.i18n?.[msg] ?? msg).replace('$1', this.msg(arg));
103
- },
104
- /** @implements */
105
- normalizeTitle(title, defaultNs = 0, include, config = Parser.getConfig(), halfParsed, decode = false, selfLink = false) {
106
- const { Title } = require('./lib/title');
107
- let titleObj;
108
- if (halfParsed) {
109
- titleObj = new Title(title, defaultNs, config, decode, selfLink);
110
- }
111
- else {
112
- const { Token } = require('./src/index');
113
- titleObj = debug_1.Shadow.run(() => {
114
- const root = new Token(title, config);
115
- root.type = 'root';
116
- root.parseOnce(0, include).parseOnce();
117
- const t = new Title(root.toString(), defaultNs, config, decode, selfLink);
118
- for (const key of ['main', 'fragment']) {
119
- const str = t[key];
120
- if (str?.includes('\0')) {
121
- const s = root.buildFromStr(str, constants_1.BuildMethod.Text);
122
- if (key === 'main') {
123
- t.main = s;
124
- }
125
- else {
126
- t.setFragment(s);
127
- }
128
- }
129
- }
130
- return t;
131
- });
132
- }
133
- /* NOT FOR BROWSER */
134
- titleObj.conversionTable = this.conversionTable;
135
- titleObj.redirects = this.redirects;
136
- /* NOT FOR BROWSER END */
137
- return titleObj;
138
- },
139
- /** @implements */
140
- parse(wikitext, include, maxStage = constants_1.MAX_STAGE, config = Parser.getConfig()) {
141
- wikitext = (0, string_1.tidy)(wikitext);
142
- const { Token } = require('./src/index');
143
- const root = debug_1.Shadow.run(() => {
144
- const token = new Token(wikitext, config);
145
- token.type = 'root';
146
- try {
147
- return token.parse(maxStage, include);
148
- }
149
- catch (e) {
150
- if (e instanceof Error) {
151
- const file = path.join(__dirname, '..', 'errors', new Date().toISOString()), stage = token.getAttribute('stage');
152
- fs.writeFileSync(file, stage === constants_1.MAX_STAGE ? wikitext : token.toString());
153
- fs.writeFileSync(`${file}.err`, e.stack);
154
- fs.writeFileSync(`${file}.json`, JSON.stringify({ stage, include, config }, null, '\t'));
155
- }
156
- throw e;
157
- }
158
- });
159
- /* NOT FOR BROWSER */
160
- if (this.debugging) {
161
- let restored = root.toString(), process = 'parsing';
162
- if (restored === wikitext) {
163
- const entities = { lt: '<', gt: '>', amp: '&' };
164
- restored = root.print().replace(/<[^<]+?>|&([lg]t|amp);/gu, (_, s) => s ? entities[s] : '');
165
- process = 'printing';
166
- }
167
- if (restored !== wikitext) {
168
- const { 0: cur, length } = promises;
169
- promises.unshift((async () => {
170
- await cur;
171
- this.error(`Original wikitext is altered when ${process}!`);
172
- return (0, diff_1.diff)(wikitext, restored, length);
173
- })());
174
- }
175
- }
176
- /* NOT FOR BROWSER END */
177
- return root;
178
- },
179
- /* NOT FOR BROWSER */
180
- /** @implements */
181
- warn(msg, ...args) {
182
- if (this.warning) {
183
- console.warn(chalk.yellow(msg), ...args);
184
- }
185
- },
186
- /** @implements */
187
- debug(msg, ...args) {
188
- if (this.debugging) {
189
- console.debug(chalk.blue(msg), ...args);
190
- }
191
- },
192
- error: diff_1.error,
193
- info: diff_1.info,
194
- /** @implements */
195
- log(f) {
196
- if (typeof f === 'function') {
197
- console.log(String(f));
198
- }
199
- },
200
- /** @implements */
201
- require(name) {
202
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
203
- return Object.hasOwn(constants_1.classes, name) ? require(constants_1.classes[name])[name] : require(path.join(__dirname, name));
204
- },
205
- /** @implements */
206
- async clearCache() {
207
- await (0, diff_1.cmd)('npm', ['--prefix', path.join(__dirname, '..'), 'run', 'build:core']);
208
- const entries = Object.entries(constants_1.classes);
209
- for (const [, filePath] of entries) {
210
- try {
211
- delete require.cache[require.resolve(filePath)];
212
- }
213
- catch { }
214
- }
215
- for (const [name, filePath] of entries) {
216
- if (name in global) {
217
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
218
- Object.assign(global, { [name]: require(filePath)[name] });
219
- }
220
- }
221
- this.info('已重新加载Parser');
222
- },
223
- /** @implements */
224
- isInterwiki(title, { interwiki } = Parser.getConfig()) {
225
- // eslint-disable-next-line @typescript-eslint/no-unused-expressions
226
- /^(zh|en)\s*:/diu;
227
- return interwiki.length > 0
228
- ? new RegExp(String.raw `^(${interwiki.join('|')})\s*:`, 'diu')
229
- .exec(title.replaceAll('_', ' ').replace(/^\s*:?\s*/u, ''))
230
- : null;
231
- },
232
- /** @implements */
233
- reparse(date = '') {
234
- const main = fs.readdirSync(path.join(__dirname, '..', 'errors'))
235
- .find(name => name.startsWith(date) && name.endsWith('Z'));
236
- if (!main) {
237
- throw new RangeError(`找不到对应时间戳的错误记录:${date}`);
238
- }
239
- const file = path.join(__dirname, '..', 'errors', main), wikitext = fs.readFileSync(file, 'utf8');
240
- const { stage, include, config } = require(`${file}.json`), { Token } = require('./src/index');
241
- debug_1.Shadow.run(() => {
242
- const halfParsed = stage < constants_1.MAX_STAGE, token = new Token(halfParsed ? wikitext : (0, string_1.tidy)(wikitext), config);
243
- token.type = 'root';
244
- if (halfParsed) {
245
- token.setAttribute('stage', stage);
246
- token.parseOnce(stage, include);
247
- }
248
- else {
249
- token.parse(undefined, include);
250
- }
251
- fs.unlinkSync(file);
252
- fs.unlinkSync(`${file}.err`);
253
- fs.unlinkSync(`${file}.json`);
254
- });
255
- },
256
- };
257
- const def = {
258
- default: { value: Parser },
259
- }, enumerable = new Set([
260
- 'normalizeTitle',
261
- 'parse',
262
- /* NOT FOR BROWSER */
263
- 'conversionTable',
264
- 'warning',
265
- 'debugging',
266
- 'isInterwiki',
267
- ]);
268
- for (const key in Parser) {
269
- if (!enumerable.has(key)) {
270
- def[key] = { enumerable: false };
271
- }
272
- }
273
- Object.defineProperties(Parser, def);
274
- exports.default = Parser;
275
- module.exports = Parser;
@@ -1,47 +0,0 @@
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 { ListRangeToken } from './src/nowiki/listBase';
35
- export type * from './src/nowiki/dd';
36
- export type * from './src/nowiki/list';
37
- export type * from './src/converterFlags';
38
- export type * from './src/converterRule';
39
- export type * from './src/converter';
40
- export type * from './src/nowiki/index';
41
- export type * from './src/pre';
42
- export type * from './src/paramTag/index';
43
- export type * from './src/paramTag/inputbox';
44
- export type * from './src/nested';
45
- export type * from './src/gallery';
46
- export type * from './src/imagemapLink';
47
- export type * from './src/imagemap';
@@ -1,125 +0,0 @@
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
- }