@blocklet/meta 1.16.11-beta-0ae58a71 → 1.16.11-beta-f74663ac

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.
@@ -61,7 +61,7 @@ interface FlatternNavigationOption {
61
61
  * @param {function} params.transform 当发生拍平处理时
62
62
  * @returns 扁平化后的导航列表
63
63
  */
64
- declare function flatternNavigation(list?: NavigationItem[], { depth, transform }?: FlatternNavigationOption): any[];
64
+ declare function flattenNavigation(list?: NavigationItem[], { depth, transform }?: FlatternNavigationOption): any[];
65
65
  /**
66
66
  * 根据导航中每一个子菜单所属的 section,将原由的导航数据分离为多个导航数据(此时每一个导航 item 只会包含一个 section)
67
67
  * @param {array} navigation 导航列表数据(树状结构,目前只适用于两层的树状结构)
@@ -89,4 +89,4 @@ declare function parseNavigation(blocklet?: Blocklet, options?: ParseNavigationO
89
89
  components: any[];
90
90
  builtinList: any[];
91
91
  };
92
- export { parseNavigation, deepWalk, isMatchSection, nestNavigationList, filterNavigation, cleanOrphanNavigation, joinLink, checkLink, flatternNavigation, splitNavigationBySection, };
92
+ export { parseNavigation, deepWalk, isMatchSection, nestNavigationList, filterNavigation, cleanOrphanNavigation, joinLink, checkLink, flattenNavigation, splitNavigationBySection, };
@@ -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.splitNavigationBySection = exports.flatternNavigation = exports.checkLink = exports.joinLink = exports.cleanOrphanNavigation = exports.filterNavigation = exports.nestNavigationList = exports.isMatchSection = exports.deepWalk = exports.parseNavigation = void 0;
6
+ exports.splitNavigationBySection = exports.flattenNavigation = exports.checkLink = exports.joinLink = exports.cleanOrphanNavigation = exports.filterNavigation = exports.nestNavigationList = exports.isMatchSection = exports.deepWalk = exports.parseNavigation = void 0;
7
7
  const unionWith_1 = __importDefault(require("lodash/unionWith"));
8
8
  const isEqual_1 = __importDefault(require("lodash/isEqual"));
9
9
  const pick_1 = __importDefault(require("lodash/pick"));
@@ -166,7 +166,7 @@ exports.joinLink = joinLink;
166
166
  * @param {function} params.transform 当发生拍平处理时
167
167
  * @returns 扁平化后的导航列表
168
168
  */
169
- function flatternNavigation(list = [], { depth = 1, transform = (v) => v } = {}) {
169
+ function flattenNavigation(list = [], { depth = 1, transform = (v) => v } = {}) {
170
170
  const copyList = (0, cloneDeep_1.default)(list);
171
171
  const finalList = [];
172
172
  deepWalk(copyList, (item, parent, { level }) => {
@@ -194,7 +194,7 @@ function flatternNavigation(list = [], { depth = 1, transform = (v) => v } = {})
194
194
  }, { key: 'items', order: 'last' });
195
195
  return finalList;
196
196
  }
197
- exports.flatternNavigation = flatternNavigation;
197
+ exports.flattenNavigation = flattenNavigation;
198
198
  /**
199
199
  * 将 blocklet 中的数据进行处理,获得当前应用的导航数据及组件数据
200
200
  * @param {object} blocklet blocklet 应用实例对象
@@ -321,7 +321,7 @@ function patchBuiltinNavigation(navigation) {
321
321
  */
322
322
  function compactNavigation(navigation, depth = 2) {
323
323
  const copyNavigation = (0, cloneDeep_1.default)(navigation);
324
- const resData = flatternNavigation(copyNavigation, {
324
+ const resData = flattenNavigation(copyNavigation, {
325
325
  depth,
326
326
  transform: (item, parent) => {
327
327
  if (parent) {
@@ -533,7 +533,7 @@ function parseNavigation(blocklet = {}, options = {}) {
533
533
  all.push(cur);
534
534
  return all;
535
535
  }, []);
536
- const flatNavigation = flatternNavigation(levelUpNavigation, {
536
+ const flatNavigation = flattenNavigation(levelUpNavigation, {
537
537
  transform(item, parent) {
538
538
  let { component } = item;
539
539
  if (parent?.component) {
@@ -240,14 +240,14 @@ declare const _default: {
240
240
  decimal: number;
241
241
  }[];
242
242
  components: any;
243
- }) => Promise<{
243
+ }) => {
244
244
  code: string;
245
245
  shares: {
246
246
  amount: string;
247
247
  tokenAddress: string;
248
248
  accountAddress: string;
249
249
  }[];
250
- }>;
250
+ };
251
251
  };
252
252
  };
253
253
  };
@@ -140,14 +140,14 @@ export declare const _test: {
140
140
  decimal: number;
141
141
  }>;
142
142
  components: any;
143
- }) => Promise<{
143
+ }) => {
144
144
  code: string;
145
145
  shares: {
146
146
  amount: string;
147
147
  tokenAddress: string;
148
148
  accountAddress: string;
149
149
  }[];
150
- }>;
150
+ };
151
151
  };
152
152
  export { createNftFactoryItx };
153
153
  export { verifyPaymentIntegrity };
@@ -229,14 +229,14 @@ declare const _default: {
229
229
  decimal: number;
230
230
  }[];
231
231
  components: any;
232
- }) => Promise<{
232
+ }) => {
233
233
  code: string;
234
234
  shares: {
235
235
  amount: string;
236
236
  tokenAddress: string;
237
237
  accountAddress: string;
238
238
  }[];
239
- }>;
239
+ };
240
240
  };
