wikiparser-node 1.27.0 → 1.28.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 (101) hide show
  1. package/bundle/bundle-es8.min.js +25 -25
  2. package/bundle/bundle-lsp.min.js +29 -29
  3. package/bundle/bundle.min.js +24 -25
  4. package/dist/addon/token.js +1 -1
  5. package/dist/base.d.mts +1 -1
  6. package/dist/base.d.ts +1 -1
  7. package/dist/bin/config.js +1 -1
  8. package/dist/index.d.ts +2 -1
  9. package/dist/index.js +2 -3
  10. package/dist/internal.d.ts +5 -5
  11. package/dist/lib/lintConfig.js +5 -5
  12. package/dist/lib/lsp.d.ts +1 -1
  13. package/dist/lib/lsp.js +1 -1
  14. package/dist/lib/node.js +51 -40
  15. package/dist/mixin/attributesParent.js +59 -57
  16. package/dist/mixin/elementLike.js +77 -75
  17. package/dist/mixin/hidden.js +3 -3
  18. package/dist/mixin/nodeLike.js +2 -2
  19. package/dist/mixin/padded.js +9 -7
  20. package/dist/mixin/singleLine.d.ts +1 -1
  21. package/dist/mixin/singleLine.js +10 -11
  22. package/dist/parser/commentAndExt.js +1 -1
  23. package/dist/parser/html.js +1 -1
  24. package/dist/parser/selector.js +2 -1
  25. package/dist/src/arg.js +2 -2
  26. package/dist/src/atom.d.ts +1 -1
  27. package/dist/src/atom.js +0 -1
  28. package/dist/src/attribute.d.ts +5 -7
  29. package/dist/src/attribute.js +17 -8
  30. package/dist/src/attributes.d.ts +7 -8
  31. package/dist/src/attributes.js +5 -3
  32. package/dist/src/commented.d.ts +3 -3
  33. package/dist/src/converterRule.js +1 -1
  34. package/dist/src/heading.js +1 -1
  35. package/dist/src/imageParameter.d.ts +0 -8
  36. package/dist/src/imageParameter.js +7 -6
  37. package/dist/src/imagemapLink.js +1 -1
  38. package/dist/src/index.d.ts +0 -5
  39. package/dist/src/index.js +2 -5
  40. package/dist/src/link/base.js +1 -2
  41. package/dist/src/link/category.js +1 -2
  42. package/dist/src/link/file.js +8 -7
  43. package/dist/src/link/galleryImage.d.ts +0 -3
  44. package/dist/src/link/galleryImage.js +3 -2
  45. package/dist/src/link/index.js +1 -1
  46. package/dist/src/magicLink.d.ts +0 -7
  47. package/dist/src/multiLine/gallery.d.ts +49 -0
  48. package/dist/src/{gallery.js → multiLine/gallery.js} +24 -37
  49. package/dist/src/multiLine/imagemap.d.ts +25 -0
  50. package/dist/src/{imagemap.js → multiLine/imagemap.js} +20 -36
  51. package/dist/src/multiLine/index.d.ts +17 -0
  52. package/dist/src/multiLine/index.js +36 -0
  53. package/dist/src/{paramTag → multiLine}/inputbox.d.ts +1 -1
  54. package/dist/src/{paramTag → multiLine}/inputbox.js +2 -2
  55. package/dist/src/multiLine/paramTag.d.ts +20 -0
  56. package/dist/src/{paramTag/index.js → multiLine/paramTag.js} +10 -24
  57. package/dist/src/nowiki/base.d.ts +1 -1
  58. package/dist/src/nowiki/comment.js +2 -0
  59. package/dist/src/nowiki/commentLine.d.ts +11 -0
  60. package/dist/src/nowiki/commentLine.js +67 -0
  61. package/dist/src/nowiki/listBase.js +1 -2
  62. package/dist/src/nowiki/noinclude.d.ts +6 -0
  63. package/dist/src/nowiki/noinclude.js +19 -4
  64. package/dist/src/nowiki/quote.js +2 -2
  65. package/dist/src/paramLine.d.ts +17 -0
  66. package/dist/src/paramLine.js +83 -0
  67. package/dist/src/parameter.d.ts +0 -1
  68. package/dist/src/parameter.js +2 -1
  69. package/dist/src/pre.d.ts +6 -8
  70. package/dist/src/pre.js +3 -2
  71. package/dist/src/syntax.d.ts +1 -1
  72. package/dist/src/table/base.d.ts +6 -1
  73. package/dist/src/table/base.js +96 -46
  74. package/dist/src/table/index.js +70 -66
  75. package/dist/src/table/td.d.ts +2 -2
  76. package/dist/src/table/td.js +8 -7
  77. package/dist/src/table/tr.d.ts +2 -2
  78. package/dist/src/table/trBase.d.ts +0 -5
  79. package/dist/src/table/trBase.js +4 -5
  80. package/dist/src/{html.d.ts → tag/html.d.ts} +6 -22
  81. package/dist/src/{html.js → tag/html.js} +43 -131
  82. package/dist/src/tag/index.d.ts +44 -0
  83. package/dist/src/tag/index.js +214 -0
  84. package/dist/src/tag/tvar.d.ts +38 -0
  85. package/dist/src/tag/tvar.js +169 -0
  86. package/dist/src/tagPair/ext.js +4 -4
  87. package/dist/src/tagPair/include.js +1 -1
  88. package/dist/src/tagPair/index.d.ts +1 -1
  89. package/dist/src/tagPair/index.js +1 -0
  90. package/dist/src/tagPair/translate.js +10 -10
  91. package/dist/src/transclude.d.ts +8 -9
  92. package/dist/src/transclude.js +8 -5
  93. package/dist/util/constants.js +1 -1
  94. package/extensions/dist/base.js +1 -1
  95. package/extensions/ui.css +1 -1
  96. package/package.json +2 -2
  97. package/dist/mixin/multiLine.d.ts +0 -4
  98. package/dist/mixin/multiLine.js +0 -33
  99. package/dist/src/gallery.d.ts +0 -66
  100. package/dist/src/imagemap.d.ts +0 -49
  101. package/dist/src/paramTag/index.d.ts +0 -28
