@next-core/brick-kit 2.127.3 → 2.129.0

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
@@ -5,7 +5,7 @@ import _asyncToGenerator$4 from '@babel/runtime/helpers/asyncToGenerator';
5
5
  import _defineProperty$1 from '@babel/runtime/helpers/defineProperty';
6
6
  import React, { useState, useEffect, useRef, forwardRef, useImperativeHandle, useMemo, useContext, createContext, useReducer, useCallback } from 'react';
7
7
  import { JsonStorage, toPath, computeRealRoutePath, hasOwnProperty, isObject, isEvaluable, transformAndInject, transform, trackContext, trackState, scanPermissionActionsInStoryboard, precookFunction, cook, resolveContextConcurrently, syncResolveContextConcurrently, shouldAllowRecursiveEvaluations, preevaluate, inject, deepFreeze, createProviderClass, getTemplateDepsOfStoryboard, getDllAndDepsOfStoryboard, asyncProcessStoryboard, getDllAndDepsByResource, scanRouteAliasInStoryboard, prefetchScript, scanBricksInBrickConf, scanProcessorsInAny, loadScript, matchPath, scanAppGetMenuInAny, asyncProcessBrick, scanInstalledAppsInStoryboard, restoreDynamicTemplates, scanStoryboard, mapCustomApisToNameAndNamespace } from '@next-core/brick-utils';
8
- import _, { set, get, difference, identity, uniqueId, cloneDeep, clamp, isNil, sortBy, merge, isEmpty, isObject as isObject$1, pick, orderBy, omit, findLastIndex, noop, isString } from 'lodash';
8
+ import _, { set, get, difference, identity, uniqueId, cloneDeep, clamp, isNil, isEmpty, sortBy, merge, isObject as isObject$1, pick, orderBy, omit, findLastIndex, noop, isString } from 'lodash';
9
9
  import { http, HttpResponseError, HttpFetchError } from '@next-core/brick-http';
10
10
  import moment from 'moment';
11
11
  import { pipes } from '@next-core/pipes';
@@ -1415,7 +1415,8 @@ function authenticate(newAuth) {
1415
1415
  userInstanceId: newAuth.userInstanceId,
1416
1416
  loginFrom: newAuth.loginFrom,
1417
1417
  accessRule: newAuth.accessRule,
1418
- isAdmin: newAuth.isAdmin
1418
+ isAdmin: newAuth.isAdmin,
1419
+ csrfToken: newAuth.csrfToken
1419
1420
  }); // re-init analytics to set user_id
1420
1421
 
