@next-core/brick-kit 2.153.4 → 2.153.5

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.esm.js CHANGED
@@ -3166,8 +3166,7 @@ function _fetchMenuById() {
3166
3166
  }
3167
3167
  }
3168
3168
  })).list;
3169
- yield Promise.all(menuList.map(loadDynamicMenuItems));
3170
- var menuData = mergeMenu(menuList);
3169
+ var menuData = yield mergeMenu(menuList, kernel);
3171
3170
 
3172
3171
  if (!menuData) {
3173
3172
  throw new Error("Menu not found: ".concat(menuId));
@@ -3180,52 +3179,63 @@ function _fetchMenuById() {
3180
3179
  return _fetchMenuById.apply(this, arguments);
3181
3180
  }
3182
3181
 
3183
- function mergeMenu(menuList) {
3184
- var mainMenu = menuList.find(menu => menu.type !== "inject");
3182
+ function mergeMenu(_x10, _x11) {
3183
+ return _mergeMenu.apply(this, arguments);
3184
+ }
3185
3185
 
3186
- if (!mainMenu) {
3187
- return undefined;
3188
- }
3186
+ function _mergeMenu() {
3187
+ _mergeMenu = _asyncToGenerator$3(function* (menuList, kernel) {
3188
+ var mainMenu = menuList.find(menu => menu.type !== "inject");
3189
3189
 
3190
- var validMenuList = [];
3191
- var injectWithMenus = new Map();
3192
- var menuWithI18n = new WeakMap();
3190
+ if (!mainMenu) {
3191
+ return undefined;
3192
+ }
3193
3193
 
3194
- for (var menu of menuList) {
3195
- var _menu$items;
3194
+ var validMenuList = [];
3195
+ var injectWithMenus = new Map();
3196
+ var menuWithI18n = new WeakMap();
3196
3197
 
3197
- if (menu.i18n) {
3198
- (function () {
3199
- var menuI18nNamespace = getI18nNamespace("menu", "".concat(menu.menuId, "~").concat(menu.app[0].appId, "+").concat(menu.instanceId)); // Support any language in `meta.i18n`.
3198
+ for (var menu of menuList) {
3199
+ if (menu.i18n) {
3200
+ (function () {
3201
+ var menuI18nNamespace = getI18nNamespace("menu", "".concat(menu.menuId, "~").concat(menu.app[0].appId, "+").concat(menu.instanceId)); // Support any language in `meta.i18n`.
3200
3202
 
3201
- Object.entries(menu.i18n).forEach(_ref => {
3202
- var [lang, resources] = _ref;
3203
- i18next.addResourceBundle(lang, menuI18nNamespace, resources);
3204
- });
3205
- menuWithI18n.set(menu, menuI18nNamespace);
3206
- })();
3203
+ Object.entries(menu.i18n).forEach(_ref3 => {
3204
+ var [lang, resources] = _ref3;
3205
+ i18next.addResourceBundle(lang, menuI18nNamespace, resources);
3206
+ });
3207
+ menuWithI18n.set(menu, menuI18nNamespace);
3208
+ })();
3209
+ }
3207
3210
  }
3208
3211
 
3209
- if (((_menu$items = menu.items) === null || _menu$items === void 0 ? void 0 : _menu$items.length) > 0) {
3210
- if (menu.type === "inject" && menu.injectMenuGroupId) {
3211
- var injectingMenus = injectWithMenus.get(menu.injectMenuGroupId);
3212
+ yield Promise.all(menuList.map(menu => loadDynamicMenuItems(menu, kernel, menuWithI18n)));
3212
3213
 
3213
- if (!injectingMenus) {
3214
- injectingMenus = [];
3215
- injectWithMenus.set(menu.injectMenuGroupId, injectingMenus);
3216
- }
3214
+ for (var _menu of menuList) {
3215
+ var _menu$items;
3217
3216
 
3218
- injectingMenus.push(menu);
3219
- } else {
3220
- validMenuList.push(menu);
3217
+ if (((_menu$items = _menu.items) === null || _menu$items === void 0 ? void 0 : _menu$items.length) > 0) {
3218
+ if (_menu.type === "inject" && _menu.injectMenuGroupId) {
3219
+ var injectingMenus = injectWithMenus.get(_menu.injectMenuGroupId);
3220
+
3221
+ if (!injectingMenus) {
3222
+ injectingMenus = [];
3223
+ injectWithMenus.set(_menu.injectMenuGroupId, injectingMenus);
3224
+ }
3225
+
3226
+ injectingMenus.push(_menu);
3227
+ } else {
3228
+ validMenuList.push(_menu);
3229
+ }
3221
3230
  }
3222
3231
  }
3223
- }
3224
3232
 
3225
- return _objectSpread(_objectSpread({}, mainMenu), {}, {
3226
- items: validMenuList.flatMap(menu => processGroupInject(menu.items, menu, injectWithMenus, menuWithI18n)),
3227
- [symbolMenuI18nNamespace]: menuWithI18n.get(mainMenu)
3233
+ return _objectSpread(_objectSpread({}, mainMenu), {}, {
3234
+ items: validMenuList.flatMap(menu => processGroupInject(menu.items, menu, injectWithMenus, menuWithI18n)),
3235
+ [symbolMenuI18nNamespace]: menuWithI18n.get(mainMenu)
3236
+ });
3228
3237
  });
3238
+ return _mergeMenu.apply(this, arguments);
3229
3239
  }
3230
3240
 
3231
3241
  function processGroupInject(items, menu, injectWithMenus, menuWithI18n) {
@@ -3247,25 +3257,39 @@ function processGroupInject(items, menu, injectWithMenus, menuWithI18n) {
3247
3257
  });
3248
3258
  }
3249
3259
 
3250
- function loadDynamicMenuItems(_x10) {
3260
+ function loadDynamicMenuItems(_x12, _x13, _x14) {
3251
3261
  return _loadDynamicMenuItems.apply(this, arguments);
3252
3262
  }
3253
3263
 
3254
3264
  function _loadDynamicMenuItems() {
3255
- _loadDynamicMenuItems = _asyncToGenerator$3(function* (menu) {
3265
+ _loadDynamicMenuItems = _asyncToGenerator$3(function* (menu, kernel, menuWithI18n) {
3256
3266
  if (menu.dynamicItems && menu.itemsResolve) {
3257
3267
  var itemsConf = {};
3268
+ var overrideAppId = menu.app[0].appId;
3269
+
3270
+ var context = _internalApiGetCurrentContext();
3271
+
3272
+ var newContext = context;
3273
+
3274
+ if (overrideAppId !== context.app.id && attemptToVisit(menu.itemsResolve, ["APP", "I18N"])) {
3275
+ var storyboard = kernel.bootstrapData.storyboards.find(story => story.app.id === overrideAppId);
3276
+ newContext = _objectSpread(_objectSpread({}, context), {}, {
3277
+ overrideApp: storyboard === null || storyboard === void 0 ? void 0 : storyboard.app,
3278
+ appendI18nNamespace: menuWithI18n.get(menu)
3279
+ });
3280
+ }
3281
+
3258
3282
  yield _internalApiGetResolver().resolveOne("reference", _objectSpread({
3259
3283
  transform: "items",
3260
3284
  transformMapArray: false
3261
- }, menu.itemsResolve), itemsConf, null, _internalApiGetCurrentContext());
3285
+ }, menu.itemsResolve), itemsConf, null, newContext);
3262
3286
  menu.items = itemsConf.items;
3263
3287
  }
3264
3288
  });
3265
3289
  return _loadDynamicMenuItems.apply(this, arguments);
3266
3290
  }
3267
3291
 
3268
- function processMenu(_x11, _x12, _x13, _x14, _x15) {
3292
+ function processMenu(_x15, _x16, _x17, _x18, _x19) {
3269
3293
  return _processMenu.apply(this, arguments);
3270
3294
  }
3271
3295
 
@@ -3323,11 +3347,11 @@ function _processMenu() {
3323
3347
 
3324
3348
  function collectAppsRequireI18nFulfilled(items, contextAppId, appIds) {
3325
3349
  function collect(items) {
3326
- for (var _ref2 of items) {
3350
+ for (var _ref of items) {
3327
3351
  var {
3328
3352
  children
3329
- } = _ref2,
3330
- rest = _objectWithoutProperties(_ref2, _excluded$6);
3353
+ } = _ref,
3354
+ rest = _objectWithoutProperties(_ref, _excluded$6);
3331
3355
 
3332
3356
  var overrideAppId = rest[symbolAppId];
3333
3357
 
@@ -3343,11 +3367,11 @@ function collectAppsRequireI18nFulfilled(items, contextAppId, appIds) {
3343
3367
  }
3344
3368
 
3345
3369
  function computeMenuItemsWithOverrideApp(items, context, kernel) {
3346
- return items.map(_ref3 => {
3370
+ return items.map(_ref2 => {
3347
3371
  var {
3348
3372
  children
3349
- } = _ref3,
3350
- rest = _objectWithoutProperties(_ref3, _excluded2$2);
3373
+ } = _ref2,
3374
+ rest = _objectWithoutProperties(_ref2, _excluded2$2);
3351
3375
 
3352
3376
  return _objectSpread(_objectSpread({}, computeRealValueWithOverrideApp(rest, rest[symbolAppId], context, kernel)), {}, {
3353
3377
  children: children && computeMenuItemsWithOverrideApp(children, context, kernel)
@@ -3355,7 +3379,7 @@ function computeMenuItemsWithOverrideApp(items, context, kernel) {
3355
3379
  });
3356
3380
  }
3357
3381
 
3358
- function processMenuTitle(_x16) {
3382
+ function processMenuTitle(_x20) {
3359
3383
  return _processMenuTitle.apply(this, arguments);
3360
3384
  }
3361
3385