wikiparser-node 1.36.0 → 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 +23 -23
- package/dist/bin/config.js +22 -48
- package/dist/bin/env.js +42 -0
- package/dist/index.js +18 -15
- package/dist/lib/document.d.ts +1 -2
- package/dist/lib/document.js +11 -11
- package/dist/lib/lsp.d.ts +1 -0
- package/dist/lib/lsp.js +21 -16
- package/dist/lib/node.js +4 -1
- package/dist/src/converterFlags.js +11 -7
- package/dist/src/nowiki/index.js +8 -19
- package/dist/src/parameter.js +4 -5
- 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 +19 -19
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",
|
|
@@ -82,58 +82,58 @@
|
|
|
82
82
|
]
|
|
83
83
|
},
|
|
84
84
|
"dependencies": {
|
|
85
|
-
"@bhsd/cm-util": "^
|
|
86
|
-
"@bhsd/common": "^
|
|
85
|
+
"@bhsd/cm-util": "^1.0.0",
|
|
86
|
+
"@bhsd/common": "^2.0.0",
|
|
87
87
|
"@bhsd/stylelint-util": "^1.0.1",
|
|
88
88
|
"binary-search": "^1.3.6",
|
|
89
89
|
"vscode-languageserver-types": "^3.17.5"
|
|
90
90
|
},
|
|
91
91
|
"optionalDependencies": {
|
|
92
92
|
"color-name": "^2.0.0",
|
|
93
|
-
"entities": "^
|
|
93
|
+
"entities": "^8.0.0",
|
|
94
94
|
"mathoid-texvcjs": "^0.6.0",
|
|
95
|
-
"prism-wiki": "^
|
|
95
|
+
"prism-wiki": "^2.0.0",
|
|
96
96
|
"prismjs": "^1.30.0",
|
|
97
|
-
"stylelint": "^17.
|
|
97
|
+
"stylelint": "^17.5.0",
|
|
98
98
|
"vscode-css-languageservice": "^6.3.10",
|
|
99
99
|
"vscode-html-languageservice": "^5.6.2",
|
|
100
100
|
"vscode-json-languageservice": "^5.7.2"
|
|
101
101
|
},
|
|
102
102
|
"devDependencies": {
|
|
103
|
-
"@bhsd/code-standard": "^2.1.
|
|
104
|
-
"@bhsd/nodejs": "^0.
|
|
105
|
-
"@bhsd/test-util": "^0.
|
|
106
|
-
"@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",
|
|
107
107
|
"@eslint/markdown": "^7.5.1",
|
|
108
|
-
"@stylistic/eslint-plugin": "^5.
|
|
108
|
+
"@stylistic/eslint-plugin": "^5.10.0",
|
|
109
109
|
"@types/color-name": "^2.0.0",
|
|
110
110
|
"@types/color-rgba": "^2.1.3",
|
|
111
111
|
"@types/mocha": "^10.0.10",
|
|
112
112
|
"@types/node": "^24.11.0",
|
|
113
113
|
"@types/prismjs": "^1.26.6",
|
|
114
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
115
|
-
"@typescript-eslint/parser": "^8.
|
|
114
|
+
"@typescript-eslint/eslint-plugin": "^8.57.0",
|
|
115
|
+
"@typescript-eslint/parser": "^8.57.0",
|
|
116
116
|
"c8": "^11.0.0",
|
|
117
117
|
"codejar-async": "^4.3.0",
|
|
118
118
|
"color-rgba": "^3.0.0",
|
|
119
119
|
"diff2html-cli": "^5.2.15",
|
|
120
|
-
"esbuild": "^0.27.
|
|
121
|
-
"eslint": "^9.39.
|
|
120
|
+
"esbuild": "^0.27.4",
|
|
121
|
+
"eslint": "^9.39.4",
|
|
122
122
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
123
123
|
"eslint-plugin-jsdoc": "^62.7.1",
|
|
124
124
|
"eslint-plugin-jsonc": "^3.1.1",
|
|
125
125
|
"eslint-plugin-n": "^17.24.0",
|
|
126
126
|
"eslint-plugin-promise": "^7.2.1",
|
|
127
|
-
"eslint-plugin-regexp": "^3.
|
|
127
|
+
"eslint-plugin-regexp": "^3.1.0",
|
|
128
128
|
"eslint-plugin-unicorn": "^63.0.0",
|
|
129
129
|
"markdownlint-cli2": "^0.21.0",
|
|
130
130
|
"mocha": "^11.7.5",
|
|
131
|
-
"monaco-editor": "
|
|
131
|
+
"monaco-editor": "~0.53.0",
|
|
132
132
|
"typescript": "^5.9.3",
|
|
133
133
|
"v8r": "^6.0.0",
|
|
134
134
|
"vscode-languageserver-textdocument": "^1.0.12"
|
|
135
135
|
},
|
|
136
136
|
"engines": {
|
|
137
|
-
"node": "
|
|
137
|
+
"node": "^20.19.0 || ^22.13.0 || >=24.11.0"
|
|
138
138
|
}
|
|
139
139
|
}
|