wikiparser-node 1.12.6 → 1.12.7-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 (174) 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/moegirl.json +21 -65
  6. package/config/zhwiki.json +28 -494
  7. package/extensions/dist/base.js +163 -0
  8. package/extensions/dist/codejar.js +53 -0
  9. package/extensions/dist/editor.js +159 -0
  10. package/extensions/dist/highlight.js +30 -0
  11. package/extensions/dist/lint.js +72 -0
  12. package/extensions/editor.css +59 -0
  13. package/extensions/ui.css +162 -0
  14. package/package.json +28 -21
  15. package/config/.schema.json +0 -203
  16. package/dist/addon/table.js +0 -494
  17. package/dist/addon/token.js +0 -392
  18. package/dist/addon/transclude.js +0 -184
  19. package/dist/base.d.ts +0 -82
  20. package/dist/base.js +0 -40
  21. package/dist/index.d.ts +0 -33
  22. package/dist/index.js +0 -275
  23. package/dist/internal.d.ts +0 -47
  24. package/dist/lib/element.d.ts +0 -125
  25. package/dist/lib/element.js +0 -377
  26. package/dist/lib/node.d.ts +0 -173
  27. package/dist/lib/node.js +0 -478
  28. package/dist/lib/range.d.ts +0 -105
  29. package/dist/lib/range.js +0 -406
  30. package/dist/lib/ranges.d.ts +0 -28
  31. package/dist/lib/ranges.js +0 -126
  32. package/dist/lib/rect.d.ts +0 -18
  33. package/dist/lib/rect.js +0 -36
  34. package/dist/lib/text.d.ts +0 -58
  35. package/dist/lib/text.js +0 -414
  36. package/dist/lib/title.d.ts +0 -49
  37. package/dist/lib/title.js +0 -253
  38. package/dist/mixin/attributesParent.d.ts +0 -49
  39. package/dist/mixin/attributesParent.js +0 -80
  40. package/dist/mixin/fixed.d.ts +0 -5
  41. package/dist/mixin/fixed.js +0 -32
  42. package/dist/mixin/flagsParent.d.ts +0 -43
  43. package/dist/mixin/flagsParent.js +0 -64
  44. package/dist/mixin/hidden.d.ts +0 -7
  45. package/dist/mixin/hidden.js +0 -39
  46. package/dist/mixin/magicLinkParent.d.ts +0 -19
  47. package/dist/mixin/magicLinkParent.js +0 -43
  48. package/dist/mixin/singleLine.d.ts +0 -5
  49. package/dist/mixin/singleLine.js +0 -25
  50. package/dist/mixin/sol.d.ts +0 -6
  51. package/dist/mixin/sol.js +0 -45
  52. package/dist/mixin/syntax.d.ts +0 -8
  53. package/dist/mixin/syntax.js +0 -46
  54. package/dist/parser/braces.js +0 -152
  55. package/dist/parser/commentAndExt.js +0 -84
  56. package/dist/parser/converter.js +0 -41
  57. package/dist/parser/externalLinks.js +0 -39
  58. package/dist/parser/hrAndDoubleUnderscore.js +0 -44
  59. package/dist/parser/html.js +0 -40
  60. package/dist/parser/links.js +0 -103
  61. package/dist/parser/list.js +0 -116
  62. package/dist/parser/magicLinks.js +0 -55
  63. package/dist/parser/quotes.js +0 -69
  64. package/dist/parser/redirect.js +0 -28
  65. package/dist/parser/selector.js +0 -393
  66. package/dist/parser/table.js +0 -125
  67. package/dist/src/arg.d.ts +0 -49
  68. package/dist/src/arg.js +0 -220
  69. package/dist/src/atom.d.ts +0 -14
  70. package/dist/src/atom.js +0 -54
  71. package/dist/src/attribute.d.ts +0 -64
  72. package/dist/src/attribute.js +0 -482
  73. package/dist/src/attributes.d.ts +0 -103
  74. package/dist/src/attributes.js +0 -380
  75. package/dist/src/converter.d.ts +0 -28
  76. package/dist/src/converter.js +0 -153
  77. package/dist/src/converterFlags.d.ts +0 -80
  78. package/dist/src/converterFlags.js +0 -241
  79. package/dist/src/converterRule.d.ts +0 -71
  80. package/dist/src/converterRule.js +0 -218
  81. package/dist/src/extLink.d.ts +0 -36
  82. package/dist/src/extLink.js +0 -223
  83. package/dist/src/gallery.d.ts +0 -51
  84. package/dist/src/gallery.js +0 -166
  85. package/dist/src/heading.d.ts +0 -44
  86. package/dist/src/heading.js +0 -222
  87. package/dist/src/hidden.d.ts +0 -9
  88. package/dist/src/hidden.js +0 -82
  89. package/dist/src/html.d.ts +0 -61
  90. package/dist/src/html.js +0 -344
  91. package/dist/src/imageParameter.d.ts +0 -60
  92. package/dist/src/imageParameter.js +0 -262
  93. package/dist/src/imagemap.d.ts +0 -47
  94. package/dist/src/imagemap.js +0 -148
  95. package/dist/src/imagemapLink.d.ts +0 -35
  96. package/dist/src/imagemapLink.js +0 -99
  97. package/dist/src/index.d.ts +0 -136
  98. package/dist/src/index.js +0 -790
  99. package/dist/src/link/base.d.ts +0 -52
  100. package/dist/src/link/base.js +0 -258
  101. package/dist/src/link/category.d.ts +0 -22
  102. package/dist/src/link/category.js +0 -36
  103. package/dist/src/link/file.d.ts +0 -102
  104. package/dist/src/link/file.js +0 -345
  105. package/dist/src/link/galleryImage.d.ts +0 -29
  106. package/dist/src/link/galleryImage.js +0 -133
  107. package/dist/src/link/index.d.ts +0 -39
  108. package/dist/src/link/index.js +0 -100
  109. package/dist/src/link/redirectTarget.d.ts +0 -27
  110. package/dist/src/link/redirectTarget.js +0 -71
  111. package/dist/src/magicLink.d.ts +0 -57
  112. package/dist/src/magicLink.js +0 -261
  113. package/dist/src/nested.d.ts +0 -40
  114. package/dist/src/nested.js +0 -108
  115. package/dist/src/nowiki/base.d.ts +0 -28
  116. package/dist/src/nowiki/base.js +0 -90
  117. package/dist/src/nowiki/comment.d.ts +0 -14
  118. package/dist/src/nowiki/comment.js +0 -123
  119. package/dist/src/nowiki/dd.d.ts +0 -8
  120. package/dist/src/nowiki/dd.js +0 -74
  121. package/dist/src/nowiki/doubleUnderscore.d.ts +0 -15
  122. package/dist/src/nowiki/doubleUnderscore.js +0 -101
  123. package/dist/src/nowiki/hr.d.ts +0 -5
  124. package/dist/src/nowiki/hr.js +0 -72
  125. package/dist/src/nowiki/index.d.ts +0 -14
  126. package/dist/src/nowiki/index.js +0 -30
  127. package/dist/src/nowiki/list.d.ts +0 -5
  128. package/dist/src/nowiki/list.js +0 -67
  129. package/dist/src/nowiki/listBase.d.ts +0 -23
  130. package/dist/src/nowiki/listBase.js +0 -100
  131. package/dist/src/nowiki/noinclude.d.ts +0 -6
  132. package/dist/src/nowiki/noinclude.js +0 -77
  133. package/dist/src/nowiki/quote.d.ts +0 -14
  134. package/dist/src/nowiki/quote.js +0 -149
  135. package/dist/src/onlyinclude.d.ts +0 -13
  136. package/dist/src/onlyinclude.js +0 -60
  137. package/dist/src/paramTag/index.d.ts +0 -28
  138. package/dist/src/paramTag/index.js +0 -80
  139. package/dist/src/paramTag/inputbox.d.ts +0 -8
  140. package/dist/src/paramTag/inputbox.js +0 -24
  141. package/dist/src/parameter.d.ts +0 -60
  142. package/dist/src/parameter.js +0 -267
  143. package/dist/src/pre.d.ts +0 -28
  144. package/dist/src/pre.js +0 -62
  145. package/dist/src/redirect.d.ts +0 -30
  146. package/dist/src/redirect.js +0 -128
  147. package/dist/src/syntax.d.ts +0 -15
  148. package/dist/src/syntax.js +0 -87
  149. package/dist/src/table/base.d.ts +0 -28
  150. package/dist/src/table/base.js +0 -81
  151. package/dist/src/table/index.d.ts +0 -230
  152. package/dist/src/table/index.js +0 -506
  153. package/dist/src/table/td.d.ts +0 -72
  154. package/dist/src/table/td.js +0 -375
  155. package/dist/src/table/tr.d.ts +0 -30
  156. package/dist/src/table/tr.js +0 -61
  157. package/dist/src/table/trBase.d.ts +0 -49
  158. package/dist/src/table/trBase.js +0 -165
  159. package/dist/src/tagPair/ext.d.ts +0 -29
  160. package/dist/src/tagPair/ext.js +0 -229
  161. package/dist/src/tagPair/include.d.ts +0 -33
  162. package/dist/src/tagPair/include.js +0 -132
  163. package/dist/src/tagPair/index.d.ts +0 -23
  164. package/dist/src/tagPair/index.js +0 -130
  165. package/dist/src/transclude.d.ts +0 -159
  166. package/dist/src/transclude.js +0 -598
  167. package/dist/util/constants.js +0 -26
  168. package/dist/util/debug.js +0 -95
  169. package/dist/util/diff.js +0 -83
  170. package/dist/util/html.js +0 -146
  171. package/dist/util/lint.js +0 -32
  172. package/dist/util/string.js +0 -107
  173. package/errors/README +0 -3
  174. 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, TokenTypes, 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, TokenTypes };
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
- }