wikiparser-node 1.35.2 → 1.37.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/LICENSE +18 -0
- package/bundle/bundle-es8.min.js +30 -27
- package/bundle/bundle-lsp.min.js +33 -30
- package/bundle/bundle.min.js +22 -22
- package/dist/addon/transclude.js +1 -1
- package/dist/bin/config.js +22 -48
- package/dist/bin/env.js +42 -0
- package/dist/index.js +32 -15
- package/dist/lib/document.d.ts +1 -2
- package/dist/lib/document.js +11 -11
- package/dist/lib/lintConfig.js +0 -2
- package/dist/lib/lsp.d.ts +1 -0
- package/dist/lib/lsp.js +21 -16
- package/dist/lib/node.d.ts +1 -1
- package/dist/lib/node.js +4 -1
- package/dist/lib/title.js +1 -1
- package/dist/src/converterFlags.js +11 -7
- package/dist/src/index.d.ts +1 -1
- package/dist/src/nowiki/comment.d.ts +1 -1
- package/dist/src/nowiki/index.js +8 -19
- package/dist/src/parameter.d.ts +1 -1
- package/dist/src/parameter.js +4 -5
- package/dist/src/tagPair/include.d.ts +1 -1
- package/dist/src/transclude.d.ts +21 -13
- package/dist/src/transclude.js +63 -30
- package/dist/util/constants.js +2 -1
- package/dist/util/diff.js +52 -50
- package/extensions/dist/base.js +4 -4
- package/extensions/dist/lsp.js +4 -1
- package/extensions/editor.css +1 -1
- package/extensions/typings.d.ts +1 -0
- package/package.json +29 -28
package/dist/src/parameter.js
CHANGED
|
@@ -82,11 +82,10 @@ let ParameterToken = (() => {
|
|
|
82
82
|
/* PRINT ONLY */
|
|
83
83
|
/** whether to be a duplicated parameter / 是否是重复参数 */
|
|
84
84
|
get duplicated() {
|
|
85
|
-
LSP:
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
return false;
|
|
85
|
+
LSP: {
|
|
86
|
+
const { parentNode, name } = this;
|
|
87
|
+
return Boolean(parentNode?.isTemplate())
|
|
88
|
+
&& parentNode.getArgs(name, false, false).size > 1;
|
|
90
89
|
}
|
|
91
90
|
}
|
|
92
91
|
/* PRINT ONLY END */
|
package/dist/src/transclude.d.ts
CHANGED
|
@@ -42,6 +42,13 @@ export declare abstract class TranscludeToken extends Token {
|
|
|
42
42
|
/** whether to contain duplicated parameters / 是否存在重复参数 */
|
|
43
43
|
get duplication(): boolean;
|
|
44
44
|
set duplication(duplication: boolean);
|
|
45
|
+
/**
|
|
46
|
+
* number of anonymous parameters
|
|
47
|
+
*
|
|
48
|
+
* 匿名参数的个数
|
|
49
|
+
* @since v1.36.0
|
|
50
|
+
*/
|
|
51
|
+
get anonCount(): number;
|
|
45
52
|
/**
|
|
46
53
|
* @param title 模板标题或魔术字
|
|
47
54
|
* @param parts 参数各部分
|
|
@@ -67,18 +74,6 @@ export declare abstract class TranscludeToken extends Token {
|
|
|
67
74
|
* @param i position to be inserted at / 插入位置
|
|
68
75
|
*/
|
|
69
76
|
insertAt<T extends ParameterToken>(token: T, i?: number): T;
|
|
70
|
-
/**
|
|
71
|
-
* Get all parameters
|
|
72
|
-
*
|
|
73
|
-
* 获取所有参数
|
|
74
|
-
*/
|
|
75
|
-
getAllArgs(): ParameterToken[];
|
|
76
|
-
/**
|
|
77
|
-
* Get all anonymous parameters
|
|
78
|
-
*
|
|
79
|
-
* 获取所有匿名参数
|
|
80
|
-
*/
|
|
81
|
-
getAnonArgs(): ParameterToken[];
|
|
82
77
|
/**
|
|
83
78
|
* Get parameters with the specified name
|
|
84
79
|
*
|
|
@@ -86,8 +81,9 @@ export declare abstract class TranscludeToken extends Token {
|
|
|
86
81
|
* @param key parameter name / 参数名
|
|
87
82
|
* @param exact whether to match anonymosity / 是否匹配匿名性
|
|
88
83
|
* @param copy whether to return a copy / 是否返回一个备份
|
|
84
|
+
* @param init whether to initialize during parsing / 是否在解析时进行初始化
|
|
89
85
|
*/
|
|
90
|
-
getArgs(key: string | number, exact?: boolean, copy?: boolean): Set<ParameterToken>;
|
|
86
|
+
getArgs(key: string | number, exact?: boolean, copy?: boolean, init?: boolean): Set<ParameterToken>;
|
|
91
87
|
/**
|
|
92
88
|
* Get duplicated parameters
|
|
93
89
|
*
|
|
@@ -120,6 +116,18 @@ export declare abstract class TranscludeToken extends Token {
|
|
|
120
116
|
* @param i position of the child node / 移除位置
|
|
121
117
|
*/
|
|
122
118
|
removeAt(i: number): ParameterToken;
|
|
119
|
+
/**
|
|
120
|
+
* Get all parameters
|
|
121
|
+
*
|
|
122
|
+
* 获取所有参数
|
|
123
|
+
*/
|
|
124
|
+
getAllArgs(): ParameterToken[];
|
|
125
|
+
/**
|
|
126
|
+
* Get all anonymous parameters
|
|
127
|
+
*
|
|
128
|
+
* 获取所有匿名参数
|
|
129
|
+
*/
|
|
130
|
+
getAnonArgs(): ParameterToken[];
|
|
123
131
|
/**
|
|
124
132
|
* Check if there is a parameter with the specified name
|
|
125
133
|
*
|
package/dist/src/transclude.js
CHANGED
|
@@ -83,6 +83,7 @@ let TranscludeToken = (() => {
|
|
|
83
83
|
#colon = ':';
|
|
84
84
|
#raw = false;
|
|
85
85
|
#args = new Map();
|
|
86
|
+
#anonCount = 0;
|
|
86
87
|
#title;
|
|
87
88
|
/* NOT FOR BROWSER */
|
|
88
89
|
#keys = new Set();
|
|
@@ -121,6 +122,15 @@ let TranscludeToken = (() => {
|
|
|
121
122
|
this.fixDuplication();
|
|
122
123
|
}
|
|
123
124
|
}
|
|
125
|
+
/**
|
|
126
|
+
* number of anonymous parameters
|
|
127
|
+
*
|
|
128
|
+
* 匿名参数的个数
|
|
129
|
+
* @since v1.36.0
|
|
130
|
+
*/
|
|
131
|
+
get anonCount() {
|
|
132
|
+
return this.#anonCount;
|
|
133
|
+
}
|
|
124
134
|
/* NOT FOR BROWSER END */
|
|
125
135
|
/**
|
|
126
136
|
* @param title 模板标题或魔术字
|
|
@@ -392,23 +402,44 @@ let TranscludeToken = (() => {
|
|
|
392
402
|
return errors;
|
|
393
403
|
}
|
|
394
404
|
}
|
|
395
|
-
|
|
396
|
-
* 处理匿名参数更改
|
|
397
|
-
* @param addedToken 新增的参数
|
|
398
|
-
*/
|
|
399
|
-
#handleAnonArgChange(addedToken) {
|
|
400
|
-
const args = this.getAnonArgs(), added = typeof addedToken !== 'number';
|
|
405
|
+
#handleAnonArgChange(addedToken, append) {
|
|
401
406
|
/* NOT FOR BROWSER */
|
|
402
|
-
const
|
|
403
|
-
|
|
407
|
+
const removing = typeof addedToken === 'number';
|
|
408
|
+
/* NOT FOR BROWSER END */
|
|
409
|
+
/* eslint-disable @stylistic/operator-linebreak */
|
|
410
|
+
this.#anonCount +=
|
|
411
|
+
removing ?
|
|
412
|
+
-1 :
|
|
413
|
+
1;
|
|
414
|
+
/* eslint-enable @stylistic/operator-linebreak */
|
|
415
|
+
/* NOT FOR BROWSER */
|
|
416
|
+
const maxAnon = String(this.#anonCount + (removing ? 1 : 0));
|
|
417
|
+
if (!removing) {
|
|
404
418
|
this.#keys.add(maxAnon);
|
|
405
419
|
}
|
|
406
420
|
else if (!this.hasArg(maxAnon, true)) {
|
|
407
421
|
this.#keys.delete(maxAnon);
|
|
408
422
|
}
|
|
423
|
+
let args;
|
|
409
424
|
/* NOT FOR BROWSER END */
|
|
410
|
-
|
|
411
|
-
|
|
425
|
+
let i;
|
|
426
|
+
if (append) {
|
|
427
|
+
i = this.#anonCount - 1;
|
|
428
|
+
/* NOT FOR BROWSER */
|
|
429
|
+
}
|
|
430
|
+
else {
|
|
431
|
+
args = this.getAnonArgs();
|
|
432
|
+
i = removing ? addedToken - 1 : args.indexOf(addedToken);
|
|
433
|
+
}
|
|
434
|
+
for (; i < this.#anonCount; i++) {
|
|
435
|
+
/* NOT FOR BROWSER END */
|
|
436
|
+
const token =
|
|
437
|
+
/* eslint-disable @stylistic/operator-linebreak, unicorn/no-negated-condition */
|
|
438
|
+
!append ?
|
|
439
|
+
args[i] :
|
|
440
|
+
addedToken,
|
|
441
|
+
/* eslint-enable @stylistic/operator-linebreak, unicorn/no-negated-condition */
|
|
442
|
+
{ name } = token, newName = String(i + 1);
|
|
412
443
|
if (name !== newName || token === addedToken) {
|
|
413
444
|
token.setAttribute('name', newName);
|
|
414
445
|
this.getArgs(newName, false, false).add(token);
|
|
@@ -427,7 +458,7 @@ let TranscludeToken = (() => {
|
|
|
427
458
|
insertAt(token, i = this.length) {
|
|
428
459
|
super.insertAt(token, i);
|
|
429
460
|
if (token.anon) {
|
|
430
|
-
this.#handleAnonArgChange(token);
|
|
461
|
+
this.#handleAnonArgChange(token, i === this.length - 1);
|
|
431
462
|
}
|
|
432
463
|
else if (token.name) {
|
|
433
464
|
this.getArgs(token.name, false, false).add(token);
|
|
@@ -436,22 +467,6 @@ let TranscludeToken = (() => {
|
|
|
436
467
|
}
|
|
437
468
|
return token;
|
|
438
469
|
}
|
|
439
|
-
/**
|
|
440
|
-
* Get all parameters
|
|
441
|
-
*
|
|
442
|
-
* 获取所有参数
|
|
443
|
-
*/
|
|
444
|
-
getAllArgs() {
|
|
445
|
-
return this.childNodes.filter((0, debug_1.isToken)('parameter'));
|
|
446
|
-
}
|
|
447
|
-
/**
|
|
448
|
-
* Get all anonymous parameters
|
|
449
|
-
*
|
|
450
|
-
* 获取所有匿名参数
|
|
451
|
-
*/
|
|
452
|
-
getAnonArgs() {
|
|
453
|
-
return this.getAllArgs().filter(({ anon }) => anon);
|
|
454
|
-
}
|
|
455
470
|
/**
|
|
456
471
|
* Get parameters with the specified name
|
|
457
472
|
*
|
|
@@ -459,8 +474,9 @@ let TranscludeToken = (() => {
|
|
|
459
474
|
* @param key parameter name / 参数名
|
|
460
475
|
* @param exact whether to match anonymosity / 是否匹配匿名性
|
|
461
476
|
* @param copy whether to return a copy / 是否返回一个备份
|
|
477
|
+
* @param init whether to initialize during parsing / 是否在解析时进行初始化
|
|
462
478
|
*/
|
|
463
|
-
getArgs(key, exact, copy = true) {
|
|
479
|
+
getArgs(key, exact, copy = true, init = true) {
|
|
464
480
|
const keyStr = String(key)
|
|
465
481
|
.replace(/^[ \t\n\0\v]+|([^ \t\n\0\v])[ \t\n\0\v]+$/gu, '$1');
|
|
466
482
|
let args;
|
|
@@ -468,7 +484,7 @@ let TranscludeToken = (() => {
|
|
|
468
484
|
args = this.#args.get(keyStr);
|
|
469
485
|
}
|
|
470
486
|
else {
|
|
471
|
-
args = new Set(this.getAllArgs().filter(({ name }) => keyStr === name));
|
|
487
|
+
args = new Set(init ? [] : this.getAllArgs().filter(({ name }) => keyStr === name));
|
|
472
488
|
this.#args.set(keyStr, args);
|
|
473
489
|
}
|
|
474
490
|
/* NOT FOR BROWSER */
|
|
@@ -618,6 +634,23 @@ let TranscludeToken = (() => {
|
|
|
618
634
|
}
|
|
619
635
|
return token;
|
|
620
636
|
}
|
|
637
|
+
/**
|
|
638
|
+
* Get all parameters
|
|
639
|
+
*
|
|
640
|
+
* 获取所有参数
|
|
641
|
+
*/
|
|
642
|
+
getAllArgs() {
|
|
643
|
+
const { childNodes } = this, i = childNodes.findIndex(({ type }) => type === 'parameter');
|
|
644
|
+
return i === -1 ? [] : childNodes.slice(i);
|
|
645
|
+
}
|
|
646
|
+
/**
|
|
647
|
+
* Get all anonymous parameters
|
|
648
|
+
*
|
|
649
|
+
* 获取所有匿名参数
|
|
650
|
+
*/
|
|
651
|
+
getAnonArgs() {
|
|
652
|
+
return this.getAllArgs().filter(({ anon }) => anon);
|
|
653
|
+
}
|
|
621
654
|
/**
|
|
622
655
|
* Check if there is a parameter with the specified name
|
|
623
656
|
*
|
|
@@ -626,7 +659,7 @@ let TranscludeToken = (() => {
|
|
|
626
659
|
* @param exact whether to match anonymosity / 是否匹配匿名性
|
|
627
660
|
*/
|
|
628
661
|
hasArg(key, exact) {
|
|
629
|
-
return this.getArgs(key, exact, false).size > 0;
|
|
662
|
+
return this.getArgs(key, exact, false, false).size > 0;
|
|
630
663
|
}
|
|
631
664
|
/**
|
|
632
665
|
* Get the effective parameter with the specified name
|
package/dist/util/constants.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/* NOT FOR BROWSER */
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.tagHooks = exports.functionHooks = exports.states = exports.aliases = exports.parsers = exports.mixins = exports.classes = exports.mathTags = exports.extensions = exports.galleryParams = exports.enMsg = exports.BuildMethod = exports.MAX_STAGE = void 0;
|
|
4
|
+
exports.tagHooks = exports.functionHooks = exports.states = exports.aliases = exports.parsers = exports.mixins = exports.classes = exports.mathTags = exports.jsonTags = exports.extensions = exports.galleryParams = exports.enMsg = exports.BuildMethod = exports.MAX_STAGE = void 0;
|
|
5
5
|
/* NOT FOR BROWSER END */
|
|
6
6
|
exports.MAX_STAGE = 11;
|
|
7
7
|
var BuildMethod;
|
|
@@ -15,6 +15,7 @@ exports.enMsg = (() => {
|
|
|
15
15
|
})();
|
|
16
16
|
exports.galleryParams = new Set(['alt', 'link', 'lang', 'page', 'caption']);
|
|
17
17
|
exports.extensions = new Set(['tiff', 'tif', 'png', 'gif', 'jpg', 'jpeg', 'webp', 'xcf', 'pdf', 'svg', 'djvu']);
|
|
18
|
+
exports.jsonTags = ['templatedata', 'mapframe', 'maplink'];
|
|
18
19
|
/* NOT FOR BROWSER ONLY */
|
|
19
20
|
exports.mathTags = new Set(['math', 'chem', 'ce']);
|
|
20
21
|
/* NOT FOR BROWSER ONLY END */
|
package/dist/util/diff.js
CHANGED
|
@@ -18,40 +18,42 @@ process.on('unhandledRejection', e => {
|
|
|
18
18
|
* @param args shell输入参数
|
|
19
19
|
*/
|
|
20
20
|
const cmd = (command, args) => new Promise(resolve => {
|
|
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
|
-
|
|
21
|
+
NPM: {
|
|
22
|
+
let timer, shell;
|
|
23
|
+
/**
|
|
24
|
+
* 清除进程并返回
|
|
25
|
+
* @param val 返回值
|
|
26
|
+
*/
|
|
27
|
+
const r = (val) => {
|
|
28
|
+
clearTimeout(timer);
|
|
29
|
+
shell?.kill('SIGINT');
|
|
30
|
+
resolve(val);
|
|
31
|
+
};
|
|
32
|
+
try {
|
|
33
|
+
shell = (0, child_process_1.spawn)(command, args);
|
|
34
|
+
timer = setTimeout(() => {
|
|
35
|
+
/* c8 ignore next */
|
|
36
|
+
shell.kill('SIGINT');
|
|
37
|
+
}, 60 * 1e3);
|
|
38
|
+
let buf = '';
|
|
39
|
+
shell.stdout.on('data', data => {
|
|
40
|
+
buf += String(data);
|
|
41
|
+
});
|
|
42
|
+
shell.stdout.on('end', () => {
|
|
43
|
+
r(buf);
|
|
44
|
+
});
|
|
45
|
+
shell.on('exit', () => {
|
|
46
|
+
r(shell.killed ? undefined : '');
|
|
47
|
+
});
|
|
48
|
+
shell.on('error', () => {
|
|
49
|
+
r(undefined);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
catch /* c8 ignore start */ {
|
|
48
53
|
r(undefined);
|
|
49
|
-
}
|
|
54
|
+
}
|
|
55
|
+
/* c8 ignore stop */
|
|
50
56
|
}
|
|
51
|
-
catch /* c8 ignore start */ {
|
|
52
|
-
r(undefined);
|
|
53
|
-
}
|
|
54
|
-
/* c8 ignore stop */
|
|
55
57
|
});
|
|
56
58
|
exports.cmd = cmd;
|
|
57
59
|
/* c8 ignore start */
|
|
@@ -62,37 +64,37 @@ exports.cmd = cmd;
|
|
|
62
64
|
* @param uid 唯一标识
|
|
63
65
|
*/
|
|
64
66
|
const diff = async (oldStr, newStr, uid) => {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
+
NPM: {
|
|
68
|
+
if (oldStr === newStr) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const oldFile = `diffOld${uid}`, newFile = `diffNew${uid}`;
|
|
72
|
+
await Promise.all([promises_1.default.writeFile(oldFile, oldStr), promises_1.default.writeFile(newFile, newStr)]);
|
|
73
|
+
const stdout = await (0, exports.cmd)('git', [
|
|
74
|
+
'diff',
|
|
75
|
+
'--color-words=[\xC0-\xFF][\x80-\xBF]+|<?/?\\w+/?>?|[^[:space:]]',
|
|
76
|
+
'-U0',
|
|
77
|
+
'--no-index',
|
|
78
|
+
oldFile,
|
|
79
|
+
newFile,
|
|
80
|
+
]);
|
|
81
|
+
console.log(stdout?.split('\n').slice(4).join('\n'));
|
|
82
|
+
await Promise.allSettled([promises_1.default.unlink(oldFile), promises_1.default.unlink(newFile)]);
|
|
67
83
|
}
|
|
68
|
-
const oldFile = `diffOld${uid}`, newFile = `diffNew${uid}`;
|
|
69
|
-
await Promise.all([promises_1.default.writeFile(oldFile, oldStr), promises_1.default.writeFile(newFile, newStr)]);
|
|
70
|
-
const stdout = await (0, exports.cmd)('git', [
|
|
71
|
-
'diff',
|
|
72
|
-
'--color-words=[\xC0-\xFF][\x80-\xBF]+|<?/?\\w+/?>?|[^[:space:]]',
|
|
73
|
-
'-U0',
|
|
74
|
-
'--no-index',
|
|
75
|
-
oldFile,
|
|
76
|
-
newFile,
|
|
77
|
-
]);
|
|
78
|
-
console.log(stdout?.split('\n').slice(4).join('\n'));
|
|
79
|
-
await Promise.allSettled([promises_1.default.unlink(oldFile), promises_1.default.unlink(newFile)]);
|
|
80
84
|
};
|
|
81
85
|
exports.diff = diff;
|
|
82
86
|
/* c8 ignore stop */
|
|
83
87
|
/* c8 ignore start */
|
|
84
88
|
/** @implements */
|
|
85
89
|
const error = (msg, ...args) => {
|
|
86
|
-
|
|
87
|
-
console.error(util_1.default.styleText?.('red', msg) ?? msg, ...args);
|
|
90
|
+
console.error(util_1.default.styleText('red', msg), ...args);
|
|
88
91
|
};
|
|
89
92
|
exports.error = error;
|
|
90
93
|
/* c8 ignore stop */
|
|
91
94
|
/* c8 ignore start */
|
|
92
95
|
/** @implements */
|
|
93
96
|
const info = (msg, ...args) => {
|
|
94
|
-
|
|
95
|
-
console.info(util_1.default.styleText?.('green', msg) ?? msg, ...args);
|
|
97
|
+
NPM: console.info(util_1.default.styleText('green', msg), ...args);
|
|
96
98
|
};
|
|
97
99
|
exports.info = info;
|
|
98
100
|
/* c8 ignore stop */
|
package/extensions/dist/base.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
(() => {
|
|
2
2
|
var _a;
|
|
3
|
-
const version = '1.
|
|
3
|
+
const version = '1.37.0', src = (_a = document.currentScript) === null || _a === void 0 ? void 0 : _a.src, file = /\/extensions\/dist\/base\.(?:min\.)?js$/u, CDN = src && file.test(src)
|
|
4
4
|
? src.replace(file, '')
|
|
5
5
|
: `https://fastly.jsdelivr.net/npm/wikiparser-node@${version}`;
|
|
6
6
|
const workerJS = () => {
|
|
@@ -226,11 +226,11 @@ const workerJS = () => {
|
|
|
226
226
|
getLSP(qid).findStyleTokens().map(token => token.json(undefined, 2)),
|
|
227
227
|
]);
|
|
228
228
|
break;
|
|
229
|
-
case '
|
|
229
|
+
case 'querySelectorAll':
|
|
230
230
|
postMessage([
|
|
231
231
|
command,
|
|
232
232
|
qid,
|
|
233
|
-
getLSP(qid).
|
|
233
|
+
getLSP(qid).querySelectorAll(wikitext).map(node => node.json(undefined, include)),
|
|
234
234
|
]);
|
|
235
235
|
}
|
|
236
236
|
};
|
|
@@ -264,7 +264,7 @@ const getConfig = () => getFeedback('getConfig', -3);
|
|
|
264
264
|
const json = (wikitext, include, qid = -4, stage) => getFeedback('json', qid, false, wikitext, include, stage);
|
|
265
265
|
const print = (wikitext, include, stage, qid = -1) => getFeedback('print', qid, false, wikitext, include, stage);
|
|
266
266
|
const lint = (wikitext, include, qid = -2) => getFeedback('lint', qid, true, wikitext, include);
|
|
267
|
-
const provide = (command, qid, wikitext, ...args) => getFeedback(command, qid, typeof wikitext === 'string', wikitext, ...args);
|
|
267
|
+
const provide = (command, qid, wikitext, ...args) => getFeedback(command, qid, typeof wikitext === 'string' && command !== 'querySelectorAll', wikitext, ...args);
|
|
268
268
|
const append = (parent, text) => {
|
|
269
269
|
if (text) {
|
|
270
270
|
parent.append(text);
|
package/extensions/dist/lsp.js
CHANGED
|
@@ -74,11 +74,14 @@ class LanguageService {
|
|
|
74
74
|
resolveCodeAction(rule = '') {
|
|
75
75
|
return wikiparse.provide('resolveCodeAction', __classPrivateFieldGet(this, _LanguageService_id, "f"), rule, __classPrivateFieldGet(this, _LanguageService_include, "f"));
|
|
76
76
|
}
|
|
77
|
+
querySelectorAll(selector, depth) {
|
|
78
|
+
return wikiparse.provide('querySelectorAll', __classPrivateFieldGet(this, _LanguageService_id, "f"), selector, depth);
|
|
79
|
+
}
|
|
77
80
|
findStyleTokens() {
|
|
78
81
|
return wikiparse.provide('findStyleTokens', __classPrivateFieldGet(this, _LanguageService_id, "f"));
|
|
79
82
|
}
|
|
80
83
|
findTemplateTokens() {
|
|
81
|
-
return
|
|
84
|
+
return this.querySelectorAll('template', 1);
|
|
82
85
|
}
|
|
83
86
|
}
|
|
84
87
|
_LanguageService_id = new WeakMap(), _LanguageService_include = new WeakMap(), _LanguageService_hasData = new WeakMap(), _LanguageService_instances = new WeakSet(), _LanguageService_loadData = async function _LanguageService_loadData() {
|
package/extensions/editor.css
CHANGED
package/extensions/typings.d.ts
CHANGED
|
@@ -43,6 +43,7 @@ export interface LanguageServiceBase extends Omit<
|
|
|
43
43
|
provideDocumentColors(text: string): Promise<ColorInformation[]>;
|
|
44
44
|
provideColorPresentations(color: ColorInformation): Promise<ColorPresentation[]>;
|
|
45
45
|
resolveCodeAction(rule?: string): Promise<CodeAction>;
|
|
46
|
+
querySelectorAll(selector: string): Promise<AST[]>;
|
|
46
47
|
findStyleTokens(): Promise<AST[]>;
|
|
47
48
|
findTemplateTokens(): Promise<AST[]>;
|
|
48
49
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wikiparser-node",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.37.0",
|
|
4
4
|
"description": "A Node.js parser for MediaWiki markup with AST",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mediawiki",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"bugs": {
|
|
13
13
|
"url": "https://github.com/bhsd-harry/wikiparser-node/issues"
|
|
14
14
|
},
|
|
15
|
-
"license": "GPL-3.0",
|
|
15
|
+
"license": "GPL-3.0-or-later",
|
|
16
16
|
"author": "Bhsd",
|
|
17
17
|
"files": [
|
|
18
18
|
"/bundle/bundle*.js",
|
|
@@ -62,6 +62,7 @@
|
|
|
62
62
|
"test:unit": "mocha dist/test/test.js",
|
|
63
63
|
"test:clonenode": "CLONENODE=1 npm run test:unit",
|
|
64
64
|
"test:parser": "LC_ALL=en.UTF-8 mocha dist/test/parserTests.js",
|
|
65
|
+
"test:perf": "mocha --reporter spec dist/test/perf.js",
|
|
65
66
|
"test": "npm run test:unit && npm run test:clonenode && npm run test:parser",
|
|
66
67
|
"test:parseronly": "LSP=0 npm run test:parser",
|
|
67
68
|
"test:ci": "LSP=0 npm test",
|
|
@@ -81,58 +82,58 @@
|
|
|
81
82
|
]
|
|
82
83
|
},
|
|
83
84
|
"dependencies": {
|
|
84
|
-
"@bhsd/cm-util": "^
|
|
85
|
-
"@bhsd/common": "^
|
|
85
|
+
"@bhsd/cm-util": "^1.0.0",
|
|
86
|
+
"@bhsd/common": "^2.0.0",
|
|
86
87
|
"@bhsd/stylelint-util": "^1.0.1",
|
|
87
88
|
"binary-search": "^1.3.6",
|
|
88
89
|
"vscode-languageserver-types": "^3.17.5"
|
|
89
90
|
},
|
|
90
91
|
"optionalDependencies": {
|
|
91
92
|
"color-name": "^2.0.0",
|
|
92
|
-
"entities": "^
|
|
93
|
+
"entities": "^8.0.0",
|
|
93
94
|
"mathoid-texvcjs": "^0.6.0",
|
|
94
|
-
"prism-wiki": "^
|
|
95
|
+
"prism-wiki": "^2.0.0",
|
|
95
96
|
"prismjs": "^1.30.0",
|
|
96
|
-
"stylelint": "^17.
|
|
97
|
-
"vscode-css-languageservice": "^6.3.
|
|
98
|
-
"vscode-html-languageservice": "^5.6.
|
|
99
|
-
"vscode-json-languageservice": "^5.7.
|
|
97
|
+
"stylelint": "^17.5.0",
|
|
98
|
+
"vscode-css-languageservice": "^6.3.10",
|
|
99
|
+
"vscode-html-languageservice": "^5.6.2",
|
|
100
|
+
"vscode-json-languageservice": "^5.7.2"
|
|
100
101
|
},
|
|
101
102
|
"devDependencies": {
|
|
102
|
-
"@bhsd/code-standard": "^2.
|
|
103
|
-
"@bhsd/nodejs": "^
|
|
104
|
-
"@bhsd/test-util": "^0.
|
|
105
|
-
"@codemirror/lint": "^6.9.
|
|
103
|
+
"@bhsd/code-standard": "^2.1.1",
|
|
104
|
+
"@bhsd/nodejs": "^1.0.0",
|
|
105
|
+
"@bhsd/test-util": "^0.4.0",
|
|
106
|
+
"@codemirror/lint": "^6.9.5",
|
|
106
107
|
"@eslint/markdown": "^7.5.1",
|
|
107
|
-
"@stylistic/eslint-plugin": "^5.
|
|
108
|
+
"@stylistic/eslint-plugin": "^5.10.0",
|
|
108
109
|
"@types/color-name": "^2.0.0",
|
|
109
110
|
"@types/color-rgba": "^2.1.3",
|
|
110
111
|
"@types/mocha": "^10.0.10",
|
|
111
|
-
"@types/node": "^24.
|
|
112
|
+
"@types/node": "^24.11.0",
|
|
112
113
|
"@types/prismjs": "^1.26.6",
|
|
113
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
114
|
-
"@typescript-eslint/parser": "^8.
|
|
115
|
-
"c8": "^
|
|
114
|
+
"@typescript-eslint/eslint-plugin": "^8.57.0",
|
|
115
|
+
"@typescript-eslint/parser": "^8.57.0",
|
|
116
|
+
"c8": "^11.0.0",
|
|
116
117
|
"codejar-async": "^4.3.0",
|
|
117
118
|
"color-rgba": "^3.0.0",
|
|
118
119
|
"diff2html-cli": "^5.2.15",
|
|
119
|
-
"esbuild": "^0.27.
|
|
120
|
-
"eslint": "^9.39.
|
|
120
|
+
"esbuild": "^0.27.4",
|
|
121
|
+
"eslint": "^9.39.4",
|
|
121
122
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
122
|
-
"eslint-plugin-jsdoc": "^62.7.
|
|
123
|
-
"eslint-plugin-jsonc": "^
|
|
124
|
-
"eslint-plugin-n": "^17.
|
|
123
|
+
"eslint-plugin-jsdoc": "^62.7.1",
|
|
124
|
+
"eslint-plugin-jsonc": "^3.1.1",
|
|
125
|
+
"eslint-plugin-n": "^17.24.0",
|
|
125
126
|
"eslint-plugin-promise": "^7.2.1",
|
|
126
|
-
"eslint-plugin-regexp": "^3.
|
|
127
|
+
"eslint-plugin-regexp": "^3.1.0",
|
|
127
128
|
"eslint-plugin-unicorn": "^63.0.0",
|
|
128
129
|
"markdownlint-cli2": "^0.21.0",
|
|
129
130
|
"mocha": "^11.7.5",
|
|
130
|
-
"monaco-editor": "
|
|
131
|
+
"monaco-editor": "~0.53.0",
|
|
131
132
|
"typescript": "^5.9.3",
|
|
132
|
-
"v8r": "^
|
|
133
|
+
"v8r": "^6.0.0",
|
|
133
134
|
"vscode-languageserver-textdocument": "^1.0.12"
|
|
134
135
|
},
|
|
135
136
|
"engines": {
|
|
136
|
-
"node": "
|
|
137
|
+
"node": "^20.19.0 || ^22.13.0 || >=24.11.0"
|
|
137
138
|
}
|
|
138
139
|
}
|