@blocklet/meta 1.8.68 → 1.8.69-beta-e0666d0d

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/channel.d.ts CHANGED
@@ -1,27 +1,32 @@
1
1
  declare const getAppPublicChannelRegex: () => RegExp;
2
+ declare const getRelayChannelRegex: () => RegExp;
2
3
  declare const getAppPublicChannel: (appDid: string) => string;
4
+ declare const getRelayChannel: (appDid: string, topic: string) => string;
3
5
  declare const CHANNEL_TYPE: {
4
6
  DID: string;
5
7
  APP: string;
8
+ RELAY: string;
6
9
  };
7
10
  declare const parseChannel: (channel: string) => {
8
11
  type: string;
9
12
  appDid?: string;
13
+ topic?: string;
10
14
  };
11
- export { CHANNEL_TYPE };
12
- export { getAppPublicChannel };
13
- export { getAppPublicChannelRegex };
14
- export { parseChannel };
15
+ export { CHANNEL_TYPE, getAppPublicChannel, getAppPublicChannelRegex, getRelayChannel, getRelayChannelRegex, parseChannel, };
15
16
  declare const _default: {
16
17
  CHANNEL_TYPE: {
17
18
  DID: string;
18
19
  APP: string;
20
+ RELAY: string;
19
21
  };
20
22
  getAppPublicChannel: (appDid: string) => string;
21
23
  getAppPublicChannelRegex: () => RegExp;
24
+ getRelayChannel: (appDid: string, topic: string) => string;
25
+ getRelayChannelRegex: () => RegExp;
22
26
  parseChannel: (channel: string) => {
23
27
  type: string;
24
28
  appDid?: string;
29
+ topic?: string;
25
30
  };
26
31
  };
27
32
  export default _default;
package/lib/channel.js CHANGED
@@ -1,26 +1,39 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseChannel = exports.getAppPublicChannelRegex = exports.getAppPublicChannel = exports.CHANNEL_TYPE = void 0;
3
+ exports.parseChannel = exports.getRelayChannelRegex = exports.getRelayChannel = exports.getAppPublicChannelRegex = exports.getAppPublicChannel = exports.CHANNEL_TYPE = void 0;
4
4
  /* eslint-disable @typescript-eslint/indent */
5
5
  const did_1 = require("@arcblock/did");
6
6
  const getAppPublicChannelRegex = () => /app:(\w+):public/;
7
7
  exports.getAppPublicChannelRegex = getAppPublicChannelRegex;
8
+ const getRelayChannelRegex = () => /relay:(\w+):(\w+)/;
9
+ exports.getRelayChannelRegex = getRelayChannelRegex;
8
10
  const getAppPublicChannel = (appDid) => `app:${appDid}:public`;
9
11
  exports.getAppPublicChannel = getAppPublicChannel;
12
+ const getRelayChannel = (appDid, topic) => `relay:${appDid}:${topic}`;
13
+ exports.getRelayChannel = getRelayChannel;
10
14
  const CHANNEL_TYPE = {
11
15
  DID: 'DID',
12
16
  APP: 'APP',
17
+ RELAY: 'RELAY',
13
18
  };
14
19
  exports.CHANNEL_TYPE = CHANNEL_TYPE;