241
241
  };
242
242
  export default _default;
package/lib/payment/v2.js CHANGED
@@ -270,7 +270,7 @@ const getTokenTransfers = ({ priceToken, shares = [], components = [], }) => {
270
270
  });
271
271
  return mergedContracts;
272
272
  };
273
- const getContract = async ({ meta, priceTokens, components, }) => {
273
+ const getContract = ({ meta, priceTokens, components, }) => {
274
274
  const shares = meta.payment.share || [];
275
275
  const [priceToken] = priceTokens;
276
276
  const contracts = getTokenTransfers({ priceToken, shares, components });
@@ -375,7 +375,7 @@ const getPaymentIntegrity = async ({ contract, factoryInput, storeComponents, me
375
375
  const { components, stores } = await getComponents(meta);
376
376
  const store = stores.find((x) => x.id === storeId);
377
377
  // eslint-disable-next-line no-param-reassign
378
- contract = (await getContract({ meta, components, priceTokens })).code;
378
+ contract = getContract({ meta, components, priceTokens }).code;
379
379
  // eslint-disable-next-line no-param-reassign
380
380
  factoryInput = await getFactoryInput(priceTokens);
381
381
  // eslint-disable-next-line no-param-reassign
@@ -455,7 +455,7 @@ const createNftFactoryItx = async ({ blockletMeta, ocapClient, issuers, storeUrl
455
455
  const priceTokens = await getPriceTokens(blockletMeta, ocapClient);
456
456
  const { components, stores } = await getComponents(blockletMeta);
457
457
  const factoryInput = getFactoryInput(priceTokens);
458
- const { code: contract, shares } = await getContract({
458
+ const { code: contract, shares } = getContract({
459
459
  meta: blockletMeta,
460
460
  priceTokens,
461
461
  components,
package/lib/util.d.ts CHANGED
@@ -4,8 +4,9 @@ import type { TBlockletMeta, TEnvironment } from './types';
4
4
  type TConfig = TEnvironment & {
5
5
  key: string;
6
6
  };
7
- type Component = BlockletState | ComponentState;
8
- type ComponentPro = Component & {
7
+ type TApp = BlockletState;
8
+ type TComponent = BlockletState | ComponentState;
9
+ type TComponentPro = TComponent & {
9
10
  configObj?: Record<string, string>;
10
11
  environmentObj?: Record<string, string>;
11
12
  };
@@ -44,7 +45,7 @@ declare const getComponentBundleId: (component: {
44
45
  * @a/b/@c/d/@e/f => @a/b/@c/d
45
46
  */
46
47
  declare const getParentComponentName: (name?: string) => string;
47
- declare const forEachBlocklet: (blocklet: ComponentPro, cb: Function, { parallel, concurrencyLimit, sync, params: inputParams, _parent, _root, _level, _tasks: inputTasks, _ancestors, _limit, }?: {
48
+ declare const forEachBlocklet: (blocklet: TComponentPro, cb: Function, { parallel, concurrencyLimit, sync, params: inputParams, _parent, _root, _level, _tasks: inputTasks, _ancestors, _limit, }?: {
48
49
  parallel?: boolean;
49
50
  concurrencyLimit?: number;
50
51
  sync?: boolean;
@@ -57,23 +58,32 @@ declare const forEachBlocklet: (blocklet: ComponentPro, cb: Function, { parallel
57
58
  _limit?: (fn: () => void) => void;
58
59
  }) => Promise<unknown>;
59
60
  declare const forEachBlockletSync: (blocklet: any, cb: Function) => Promise<unknown>;
61
+ declare const forEachComponentV2: (blocklet: TApp, cb: Function, { parallel, concurrencyLimit, sync, }?: {
62
+ parallel?: boolean;
63
+ concurrencyLimit?: number;
64
+ sync?: boolean;
65
+ }) => Promise<unknown>;
66
+ declare const forEachComponentV2Sync: (blocklet: any, cb: Function) => Promise<unknown>;
60
67
  declare const forEachChild: (blocklet: any, cb: Function, params?: any) => Promise<any>;
61
68
  declare const forEachChildSync: (blocklet: BlockletState, cb: Function) => Promise<any>;
62
- declare const findComponent: (blocklet: Component, isEqualFn: (component: Component, context: {
63
- ancestors: Array<Component>;
69
+ declare const findComponent: (blocklet: TComponent, isEqualFn: (component: TComponent, context: {
70
+ ancestors: Array<TComponent>;
64
71
  }) => boolean, { _ancestors, returnAncestors, }?: {
65
- _ancestors?: Array<Component>;
72
+ _ancestors?: Array<TComponent>;
66
73
  returnAncestors?: boolean;
67
- }) => Component | {
68
- component: Component;
69
- ancestors: Array<Component>;
74
+ }) => TComponent | {
75
+ component: TComponent;
76
+ ancestors: Array<TComponent>;
70
77
  };
71
78
  declare const findComponentById: (blocklet: BlockletState | ComponentState, componentId: string | Array<string>, { returnAncestors, }?: {
72
79
  returnAncestors?: boolean;
73
- }) => Component | {
74
- component: Component;
75
- ancestors: Array<Component>;
80
+ }) => TComponent | {
81
+ component: TComponent;
82
+ ancestors: Array<TComponent>;
76
83
  };
84
+ declare const findComponentV2: (app: TApp, isEqualFn: (component: TComponent, app: TApp) => boolean) => ComponentState;
85
+ declare const findComponentByIdV2: (app: TApp, componentId: string | Array<string>) => ComponentState;
86
+ declare const filterComponentsV2: (app: TApp, isEqualFn: (component: TComponent, app: TApp) => boolean) => any[];
77
87
  declare const isEnvShareable: (env?: TConfig) => boolean;
78
88
  declare const getSharedConfigObj: (component: BlockletState, ancestors?: any[]) => any;
79
89
  declare const isPreferenceKey: (x: TConfig) => Boolean;
@@ -115,7 +125,7 @@ type ChainInfo = {
115
125
  host: string;
116
126
  };
117
127
  declare const getChainInfo: (env: Record<string, string>) => ChainInfo;
118
- declare const getBlockletChainInfo: (blocklet?: ComponentPro) => ChainInfo;
128
+ declare const getBlockletChainInfo: (blocklet?: TComponentPro) => ChainInfo;
119
129
  declare const isExternalBlocklet: (blocklet?: BlockletState) => boolean;
120
130
  declare const getRolesFromAuthConfig: (config: {
121
131
  whoCanAccess: string;
@@ -130,12 +140,21 @@ declare const getBlockletServices: (blocklet: Partial<BlockletState>) => Array<{
130
140
  declare const isInProgress: (status: string | number) => boolean;
131
141
  declare const isBeforeInstalled: (status: string | number) => boolean;
132
142
  declare const isRunning: (status: string | number) => boolean;
133
- export { isFreeBlocklet, isFreeComponent, isComponentBlocklet, forEachBlocklet, forEachBlockletSync, forEachChild, forEachChildSync, isDeletableBlocklet, getSharedConfigObj, getAppMissingConfigs, getComponentMissingConfigs, isEnvShareable, wipeSensitiveData, hasRunnableComponent, getAppName, getAppName as getDisplayName, getAppDescription, fixBlockletStatus, findWebInterface, findWebInterfacePort, findServiceFromMeta, getWhoCanAccess, replaceSlotToIp, getComponentId, getComponentName, getComponentBundleId, findComponent, findComponentById, getParentComponentName, getConnectAppUrl, getChainInfo, getBlockletChainInfo, isExternalBlocklet, isPreferenceKey, getRolesFromAuthConfig, getBlockletAppIdList, getBlockletServices, isInProgress, isBeforeInstalled, isRunning, };
143
+ type TComponentInternalInfo = {
144
+ title: string;
145
+ did: string;
146
+ name: string;
147
+ mountPoint: string;
148
+ status: number;
149
+ port: number;
150
+ };
151
+ declare const getComponentsInternalInfo: (app: TApp) => Array<TComponentInternalInfo>;
152
+ export { isFreeBlocklet, isFreeComponent, isComponentBlocklet, forEachBlocklet, forEachBlockletSync, forEachChild, forEachChildSync, forEachComponentV2, forEachComponentV2Sync, isDeletableBlocklet, getSharedConfigObj, getAppMissingConfigs, getComponentMissingConfigs, isEnvShareable, wipeSensitiveData, hasRunnableComponent, getAppName, getAppName as getDisplayName, getAppDescription, fixBlockletStatus, findWebInterface, findWebInterfacePort, findServiceFromMeta, getWhoCanAccess, replaceSlotToIp, getComponentId, getComponentName, getComponentBundleId, findComponent, findComponentById, findComponentV2, findComponentByIdV2, filterComponentsV2, getParentComponentName, getConnectAppUrl, getChainInfo, getBlockletChainInfo, isExternalBlocklet, isPreferenceKey, getRolesFromAuthConfig, getBlockletAppIdList, getBlockletServices, isInProgress, isBeforeInstalled, isRunning, getComponentsInternalInfo, TComponentInternalInfo, };
134
153
  declare const _default: {
135
154
  isFreeBlocklet: (meta: TBlockletMeta) => boolean;
136
155
  isFreeComponent: (meta: TBlockletMeta) => boolean;
137
156
  isComponentBlocklet: (meta?: TBlockletMeta) => boolean;
138
- forEachBlocklet: (blocklet: ComponentPro, cb: Function, { parallel, concurrencyLimit, sync, params: inputParams, _parent, _root, _level, _tasks: inputTasks, _ancestors, _limit, }?: {
157
+ forEachBlocklet: (blocklet: TComponentPro, cb: Function, { parallel, concurrencyLimit, sync, params: inputParams, _parent, _root, _level, _tasks: inputTasks, _ancestors, _limit, }?: {
139
158
  parallel?: boolean;
140
159
  concurrencyLimit?: number;
141
160
  sync?: boolean;
@@ -150,6 +169,12 @@ declare const _default: {
150
169
  forEachBlockletSync: (blocklet: any, cb: Function) => Promise<unknown>;
151
170
  forEachChild: (blocklet: any, cb: Function, params?: any) => Promise<any>;
152
171
  forEachChildSync: (blocklet: BlockletState, cb: Function) => Promise<any>;
172
+ forEachComponentV2: (blocklet: BlockletState, cb: Function, { parallel, concurrencyLimit, sync, }?: {
173
+ parallel?: boolean;
174
+ concurrencyLimit?: number;
175
+ sync?: boolean;
176
+ }) => Promise<unknown>;
177
+ forEachComponentV2Sync: (blocklet: any, cb: Function) => Promise<unknown>;
153
178
  isDeletableBlocklet: (blocklet?: BlockletState) => boolean;
154
179
  getSharedConfigObj: (component: BlockletState, ancestors?: any[]) => any;
155
180
  getAppMissingConfigs: (blocklet?: any) => any[];
@@ -190,28 +215,31 @@ declare const _default: {
190
215
  version: string;
191
216
  };
192
217
  }) => string;
193
- findComponent: (blocklet: Component, isEqualFn: (component: Component, context: {
194
- ancestors: Component[];
218
+ findComponent: (blocklet: TComponent, isEqualFn: (component: TComponent, context: {
219
+ ancestors: TComponent[];
195
220
  }) => boolean, { _ancestors, returnAncestors, }?: {
196
- _ancestors?: Component[];
221
+ _ancestors?: TComponent[];
197
222
  returnAncestors?: boolean;
198
- }) => Component | {
199
- component: Component;
200
- ancestors: Component[];
223
+ }) => TComponent | {
224
+ component: TComponent;
225
+ ancestors: TComponent[];
201
226
  };
202
227
  findComponentById: (blocklet: BlockletState | ComponentState, componentId: string | string[], { returnAncestors, }?: {
203
228
  returnAncestors?: boolean;
204
- }) => Component | {
205
- component: Component;
206
- ancestors: Component[];
229
+ }) => TComponent | {
230
+ component: TComponent;
231
+ ancestors: TComponent[];
207
232
  };
233
+ findComponentV2: (app: BlockletState, isEqualFn: (component: TComponent, app: BlockletState) => boolean) => ComponentState;
234
+ findComponentByIdV2: (app: BlockletState, componentId: string | string[]) => ComponentState;
235
+ filterComponentsV2: (app: BlockletState, isEqualFn: (component: TComponent, app: BlockletState) => boolean) => any[];
208
236
  getParentComponentName: (name?: string) => string;
209
237
  getConnectAppUrl: ({ request, baseUrl }: {
210
238
  request: Partial<Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>>;
211
239
  baseUrl: string;
212
240
  }) => string;
213
241
  getChainInfo: (env: Record<string, string>) => ChainInfo;
214
- getBlockletChainInfo: (blocklet?: ComponentPro) => ChainInfo;
242
+ getBlockletChainInfo: (blocklet?: TComponentPro) => ChainInfo;
215
243
  isExternalBlocklet: (blocklet?: BlockletState) => boolean;
216
244
  isPreferenceKey: (x: TConfig) => Boolean;
217
245
  getRolesFromAuthConfig: (config: {
@@ -226,5 +254,6 @@ declare const _default: {
226
254
  isInProgress: (status: string | number) => boolean;
227
255
  isBeforeInstalled: (status: string | number) => boolean;
228
256
  isRunning: (status: string | number) => boolean;
257
+ getComponentsInternalInfo: (app: BlockletState) => TComponentInternalInfo[];
229
258
  };
230
259
  export default _default;
package/lib/util.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.isRunning = exports.isBeforeInstalled = exports.isInProgress = exports.getBlockletServices = exports.getBlockletAppIdList = exports.getRolesFromAuthConfig = exports.isPreferenceKey = exports.isExternalBlocklet = exports.getBlockletChainInfo = exports.getChainInfo = exports.getConnectAppUrl = exports.getParentComponentName = exports.findComponentById = exports.findComponent = exports.getComponentBundleId = exports.getComponentName = exports.getComponentId = exports.replaceSlotToIp = exports.getWhoCanAccess = exports.findServiceFromMeta = exports.findWebInterfacePort = exports.findWebInterface = exports.fixBlockletStatus = exports.getAppDescription = exports.getDisplayName = exports.getAppName = exports.hasRunnableComponent = exports.wipeSensitiveData = exports.isEnvShareable = exports.getComponentMissingConfigs = exports.getAppMissingConfigs = exports.getSharedConfigObj = exports.isDeletableBlocklet = exports.forEachChildSync = exports.forEachChild = exports.forEachBlockletSync = exports.forEachBlocklet = exports.isComponentBlocklet = exports.isFreeComponent = exports.isFreeBlocklet = void 0;
6
+ exports.getComponentsInternalInfo = exports.isRunning = exports.isBeforeInstalled = exports.isInProgress = exports.getBlockletServices = exports.getBlockletAppIdList = exports.getRolesFromAuthConfig = exports.isPreferenceKey = exports.isExternalBlocklet = exports.getBlockletChainInfo = exports.getChainInfo = exports.getConnectAppUrl = exports.getParentComponentName = exports.filterComponentsV2 = exports.findComponentByIdV2 = exports.findComponentV2 = exports.findComponentById = exports.findComponent = exports.getComponentBundleId = exports.getComponentName = exports.getComponentId = exports.replaceSlotToIp = exports.getWhoCanAccess = exports.findServiceFromMeta = exports.findWebInterfacePort = exports.findWebInterface = exports.fixBlockletStatus = exports.getAppDescription = exports.getDisplayName = exports.getAppName = exports.hasRunnableComponent = exports.wipeSensitiveData = exports.isEnvShareable = exports.getComponentMissingConfigs = exports.getAppMissingConfigs = exports.getSharedConfigObj = exports.isDeletableBlocklet = exports.forEachComponentV2Sync = exports.forEachComponentV2 = exports.forEachChildSync = exports.forEachChild = exports.forEachBlockletSync = exports.forEachBlocklet = exports.isComponentBlocklet = exports.isFreeComponent = exports.isFreeBlocklet = void 0;
7
7
  /* eslint-disable no-await-in-loop */
8
8
  const get_1 = __importDefault(require("lodash/get"));
9
9
  const uniq_1 = __importDefault(require("lodash/uniq"));
@@ -131,6 +131,46 @@ const forEachBlocklet = (blocklet, cb, { parallel = false, concurrencyLimit = 5,
131
131
  exports.forEachBlocklet = forEachBlocklet;
132
132
  const forEachBlockletSync = (blocklet, cb) => forEachBlocklet(blocklet, cb, { sync: true });
133
133
  exports.forEachBlockletSync = forEachBlockletSync;
134
+ const forEachComponentV2 = (blocklet, cb, { parallel = false, concurrencyLimit = 5, sync, } = {}) => {
135
+ // sync
136
+ if (sync) {
137
+ if (blocklet.children) {
138
+ for (const child of blocklet.children) {
139
+ cb(child);
140
+ }
141
+ }
142
+ return null;
143
+ }
144
+ // serial
145
+ if (!parallel) {
146
+ // eslint-disable-next-line no-async-promise-executor
147
+ return new Promise(async (resolve, reject) => {
148
+ try {
149
+ if (blocklet.children) {
150
+ for (const child of blocklet.children) {
151
+ await cb(child);
152
+ }
153
+ }
154
+ resolve(null);
155
+ }
156
+ catch (err) {
157
+ reject(err);
158
+ }
159
+ });
160
+ }
161
+ // parallel
162
+ const limit = (0, p_limit_1.default)(concurrencyLimit);
163
+ const tasks = [];
164
+ if (blocklet.children) {
165
+ for (const child of blocklet.children) {
166
+ tasks.push(limit(() => cb(child)));
167
+ }
168
+ }
169
+ return Promise.all(tasks);
170
+ };
171
+ exports.forEachComponentV2 = forEachComponentV2;
172
+ const forEachComponentV2Sync = (blocklet, cb) => forEachComponentV2(blocklet, cb, { sync: true });
173
+ exports.forEachComponentV2Sync = forEachComponentV2Sync;
134
174
  const forEachChild = (blocklet, cb, params) => {
135
175
  return forEachBlocklet(blocklet, (b, opt) => {
136
176
  if (opt.level === 0) {
@@ -177,6 +217,48 @@ const findComponentById = (blocklet, componentId, { returnAncestors = false, } =
177
217
  }, { returnAncestors });
178
218
  };
179
219
  exports.findComponentById = findComponentById;
220
+ const findComponentV2 = (app, isEqualFn) => {
221
+ if (!isEqualFn) {
222
+ return null;
223
+ }
224
+ for (const child of app.children || []) {
225
+ if (isEqualFn(child, app)) {
226
+ return child;
227
+ }
228
+ }
229
+ return null;
230
+ };
231
+ exports.findComponentV2 = findComponentV2;
232
+ const findComponentByIdV2 = (app, componentId) => {
233
+ if (!componentId) {
234
+ return null;
235
+ }
236
+ if (Array.isArray(componentId)) {
237
+ // eslint-disable-next-line no-param-reassign
238
+ componentId = componentId.join('/');
239
+ }
240
+ return findComponentV2(app, (component, _app) => {
241
+ if (componentId.includes('/')) {
242
+ const id = getComponentId(component, [_app]);
243
+ return componentId === id;
244
+ }
245
+ return componentId === component.meta.did;
246
+ });
247
+ };
248
+ exports.findComponentByIdV2 = findComponentByIdV2;
249
+ const filterComponentsV2 = (app, isEqualFn) => {
250
+ if (!isEqualFn) {
251
+ return [];
252
+ }
253
+ const list = [];
254
+ for (const child of app.children || []) {
255
+ if (isEqualFn(child, app)) {
256
+ list.push(child);
257
+ }
258
+ }
259
+ return list;
260
+ };
261
+ exports.filterComponentsV2 = filterComponentsV2;
180
262
  const isEnvShareable = (env) => {
181
263
  return (!!env &&
182
264
  !!(env.key || env.name) &&
@@ -572,6 +654,29 @@ const isBeforeInstalled = (status) => [
572
654
  exports.isBeforeInstalled = isBeforeInstalled;
573
655
  const isRunning = (status) => [constant_2.BlockletStatus.running, 'running'].includes(status);
574
656
  exports.isRunning = isRunning;
657
+ const getComponentsInternalInfo = (app) => {
658
+ const components = [];
659
+ if (!app) {
660
+ return components;
661
+ }
662
+ forEachComponentV2Sync(app, (x) => {
663
+ const component = {
664
+ title: x.meta.title,
665
+ did: x.meta.did,
666
+ name: x.meta.name,
667
+ mountPoint: x.mountPoint || '',
668
+ status: x.status,
669
+ port: 0,
670
+ };
671
+ const webInterface = findWebInterface(x);
672
+ if (webInterface && (x.environments || []).find((y) => y.key === webInterface.port)) {
673
+ component.port = x.environments.find((y) => y.key === webInterface.port).value;
674
+ }
675
+ components.push(component);
676
+ });
677
+ return components;
678
+ };
679
+ exports.getComponentsInternalInfo = getComponentsInternalInfo;
575
680
  exports.default = {
576
681
  isFreeBlocklet,
577
682
  isFreeComponent,
@@ -580,6 +685,8 @@ exports.default = {
580
685
  forEachBlockletSync,
581
686
  forEachChild,
582
687
  forEachChildSync,
688
+ forEachComponentV2,
689
+ forEachComponentV2Sync,
583
690
  isDeletableBlocklet,
584
691
  getSharedConfigObj,
585
692
  getAppMissingConfigs,
@@ -601,6 +708,9 @@ exports.default = {
601
708
  getComponentBundleId,
602
709
  findComponent,
603
710
  findComponentById,
711
+ findComponentV2,
712
+ findComponentByIdV2,
713
+ filterComponentsV2,
604
714
  getParentComponentName,
605
715
  getConnectAppUrl,
606
716
  getChainInfo,
@@ -612,4 +722,5 @@ exports.default = {
612
722
  isInProgress,
613
723
  isBeforeInstalled,
614
724
  isRunning,
725
+ getComponentsInternalInfo,
615
726
  };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.16.11-beta-0ae58a71",
6
+ "version": "1.16.11-beta-f74663ac",
7
7
  "description": "Library to parse/validate/fix blocklet meta",
8
8
  "main": "./lib/index.js",
9
9
  "typings": "./lib/index.d.ts",
@@ -24,13 +24,13 @@
24
24
  "author": "wangshijun <wangshijun2020@gmail.com> (http://github.com/wangshijun)",
25
25
  "license": "Apache-2.0",
26
26
  "dependencies": {
27
- "@abtnode/constant": "1.16.11-beta-0ae58a71",
28
- "@abtnode/util": "1.16.11-beta-0ae58a71",
27
+ "@abtnode/constant": "1.16.11-beta-f74663ac",
28
+ "@abtnode/util": "1.16.11-beta-f74663ac",
29
29
  "@arcblock/did": "1.18.80",
30
30
  "@arcblock/did-ext": "1.18.80",
31
31
  "@arcblock/did-util": "1.18.80",
32
32
  "@arcblock/jwt": "1.18.80",
33
- "@blocklet/constant": "1.16.11-beta-0ae58a71",
33
+ "@blocklet/constant": "1.16.11-beta-f74663ac",
34
34
  "@ocap/asset": "1.18.80",
35
35
  "@ocap/mcrypto": "1.18.80",
36
36
  "@ocap/types": "1.18.80",
@@ -58,7 +58,7 @@
58
58
  "validate-npm-package-name": "^3.0.0"
59
59
  },
60
60
  "devDependencies": {
61
- "@arcblock/eslint-config-ts": "^0.2.3",
61
+ "@arcblock/eslint-config-ts": "^0.2.4",
62
62
  "@types/express": "^4.17.14",
63
63
  "@types/jest": "^29.2.2",
64
64
  "@types/joi": "^17.2.3",
@@ -79,5 +79,5 @@
79
79
  "ts-node": "^10.9.1",
80
80
  "typescript": "^5.0.4"
81
81
  },
82
- "gitHead": "5d044a08b4399eb855563e670af7cbd0d3851e94"
82
+ "gitHead": "c59bc852f73b9e216af9d806b9c9e24b2e37ae27"
83
83
  }