@cabloy/module-info 1.3.31 → 1.3.33
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.js +151 -5
- package/dist/interface.d.ts +1 -0
- package/package.json +2 -3
- package/dist/interface.js +0 -1
- package/dist/onionScenesMeta.js +0 -40
- package/dist/utils.js +0 -130
- package/dist/vona.js +0 -1
- package/dist/zova.js +0 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,151 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
let __onionScenesMeta;
|
|
2
|
+
function getOnionScenesMeta(modules) {
|
|
3
|
+
if (!__onionScenesMeta) {
|
|
4
|
+
__onionScenesMeta = _getOnionScenesMeta(modules);
|
|
5
|
+
}
|
|
6
|
+
return __onionScenesMeta;
|
|
7
|
+
}
|
|
8
|
+
let __onionMetasMeta;
|
|
9
|
+
function getOnionMetasMeta(modules) {
|
|
10
|
+
if (!__onionMetasMeta) {
|
|
11
|
+
__onionMetasMeta = _getOnionMetasMeta(modules);
|
|
12
|
+
}
|
|
13
|
+
return __onionMetasMeta;
|
|
14
|
+
}
|
|
15
|
+
function _getOnionScenesMeta(modules) {
|
|
16
|
+
const result = {};
|
|
17
|
+
for (const moduleName in modules) {
|
|
18
|
+
const module = modules[moduleName];
|
|
19
|
+
const onions = module.info.onionsMeta?.onions;
|
|
20
|
+
if (!onions) continue;
|
|
21
|
+
for (const sceneName in onions) {
|
|
22
|
+
result[sceneName] = {
|
|
23
|
+
...onions[sceneName],
|
|
24
|
+
module
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return result;
|
|
29
|
+
}
|
|
30
|
+
function _getOnionMetasMeta(modules) {
|
|
31
|
+
const result = {};
|
|
32
|
+
for (const moduleName in modules) {
|
|
33
|
+
const module = modules[moduleName];
|
|
34
|
+
const metas = module.info.onionsMeta?.metas;
|
|
35
|
+
if (!metas) continue;
|
|
36
|
+
for (const sceneName in metas) {
|
|
37
|
+
result[sceneName] = {
|
|
38
|
+
...metas[sceneName],
|
|
39
|
+
module
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return result;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function parseInfoFromPath(pathName) {
|
|
47
|
+
if (!pathName) return;
|
|
48
|
+
pathName = pathName.replace(/\\/g, '/');
|
|
49
|
+
const parts = pathName.split('/');
|
|
50
|
+
for (let i = parts.length - 1; i >= 0; i--) {
|
|
51
|
+
const part = parts[i];
|
|
52
|
+
if (!part.includes('-')) continue;
|
|
53
|
+
const info = parseInfo(part);
|
|
54
|
+
if (!info) continue;
|
|
55
|
+
return info;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const PREFIX_A = '/api/';
|
|
59
|
+
const PREFIX_B = 'vona-module-';
|
|
60
|
+
const PREFIX_C = './vona-module-';
|
|
61
|
+
const PREFIX_D = './';
|
|
62
|
+
const PREFIX_E = '/';
|
|
63
|
+
|
|
64
|
+
// aa-hello aa/hello
|
|
65
|
+
// first check / then -
|
|
66
|
+
function parseInfo(moduleName) {
|
|
67
|
+
if (!moduleName) return;
|
|
68
|
+
if (moduleName.includes('://')) return;
|
|
69
|
+
if (moduleName.charAt(0) === '/') moduleName = moduleName.substring(1);
|
|
70
|
+
let parts = moduleName.split('/').filter(item => item);
|
|
71
|
+
if (parts.length < 2) {
|
|
72
|
+
parts = moduleName.split('-').filter(item => item);
|
|
73
|
+
if (parts.length < 2) return;
|
|
74
|
+
if (parts.length === 4) parts = parts.slice(2);
|
|
75
|
+
if (parts.length === 5) parts = parts.slice(3);
|
|
76
|
+
}
|
|
77
|
+
const info = {
|
|
78
|
+
pid: parts[0],
|
|
79
|
+
name: parts[1],
|
|
80
|
+
relativeName: `${parts[0]}-${parts[1]}`,
|
|
81
|
+
url: `${parts[0]}/${parts[1]}`,
|
|
82
|
+
originalName: parts.join('-')
|
|
83
|
+
};
|
|
84
|
+
return info;
|
|
85
|
+
}
|
|
86
|
+
function parseInfoPro(moduleName, projectMode, projectEntityType) {
|
|
87
|
+
const info = parseInfo(moduleName);
|
|
88
|
+
if (!info) return info;
|
|
89
|
+
if (['zova', 'vona'].includes(projectMode)) {
|
|
90
|
+
info.fullName = `${projectMode}-${projectEntityType}-${info.relativeName}`;
|
|
91
|
+
} else {
|
|
92
|
+
info.fullName = `cabloy-${projectEntityType}-${projectMode}-${info.relativeName}`;
|
|
93
|
+
}
|
|
94
|
+
return info;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// /api/aa/hello/home/index
|
|
98
|
+
// vona-module-aa-hello
|
|
99
|
+
// ./aa-hello/
|
|
100
|
+
// ./vona-module-aa-hello/
|
|
101
|
+
function parseName(moduleUrl) {
|
|
102
|
+
const moduleName = _parseNameInner(moduleUrl);
|
|
103
|
+
if (!moduleName) return;
|
|
104
|
+
const [a, b] = moduleName.split('-');
|
|
105
|
+
if (!a || !b) return;
|
|
106
|
+
return moduleName;
|
|
107
|
+
}
|
|
108
|
+
function _parseNameInner(moduleUrl) {
|
|
109
|
+
if (!moduleUrl) return;
|
|
110
|
+
if (moduleUrl.indexOf('/api/static/') === 0) {
|
|
111
|
+
moduleUrl = `/api/${moduleUrl.substring('/api/static/'.length)}`;
|
|
112
|
+
}
|
|
113
|
+
if (moduleUrl.indexOf(PREFIX_A) === 0) {
|
|
114
|
+
return _parseNameLikeUrl(moduleUrl, PREFIX_A);
|
|
115
|
+
} else if (moduleUrl.indexOf(PREFIX_B) === 0) {
|
|
116
|
+
return _parseName(moduleUrl, PREFIX_B);
|
|
117
|
+
} else if (moduleUrl.indexOf(PREFIX_C) === 0) {
|
|
118
|
+
return _parseName(moduleUrl, PREFIX_C);
|
|
119
|
+
} else if (moduleUrl.indexOf(PREFIX_D) === 0) {
|
|
120
|
+
return _parseName(moduleUrl, PREFIX_D);
|
|
121
|
+
} else if (moduleUrl.indexOf(PREFIX_E) === 0) {
|
|
122
|
+
return _parseNameLikeUrl(moduleUrl, PREFIX_E);
|
|
123
|
+
} else {
|
|
124
|
+
// test-home test/home
|
|
125
|
+
return _parseName(moduleUrl.replace('/', '-'), '');
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
function _parseNameLikeUrl(moduleUrl, prefix) {
|
|
129
|
+
const posA = prefix.length;
|
|
130
|
+
const posB = moduleUrl.indexOf('/', posA) + 1;
|
|
131
|
+
if (posB === 0) return;
|
|
132
|
+
let posC = moduleUrl.indexOf('/', posB);
|
|
133
|
+
if (posC === -1) posC = moduleUrl.length;
|
|
134
|
+
return moduleUrl.substring(posA, posC).replace('/', '-');
|
|
135
|
+
}
|
|
136
|
+
function _parseName(moduleUrl, prefix) {
|
|
137
|
+
const posA = prefix.length;
|
|
138
|
+
let posB = moduleUrl.indexOf('/', posA);
|
|
139
|
+
if (posB === -1) posB = moduleUrl.indexOf(':', posA);
|
|
140
|
+
if (posB === -1) posB = moduleUrl.indexOf('.', posA);
|
|
141
|
+
if (posB === -1) posB = moduleUrl.length;
|
|
142
|
+
return moduleUrl.substring(posA, posB);
|
|
143
|
+
}
|
|
144
|
+
function relativeNameToCapitalize(moduleName, firstCharToUpperCase) {
|
|
145
|
+
return moduleName.split('-').map((name, index) => {
|
|
146
|
+
if (index === 0 && !firstCharToUpperCase) return name;
|
|
147
|
+
return name.charAt(0).toUpperCase() + name.substring(1);
|
|
148
|
+
}).join('');
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export { _getOnionMetasMeta, _getOnionScenesMeta, getOnionMetasMeta, getOnionScenesMeta, parseInfo, parseInfoFromPath, parseInfoPro, parseName, relativeNameToCapitalize };
|
package/dist/interface.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cabloy/module-info",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.3.
|
|
4
|
+
"version": "1.3.33",
|
|
5
5
|
"description": "cabloy module-info",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -26,8 +26,7 @@
|
|
|
26
26
|
],
|
|
27
27
|
"gitHead": "0eab9dc4a5622caffe89e7b1b3f02c08ccbc4c4b",
|
|
28
28
|
"scripts": {
|
|
29
|
-
"lint": "eslint .",
|
|
30
29
|
"clean": "rimraf dist tsconfig.tsbuildinfo",
|
|
31
|
-
"tsc:publish": "npm run clean && tsc"
|
|
30
|
+
"tsc:publish": "npm run clean && vona :bin:buildGeneral && tsc"
|
|
32
31
|
}
|
|
33
32
|
}
|
package/dist/interface.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/onionScenesMeta.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
let __onionScenesMeta;
|
|
2
|
-
export function getOnionScenesMeta(modules) {
|
|
3
|
-
if (!__onionScenesMeta) {
|
|
4
|
-
__onionScenesMeta = _getOnionScenesMeta(modules);
|
|
5
|
-
}
|
|
6
|
-
return __onionScenesMeta;
|
|
7
|
-
}
|
|
8
|
-
let __onionMetasMeta;
|
|
9
|
-
export function getOnionMetasMeta(modules) {
|
|
10
|
-
if (!__onionMetasMeta) {
|
|
11
|
-
__onionMetasMeta = _getOnionMetasMeta(modules);
|
|
12
|
-
}
|
|
13
|
-
return __onionMetasMeta;
|
|
14
|
-
}
|
|
15
|
-
export function _getOnionScenesMeta(modules) {
|
|
16
|
-
const result = {};
|
|
17
|
-
for (const moduleName in modules) {
|
|
18
|
-
const module = modules[moduleName];
|
|
19
|
-
const onions = module.info.onionsMeta?.onions;
|
|
20
|
-
if (!onions)
|
|
21
|
-
continue;
|
|
22
|
-
for (const sceneName in onions) {
|
|
23
|
-
result[sceneName] = { ...onions[sceneName], module };
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
return result;
|
|
27
|
-
}
|
|
28
|
-
export function _getOnionMetasMeta(modules) {
|
|
29
|
-
const result = {};
|
|
30
|
-
for (const moduleName in modules) {
|
|
31
|
-
const module = modules[moduleName];
|
|
32
|
-
const metas = module.info.onionsMeta?.metas;
|
|
33
|
-
if (!metas)
|
|
34
|
-
continue;
|
|
35
|
-
for (const sceneName in metas) {
|
|
36
|
-
result[sceneName] = { ...metas[sceneName], module };
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return result;
|
|
40
|
-
}
|
package/dist/utils.js
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
export function parseInfoFromPath(pathName) {
|
|
2
|
-
if (!pathName)
|
|
3
|
-
return;
|
|
4
|
-
pathName = pathName.replace(/\\/g, '/');
|
|
5
|
-
const parts = pathName.split('/');
|
|
6
|
-
for (let i = parts.length - 1; i >= 0; i--) {
|
|
7
|
-
const part = parts[i];
|
|
8
|
-
if (!part.includes('-'))
|
|
9
|
-
continue;
|
|
10
|
-
const info = parseInfo(part);
|
|
11
|
-
if (!info)
|
|
12
|
-
continue;
|
|
13
|
-
return info;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
const PREFIX_A = '/api/';
|
|
17
|
-
const PREFIX_B = 'vona-module-';
|
|
18
|
-
const PREFIX_C = './vona-module-';
|
|
19
|
-
const PREFIX_D = './';
|
|
20
|
-
const PREFIX_E = '/';
|
|
21
|
-
// aa-hello aa/hello
|
|
22
|
-
// first check / then -
|
|
23
|
-
export function parseInfo(moduleName) {
|
|
24
|
-
if (!moduleName)
|
|
25
|
-
return;
|
|
26
|
-
if (moduleName.includes('://'))
|
|
27
|
-
return;
|
|
28
|
-
if (moduleName.charAt(0) === '/')
|
|
29
|
-
moduleName = moduleName.substring(1);
|
|
30
|
-
let parts = moduleName.split('/').filter(item => item);
|
|
31
|
-
if (parts.length < 2) {
|
|
32
|
-
parts = moduleName.split('-').filter(item => item);
|
|
33
|
-
if (parts.length < 2)
|
|
34
|
-
return;
|
|
35
|
-
if (parts.length === 4)
|
|
36
|
-
parts = parts.slice(2);
|
|
37
|
-
if (parts.length === 5)
|
|
38
|
-
parts = parts.slice(3);
|
|
39
|
-
}
|
|
40
|
-
const info = {
|
|
41
|
-
pid: parts[0],
|
|
42
|
-
name: parts[1],
|
|
43
|
-
relativeName: `${parts[0]}-${parts[1]}`,
|
|
44
|
-
url: `${parts[0]}/${parts[1]}`,
|
|
45
|
-
originalName: parts.join('-'),
|
|
46
|
-
};
|
|
47
|
-
return info;
|
|
48
|
-
}
|
|
49
|
-
export function parseInfoPro(moduleName, projectMode, projectEntityType) {
|
|
50
|
-
const info = parseInfo(moduleName);
|
|
51
|
-
if (!info)
|
|
52
|
-
return info;
|
|
53
|
-
if (['zova', 'vona'].includes(projectMode)) {
|
|
54
|
-
info.fullName = `${projectMode}-${projectEntityType}-${info.relativeName}`;
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
info.fullName = `cabloy-${projectEntityType}-${projectMode}-${info.relativeName}`;
|
|
58
|
-
}
|
|
59
|
-
return info;
|
|
60
|
-
}
|
|
61
|
-
// /api/aa/hello/home/index
|
|
62
|
-
// vona-module-aa-hello
|
|
63
|
-
// ./aa-hello/
|
|
64
|
-
// ./vona-module-aa-hello/
|
|
65
|
-
export function parseName(moduleUrl) {
|
|
66
|
-
const moduleName = _parseNameInner(moduleUrl);
|
|
67
|
-
if (!moduleName)
|
|
68
|
-
return;
|
|
69
|
-
const [a, b] = moduleName.split('-');
|
|
70
|
-
if (!a || !b)
|
|
71
|
-
return;
|
|
72
|
-
return moduleName;
|
|
73
|
-
}
|
|
74
|
-
function _parseNameInner(moduleUrl) {
|
|
75
|
-
if (!moduleUrl)
|
|
76
|
-
return;
|
|
77
|
-
if (moduleUrl.indexOf('/api/static/') === 0) {
|
|
78
|
-
moduleUrl = `/api/${moduleUrl.substring('/api/static/'.length)}`;
|
|
79
|
-
}
|
|
80
|
-
if (moduleUrl.indexOf(PREFIX_A) === 0) {
|
|
81
|
-
return _parseNameLikeUrl(moduleUrl, PREFIX_A);
|
|
82
|
-
}
|
|
83
|
-
else if (moduleUrl.indexOf(PREFIX_B) === 0) {
|
|
84
|
-
return _parseName(moduleUrl, PREFIX_B);
|
|
85
|
-
}
|
|
86
|
-
else if (moduleUrl.indexOf(PREFIX_C) === 0) {
|
|
87
|
-
return _parseName(moduleUrl, PREFIX_C);
|
|
88
|
-
}
|
|
89
|
-
else if (moduleUrl.indexOf(PREFIX_D) === 0) {
|
|
90
|
-
return _parseName(moduleUrl, PREFIX_D);
|
|
91
|
-
}
|
|
92
|
-
else if (moduleUrl.indexOf(PREFIX_E) === 0) {
|
|
93
|
-
return _parseNameLikeUrl(moduleUrl, PREFIX_E);
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
// test-home test/home
|
|
97
|
-
return _parseName(moduleUrl.replace('/', '-'), '');
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
function _parseNameLikeUrl(moduleUrl, prefix) {
|
|
101
|
-
const posA = prefix.length;
|
|
102
|
-
const posB = moduleUrl.indexOf('/', posA) + 1;
|
|
103
|
-
if (posB === 0)
|
|
104
|
-
return;
|
|
105
|
-
let posC = moduleUrl.indexOf('/', posB);
|
|
106
|
-
if (posC === -1)
|
|
107
|
-
posC = moduleUrl.length;
|
|
108
|
-
return moduleUrl.substring(posA, posC).replace('/', '-');
|
|
109
|
-
}
|
|
110
|
-
function _parseName(moduleUrl, prefix) {
|
|
111
|
-
const posA = prefix.length;
|
|
112
|
-
let posB = moduleUrl.indexOf('/', posA);
|
|
113
|
-
if (posB === -1)
|
|
114
|
-
posB = moduleUrl.indexOf(':', posA);
|
|
115
|
-
if (posB === -1)
|
|
116
|
-
posB = moduleUrl.indexOf('.', posA);
|
|
117
|
-
if (posB === -1)
|
|
118
|
-
posB = moduleUrl.length;
|
|
119
|
-
return moduleUrl.substring(posA, posB);
|
|
120
|
-
}
|
|
121
|
-
export function relativeNameToCapitalize(moduleName, firstCharToUpperCase) {
|
|
122
|
-
return moduleName
|
|
123
|
-
.split('-')
|
|
124
|
-
.map((name, index) => {
|
|
125
|
-
if (index === 0 && !firstCharToUpperCase)
|
|
126
|
-
return name;
|
|
127
|
-
return name.charAt(0).toUpperCase() + name.substring(1);
|
|
128
|
-
})
|
|
129
|
-
.join('');
|
|
130
|
-
}
|
package/dist/vona.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/zova.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|