15
20
  const parseChannel = (channel) => {
16
21
  if (!channel) {
17
22
  throw new Error('Channel should not be empty');
18
23
  }
19
- const matchAppPublicChannel = getAppPublicChannelRegex().exec(channel);
20
- if (matchAppPublicChannel) {
24
+ let match = getRelayChannelRegex().exec(channel);
25
+ if (match && (0, did_1.isValid)(match[1])) {
26
+ return {
27
+ type: CHANNEL_TYPE.RELAY,
28
+ appDid: match[1],
29
+ topic: match[2],
30
+ };
31
+ }
32
+ match = getAppPublicChannelRegex().exec(channel);
33
+ if (match && (0, did_1.isValid)(match[1])) {
21
34
  return {
22
35
  type: CHANNEL_TYPE.APP,
23
- appDid: matchAppPublicChannel[1],
36
+ appDid: match[1],
24
37
  };
25
38
  }
26
39
  if ((0, did_1.isValid)(channel)) {
@@ -35,5 +48,7 @@ exports.default = {
35
48
  CHANNEL_TYPE,
36
49
  getAppPublicChannel,
37
50
  getAppPublicChannelRegex,
51
+ getRelayChannel,
52
+ getRelayChannelRegex,
38
53
  parseChannel,
39
54
  };
package/lib/did.js CHANGED
@@ -3,6 +3,9 @@ const mcrypto_1 = require("@ocap/mcrypto");
3
3
  const util_1 = require("@ocap/util");
4
4
  const did_1 = require("@arcblock/did");
5
5
  const toBlockletDid = (name) => {
6
+ if ((0, did_1.isValid)(name)) {
7
+ return name;
8
+ }
6
9
  const pk = (0, util_1.toHex)(Buffer.from(typeof name === 'string' ? name.trim() : name));
7
10
  return (0, did_1.fromPublicKey)(pk, { role: mcrypto_1.types.RoleType.ROLE_ANY });
8
11
  };
@@ -1,5 +1,9 @@
1
1
  import { Extension, Root } from 'joi';
2
2
  declare const fileExtension: (joi: Root) => Extension;
3
+ /**
4
+ * joi extend did 判断
5
+ * 由于需要兼容新旧两种 did 模式判断,所以这里不能做 role 类型判断
6
+ */
3
7
  declare const didExtension: (joi: Root) => Extension;
4
8
  export { fileExtension };
5
9
  export { didExtension };
package/lib/extension.js CHANGED
@@ -60,6 +60,10 @@ const fileExtension = (joi) => ({
60
60
  },
61
61
  });
62
62
  exports.fileExtension = fileExtension;
63
+ /**
64
+ * joi extend did 判断
65
+ * 由于需要兼容新旧两种 did 模式判断,所以这里不能做 role 类型判断
66
+ */
63
67
  const didExtension = (joi) => ({
64
68
  type: 'DID',
65
69
  base: joi.string(),
package/lib/file.d.ts CHANGED
@@ -6,7 +6,9 @@ declare const select: (dir: string, { throwOnError }?: {
6
6
  declare const update: (file: string, meta: TBlockletMeta, { fix }?: {
7
7
  fix?: boolean;
8
8
  }) => void;
9
+ declare const read: (file: string) => unknown;
9
10
  export { list };
11
+ export { read };
10
12
  export { select };
11
13
  export { update };
12
14
  declare const _default: {
package/lib/file.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.update = exports.select = exports.list = void 0;
6
+ exports.update = exports.select = exports.read = exports.list = void 0;
7
7
  const path_1 = __importDefault(require("path"));
8
8
  const js_yaml_1 = __importDefault(require("js-yaml"));
9
9
  const fs_extra_1 = __importDefault(require("fs-extra"));
@@ -43,6 +43,11 @@ const update = (file, meta, { fix = true } = {}) => {
43
43
  fs_extra_1.default.writeFileSync(file, js_yaml_1.default.dump(meta, { sortKeys: false, skipInvalid: true }));
44
44
  };
45
45
  exports.update = update;
46
+ const read = (file) => {
47
+ const fileContent = fs_extra_1.default.readFileSync(file, 'utf8').toString();
48
+ return js_yaml_1.default.load(fileContent);
49
+ };
50
+ exports.read = read;
46
51
  exports.default = {
47
52
  list,
48
53
  select,
package/lib/fix.d.ts CHANGED
@@ -8,12 +8,14 @@ declare const formatPerson: (person: string | Record<string, any>) => string;
8
8
  declare const parsePerson: (person: string) => any;
9
9
  declare const fixPerson: (data: any) => any;
10
10
  declare const fixInterfaces: (meta: any, removeMerged?: boolean) => any;
11
+ declare const fixName: (meta: any) => any;
11
12
  export { fixRequired };
12
13
  export { fixRepository };
13
14
  export { fixFiles };
14
15
  export { fixKeywords };
15
16
  export { fixPerson };
16
17
  export { fixTags };
18
+ export { fixName };
17
19
  export { formatPerson };
18
20
  export { parsePerson };
19
21
  export { fixInterfaces };
@@ -25,6 +27,7 @@ declare const _default: {
25
27
  fixKeywords: (data: any) => void;
26
28
  fixPerson: (data: any) => any;
27
29
  fixTags: (data: any) => void;
30
+ fixName: (meta: any) => any;
28
31
  formatPerson: (person: string | Record<string, any>) => string;
29
32
  parsePerson: (person: string) => any;
30
33
  fixInterfaces: (meta: any, removeMerged?: boolean) => any;
package/lib/fix.js CHANGED
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.fixService = exports.fixInterfaces = exports.parsePerson = exports.formatPerson = exports.fixTags = exports.fixPerson = exports.fixKeywords = exports.fixFiles = exports.fixRepository = exports.fixRequired = void 0;
29
+ exports.fixService = exports.fixInterfaces = exports.parsePerson = exports.formatPerson = exports.fixName = exports.fixTags = exports.fixPerson = exports.fixKeywords = exports.fixFiles = exports.fixRepository = exports.fixRequired = void 0;
30
30
  const fs_1 = __importDefault(require("fs"));
31
31
  const path_1 = __importDefault(require("path"));
32
32
  const get_1 = __importDefault(require("lodash/get"));
@@ -35,6 +35,7 @@ const debug_1 = __importDefault(require("debug"));
35
35
  const validate_1 = require("./validate");
36
36
  Object.defineProperty(exports, "fixService", { enumerable: true, get: function () { return validate_1.fixAndValidateService; } });
37
37
  const constants_1 = __importDefault(require("./constants"));
38
+ const name_1 = require("./name");
38
39
  const debug = (0, debug_1.default)('@blocklet/meta:fix');
39
40
  const { BLOCKLET_DEFAULT_VERSION, BLOCKLET_DEFAULT_PORT_NAME, BLOCKLET_DYNAMIC_PATH_PREFIX, BLOCKLET_INTERFACE_TYPE_WEB, BLOCKLET_INTERFACE_PUBLIC, } = constants_1.default;
40
41
  // Assign sensible defaults: description/main/group/version/public_url
@@ -228,6 +229,18 @@ const fixInterfaces = (meta, removeMerged = true) => {
228
229
  return meta;
229
230
  };
230
231
  exports.fixInterfaces = fixInterfaces;
232
+ const fixName = (meta) => {
233
+ const { did } = meta;
234
+ try {
235
+ (0, name_1.validateNewDid)(did);
236
+ meta.name = did;
237
+ }
238
+ catch {
239
+ /* empty */
240
+ }
241
+ return meta;
242
+ };
243
+ exports.fixName = fixName;
231
244
  exports.default = {
232
245
  fixRequired,
233
246
  fixRepository,
@@ -235,6 +248,7 @@ exports.default = {
235
248
  fixKeywords,
236
249
  fixPerson,
237
250
  fixTags,
251
+ fixName,
238
252
  formatPerson,
239
253
  parsePerson,
240
254
  fixInterfaces,
package/lib/index.d.ts CHANGED
@@ -6,13 +6,14 @@ import getBlockletWallet from './wallet';
6
6
  import getBlockletInfo from './info';
7
7
  import getBlockletEngine from './engine';
8
8
  import { validateMeta, fixAndValidateService } from './validate';
9
- import { formatPerson, parsePerson, fixPerson, fixInterfaces, fixService } from './fix';
10
- import { list, select, update } from './file';
9
+ import { formatPerson, parsePerson, fixPerson, fixInterfaces, fixService, fixName } from './fix';
10
+ import { list, select, update, read } from './file';
11
11
  import verifyMultiSig from './verify-multi-sig';
12
12
  export { constants };
13
13
  export { list };
14
14
  export { select };
15
15
  export { update };
16
+ export { read };
16
17
  export { parse };
17
18
  export { validateMeta };
18
19
  export { fixAndValidateService };
@@ -21,6 +22,7 @@ export { parsePerson };
21
22
  export { fixPerson };
22
23
  export { fixInterfaces };
23
24
  export { fixService };
25
+ export { fixName };
24
26
  export { toBlockletDid };
25
27
  export { getBlockletWallet };
26
28
  export { getBlockletInfo };
@@ -35,6 +37,7 @@ declare const _default: {
35
37
  update: (file: string, meta: import("./types").TBlockletMeta, { fix }?: {
36
38
  fix?: boolean;
37
39
  }) => void;
40
+ read: (file: string) => unknown;
38
41
  parse: (dir: string, { ensureMain, ensureFiles, ensureDist, ensureComponentStore, extraRawAttrs, schemaOptions, defaultStoreUrl, fix, }?: {
39
42
  ensureMain?: boolean;
40
43
  ensureFiles?: boolean;
@@ -59,6 +62,7 @@ declare const _default: {
59
62
  parsePerson: (person: string) => any;
60
63
  fixPerson: (data: any) => any;
61
64
  fixInterfaces: (meta: any, removeMerged?: boolean) => any;
65
+ fixName: (meta: any) => any;
62
66
  fixService: (meta: import("./types").TBlockletMeta) => import("./types").TBlockletMeta;
63
67
  toBlockletDid: {
64
68
  (name: string | Buffer): string;
@@ -70,7 +74,7 @@ declare const _default: {
70
74
  name: string;
71
75
  };
72
76
  };
73
- getBlockletWallet: (blockletDid: string, nodeSk?: string, type?: import("@arcblock/did").DIDType, index?: number) => import("@ocap/wallet").WalletObject<string>;
77
+ getBlockletWallet: (blockletDid: string, nodeSk?: string, type?: string | import("@arcblock/did").DIDType, index?: number) => import("@ocap/wallet").WalletObject<string>;
74
78
  getBlockletInfo: (state: import("@abtnode/client").BlockletState, nodeSk?: string, { returnWallet }?: {
75
79
  returnWallet?: boolean;
76
80
  }) => {
@@ -78,9 +82,10 @@ declare const _default: {
78
82
  name: string;
79
83
  version: string;
80
84
  description: string;
81
- passportColor?: string;
85
+ passportColor: string;
82
86
  appUrl: string;
83
- wallet?: import("@ocap/wallet").WalletObject<string>;
87
+ wallet: import("@ocap/wallet").WalletObject<string>;
88
+ permanentWallet: import("@ocap/wallet").WalletObject<string>;
84
89
  };
85
90
  getBlockletEngine: (meta: import("./types").TBlockletMeta) => import("./types").TEngine;
86
91
  verifyMultiSig: (blockletMeta: import("./types").TBlockletMeta) => boolean;
package/lib/index.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.verifyMultiSig = exports.getBlockletEngine = exports.getBlockletInfo = exports.getBlockletWallet = exports.toBlockletDid = exports.fixService = exports.fixInterfaces = exports.fixPerson = exports.parsePerson = exports.formatPerson = exports.fixAndValidateService = exports.validateMeta = exports.parse = exports.update = exports.select = exports.list = exports.constants = void 0;
6
+ exports.verifyMultiSig = exports.getBlockletEngine = exports.getBlockletInfo = exports.getBlockletWallet = exports.toBlockletDid = exports.fixName = exports.fixService = exports.fixInterfaces = exports.fixPerson = exports.parsePerson = exports.formatPerson = exports.fixAndValidateService = exports.validateMeta = exports.parse = exports.read = exports.update = exports.select = exports.list = exports.constants = void 0;
7
7
  const constants_1 = __importDefault(require("./constants"));
8
8
  exports.constants = constants_1.default;
9
9
  const parse_1 = __importDefault(require("./parse"));
@@ -25,10 +25,12 @@ Object.defineProperty(exports, "parsePerson", { enumerable: true, get: function
25
25
  Object.defineProperty(exports, "fixPerson", { enumerable: true, get: function () { return fix_1.fixPerson; } });
26
26
  Object.defineProperty(exports, "fixInterfaces", { enumerable: true, get: function () { return fix_1.fixInterfaces; } });
27
27
  Object.defineProperty(exports, "fixService", { enumerable: true, get: function () { return fix_1.fixService; } });
28
+ Object.defineProperty(exports, "fixName", { enumerable: true, get: function () { return fix_1.fixName; } });
28
29
  const file_1 = require("./file");
29
30
  Object.defineProperty(exports, "list", { enumerable: true, get: function () { return file_1.list; } });
30
31
  Object.defineProperty(exports, "select", { enumerable: true, get: function () { return file_1.select; } });
31
32
  Object.defineProperty(exports, "update", { enumerable: true, get: function () { return file_1.update; } });
33
+ Object.defineProperty(exports, "read", { enumerable: true, get: function () { return file_1.read; } });
32
34
  const verify_multi_sig_1 = __importDefault(require("./verify-multi-sig"));
33
35
  exports.verifyMultiSig = verify_multi_sig_1.default;
34
36
  exports.default = {
@@ -36,6 +38,7 @@ exports.default = {
36
38
  list: file_1.list,
37
39
  select: file_1.select,
38
40
  update: file_1.update,
41
+ read: file_1.read,
39
42
  parse: parse_1.default,
40
43
  validateMeta: validate_1.validateMeta,
41
44
  fixAndValidateService: validate_1.fixAndValidateService,
@@ -43,6 +46,7 @@ exports.default = {
43
46
  parsePerson: fix_1.parsePerson,
44
47
  fixPerson: fix_1.fixPerson,
45
48
  fixInterfaces: fix_1.fixInterfaces,
49
+ fixName: fix_1.fixName,
46
50
  fixService: fix_1.fixService,
47
51
  toBlockletDid: did_1.default,
48
52
  getBlockletWallet: wallet_1.default,
package/lib/info.d.ts CHANGED
@@ -7,8 +7,9 @@ declare const getBlockletInfo: (state: BlockletState, nodeSk?: string, { returnW
7
7
  name: string;
8
8
  version: string;
9
9
  description: string;
10
- passportColor?: string;
10
+ passportColor: string;
11
11
  appUrl: string;
12
- wallet?: WalletObject;
12
+ wallet: WalletObject;
13
+ permanentWallet: WalletObject;
13
14
  };
14
15
  export = getBlockletInfo;
package/lib/info.js CHANGED
@@ -25,21 +25,26 @@ const getBlockletInfo = (state, nodeSk, { returnWallet = true } = {}) => {
25
25
  version,
26
26
  name,
27
27
  description,
28
+ passportColor,
28
29
  appUrl,
30
+ wallet: null,
31
+ permanentWallet: null,
29
32
  };
30
33
  }
31
34
  const customSk = envs.find((x) => x.key === 'BLOCKLET_APP_SK');
32
35
  const customType = envs.find((x) => x.key === 'BLOCKLET_WALLET_TYPE');
36
+ const permanentSk = envs.find((x) => x.key === 'BLOCKLET_APP_PSK');
33
37
  let type;
34
38
  if (customType && customType.value === 'eth') {
35
39
  type = customType.value;
36
40
  }
37
41
  let wallet = null;
38
- if (customSk && customSk.value && customType) {
39
- wallet = (0, wallet_1.default)(customSk.value, null, type);
40
- }
41
- else if (customSk && customSk.value) {
42
- wallet = (0, wallet_1.default)(customSk.value);
42
+ let permanentWallet = null;
43
+ if (customSk && customSk.value) {
44
+ wallet = (0, wallet_1.default)(customSk.value, undefined, type);
45
+ if (permanentSk && permanentSk.value && permanentSk.value !== customSk.value) {
46
+ permanentWallet = (0, wallet_1.default)(permanentSk.value, undefined, type);
47
+ }
43
48
  }
44
49
  else {
45
50
  if (!nodeSk || typeof nodeSk !== 'string') {
@@ -60,6 +65,7 @@ const getBlockletInfo = (state, nodeSk, { returnWallet = true } = {}) => {
60
65
  passportColor,
61
66
  appUrl,
62
67
  wallet,
68
+ permanentWallet: permanentWallet || wallet,
63
69
  };
64
70
  };
65
71
  module.exports = getBlockletInfo;
package/lib/name.d.ts CHANGED
@@ -1,5 +1,11 @@
1
+ /**
2
+ * 检查一个 did 是否为新版 blocklet-did(这里只需要判断是否为 ROLE_BLOCKLET 即可)
3
+ * @param did 需要检查是否为新版 did 的值
4
+ */
5
+ export declare const validateNewDid: (did: string) => void;
1
6
  export declare const validateName: (name: string) => void;
2
7
  declare const _default: {
3
8
  validateName: (name: string) => void;
9
+ validateNewDid: (did: string) => void;
4
10
  };
5
11
  export default _default;
package/lib/name.js CHANGED
@@ -3,15 +3,39 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.validateName = void 0;
6
+ exports.validateName = exports.validateNewDid = void 0;
7
+ const did_1 = require("@arcblock/did");
7
8
  const validate_npm_package_name_1 = __importDefault(require("validate-npm-package-name"));
9
+ const MAX_NAME_LENGTH = 32;
10
+ /**
11
+ * 检查一个 did 是否为新版 blocklet-did(这里只需要判断是否为 ROLE_BLOCKLET 即可)
12
+ * @param did 需要检查是否为新版 did 的值
13
+ */
14
+ const validateNewDid = (did) => {
15
+ const typeInfo = (0, did_1.toTypeInfo)(did);
16
+ if (typeInfo.role !== did_1.types.RoleType.ROLE_BLOCKLET) {
17
+ throw new Error("Blocklet DID's type must be ROLE_BLOCKLET");
18
+ }
19
+ };
20
+ exports.validateNewDid = validateNewDid;
8
21
  const validateName = (name) => {
9
- const { validForNewPackages, errors = [], warnings = [] } = (0, validate_npm_package_name_1.default)(name);
10
- if (!validForNewPackages) {
11
- throw new Error(errors[0] || warnings[0]);
22
+ if ((0, did_1.isValid)(name)) {
23
+ // new did mode
24
+ (0, exports.validateNewDid)(name);
25
+ }
26
+ else {
27
+ // old did mode
28
+ const { validForNewPackages, errors = [], warnings = [] } = (0, validate_npm_package_name_1.default)(name);
29
+ if (!validForNewPackages) {
30
+ throw new Error(errors[0] || warnings[0]);
31
+ }
32
+ if (name.length > MAX_NAME_LENGTH) {
33
+ throw new Error('Blocklet name is too long');
34
+ }
12
35
  }
13
36
  };
14
37
  exports.validateName = validateName;
15
38
  exports.default = {
16
39
  validateName: exports.validateName,
40
+ validateNewDid: exports.validateNewDid,
17
41
  };
@@ -74,13 +74,13 @@ function tryParseItem(item) {
74
74
  try {
75
75
  return JSON.parse(item);
76
76
  }
77
- catch (_a) {
77
+ catch {
78
78
  return item;
79
79
  }
80
80
  }
81
81
  function normalizeNavigationList(navigationList) {
82
82
  return navigationList.map((item) => {
83
- const tempData = Object.assign({}, item);
83
+ const tempData = { ...item };
84
84
  if (tempData.role) {
85
85
  tempData.role = tryParseItem(tempData.role);
86
86
  }
@@ -209,11 +209,10 @@ function parseBlockletNavigationList(blocklet = {}) {
209
209
  * @returns
210
210
  */
211
211
  function genNavigationListByBlocklet(current, parent = {}) {
212
- var _a, _b, _c, _d, _e, _f, _g;
213
212
  const targetList = [];
214
213
  const { children = [], meta = {} } = current;
215
- const navigation = (0, cloneDeep_1.default)((meta === null || meta === void 0 ? void 0 : meta.navigation) || []);
216
- if (((_b = (_a = current.meta) === null || _a === void 0 ? void 0 : _a.capabilities) === null || _b === void 0 ? void 0 : _b.navigation) !== false) {
214
+ const navigation = (0, cloneDeep_1.default)(meta?.navigation || []);
215
+ if (current.meta?.capabilities?.navigation !== false) {
217
216
  targetList.push(...navigation);
218
217
  }
219
218
  const parentName = parent.name || '';
@@ -226,15 +225,17 @@ function parseBlockletNavigationList(blocklet = {}) {
226
225
  const mergeName = [parentName, currentName, childName].filter(Boolean).join('.');
227
226
  const childNavigation = child.meta.navigation || [];
228
227
  const mergeBase = (0, url_join_1.default)(parentBase, currentBase, childBase);
229
- if (((_d = (_c = child.meta) === null || _c === void 0 ? void 0 : _c.capabilities) === null || _d === void 0 ? void 0 : _d.navigation) !== false) {
228
+ if (child.meta?.capabilities?.navigation !== false) {
230
229
  components.push({
231
230
  did: child.meta.did,
232
231
  name: mergeName,
233
232
  link: mergeBase,
234
233
  title: child.meta.title || '',
235
- navigation: childNavigation.map((item) => (Object.assign({
234
+ navigation: childNavigation.map((item) => ({
236
235
  // 给每个 navigation 赋予一个 setion,用于在 autocomplete 提供依据 section 筛选的基础
237
- section: DEFAULT_SECTION }, item))),
236
+ section: DEFAULT_SECTION,
237
+ ...item,
238
+ })),
238
239
  });
239
240
  }
240
241
  // 在现有的 navigation 中判断是否存在 children
@@ -250,7 +251,7 @@ function parseBlockletNavigationList(blocklet = {}) {
250
251
  if (child.meta.navigation && child.meta.navigation.length > 0) {
251
252
  const items = genNavigationListByBlocklet(child, { mountPoint: currentBase, name: currentName });
252
253
  if (items.length > 0) {
253
- matchNavigation.items = (_e = matchNavigation.items) !== null && _e !== void 0 ? _e : [];
254
+ matchNavigation.items = matchNavigation.items ?? [];
254
255
  matchNavigation.items.push(...items);
255
256
  }
256
257
  }
@@ -259,7 +260,7 @@ function parseBlockletNavigationList(blocklet = {}) {
259
260
  }
260
261
  }
261
262
  }
262
- else if (((_g = (_f = child.meta) === null || _f === void 0 ? void 0 : _f.capabilities) === null || _g === void 0 ? void 0 : _g.navigation) !== false) {
263
+ else if (child.meta?.capabilities?.navigation !== false) {
263
264
  const childItems = genNavigationListByBlocklet(child, { mountPoint: currentBase, name: currentName });
264
265
  // 否则动态注入一个 navigation
265
266
  const tmpData = {
@@ -289,7 +290,6 @@ function parseBlockletNavigationList(blocklet = {}) {
289
290
  function patchBuiltinNavigation(navigation) {
290
291
  const copyNavigation = (0, cloneDeep_1.default)(navigation).filter((item) => item.id);
291
292
  deepWalk(copyNavigation, (item, parent) => {
292
- var _a;
293
293
  if (item.items && item.items.length) {
294
294
  for (let i = item.items.length - 1; i >= 0; i--) {
295
295
  if (!item.items[i].id) {
@@ -309,7 +309,7 @@ function patchBuiltinNavigation(navigation) {
309
309
  item.id = [parent.id, item.id].join(ID_SEPARATE);
310
310
  }
311
311
  item.from = item.from || 'yaml';
312
- item.visible = (_a = item.visible) !== null && _a !== void 0 ? _a : true;
312
+ item.visible = item.visible ?? true;
313
313
  }, { key: 'items' });
314
314
  return copyNavigation;
315
315
  }
@@ -324,7 +324,6 @@ function compactNavigation(navigation, depth = 2) {
324
324
  const resData = flatternNavigation(copyNavigation, {
325
325
  depth,
326
326
  transform: (item, parent) => {
327
- var _a;
328
327
  if (parent) {
329
328
  if (!item._parent) {
330
329
  item._parent = parent.id;
@@ -333,7 +332,7 @@ function compactNavigation(navigation, depth = 2) {
333
332
  }
334
333
  }
335
334
  item.section = item.section || parent.section || [DEFAULT_SECTION];
336
- item.visible = (_a = item.visible) !== null && _a !== void 0 ? _a : parent.visible;
335
+ item.visible = item.visible ?? parent.visible;
337
336
  }
338
337
  item.component = [parent.component, item.component].filter(Boolean).join('.');
339
338
  return item;
@@ -374,7 +373,7 @@ function getNavigationListBySection(navigationItem, section) {
374
373
  }
375
374
  return false;
376
375
  })
377
- .map((item) => (Object.assign(Object.assign({}, item), { section })));
376
+ .map((item) => ({ ...item, section }));
378
377
  }
379
378
  return [];
380
379
  }
@@ -392,7 +391,11 @@ function splitNavigationBySection(navigation) {
392
391
  // eslint-disable-next-line no-inner-declarations
393
392
  function patchNavigationItem(item, section) {
394
393
  const sectionNavigationList = getNavigationListBySection(item, section);
395
- itemNavigationList.push(Object.assign(Object.assign({}, baseNavigation), { section, items: sectionNavigationList }));
394
+ itemNavigationList.push({
395
+ ...baseNavigation,
396
+ section,
397
+ items: sectionNavigationList,
398
+ });
396
399
  }
397
400
  if (Array.isArray(navigationItem.section)) {
398
401
  for (const section of navigationItem.section) {
@@ -415,7 +418,10 @@ function splitNavigationBySection(navigation) {
415
418
  }
416
419
  }
417
420
  else {
418
- itemNavigationList.push(Object.assign(Object.assign({}, navigationItem), { section: DEFAULT_SECTION }));
421
+ itemNavigationList.push({
422
+ ...navigationItem,
423
+ section: DEFAULT_SECTION,
424
+ });
419
425
  }
420
426
  allNavigationList.push(...itemNavigationList);
421
427
  }
@@ -453,7 +459,7 @@ exports.nestNavigationList = nestNavigationList;
453
459
  function filterNavigation(navigationList, components = []) {
454
460
  const nestedNavigation = nestNavigationList(navigationList);
455
461
  deepWalk(nestedNavigation, (item) => {
456
- if (item === null || item === void 0 ? void 0 : item.component) {
462
+ if (item?.component) {
457
463
  if (!components.some((x) => x.name === item.component)) {
458
464
  item.visible = false;
459
465
  }
@@ -467,14 +473,13 @@ function filterNavigation(navigationList, components = []) {
467
473
  }
468
474
  }, { key: 'items' });
469
475
  const filteredNavigation = nestedNavigation.filter((item) => {
470
- var _a;
471
476
  if (item.visible === false)
472
477
  return false;
473
478
  // 如果某一菜单的 子菜单 均为隐藏状态,则一级菜单本身也不显示出来
474
479
  if (item.items &&
475
480
  Array.isArray(item.items) &&
476
481
  item.items.length > 0 &&
477
- ((_a = item.items) === null || _a === void 0 ? void 0 : _a.every((v) => v.visible === false)))
482
+ item.items?.every((v) => v.visible === false))
478
483
  return false;
479
484
  return true;
480
485
  });
@@ -494,10 +499,9 @@ function cleanOrphanNavigation(list) {
494
499
  }
495
500
  exports.cleanOrphanNavigation = cleanOrphanNavigation;
496
501
  function parseNavigation(blocklet = {}, options = {}) {
497
- var _a;
498
502
  const { beforeProcess = (v) => v } = options;
499
503
  const { navigationList: builtinNavigation, components } = parseBlockletNavigationList(blocklet);
500
- const customNavigationList = ((_a = blocklet === null || blocklet === void 0 ? void 0 : blocklet.settings) === null || _a === void 0 ? void 0 : _a.navigations) || [];
504
+ const customNavigationList = blocklet?.settings?.navigations || [];
501
505
  const compactedNavigation = compactNavigation(beforeProcess(builtinNavigation));
502
506
  const patchedNavigation = patchBuiltinNavigation(compactedNavigation);
503
507
  const splitNavigation = splitNavigationBySection(patchedNavigation);
@@ -509,7 +513,7 @@ function parseNavigation(blocklet = {}, options = {}) {
509
513
  const { section } = cur;
510
514
  const link = smartJoinLink(cur.link, x.link);
511
515
  const component = [cur.component, x.component].filter(Boolean).join('.');
512
- return Object.assign(Object.assign({}, x), { section, link, component, parent: '' });
516
+ return { ...x, section, link, component, parent: '' };
513
517
  }));
514
518
  return all;
515
519
  }
@@ -520,10 +524,10 @@ function parseNavigation(blocklet = {}, options = {}) {
520
524
  const flatNavigation = flatternNavigation(levelUpNavigation, {
521
525
  transform(item, parent) {
522
526
  let { component } = item;
523
- if (parent === null || parent === void 0 ? void 0 : parent.component) {
527
+ if (parent?.component) {
524
528
  component = [parent.component, item.component].filter(Boolean).join('.');
525
529
  }
526
- return Object.assign(Object.assign({}, item), { component });
530
+ return { ...item, component };
527
531
  },
528
532
  });
529
533
  const rawNavigation = (0, unionWith_1.default)(normalizeNavigationList(customNavigationList), flatNavigation, (prev, next) => {