@bhsd/common 0.14.0 → 0.14.2
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/dist/index.d.ts +2 -1
- package/dist/index.js +5 -4
- package/dist/index.mjs +5 -4
- package/dist/stylelint.d.ts +3 -3
- package/eslintrc.browser.cjs +10 -0
- package/package.json +10 -10
package/dist/index.d.ts
CHANGED
|
@@ -52,11 +52,12 @@ export declare const compareVersion: (version: string, baseVersion: string) => b
|
|
|
52
52
|
* @param url 下载地址
|
|
53
53
|
* @param cur 当前版本号
|
|
54
54
|
* @param languages 语言代码列表
|
|
55
|
+
* @param acceptableLangs 可接受的语言代码列表
|
|
55
56
|
* @param key 存储的键名
|
|
56
57
|
* @param i18n 已存储的I18N对象
|
|
57
58
|
* @throws `Error` 无法获取语言包
|
|
58
59
|
*/
|
|
59
|
-
export declare const setI18N: (url: string, cur: string, languages: string[] | string, key: string, i18n?: Record<string, string>) => Promise<Record<string, string>>;
|
|
60
|
+
export declare const setI18N: (url: string, cur: string, languages: string[] | string, acceptableLangs: string[], key: string, i18n?: Record<string, string>) => Promise<Record<string, string>>;
|
|
60
61
|
/**
|
|
61
62
|
* 加载 wikiparse
|
|
62
63
|
* @param getConfig 获取解析配置的函数
|
package/dist/index.js
CHANGED
|
@@ -116,14 +116,14 @@ const compareVersion = (version, baseVersion) => {
|
|
|
116
116
|
const [major, minor] = parseVersion(version), [baseMajor, baseMinor] = parseVersion(baseVersion);
|
|
117
117
|
return major > baseMajor || major === baseMajor && minor >= baseMinor;
|
|
118
118
|
};
|
|
119
|
-
const setI18N = async (url, cur, languages, key, i18n = getObject(key) ?? {}) => {
|
|
119
|
+
const setI18N = async (url, cur, languages, acceptableLangs, key, i18n = getObject(key) ?? {}) => {
|
|
120
120
|
const { version, lang } = i18n, langs = Array.isArray(languages) ? languages : [languages];
|
|
121
121
|
if (version === cur && langs.includes(lang)) {
|
|
122
122
|
return i18n;
|
|
123
123
|
}
|
|
124
124
|
for (const language of langs) {
|
|
125
125
|
const l = language.toLowerCase();
|
|
126
|
-
if (!
|
|
126
|
+
if (!acceptableLangs.includes(l)) {
|
|
127
127
|
continue;
|
|
128
128
|
}
|
|
129
129
|
try {
|
|
@@ -156,7 +156,7 @@ const getWikiparse = async (getConfig, langs, cdn) => {
|
|
|
156
156
|
i18nLoaded = true;
|
|
157
157
|
const key = "wikiparse-i18n", { version } = wikiparse;
|
|
158
158
|
try {
|
|
159
|
-
wikiparse.setI18N(await setI18N(`${wikiparse.CDN}/i18n`, version, langs, key));
|
|
159
|
+
wikiparse.setI18N(await setI18N(`${wikiparse.CDN}/i18n`, version, langs, define_LANGS_default, key));
|
|
160
160
|
} catch {
|
|
161
161
|
setObject(key, { version, lang: "en" });
|
|
162
162
|
}
|
|
@@ -177,8 +177,9 @@ const refreshStdout = (str) => {
|
|
|
177
177
|
process.stdout.write(`\x1B[K\x1B[?7l${str}\x1B[?7h\r`);
|
|
178
178
|
};
|
|
179
179
|
function getRegex(f) {
|
|
180
|
+
const map = /* @__PURE__ */ new Map(), weakMap = /* @__PURE__ */ new WeakMap();
|
|
180
181
|
return (s) => {
|
|
181
|
-
const regexp =
|
|
182
|
+
const regexp = typeof s === "string" ? map : weakMap;
|
|
182
183
|
if (regexp.has(s)) {
|
|
183
184
|
const re2 = regexp.get(s);
|
|
184
185
|
re2.lastIndex = 0;
|
package/dist/index.mjs
CHANGED
|
@@ -77,14 +77,14 @@ const compareVersion = (version, baseVersion) => {
|
|
|
77
77
|
const [major, minor] = parseVersion(version), [baseMajor, baseMinor] = parseVersion(baseVersion);
|
|
78
78
|
return major > baseMajor || major === baseMajor && minor >= baseMinor;
|
|
79
79
|
};
|
|
80
|
-
const setI18N = async (url, cur, languages, key, i18n = getObject(key) ?? {}) => {
|
|
80
|
+
const setI18N = async (url, cur, languages, acceptableLangs, key, i18n = getObject(key) ?? {}) => {
|
|
81
81
|
const { version, lang } = i18n, langs = Array.isArray(languages) ? languages : [languages];
|
|
82
82
|
if (version === cur && langs.includes(lang)) {
|
|
83
83
|
return i18n;
|
|
84
84
|
}
|
|
85
85
|
for (const language of langs) {
|
|
86
86
|
const l = language.toLowerCase();
|
|
87
|
-
if (!
|
|
87
|
+
if (!acceptableLangs.includes(l)) {
|
|
88
88
|
continue;
|
|
89
89
|
}
|
|
90
90
|
try {
|
|
@@ -117,7 +117,7 @@ const getWikiparse = async (getConfig, langs, cdn) => {
|
|
|
117
117
|
i18nLoaded = true;
|
|
118
118
|
const key = "wikiparse-i18n", { version } = wikiparse;
|
|
119
119
|
try {
|
|
120
|
-
wikiparse.setI18N(await setI18N(`${wikiparse.CDN}/i18n`, version, langs, key));
|
|
120
|
+
wikiparse.setI18N(await setI18N(`${wikiparse.CDN}/i18n`, version, langs, define_LANGS_default, key));
|
|
121
121
|
} catch {
|
|
122
122
|
setObject(key, { version, lang: "en" });
|
|
123
123
|
}
|
|
@@ -138,8 +138,9 @@ const refreshStdout = (str) => {
|
|
|
138
138
|
process.stdout.write(`\x1B[K\x1B[?7l${str}\x1B[?7h\r`);
|
|
139
139
|
};
|
|
140
140
|
function getRegex(f) {
|
|
141
|
+
const map = /* @__PURE__ */ new Map(), weakMap = /* @__PURE__ */ new WeakMap();
|
|
141
142
|
return (s) => {
|
|
142
|
-
const regexp =
|
|
143
|
+
const regexp = typeof s === "string" ? map : weakMap;
|
|
143
144
|
if (regexp.has(s)) {
|
|
144
145
|
const re2 = regexp.get(s);
|
|
145
146
|
re2.lastIndex = 0;
|
package/dist/stylelint.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ import type { PublicApi, Warning, Config } from 'stylelint';
|
|
|
3
3
|
* 使用Stylelint检查CSS代码
|
|
4
4
|
* @param stylelint Stylelint实例
|
|
5
5
|
* @param code CSS代码
|
|
6
|
-
* @param
|
|
6
|
+
* @param additionalConfig 额外的规则
|
|
7
7
|
* @param fix 是否修正
|
|
8
8
|
*/
|
|
9
|
-
export declare function styleLint(stylelint: PublicApi, code: string,
|
|
10
|
-
export declare function styleLint(stylelint: PublicApi, code: string,
|
|
9
|
+
export declare function styleLint(stylelint: PublicApi, code: string, additionalConfig?: Config | Config['rules'] | null, fix: true): Promise<string>;
|
|
10
|
+
export declare function styleLint(stylelint: PublicApi, code: string, additionalConfig?: Config | Config['rules'] | null): Promise<Warning[]>;
|
package/eslintrc.browser.cjs
CHANGED
|
@@ -23,13 +23,23 @@ module.exports = {
|
|
|
23
23
|
'es-x/no-array-prototype-with': 2,
|
|
24
24
|
'es-x/no-error-cause': 2,
|
|
25
25
|
'es-x/no-map-groupby': 2,
|
|
26
|
+
'es-x/no-math-f16round': 2,
|
|
26
27
|
'es-x/no-object-groupby': 2,
|
|
27
28
|
'es-x/no-object-hasown': 2,
|
|
28
29
|
'es-x/no-promise-any': 2,
|
|
30
|
+
'es-x/no-promise-try': 2,
|
|
29
31
|
'es-x/no-promise-withresolvers': 2,
|
|
30
32
|
'es-x/no-regexp-d-flag': 2,
|
|
33
|
+
'es-x/no-regexp-escape': 2,
|
|
31
34
|
'es-x/no-regexp-lookbehind-assertions': 2,
|
|
32
35
|
'es-x/no-regexp-v-flag': 2,
|
|
36
|
+
'es-x/no-set-prototype-difference': 2,
|
|
37
|
+
'es-x/no-set-prototype-intersection': 2,
|
|
38
|
+
'es-x/no-set-prototype-isdisjointfrom': 2,
|
|
39
|
+
'es-x/no-set-prototype-issubsetof': 2,
|
|
40
|
+
'es-x/no-set-prototype-issupersetof': 2,
|
|
41
|
+
'es-x/no-set-prototype-symmetricdifference': 2,
|
|
42
|
+
'es-x/no-set-prototype-union': 2,
|
|
33
43
|
'es-x/no-string-prototype-at': 2,
|
|
34
44
|
'es-x/no-string-prototype-iswellformed': 2,
|
|
35
45
|
'es-x/no-string-prototype-replaceall': 2,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bhsd/common",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Bhsd",
|
|
6
6
|
"files": [
|
|
@@ -47,20 +47,20 @@
|
|
|
47
47
|
"@stylistic/eslint-plugin": "^3.1.0",
|
|
48
48
|
"@stylistic/stylelint-plugin": "^3.1.2",
|
|
49
49
|
"@types/mocha": "^10.0.10",
|
|
50
|
-
"@types/node": "^
|
|
51
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
52
|
-
"@typescript-eslint/parser": "^8.
|
|
53
|
-
"esbuild": "^0.25.
|
|
50
|
+
"@types/node": "^24.0.10",
|
|
51
|
+
"@typescript-eslint/eslint-plugin": "^8.35.1",
|
|
52
|
+
"@typescript-eslint/parser": "^8.35.1",
|
|
53
|
+
"esbuild": "^0.25.5",
|
|
54
54
|
"eslint": "^8.57.1",
|
|
55
|
-
"eslint-plugin-es-x": "^8.
|
|
55
|
+
"eslint-plugin-es-x": "^8.7.0",
|
|
56
56
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
57
|
-
"eslint-plugin-jsdoc": "^
|
|
57
|
+
"eslint-plugin-jsdoc": "^51.3.3",
|
|
58
58
|
"eslint-plugin-json-es": "^1.6.0",
|
|
59
|
-
"eslint-plugin-n": "^17.
|
|
59
|
+
"eslint-plugin-n": "^17.20.0",
|
|
60
60
|
"eslint-plugin-promise": "^7.2.1",
|
|
61
|
-
"eslint-plugin-regexp": "^2.
|
|
61
|
+
"eslint-plugin-regexp": "^2.9.0",
|
|
62
62
|
"eslint-plugin-unicorn": "^56.0.1",
|
|
63
|
-
"stylelint": "^16.21.
|
|
63
|
+
"stylelint": "^16.21.1",
|
|
64
64
|
"typescript": "^5.8.2",
|
|
65
65
|
"wikiparser-node": "^1.21.2"
|
|
66
66
|
}
|