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.
- package/bundle/bundle-es8.min.js +25 -25
- package/bundle/bundle-lsp.min.js +29 -29
- package/bundle/bundle.min.js +24 -25
- package/dist/addon/token.js +1 -1
- package/dist/base.d.mts +1 -1
- package/dist/base.d.ts +1 -1
- package/dist/bin/config.js +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -3
- package/dist/internal.d.ts +5 -5
- package/dist/lib/lintConfig.js +5 -5
- package/dist/lib/lsp.d.ts +1 -1
- package/dist/lib/lsp.js +1 -1
- package/dist/lib/node.js +51 -40
- package/dist/mixin/attributesParent.js +59 -57
- package/dist/mixin/elementLike.js +77 -75
- package/dist/mixin/hidden.js +3 -3
- package/dist/mixin/nodeLike.js +2 -2
- package/dist/mixin/padded.js +9 -7
- package/dist/mixin/singleLine.d.ts +1 -1
- package/dist/mixin/singleLine.js +10 -11
- package/dist/parser/commentAndExt.js +1 -1
- package/dist/parser/html.js +1 -1
- package/dist/parser/selector.js +2 -1
- package/dist/src/arg.js +2 -2
- package/dist/src/atom.d.ts +1 -1
- package/dist/src/atom.js +0 -1
- package/dist/src/attribute.d.ts +5 -7
- package/dist/src/attribute.js +17 -8
- package/dist/src/attributes.d.ts +7 -8
- package/dist/src/attributes.js +5 -3
- package/dist/src/commented.d.ts +3 -3
- package/dist/src/converterRule.js +1 -1
- package/dist/src/heading.js +1 -1
- package/dist/src/imageParameter.d.ts +0 -8
- package/dist/src/imageParameter.js +7 -6
- package/dist/src/imagemapLink.js +1 -1
- package/dist/src/index.d.ts +0 -5
- package/dist/src/index.js +2 -5
- package/dist/src/link/base.js +1 -2
- package/dist/src/link/category.js +1 -2
- package/dist/src/link/file.js +8 -7
- package/dist/src/link/galleryImage.d.ts +0 -3
- package/dist/src/link/galleryImage.js +3 -2
- package/dist/src/link/index.js +1 -1
- package/dist/src/magicLink.d.ts +0 -7
- package/dist/src/multiLine/gallery.d.ts +49 -0
- package/dist/src/{gallery.js → multiLine/gallery.js} +24 -37
- package/dist/src/multiLine/imagemap.d.ts +25 -0
- package/dist/src/{imagemap.js → multiLine/imagemap.js} +20 -36
- package/dist/src/multiLine/index.d.ts +17 -0
- package/dist/src/multiLine/index.js +36 -0
- package/dist/src/{paramTag → multiLine}/inputbox.d.ts +1 -1
- package/dist/src/{paramTag → multiLine}/inputbox.js +2 -2
- package/dist/src/multiLine/paramTag.d.ts +20 -0
- package/dist/src/{paramTag/index.js → multiLine/paramTag.js} +10 -24
- package/dist/src/nowiki/base.d.ts +1 -1
- package/dist/src/nowiki/comment.js +2 -0
- package/dist/src/nowiki/commentLine.d.ts +11 -0
- package/dist/src/nowiki/commentLine.js +67 -0
- package/dist/src/nowiki/listBase.js +1 -2
- package/dist/src/nowiki/noinclude.d.ts +6 -0
- package/dist/src/nowiki/noinclude.js +19 -4
- package/dist/src/nowiki/quote.js +2 -2
- package/dist/src/paramLine.d.ts +17 -0
- package/dist/src/paramLine.js +83 -0
- package/dist/src/parameter.d.ts +0 -1
- package/dist/src/parameter.js +2 -1
- package/dist/src/pre.d.ts +6 -8
- package/dist/src/pre.js +3 -2
- package/dist/src/syntax.d.ts +1 -1
- package/dist/src/table/base.d.ts +6 -1
- package/dist/src/table/base.js +96 -46
- package/dist/src/table/index.js +70 -66
- package/dist/src/table/td.d.ts +2 -2
- package/dist/src/table/td.js +8 -7
- package/dist/src/table/tr.d.ts +2 -2
- package/dist/src/table/trBase.d.ts +0 -5
- package/dist/src/table/trBase.js +4 -5
- package/dist/src/{html.d.ts → tag/html.d.ts} +6 -22
- package/dist/src/{html.js → tag/html.js} +43 -131
- package/dist/src/tag/index.d.ts +44 -0
- package/dist/src/tag/index.js +214 -0
- package/dist/src/tag/tvar.d.ts +38 -0
- package/dist/src/tag/tvar.js +169 -0
- package/dist/src/tagPair/ext.js +4 -4
- package/dist/src/tagPair/include.js +1 -1
- package/dist/src/tagPair/index.d.ts +1 -1
- package/dist/src/tagPair/index.js +1 -0
- package/dist/src/tagPair/translate.js +10 -10
- package/dist/src/transclude.d.ts +8 -9
- package/dist/src/transclude.js +8 -5
- package/dist/util/constants.js +1 -1
- package/extensions/dist/base.js +1 -1
- package/extensions/ui.css +1 -1
- package/package.json +2 -2
- package/dist/mixin/multiLine.d.ts +0 -4
- package/dist/mixin/multiLine.js +0 -33
- package/dist/src/gallery.d.ts +0 -66
- package/dist/src/imagemap.d.ts +0 -49
- package/dist/src/paramTag/index.d.ts +0 -28
package/dist/addon/token.js
CHANGED
|
@@ -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;
|
package/dist/bin/config.js
CHANGED
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:
|
|
156
|
-
|
|
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) {
|
package/dist/internal.d.ts
CHANGED
|
@@ -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
|
|
43
|
-
export type { InputboxToken } from './src/
|
|
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';
|
package/dist/lib/lintConfig.js
CHANGED
|
@@ -175,11 +175,11 @@ const defaultLintRuleConfig = {
|
|
|
175
175
|
'unmatched-tag': [
|
|
176
176
|
1,
|
|
177
177
|
{
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
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
|
-
|
|
225
|
-
|
|
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
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
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
|
-
|
|
299
|
-
|
|
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
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
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
|
-
|
|
331
|
-
|
|
332
|
-
|
|
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)(
|
|
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
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
const
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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
|
-
|
|
48
|
+
return undefined;
|
|
61
49
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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.
|
|
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
|
-
|
|
73
|
-
|
|
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
|
-
/*
|
|
77
|
-
|
|
78
|
-
|
|
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;
|
package/dist/mixin/hidden.js
CHANGED
|
@@ -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);
|
package/dist/mixin/nodeLike.js
CHANGED
|
@@ -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 */
|
package/dist/mixin/padded.js
CHANGED
|
@@ -11,15 +11,17 @@ const constants_1 = require("../util/constants");
|
|
|
11
11
|
* @param padding.length
|
|
12
12
|
*/
|
|
13
13
|
const padded = ({ length }) => (constructor) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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;
|