@blocklet/meta 1.8.11 → 1.8.12
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/lib/parse-navigation.js +80 -30
- package/lib/payment.js +2 -1
- package/package.json +12 -12
package/lib/parse-navigation.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const get = require('lodash/get');
|
|
2
|
+
const cloneDeep = require('lodash/cloneDeep');
|
|
2
3
|
const isEqual = require('lodash/isEqual');
|
|
3
4
|
const normalizePathPrefix = require('@abtnode/util/lib/normalize-path-prefix');
|
|
4
5
|
|
|
@@ -16,6 +17,29 @@ const parseLink = (input, prefix) => {
|
|
|
16
17
|
return parseLinkString(input, prefix);
|
|
17
18
|
};
|
|
18
19
|
|
|
20
|
+
const getGroups = (navigation) => {
|
|
21
|
+
const groups = {};
|
|
22
|
+
for (const nav of navigation) {
|
|
23
|
+
const sections = !nav.section || !nav.section.length ? ['__undefined__'] : nav.section;
|
|
24
|
+
for (const sec of sections) {
|
|
25
|
+
if (!groups[sec]) {
|
|
26
|
+
groups[sec] = [];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const item = {
|
|
30
|
+
...nav,
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
if (nav.section) {
|
|
34
|
+
item.section = sec === '__undefined__' ? [] : [sec];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
groups[sec].push(item);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return Object.values(groups);
|
|
41
|
+
};
|
|
42
|
+
|
|
19
43
|
/**
|
|
20
44
|
* @param {*} navigation src
|
|
21
45
|
* @param {*} blocklet
|
|
@@ -37,7 +61,7 @@ const doParseNavigation = (navigation, blocklet, prefix = '/', _level = 1) => {
|
|
|
37
61
|
title: nav.title,
|
|
38
62
|
};
|
|
39
63
|
|
|
40
|
-
if (
|
|
64
|
+
if (nav.section) {
|
|
41
65
|
item.section = nav.section;
|
|
42
66
|
}
|
|
43
67
|
|
|
@@ -77,50 +101,76 @@ const doParseNavigation = (navigation, blocklet, prefix = '/', _level = 1) => {
|
|
|
77
101
|
}
|
|
78
102
|
const childTitle = child.meta.title || child.meta.name;
|
|
79
103
|
|
|
80
|
-
const
|
|
104
|
+
const itemProto = {
|
|
81
105
|
title: nav.title || childTitle,
|
|
82
106
|
};
|
|
83
107
|
|
|
84
|
-
if (
|
|
85
|
-
|
|
108
|
+
if (nav.section) {
|
|
109
|
+
itemProto.section = nav.section;
|
|
86
110
|
}
|
|
87
111
|
|
|
88
112
|
if (nav.icon) {
|
|
89
|
-
|
|
113
|
+
itemProto.icon = nav.icon;
|
|
90
114
|
}
|
|
91
115
|
|
|
92
116
|
if (nav.role) {
|
|
93
|
-
|
|
117
|
+
itemProto.role = nav.role;
|
|
94
118
|
}
|
|
95
119
|
|
|
96
|
-
|
|
97
|
-
|
|
120
|
+
// get groups by section
|
|
121
|
+
const groups = getGroups(get(child, 'meta.navigation', []));
|
|
122
|
+
|
|
123
|
+
if (!groups.length) {
|
|
98
124
|
// child does not declares menu
|
|
125
|
+
const item = cloneDeep(itemProto);
|
|
99
126
|
item.link = parseLink(child.mountPoint || '/', prefix);
|
|
100
127
|
result.push(item);
|
|
101
|
-
} else if (childNavigation.length === 1) {
|
|
102
|
-
// child declares one menu
|
|
103
|
-
item.title = nav.title || childNavigation[0].title || childTitle;
|
|
104
|
-
item.link = parseLink(childNavigation[0].link || '/', normalizePathPrefix(`${prefix}${child.mountPoint}`));
|
|
105
|
-
result.push(item);
|
|
106
128
|
} else {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
129
|
+
for (const childNavigation of groups) {
|
|
130
|
+
if (childNavigation.length === 1) {
|
|
131
|
+
// child declares one menu
|
|
132
|
+
const childNav = childNavigation[0];
|
|
133
|
+
|
|
134
|
+
const item = cloneDeep(itemProto);
|
|
135
|
+
|
|
136
|
+
item.title = nav.title || childNav.title || childTitle;
|
|
137
|
+
|
|
138
|
+
if (childNav.icon) {
|
|
139
|
+
item.icon = item.icon || childNav.icon;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if (childNav.role) {
|
|
143
|
+
item.role = item.icon || childNav.role;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (childNav.section) {
|
|
147
|
+
item.section = item.section || childNav.section;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
item.link = parseLink(childNavigation[0].link || '/', normalizePathPrefix(`${prefix}${child.mountPoint}`));
|
|
151
|
+
result.push(item);
|
|
152
|
+
} else {
|
|
153
|
+
// child declares multiple menus
|
|
154
|
+
const list = doParseNavigation(
|
|
155
|
+
childNavigation,
|
|
156
|
+
child,
|
|
157
|
+
normalizePathPrefix(`${prefix}${child.mountPoint}`),
|
|
158
|
+
_level + 1
|
|
159
|
+
);
|
|
160
|
+
|
|
161
|
+
if (_level === 1) { // eslint-disable-line
|
|
162
|
+
// primary menu
|
|
163
|
+
const item = cloneDeep(itemProto);
|
|
164
|
+
item.items = list;
|
|
165
|
+
result.push({
|
|
166
|
+
...item,
|
|
167
|
+
items: list,
|
|
168
|
+
});
|
|
169
|
+
} else {
|
|
170
|
+
// secondary menu
|
|
171
|
+
result.push(...list);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
124
174
|
}
|
|
125
175
|
}
|
|
126
176
|
});
|
package/lib/payment.js
CHANGED
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.8.
|
|
6
|
+
"version": "1.8.12",
|
|
7
7
|
"description": "Library to parse/validate/fix blocklet meta",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -18,16 +18,16 @@
|
|
|
18
18
|
"author": "wangshijun <wangshijun2020@gmail.com> (http://github.com/wangshijun)",
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@abtnode/constant": "1.8.
|
|
22
|
-
"@abtnode/util": "1.8.
|
|
23
|
-
"@arcblock/did": "1.17.
|
|
24
|
-
"@arcblock/did-ext": "1.17.
|
|
25
|
-
"@arcblock/did-util": "1.17.
|
|
26
|
-
"@arcblock/jwt": "1.17.
|
|
27
|
-
"@ocap/asset": "1.17.
|
|
28
|
-
"@ocap/mcrypto": "1.17.
|
|
29
|
-
"@ocap/util": "1.17.
|
|
30
|
-
"@ocap/wallet": "1.17.
|
|
21
|
+
"@abtnode/constant": "1.8.12",
|
|
22
|
+
"@abtnode/util": "1.8.12",
|
|
23
|
+
"@arcblock/did": "1.17.12",
|
|
24
|
+
"@arcblock/did-ext": "1.17.12",
|
|
25
|
+
"@arcblock/did-util": "1.17.12",
|
|
26
|
+
"@arcblock/jwt": "1.17.12",
|
|
27
|
+
"@ocap/asset": "1.17.12",
|
|
28
|
+
"@ocap/mcrypto": "1.17.12",
|
|
29
|
+
"@ocap/util": "1.17.12",
|
|
30
|
+
"@ocap/wallet": "1.17.12",
|
|
31
31
|
"ajv": "^8.11.0",
|
|
32
32
|
"cjk-length": "^1.0.0",
|
|
33
33
|
"debug": "^4.3.4",
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"jest": "^27.5.1"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "f4cb25a77f7ee48333b3243918a0a9c81b94ab8c"
|
|
50
50
|
}
|