@@ -13,7 +13,7 @@ const index_2 = require("../src/index");
13
13
  const comment_1 = require("../src/nowiki/comment");
14
14
  const include_1 = require("../src/tagPair/include");
15
15
  const ext_1 = require("../src/tagPair/ext");
16
- const html_1 = require("../src/html");
16
+ const html_1 = require("../src/tag/html");
17
17
  const attributes_1 = require("../src/attributes");
18
18
  const blockElems = 'table|h1|h2|h3|h4|h5|h6|pre|p|ul|ol|dl', antiBlockElems = 'td|th', solvedMagicWords = new Set([
19
19
  'if',
package/dist/base.d.mts CHANGED
@@ -18,7 +18,7 @@ export interface Config {
18
18
  readonly redirects?: [string, string][];
19
19
  }
20
20
  export type ConfigData = Omit<Config, 'excludes'>;
21
- export type TokenTypes = 'root' | 'plain' | 'redirect' | 'redirect-syntax' | 'redirect-target' | 'translate' | 'translate-attr' | 'translate-inner' | 'onlyinclude' | 'noinclude' | 'include' | 'comment' | 'ext' | 'ext-attrs' | 'ext-attr-dirty' | 'ext-attr' | 'attr-key' | 'attr-value' | 'ext-inner' | 'arg' | 'arg-name' | 'arg-default' | 'hidden' | 'magic-word' | 'magic-word-name' | 'invoke-function' | 'invoke-module' | 'template' | 'template-name' | 'parameter' | 'parameter-key' | 'parameter-value' | 'heading' | 'heading-title' | 'heading-trail' | 'html' | 'html-attrs' | 'html-attr-dirty' | 'html-attr' | 'table' | 'tr' | 'td' | 'table-syntax' | 'table-attrs' | 'table-attr-dirty' | 'table-attr' | 'table-inter' | 'td-inner' | 'hr' | 'double-underscore' | 'link' | 'link-target' | 'link-text' | 'category' | 'file' | 'gallery-image' | 'imagemap-image' | 'image-parameter' | 'quote' | 'ext-link' | 'ext-link-text' | 'ext-link-url' | 'free-ext-link' | 'magic-link' | 'list' | 'dd' | 'list-range' | 'converter' | 'converter-flags' | 'converter-flag' | 'converter-rule' | 'converter-rule-variant' | 'converter-rule-to' | 'converter-rule-from' | 'param-line' | 'imagemap-link';
21
+ export type TokenTypes = 'root' | 'plain' | 'redirect' | 'redirect-syntax' | 'redirect-target' | 'translate' | 'translate-attr' | 'translate-inner' | 'tvar' | 'tvar-name' | 'onlyinclude' | 'noinclude' | 'include' | 'comment' | 'ext' | 'ext-attrs' | 'ext-attr-dirty' | 'ext-attr' | 'attr-key' | 'attr-value' | 'ext-inner' | 'arg' | 'arg-name' | 'arg-default' | 'hidden' | 'magic-word' | 'magic-word-name' | 'invoke-function' | 'invoke-module' | 'template' | 'template-name' | 'parameter' | 'parameter-key' | 'parameter-value' | 'heading' | 'heading-title' | 'heading-trail' | 'html' | 'html-attrs' | 'html-attr-dirty' | 'html-attr' | 'table' | 'tr' | 'td' | 'table-syntax' | 'table-attrs' | 'table-attr-dirty' | 'table-attr' | 'table-inter' | 'td-inner' | 'hr' | 'double-underscore' | 'link' | 'link-target' | 'link-text' | 'category' | 'file' | 'gallery-image' | 'imagemap-image' | 'image-parameter' | 'quote' | 'ext-link' | 'ext-link-text' | 'ext-link-url' | 'free-ext-link' | 'magic-link' | 'list' | 'dd' | 'list-range' | 'converter' | 'converter-flags' | 'converter-flag' | 'converter-rule' | 'converter-rule-variant' | 'converter-rule-to' | 'converter-rule-from' | 'param-line' | 'imagemap-link';
22
22
  export declare const stages: {
23
23
  redirect: number;
24
24
  onlyinclude: number;
package/dist/base.d.ts CHANGED
@@ -18,7 +18,7 @@ export interface Config {
18
18
  readonly redirects?: [string, string][];
19
19
  }
20
20
  export type ConfigData = Omit<Config, 'excludes'>;
21
- export type TokenTypes = 'root' | 'plain' | 'redirect' | 'redirect-syntax' | 'redirect-target' | 'translate' | 'translate-attr' | 'translate-inner' | 'onlyinclude' | 'noinclude' | 'include' | 'comment' | 'ext' | 'ext-attrs' | 'ext-attr-dirty' | 'ext-attr' | 'attr-key' | 'attr-value' | 'ext-inner' | 'arg' | 'arg-name' | 'arg-default' | 'hidden' | 'magic-word' | 'magic-word-name' | 'invoke-function' | 'invoke-module' | 'template' | 'template-name' | 'parameter' | 'parameter-key' | 'parameter-value' | 'heading' | 'heading-title' | 'heading-trail' | 'html' | 'html-attrs' | 'html-attr-dirty' | 'html-attr' | 'table' | 'tr' | 'td' | 'table-syntax' | 'table-attrs' | 'table-attr-dirty' | 'table-attr' | 'table-inter' | 'td-inner' | 'hr' | 'double-underscore' | 'link' | 'link-target' | 'link-text' | 'category' | 'file' | 'gallery-image' | 'imagemap-image' | 'image-parameter' | 'quote' | 'ext-link' | 'ext-link-text' | 'ext-link-url' | 'free-ext-link' | 'magic-link' | 'list' | 'dd' | 'list-range' | 'converter' | 'converter-flags' | 'converter-flag' | 'converter-rule' | 'converter-rule-variant' | 'converter-rule-to' | 'converter-rule-from' | 'param-line' | 'imagemap-link';
21
+ export type TokenTypes = 'root' | 'plain' | 'redirect' | 'redirect-syntax' | 'redirect-target' | 'translate' | 'translate-attr' | 'translate-inner' | 'tvar' | 'tvar-name' | 'onlyinclude' | 'noinclude' | 'include' | 'comment' | 'ext' | 'ext-attrs' | 'ext-attr-dirty' | 'ext-attr' | 'attr-key' | 'attr-value' | 'ext-inner' | 'arg' | 'arg-name' | 'arg-default' | 'hidden' | 'magic-word' | 'magic-word-name' | 'invoke-function' | 'invoke-module' | 'template' | 'template-name' | 'parameter' | 'parameter-key' | 'parameter-value' | 'heading' | 'heading-title' | 'heading-trail' | 'html' | 'html-attrs' | 'html-attr-dirty' | 'html-attr' | 'table' | 'tr' | 'td' | 'table-syntax' | 'table-attrs' | 'table-attr-dirty' | 'table-attr' | 'table-inter' | 'td-inner' | 'hr' | 'double-underscore' | 'link' | 'link-target' | 'link-text' | 'category' | 'file' | 'gallery-image' | 'imagemap-image' | 'image-parameter' | 'quote' | 'ext-link' | 'ext-link-text' | 'ext-link-url' | 'free-ext-link' | 'magic-link' | 'list' | 'dd' | 'list-range' | 'converter' | 'converter-flags' | 'converter-flag' | 'converter-rule' | 'converter-rule-variant' | 'converter-rule-to' | 'converter-rule-from' | 'param-line' | 'imagemap-link';
22
22
  export declare const stages: {
23
23
  redirect: number;
24
24
  onlyinclude: number;
@@ -77,7 +77,7 @@ const mw = {
77
77
  },
78
78
  },
79
79
  };
80
- const pkg = "wikiparser-node", version = "1.27.0";
80
+ const pkg = "wikiparser-node", version = "1.28.0";
81
81
  let mwConfig;
82
82
  /**
83
83
  * Get the parser configuration for a Wikimedia Foundation project.
package/dist/index.d.ts CHANGED
@@ -3,6 +3,7 @@ import type { Config, ConfigData, LintError, LintConfig, TokenTypes, Parser as P
3
3
  import type { Title, TitleOptions } from './lib/title';
4
4
  import type { LanguageService, QuickFixData } from './lib/lsp';
5
5
  import type { Token, TranscludeToken, ExtToken } from './internal';
6
+ import type { AstRange } from './lib/range';
6
7
  declare type FunctionHook = (token: TranscludeToken, context?: TranscludeToken) => string;
7
8
  declare type TagHook = (token: ExtToken) => string;
8
9
  declare interface Parser extends ParserBase {
@@ -91,6 +92,6 @@ declare const Parser: Parser;
91
92
  // @ts-expect-error mixed export styles
92
93
  export = Parser;
93
94
  export default Parser;
94
- export type { Config, ConfigData, LintConfig, LintError, TokenTypes, LanguageService, QuickFixData, AST, };
95
+ export type { Config, ConfigData, LintConfig, LintError, TokenTypes, LanguageService, QuickFixData, Title, AST, AstRange, };
95
96
  export type * from './internal';
96
97
  declare global { type WikiParserAcceptable = Record<string, any>; }
package/dist/index.js CHANGED
@@ -152,9 +152,8 @@ const Parser = {
152
152
  },
153
153
  /** @implements */
154
154
  msg(msg, arg = '') {
155
- LINT: { // eslint-disable-line no-unused-labels
156
- return msg && (this.i18n[msg] ?? msg).replace('$1', this.msg(arg));
157
- }
155
+ LINT: return msg // eslint-disable-line no-unused-labels
156
+ && (this.i18n[msg] ?? msg).replace('$1', this.msg(arg));
158
157
  },
159
158
  /** @implements */
160
159
  normalizeTitle(title, defaultNs = 0, include, config = Parser.getConfig(), opt) {
@@ -17,7 +17,7 @@ export type { SyntaxToken } from './src/syntax';
17
17
  export type { ParameterToken } from './src/parameter';
18
18
  export type { TranscludeToken } from './src/transclude';
19
19
  export type { HeadingToken } from './src/heading';
20
- export type { HtmlToken } from './src/html';
20
+ export type { HtmlToken } from './src/tag/html';
21
21
  export type { TdToken } from './src/table/td';
22
22
  export type { TrToken } from './src/table/tr';
23
23
  export type { TableToken } from './src/table/index';
@@ -39,11 +39,11 @@ export type { ConverterRuleToken } from './src/converterRule';
39
39
  export type { ConverterToken } from './src/converter';
40
40
  export type { NowikiToken } from './src/nowiki/index';
41
41
  export type { PreToken } from './src/pre';
42
- export type { ParamTagToken } from './src/paramTag/index';
43
- export type { InputboxToken } from './src/paramTag/inputbox';
42
+ export type { ParamTagToken } from './src/multiLine/paramTag';
43
+ export type { InputboxToken } from './src/multiLine/inputbox';
44
44
  export type { NestedToken } from './src/nested';
45
- export type { GalleryToken } from './src/gallery';
45
+ export type { GalleryToken } from './src/multiLine/gallery';
46
46
  export type { ImagemapLinkToken } from './src/imagemapLink';
47
- export type { ImagemapToken } from './src/imagemap';
47
+ export type { ImagemapToken } from './src/multiLine/imagemap';
48
48
  export type { CommentedToken } from './src/commented';
49
49
  export type { TranslateToken } from './src/tagPair/translate';
@@ -175,11 +175,11 @@ const defaultLintRuleConfig = {
175
175
  'unmatched-tag': [
176
176
  1,
177
177
  {
178
- // both: 1,
179
- // closing: 1,
180
- // conditional: 1,
181
- // opening: 1,
182
- // selfClosing: 1,
178
+ both: 2,
179
+ // closing: 1,
180
+ // conditional: 1,
181
+ // opening: 1,
182
+ selfClosing: 2,
183
183
  },
184
184
  ],
185
185
  'unterminated-url': [
package/dist/lib/lsp.d.ts CHANGED
@@ -167,8 +167,8 @@ export declare class LanguageService implements LanguageServiceBase {
167
167
  * 设置目标维基百科
168
168
  * @param wiki Wikipedia URL / 维基百科网址
169
169
  * @param user URI for wiki userpage or email address of the user / 维基用户页面地址或用户的电子邮件地址
170
- * @throws `RangeError` 不是有效的维基百科网址
171
170
  * @since v1.18.1
171
+ * @throws `RangeError` 不是有效的维基百科网址
172
172
  */
173
173
  setTargetWikipedia(wiki: string, user: string): Promise<void>;
174
174
  }
package/dist/lib/lsp.js CHANGED
@@ -1532,8 +1532,8 @@ class LanguageService {
1532
1532
  * 设置目标维基百科
1533
1533
  * @param wiki Wikipedia URL / 维基百科网址
1534
1534
  * @param user URI for wiki userpage or email address of the user / 维基用户页面地址或用户的电子邮件地址
1535
- * @throws `RangeError` 不是有效的维基百科网址
1536
1535
  * @since v1.18.1
1536
+ * @throws `RangeError` 不是有效的维基百科网址
1537
1537
  */
1538
1538
  async setTargetWikipedia(wiki, user) {
1539
1539
  const [site, host] = index_1.default.getWMFSite(wiki);
package/dist/lib/node.js CHANGED
@@ -221,8 +221,10 @@ let AstNode = (() => {
221
221
  this.#previousSibling = value;
222
222
  break;
223
223
  case 'aIndex':
224
- if (index_1.default.viewOnly) {
225
- this.#aIndex = [debug_1.Shadow.rev, value];
224
+ LINT: { // eslint-disable-line no-unused-labels
225
+ if (index_1.default.viewOnly) {
226
+ this.#aIndex = [debug_1.Shadow.rev, value];
227
+ }
226
228
  }
227
229
  break;
228
230
  default:
@@ -285,18 +287,22 @@ let AstNode = (() => {
285
287
  * @param index character index / 字符位置
286
288
  */
287
289
  posFromIndex(index) {
288
- const { length } = String(this);
289
- index += index < 0 ? length : 0;
290
- if (index >= 0 && index <= length) {
291
- const lines = this.getLines(), top = lines.findIndex(([, , end]) => index <= end);
292
- return { top, left: index - lines[top][1] };
290
+ LINT: { // eslint-disable-line no-unused-labels
291
+ const { length } = String(this);
292
+ index += index < 0 ? length : 0;
293
+ if (index >= 0 && index <= length) {
294
+ const lines = this.getLines(), top = lines.findIndex(([, , end]) => index <= end);
295
+ return { top, left: index - lines[top][1] };
296
+ }
297
+ return undefined;
293
298
  }
294
- return undefined;
295
299
  }
296
300
  /** @private */
297
301
  getDimension() {
298
- const lines = this.getLines(), last = lines[lines.length - 1];
299
- return { height: lines.length, width: last[2] - last[1] };
302
+ LINT: { // eslint-disable-line no-unused-labels
303
+ const lines = this.getLines(), last = lines[lines.length - 1];
304
+ return { height: lines.length, width: last[2] - last[1] };
305
+ }
300
306
  }
301
307
  /** @private */
302
308
  getGaps(_) {
@@ -309,28 +315,30 @@ let AstNode = (() => {
309
315
  * @param j rank of the child node / 子节点序号
310
316
  */
311
317
  getRelativeIndex(j) {
312
- if (j === undefined) {
313
- const { parentNode } = this;
314
- return parentNode
315
- ? parentNode.getRelativeIndex(parentNode.childNodes.indexOf(this))
316
- : 0;
317
- }
318
- /* NOT FOR BROWSER */
319
- this.verifyChild(j, 1);
320
- /* NOT FOR BROWSER END */
321
- return (0, lint_1.cache)(this.#rIndex[j], () => {
322
- const { childNodes } = this, n = j + (j < 0 ? childNodes.length : 0);
323
- let acc = this.getAttribute('padding');
324
- for (let i = 0; i < n; i++) {
325
- if (index_1.default.viewOnly) {
326
- this.#rIndex[i] = [debug_1.Shadow.rev, acc];
327
- }
328
- acc += childNodes[i].toString().length + this.getGaps(i);
318
+ LINT: { // eslint-disable-line no-unused-labels
319
+ if (j === undefined) {
320
+ const { parentNode } = this;
321
+ return parentNode
322
+ ? parentNode.getRelativeIndex(parentNode.childNodes.indexOf(this))
323
+ : 0;
329
324
  }
330
- return acc;
331
- }, value => {
332
- this.#rIndex[j] = value;
333
- });
325
+ /* NOT FOR BROWSER */
326
+ this.verifyChild(j, 1);
327
+ /* NOT FOR BROWSER END */
328
+ return (0, lint_1.cache)(this.#rIndex[j], () => {
329
+ const { childNodes } = this, n = j + (j < 0 ? childNodes.length : 0);
330
+ let acc = this.getAttribute('padding');
331
+ for (let i = 0; i < n; i++) {
332
+ if (index_1.default.viewOnly) {
333
+ this.#rIndex[i] = [debug_1.Shadow.rev, acc];
334
+ }
335
+ acc += childNodes[i].toString().length + this.getGaps(i);
336
+ }
337
+ return acc;
338
+ }, value => {
339
+ this.#rIndex[j] = value;
340
+ });
341
+ }
334
342
  }
335
343
  /**
336
344
  * Get the absolute character index of the current node
@@ -338,7 +346,8 @@ let AstNode = (() => {
338
346
  * 获取当前节点的绝对位置
339
347
  */
340
348
  getAbsoluteIndex() {
341
- return (0, lint_1.cache)(this.#aIndex, () => {
349
+ LINT: return (0, lint_1.cache)(// eslint-disable-line no-unused-labels
350
+ this.#aIndex, () => {
342
351
  const { parentNode } = this;
343
352
  return parentNode ? parentNode.getAbsoluteIndex() + this.getRelativeIndex() : 0;
344
353
  }, value => {
@@ -374,14 +383,16 @@ let AstNode = (() => {
374
383
  * @since v1.16.3
375
384
  */
376
385
  getLines() {
377
- const results = [];
378
- let start = 0;
379
- for (const line of String(this).split('\n')) {
380
- const end = start + line.length;
381
- results.push([line, start, end]);
382
- start = end + 1;
383
- }
384
- return results;
386
+ LINT: { // eslint-disable-line no-unused-labels
387
+ const results = [];
388
+ let start = 0;
389
+ for (const line of String(this).split('\n')) {
390
+ const end = start + line.length;
391
+ results.push([line, start, end]);
392
+ start = end + 1;
393
+ }
394
+ return results;
395
+ }
385
396
  }
386
397
  /* PRINT ONLY */
387
398
  /** @private */
@@ -9,64 +9,66 @@ const constants_1 = require("../util/constants");
9
9
  * @param i AttributesToken子节点的位置
10
10
  */
11
11
  const attributesParent = (i = 0) => (constructor) => {
12
- /* eslint-disable jsdoc/require-jsdoc */
13
- class AttributesParent extends constructor {
14
- /* NOT FOR BROWSER */
15
- get attributes() {
16
- return this.#getAttributesChild().attributes;
17
- }
18
- set attributes(attributes) {
19
- this.#getAttributesChild().attributes = attributes;
20
- }
21
- get className() {
22
- return this.#getAttributesChild().className;
23
- }
24
- set className(className) {
25
- this.#getAttributesChild().className = className;
26
- }
27
- get classList() {
28
- return this.#getAttributesChild().classList;
29
- }
30
- get id() {
31
- return this.#getAttributesChild().id;
32
- }
33
- set id(id) {
34
- this.#getAttributesChild().id = id;
35
- }
36
- /* NOT FOR BROWSER END */
37
- /** AttributesToken子节点 */
38
- #getAttributesChild() {
39
- return this.childNodes[i];
40
- }
41
- hasAttr(key) {
42
- LSP: return this.#getAttributesChild().hasAttr(key); // eslint-disable-line no-unused-labels
43
- }
44
- getAttr(key) {
45
- return this.#getAttributesChild().getAttr(key);
46
- }
47
- /* NOT FOR BROWSER */
48
- getAttrNames() {
49
- return this.#getAttributesChild().getAttrNames();
50
- }
51
- getAttrs() {
52
- return this.#getAttributesChild().getAttrs();
53
- }
54
- setAttr(keyOrProp, value) {
55
- this.#getAttributesChild().setAttr(keyOrProp, value);
56
- }
57
- removeAttr(key) {
58
- this.#getAttributesChild().removeAttr(key);
59
- }
60
- toggleAttr(key, force) {
61
- this.#getAttributesChild().toggleAttr(key, force);
62
- }
63
- css(key, value) {
64
- return this.#getAttributesChild().css(key, value);
65
- }
12
+ LINT: { // eslint-disable-line no-unused-labels
13
+ /* eslint-disable jsdoc/require-jsdoc */
14
+ class AttributesParent extends constructor {
15
+ /* NOT FOR BROWSER */
16
+ get attributes() {
17
+ return this.#getAttributesChild().attributes;
18
+ }
19
+ set attributes(attributes) {
20
+ this.#getAttributesChild().attributes = attributes;
21
+ }
22
+ get className() {
23
+ return this.#getAttributesChild().className;
24
+ }
25
+ set className(className) {
26
+ this.#getAttributesChild().className = className;
27
+ }
28
+ get classList() {
29
+ return this.#getAttributesChild().classList;
30
+ }
31
+ get id() {
32
+ return this.#getAttributesChild().id;
33
+ }
34
+ set id(id) {
35
+ this.#getAttributesChild().id = id;
36
+ }
37
+ /* NOT FOR BROWSER END */
38
+ /** AttributesToken子节点 */
39
+ #getAttributesChild() {
40
+ return this.childNodes[i];
41
+ }
42
+ hasAttr(key) {
43
+ LSP: return this.#getAttributesChild().hasAttr(key); // eslint-disable-line no-unused-labels
44
+ }
45
+ getAttr(key) {
46
+ return this.#getAttributesChild().getAttr(key);
47
+ }
48
+ /* NOT FOR BROWSER */
49
+ getAttrNames() {
50
+ return this.#getAttributesChild().getAttrNames();
51
+ }
52
+ getAttrs() {
53
+ return this.#getAttributesChild().getAttrs();
54
+ }
55
+ setAttr(keyOrProp, value) {
56
+ this.#getAttributesChild().setAttr(keyOrProp, value);
57
+ }
58
+ removeAttr(key) {
59
+ this.#getAttributesChild().removeAttr(key);
60
+ }
61
+ toggleAttr(key, force) {
62
+ this.#getAttributesChild().toggleAttr(key, force);
63
+ }
64
+ css(key, value) {
65
+ return this.#getAttributesChild().css(key, value);
66
+ }
67
+ }
68
+ /* eslint-enable jsdoc/require-jsdoc */
69
+ (0, debug_1.mixin)(AttributesParent, constructor);
70
+ return AttributesParent;
66
71
  }
67
- /* eslint-enable jsdoc/require-jsdoc */
68
- (0, debug_1.mixin)(AttributesParent, constructor);
69
- return AttributesParent;
70
72
  };
71
73
  exports.attributesParent = attributesParent;
72
74
  constants_1.mixins['attributesParent'] = __filename;
@@ -8,89 +8,91 @@ const constants_1 = require("../util/constants");
8
8
  const element_1 = require("../lib/element");
9
9
  /** @ignore */
10
10
  const elementLike = (constructor) => {
11
- /* eslint-disable jsdoc/require-jsdoc */
12
- class ElementLike extends constructor {
13
- /* NOT FOR BROWSER */
14
- get children() {
15
- return this.childNodes.filter((child) => child.type !== 'text');
16
- }
17
- get firstElementChild() {
18
- return this.childNodes.find((child) => child.type !== 'text');
19
- }
20
- get lastElementChild() {
21
- return this.childNodes.findLast((child) => child.type !== 'text');
22
- }
23
- get childElementCount() {
24
- return this.children.length;
25
- }
26
- /* NOT FOR BROWSER END */
27
- #getCondition(selector) {
28
- return (0, selector_1.getCondition)(selector,
29
- // eslint-disable-next-line unicorn/no-negated-condition, @stylistic/operator-linebreak
30
- !(this instanceof element_1.AstElement) ?
31
- undefined : // eslint-disable-line @stylistic/operator-linebreak
32
- this);
33
- }
34
- getElementBy(condition) {
35
- for (const child of this.childNodes) {
36
- if (child.type === 'text') {
37
- continue;
38
- }
39
- else if (condition(child)) {
40
- return child;
41
- }
42
- const descendant = child.getElementBy(condition);
43
- if (descendant) {
44
- return descendant;
45
- }
11
+ LINT: { // eslint-disable-line no-unused-labels
12
+ /* eslint-disable jsdoc/require-jsdoc */
13
+ class ElementLike extends constructor {
14
+ /* NOT FOR BROWSER */
15
+ get children() {
16
+ return this.childNodes.filter((child) => child.type !== 'text');
46
17
  }
47
- return undefined;
48
- }
49
- querySelector(selector) {
50
- return this.getElementBy(this.#getCondition(selector));
51
- }
52
- getElementsBy(condition, descendants = []) {
53
- for (const child of this.childNodes) {
54
- if (child.type === 'text') {
55
- continue;
56
- }
57
- else if (condition(child)) {
58
- descendants.push(child);
18
+ get firstElementChild() {
19
+ return this.childNodes.find((child) => child.type !== 'text');
20
+ }
21
+ get lastElementChild() {
22
+ return this.childNodes.findLast((child) => child.type !== 'text');
23
+ }
24
+ get childElementCount() {
25
+ return this.children.length;
26
+ }
27
+ /* NOT FOR BROWSER END */
28
+ #getCondition(selector) {
29
+ return (0, selector_1.getCondition)(selector,
30
+ // eslint-disable-next-line unicorn/no-negated-condition, @stylistic/operator-linebreak
31
+ !(this instanceof element_1.AstElement) ?
32
+ undefined : // eslint-disable-line @stylistic/operator-linebreak
33
+ this);
34
+ }
35
+ getElementBy(condition) {
36
+ for (const child of this.childNodes) {
37
+ if (child.type === 'text') {
38
+ continue;
39
+ }
40
+ else if (condition(child)) {
41
+ return child;
42
+ }
43
+ const descendant = child.getElementBy(condition);
44
+ if (descendant) {
45
+ return descendant;
46
+ }
59
47
  }
60
- child.getElementsBy(condition, descendants);
48
+ return undefined;
61
49
  }
62
- return descendants;
63
- }
64
- querySelectorAll(selector) {
65
- return this.getElementsBy(this.#getCondition(selector));
66
- }
67
- escape() {
68
- LSP: { // eslint-disable-line no-unused-labels
50
+ querySelector(selector) {
51
+ return this.getElementBy(this.#getCondition(selector));
52
+ }
53
+ getElementsBy(condition, descendants = []) {
69
54
  for (const child of this.childNodes) {
70
- child.escape();
55
+ if (child.type === 'text') {
56
+ continue;
57
+ }
58
+ else if (condition(child)) {
59
+ descendants.push(child);
60
+ }
61
+ child.getElementsBy(condition, descendants);
71
62
  }
72
- /* NOT FOR BROWSER */
73
- this.detach?.();
63
+ return descendants;
64
+ }
65
+ querySelectorAll(selector) {
66
+ return this.getElementsBy(this.#getCondition(selector));
67
+ }
68
+ escape() {
69
+ LSP: { // eslint-disable-line no-unused-labels
70
+ for (const child of this.childNodes) {
71
+ child.escape();
72
+ }
73
+ /* NOT FOR BROWSER */
74
+ this.detach?.();
75
+ }
76
+ }
77
+ /* NOT FOR BROWSER */
78
+ getElementByTypes(types) {
79
+ const typeSet = new Set(types.split(',').map(str => str.trim()));
80
+ return this.getElementBy((({ type }) => typeSet.has(type)));
81
+ }
82
+ getElementById(id) {
83
+ return this.getElementBy((token => 'id' in token && token.id === id));
84
+ }
85
+ getElementsByClassName(className) {
86
+ return this.getElementsBy((token => 'classList' in token && token.classList.has(className)));
87
+ }
88
+ getElementsByTagName(tag) {
89
+ return this.getElementsBy((({ type, name }) => name === tag && (type === 'html' || type === 'ext')));
74
90
  }
75
91
  }
76
- /* NOT FOR BROWSER */
77
- getElementByTypes(types) {
78
- const typeSet = new Set(types.split(',').map(str => str.trim()));
79
- return this.getElementBy((({ type }) => typeSet.has(type)));
80
- }
81
- getElementById(id) {
82
- return this.getElementBy((token => 'id' in token && token.id === id));
83
- }
84
- getElementsByClassName(className) {
85
- return this.getElementsBy((token => 'classList' in token && token.classList.has(className)));
86
- }
87
- getElementsByTagName(tag) {
88
- return this.getElementsBy((({ type, name }) => name === tag && (type === 'html' || type === 'ext')));
89
- }
92
+ /* eslint-enable jsdoc/require-jsdoc */
93
+ (0, debug_1.mixin)(ElementLike, constructor);
94
+ return ElementLike;
90
95
  }
91
- /* eslint-enable jsdoc/require-jsdoc */
92
- (0, debug_1.mixin)(ElementLike, constructor);
93
- return ElementLike;
94
96
  };
95
97
  exports.elementLike = elementLike;
96
98
  constants_1.mixins['elementLike'] = __filename;
@@ -58,7 +58,6 @@ const hiddenToken = (linter = true, html = true) => (constructor) => {
58
58
  __esDecorate(this, null, _toHtmlInternal_decorators, { kind: "method", name: "toHtmlInternal", static: false, private: false, access: { has: obj => "toHtmlInternal" in obj, get: obj => obj.toHtmlInternal }, metadata: _metadata }, null, _instanceExtraInitializers);
59
59
  if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
60
60
  }
61
- /** 没有可见部分 */
62
61
  text() {
63
62
  return '';
64
63
  }
@@ -67,8 +66,9 @@ const hiddenToken = (linter = true, html = true) => (constructor) => {
67
66
  LINT: return linter ? [] : super.lint(start); // eslint-disable-line no-unused-labels
68
67
  }
69
68
  /* NOT FOR BROWSER */
70
- dispatchEvent() {
71
- //
69
+ dispatchEvent(e, data) {
70
+ e.stopPropagation();
71
+ super.dispatchEvent(e, data);
72
72
  }
73
73
  toHtmlInternal(opt) {
74
74
  return html ? '' : super.toHtmlInternal(opt);
@@ -15,10 +15,10 @@ const nodeLike = (constructor) => {
15
15
  return this.childNodes[this.childNodes.length - 1];
16
16
  }
17
17
  get offsetHeight() {
18
- return this.getDimension().height;
18
+ LINT: return this.getDimension().height; // eslint-disable-line no-unused-labels
19
19
  }
20
20
  get offsetWidth() {
21
- return this.getDimension().width;
21
+ LINT: return this.getDimension().width; // eslint-disable-line no-unused-labels
22
22
  }
23
23
  }
24
24
  /* eslint-enable jsdoc/require-jsdoc */
@@ -11,15 +11,17 @@ const constants_1 = require("../util/constants");
11
11
  * @param padding.length
12
12
  */
13
13
  const padded = ({ length }) => (constructor) => {
14
- /* eslint-disable jsdoc/require-jsdoc */
15
- class PaddedToken extends constructor {
16
- getAttribute(key) {
17
- return key === 'padding' ? length : super.getAttribute(key);
14
+ LINT: { // eslint-disable-line no-unused-labels
15
+ /* eslint-disable jsdoc/require-jsdoc */
16
+ class PaddedToken extends constructor {
17
+ getAttribute(key) {
18
+ return key === 'padding' ? length : super.getAttribute(key);
19
+ }
18
20
  }
21
+ /* eslint-enable jsdoc/require-jsdoc */
22
+ (0, debug_1.mixin)(PaddedToken, constructor);
23
+ return PaddedToken;
19
24
  }
20
- /* eslint-enable jsdoc/require-jsdoc */
21
- (0, debug_1.mixin)(PaddedToken, constructor);
22
- return PaddedToken;
23
25
  };
24
26
  exports.padded = padded;
25
27
  constants_1.mixins['padded'] = __filename;
@@ -1,4 +1,4 @@
1
1
  /**
2
2
  * 不可包含换行符的类
3
- * @param strict 是否严格
3
+ * @ignore
4
4
  */