@blocklet/meta 1.8.41 → 1.8.42
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.
|
@@ -45,9 +45,10 @@ declare function splitNavigationBySection(navigation: any): any[];
|
|
|
45
45
|
*/
|
|
46
46
|
declare function nestNavigationList(list?: any[]): any[];
|
|
47
47
|
declare function filterNavigation(navigationList: any, components?: any[]): any[];
|
|
48
|
+
declare function cleanOrphanNavigation(list: any): any;
|
|
48
49
|
declare function parseNavigation(blocklet?: {}, options?: {}): {
|
|
49
50
|
navigationList: any[];
|
|
50
51
|
components: any[];
|
|
51
52
|
builtinList: any[];
|
|
52
53
|
};
|
|
53
|
-
export { parseNavigation, deepWalk, isMatchSection, nestNavigationList, filterNavigation, joinLink, checkLink, flatternNavigation, splitNavigationBySection, };
|
|
54
|
+
export { parseNavigation, deepWalk, isMatchSection, nestNavigationList, filterNavigation, cleanOrphanNavigation, joinLink, checkLink, flatternNavigation, splitNavigationBySection, };
|
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
5
|
};
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.splitNavigationBySection = exports.flatternNavigation = exports.checkLink = exports.joinLink = exports.filterNavigation = exports.nestNavigationList = exports.isMatchSection = exports.deepWalk = exports.parseNavigation = void 0;
|
|
7
|
+
exports.splitNavigationBySection = exports.flatternNavigation = exports.checkLink = exports.joinLink = exports.cleanOrphanNavigation = exports.filterNavigation = exports.nestNavigationList = exports.isMatchSection = exports.deepWalk = exports.parseNavigation = void 0;
|
|
8
8
|
const unionWith_1 = __importDefault(require("lodash/unionWith"));
|
|
9
9
|
const isEqual_1 = __importDefault(require("lodash/isEqual"));
|
|
10
10
|
const pick_1 = __importDefault(require("lodash/pick"));
|
|
@@ -462,8 +462,8 @@ function nestNavigationList(list = []) {
|
|
|
462
462
|
}
|
|
463
463
|
exports.nestNavigationList = nestNavigationList;
|
|
464
464
|
function filterNavigation(navigationList, components = []) {
|
|
465
|
-
const
|
|
466
|
-
deepWalk(
|
|
465
|
+
const nestedNavigation = nestNavigationList(navigationList);
|
|
466
|
+
deepWalk(nestedNavigation, (item) => {
|
|
467
467
|
if (item === null || item === void 0 ? void 0 : item.component) {
|
|
468
468
|
if (!components.some((x) => x.name === item.component)) {
|
|
469
469
|
item.visible = false;
|
|
@@ -477,9 +477,22 @@ function filterNavigation(navigationList, components = []) {
|
|
|
477
477
|
}
|
|
478
478
|
}
|
|
479
479
|
}, { key: 'items' });
|
|
480
|
-
|
|
480
|
+
const filteredNavigation = nestedNavigation.filter((item) => item.visible !== false);
|
|
481
|
+
return filteredNavigation;
|
|
481
482
|
}
|
|
482
483
|
exports.filterNavigation = filterNavigation;
|
|
484
|
+
function cleanOrphanNavigation(list) {
|
|
485
|
+
// 将仅有一个 child 的菜单提升到上一级
|
|
486
|
+
return list.map((item) => {
|
|
487
|
+
if (item.items && Array.isArray(item.items) && item.items.length === 1) {
|
|
488
|
+
if (['header', 'footer', '', undefined, null].includes(item.section)) {
|
|
489
|
+
return item.items[0];
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
return item;
|
|
493
|
+
});
|
|
494
|
+
}
|
|
495
|
+
exports.cleanOrphanNavigation = cleanOrphanNavigation;
|
|
483
496
|
function parseNavigation(blocklet = {}, options = {}) {
|
|
484
497
|
var _a;
|
|
485
498
|
const { beforeProcess = (v) => v } = options;
|
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.42",
|
|
7
7
|
"description": "Library to parse/validate/fix blocklet meta",
|
|
8
8
|
"main": "./lib/index.js",
|
|
9
9
|
"typings": "./lib/index.d.ts",
|
|
@@ -24,14 +24,14 @@
|
|
|
24
24
|
"author": "wangshijun <wangshijun2020@gmail.com> (http://github.com/wangshijun)",
|
|
25
25
|
"license": "MIT",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@abtnode/client": "1.8.
|
|
28
|
-
"@abtnode/constant": "1.8.
|
|
29
|
-
"@abtnode/util": "1.8.
|
|
27
|
+
"@abtnode/client": "1.8.42",
|
|
28
|
+
"@abtnode/constant": "1.8.42",
|
|
29
|
+
"@abtnode/util": "1.8.42",
|
|
30
30
|
"@arcblock/did": "1.18.26",
|
|
31
31
|
"@arcblock/did-ext": "1.18.26",
|
|
32
32
|
"@arcblock/did-util": "1.18.26",
|
|
33
33
|
"@arcblock/jwt": "1.18.26",
|
|
34
|
-
"@blocklet/constant": "1.8.
|
|
34
|
+
"@blocklet/constant": "1.8.42",
|
|
35
35
|
"@ocap/asset": "1.18.26",
|
|
36
36
|
"@ocap/mcrypto": "1.18.26",
|
|
37
37
|
"@ocap/types": "1.18.26",
|
|
@@ -79,5 +79,5 @@
|
|
|
79
79
|
"ts-node": "^10.9.1",
|
|
80
80
|
"typescript": "^4.8.4"
|
|
81
81
|
},
|
|
82
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "04771ed44e11deb3f214b637be6e3b78ca2b9245"
|
|
83
83
|
}
|