@choiceform/os-client-core 3.6.53 → 3.6.55
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/README.md +183 -183
- package/changelog.md +825 -0
- package/dist/core.js +1 -1
- package/dist/web-core.js +1 -1
- package/enum2union.js +28 -28
- package/index.d.ts +5985 -5985
- package/package.json +1 -1
package/enum2union.js
CHANGED
@@ -1,28 +1,28 @@
|
|
1
|
-
/**
|
2
|
-
* typescript类型文件中包含常量枚举,某些项目中可能使用了isolatedModules编译模式,无法处理这些常量枚举,
|
3
|
-
*
|
4
|
-
* 这时候这些模块可以添加一个postinstall任务,在任务中调用该模块,就会自动将安装的常量枚举转换成联合类型
|
5
|
-
*/
|
6
|
-
const fs = require('fs');
|
7
|
-
function enum2union() {
|
8
|
-
const typeFile = __dirname + '/' + 'index.d.ts';
|
9
|
-
const content = fs.readFileSync(typeFile).toString();
|
10
|
-
if (!content.includes('declare const enum')) {
|
11
|
-
console.info('enum2union no updates: skipped');
|
12
|
-
return;
|
13
|
-
}
|
14
|
-
console.info('enum2union updated: processing...');
|
15
|
-
|
16
|
-
const unionText = content.replace(/declare const enum.+?\{\s*\n(?:.+?\s*\n)+?\s*\}/g, match => {
|
17
|
-
return match
|
18
|
-
.replace(/declare const enum (.+?) \{/, `type $1 =`)
|
19
|
-
.replace(/[A-Z_-]+ = (.*?),/g, '| $1')
|
20
|
-
.replace('}', '');
|
21
|
-
});
|
22
|
-
|
23
|
-
fs.writeFileSync(typeFile, unionText);
|
24
|
-
|
25
|
-
console.info('enum2union updated: processing succeed');
|
26
|
-
}
|
27
|
-
|
28
|
-
enum2union();
|
1
|
+
/**
|
2
|
+
* typescript类型文件中包含常量枚举,某些项目中可能使用了isolatedModules编译模式,无法处理这些常量枚举,
|
3
|
+
*
|
4
|
+
* 这时候这些模块可以添加一个postinstall任务,在任务中调用该模块,就会自动将安装的常量枚举转换成联合类型
|
5
|
+
*/
|
6
|
+
const fs = require('fs');
|
7
|
+
function enum2union() {
|
8
|
+
const typeFile = __dirname + '/' + 'index.d.ts';
|
9
|
+
const content = fs.readFileSync(typeFile).toString();
|
10
|
+
if (!content.includes('declare const enum')) {
|
11
|
+
console.info('enum2union no updates: skipped');
|
12
|
+
return;
|
13
|
+
}
|
14
|
+
console.info('enum2union updated: processing...');
|
15
|
+
|
16
|
+
const unionText = content.replace(/declare const enum.+?\{\s*\n(?:.+?\s*\n)+?\s*\}/g, match => {
|
17
|
+
return match
|
18
|
+
.replace(/declare const enum (.+?) \{/, `type $1 =`)
|
19
|
+
.replace(/[A-Z_-]+ = (.*?),/g, '| $1')
|
20
|
+
.replace('}', '');
|
21
|
+
});
|
22
|
+
|
23
|
+
fs.writeFileSync(typeFile, unionText);
|
24
|
+
|
25
|
+
console.info('enum2union updated: processing succeed');
|
26
|
+
}
|
27
|
+
|
28
|
+
enum2union();
|