1421
1422
  if (userAnalytics.initialized) {
@@ -1439,6 +1440,7 @@ function logout() {
1439
1440
  auth.userInstanceId = undefined;
1440
1441
  auth.accessRule = undefined;
1441
1442
  auth.isAdmin = undefined;
1443
+ auth.csrfToken = undefined;
1442
1444
  resetPermissionPreChecks(); // re-init analytics to clear user_id
1443
1445
 
1444
1446
  userAnalytics.setUserId();
@@ -1636,10 +1638,14 @@ function getIndividualGlobal(variableName, _ref) {
1636
1638
  case "location":
1637
1639
  return collectCoverage ? {
1638
1640
  href: "http://localhost:3000/functions/test",
1639
- origin: "http://localhost:3000"
1641
+ origin: "http://localhost:3000",
1642
+ host: "localhost:3000",
1643
+ hostname: "localhost"
1640
1644
  } : {
1641
1645
  href: location.href,
1642
- origin: location.origin
1646
+ origin: location.origin,
1647
+ host: location.host,
1648
+ hostname: location.hostname
1643
1649
  };
1644
1650
  }
1645
1651
  }
@@ -3008,30 +3014,30 @@ function _constructMenu() {
3008
3014
  return _constructMenu.apply(this, arguments);
3009
3015
  }
3010
3016
 
3011
- function constructMenuByMenusList(_x4, _x5, _x6) {
3012
- return _constructMenuByMenusList.apply(this, arguments);
3017
+ function preConstructMenus(_x4, _x5, _x6) {
3018
+ return _preConstructMenus.apply(this, arguments);
3013
3019
  }
3014
3020
 
3015
- function _constructMenuByMenusList() {
3016
- _constructMenuByMenusList = _asyncToGenerator$4(function* (menus, context, kernel) {
3017
- var data = yield Promise.all(menus.map(menuId => processMenu(menuId, context, kernel)));
3021
+ function _preConstructMenus() {
3022
+ _preConstructMenus = _asyncToGenerator$4(function* (menus, context, kernel) {
3023
+ var data = yield Promise.all(menus.map(menuId => processMenu(menuId, context, kernel, undefined, true)));
3018
3024
  data.forEach((item, index) => processMenuCache.set(menus[index], item));
3019
3025
  });
3020
- return _constructMenuByMenusList.apply(this, arguments);
3026
+ return _preConstructMenus.apply(this, arguments);
3021
3027
  }
3022
3028
 
3023
3029
  var getMenu = menuId => processMenuCache.get(menuId);
3024
- function fetchMenuById(_x7, _x8) {
3030
+ function fetchMenuById(_x7, _x8, _x9) {
3025
3031
  return _fetchMenuById.apply(this, arguments);
3026
3032
  }
3027
3033
 
3028
3034
  function _fetchMenuById() {
3029
- _fetchMenuById = _asyncToGenerator$4(function* (menuId, kernel) {
3035
+ _fetchMenuById = _asyncToGenerator$4(function* (menuId, kernel, isPreFetch) {
3030
3036
  if (menuCache.has(menuId)) {
3031
3037
  return menuCache.get(menuId);
3032
3038
  }
3033
3039
 
3034
- var menuList = window.STANDALONE_MICRO_APPS ? kernel.getStandaloneMenus(menuId) : (yield InstanceApi_postSearch("EASYOPS_STORYBOARD_MENU", {
3040
+ var menuList = window.STANDALONE_MICRO_APPS ? kernel.getStandaloneMenus(menuId, isPreFetch) : (yield InstanceApi_postSearch("EASYOPS_STORYBOARD_MENU", {
3035
3041
  page: 1,
3036
3042
  page_size: 200,
3037
3043
  fields: {
@@ -3127,7 +3133,7 @@ function processGroupInject(items, menu, injectWithMenus) {
3127
3133
  });
3128
3134
  }
3129
3135
 
3130
- function loadDynamicMenuItems(_x9) {
3136
+ function loadDynamicMenuItems(_x10) {
3131
3137
  return _loadDynamicMenuItems.apply(this, arguments);
3132
3138
  }
3133
3139
 
@@ -3145,13 +3151,13 @@ function _loadDynamicMenuItems() {
3145
3151
  return _loadDynamicMenuItems.apply(this, arguments);
3146
3152
  }
3147
3153
 
3148
- function processMenu(_x10, _x11, _x12, _x13) {
3154
+ function processMenu(_x11, _x12, _x13, _x14, _x15) {
3149
3155
  return _processMenu.apply(this, arguments);
3150
3156
  }
3151
3157
 
3152
3158
  function _processMenu() {
3153
- _processMenu = _asyncToGenerator$4(function* (menuId, context, kernel, hasSubMenu) {
3154
- var _yield$fetchMenuById = yield fetchMenuById(menuId, kernel),
3159
+ _processMenu = _asyncToGenerator$4(function* (menuId, context, kernel, hasSubMenu, isPreFetch) {
3160
+ var _yield$fetchMenuById = yield fetchMenuById(menuId, kernel, isPreFetch),
3155
3161
  {
3156
3162
  items,
3157
3163
  app
@@ -3204,19 +3210,19 @@ function computeMenuItemsWithOverrideApp(items, context, kernel) {
3204
3210
  });
3205
3211
  });
3206
3212
 
3207
- return function (_x14) {
3213
+ return function (_x16) {
3208
3214
  return _ref2.apply(this, arguments);
3209
3215
  };
3210
3216
  }()));
3211
3217
  }
3212
3218
 
3213
- function processMenuTitle(_x15) {
3219
+ function processMenuTitle(_x17) {
3214
3220
  return _processMenuTitle.apply(this, arguments);
3215
3221
  }
3216
3222
 
3217
3223
  function _processMenuTitle() {
3218
3224
  _processMenuTitle = _asyncToGenerator$4(function* (menuData) {
3219
- if (menuData.title || !menuData.titleDataSource) {
3225
+ if (menuData.title || isEmpty(menuData.titleDataSource)) {
3220
3226
  return menuData.title;
3221
3227
  }
3222
3228
 
@@ -3305,7 +3311,7 @@ function requireOverrideApp(data) {
3305
3311
  return false;
3306
3312
  }
3307
3313
 
3308
- function computeRealValueWithOverrideApp(_x16, _x17, _x18, _x19) {
3314
+ function computeRealValueWithOverrideApp(_x18, _x19, _x20, _x21) {
3309
3315
  return _computeRealValueWithOverrideApp.apply(this, arguments);
3310
3316
  }
3311
3317
 
@@ -9518,10 +9524,11 @@ class Kernel {
9518
9524
  return Object.assign({}, (_this$bootstrapData = this.bootstrapData) === null || _this$bootstrapData === void 0 ? void 0 : (_this$bootstrapData$s = _this$bootstrapData.settings) === null || _this$bootstrapData$s === void 0 ? void 0 : _this$bootstrapData$s.featureFlags);
9519
9525
  }
9520
9526
 
9521
- getStandaloneMenus(menuId) {
9527
+ getStandaloneMenus(menuId, isPreFetch) {
9522
9528
  var _currentStoryboard$me, _currentStoryboard$me2;
9523
9529
 
9524
- var currentAppId = this.currentApp.id;
9530
+ var app = isPreFetch ? this.nextApp : this.currentApp;
9531
+ var currentAppId = app.id;
9525
9532
  var currentStoryboard = this.bootstrapData.storyboards.find(storyboard => storyboard.app.id === currentAppId);
9526
9533
  var menus = (_currentStoryboard$me = currentStoryboard.meta) !== null && _currentStoryboard$me !== void 0 && _currentStoryboard$me.injectMenus ? cloneDeep(currentStoryboard.meta.injectMenus) : (_currentStoryboard$me2 = currentStoryboard.meta) !== null && _currentStoryboard$me2 !== void 0 && _currentStoryboard$me2.menus ? cloneDeep(currentStoryboard.meta.menus) : [];
9527
9534
  return menus.filter(menu => menu.menuId === menuId).map(menu => {
@@ -10952,7 +10959,7 @@ class LocationContext {
10952
10959
  var useMenus = scanAppGetMenuInAny(data);
10953
10960
 
10954
10961
  if (useMenus.length) {
10955
- yield constructMenuByMenusList(useMenus, _this7.getCurrentContext(), _this7.kernel);
10962
+ yield preConstructMenus(useMenus, _this7.getCurrentContext(), _this7.kernel);
10956
10963
  }
10957
10964
  })();
10958
10965
  }