@next-core/brick-kit 2.127.2 → 2.128.1

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/CHANGELOG.md CHANGED
@@ -3,6 +3,40 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [2.128.1](https://github.com/easyops-cn/next-core/compare/@next-core/brick-kit@2.128.0...@next-core/brick-kit@2.128.1) (2022-08-19)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * fix menu prefetch in standalone apps ([e96b0cf](https://github.com/easyops-cn/next-core/commit/e96b0cfbe973a285ec6f8b5ceb2d8a3e638210bb))
12
+ * support setting standalone app root ([8e0d3e4](https://github.com/easyops-cn/next-core/commit/8e0d3e49c2c2b93f2b05de4a857c6c6724f27b82))
13
+
14
+
15
+
16
+
17
+
18
+ # [2.128.0](https://github.com/easyops-cn/next-core/compare/@next-core/brick-kit@2.127.3...@next-core/brick-kit@2.128.0) (2022-08-18)
19
+
20
+
21
+ ### Features
22
+
23
+ * **brick-kit:** support location.host and location.hostname ([0548c9f](https://github.com/easyops-cn/next-core/commit/0548c9fab28e58e4194bfedea44c92a39f0c27e2))
24
+
25
+
26
+
27
+
28
+
29
+ ## [2.127.3](https://github.com/easyops-cn/next-core/compare/@next-core/brick-kit@2.127.2...@next-core/brick-kit@2.127.3) (2022-08-17)
30
+
31
+
32
+ ### Bug Fixes
33
+
34
+ * **devtools:** emit messages only if applicable ([e0b1edc](https://github.com/easyops-cn/next-core/commit/e0b1edc2182472591728ddc0f874cd8b5c8565fc))
35
+
36
+
37
+
38
+
39
+
6
40
  ## [2.127.2](https://github.com/easyops-cn/next-core/compare/@next-core/brick-kit@2.127.1...@next-core/brick-kit@2.127.2) (2022-08-11)
7
41
 
8
42
 
@@ -1133,12 +1133,17 @@
1133
1133
  var MESSAGE_SOURCE_PANEL = "brick-next-devtools-panel";
1134
1134
  var EVALUATION_EDIT = "devtools-evaluation-edit";
1135
1135
  var TRANSFORMATION_EDIT = "devtools-transformation-edit";
1136
-
1136
+ var FRAME_ACTIVE_CHANGE = "devtools-frame-active-change";
1137
+ var PANEL_CHANGE = "devtools-panel-change";
1138
+ var frameIsActive = true;
1139
+ var selectedPanel;
1137
1140
  /* istanbul ignore next */
1141
+
1138
1142
  function devtoolsHookEmit(type, payload) {
1139
1143
  var devtools = getDevHook();
1140
1144
 
1141
- if (!devtools) {
1145
+ if (!devtools || !(type === "evaluation" ? frameIsActive && (!selectedPanel || selectedPanel === "Evaluations") : type === "transformation" ? frameIsActive && (!selectedPanel || selectedPanel === "Transformations") : true)) {
1146
+ // Ignore messages if current devtools panel is not relevant.
1142
1147
  return;
1143
1148
  }
1144
1149
 
@@ -1158,41 +1163,78 @@
1158
1163
  setTimeout(emit, 0);
1159
1164
  }
1160
1165
  }
1166
+ function listenDevtoolsEagerly() {
1167
+ window.addEventListener("message", _ref => {
1168
+ var {
1169
+ data
1170
+ } = _ref;
1171
+
1172
+ if ((data === null || data === void 0 ? void 0 : data.source) !== MESSAGE_SOURCE_PANEL) {
1173
+ return;
1174
+ }
1175
+
1176
+ var payload = data.payload;
1177
+
1178
+ switch (payload === null || payload === void 0 ? void 0 : payload.type) {
1179
+ case FRAME_ACTIVE_CHANGE:
1180
+ {
1181
+ frameIsActive = payload.active;
1182
+ break;
1183
+ }
1184
+
1185
+ case PANEL_CHANGE:
1186
+ {
1187
+ selectedPanel = payload.panel;
1188
+ break;
1189
+ }
1190
+ }
1191
+ });
1192
+ }
1161
1193
  function listenDevtools() {
1162
- window.addEventListener("message", event => {
1163
- var _event$data;
1194
+ window.addEventListener("message", _ref2 => {
1195
+ var {
1196
+ data
1197
+ } = _ref2;
1164
1198
 
1165
- if (((_event$data = event.data) === null || _event$data === void 0 ? void 0 : _event$data.source) !== MESSAGE_SOURCE_PANEL) {
1199
+ if ((data === null || data === void 0 ? void 0 : data.source) !== MESSAGE_SOURCE_PANEL) {
1166
1200
  return;
1167
1201
  }
1168
1202
 
1169
- var payload = event.data.payload;
1203
+ var payload = data.payload;
1170
1204
 
1171
- if ((payload === null || payload === void 0 ? void 0 : payload.type) === EVALUATION_EDIT) {
1172
- var {
1173
- raw,
1174
- context,
1175
- id
1176
- } = payload;
1177
- evaluate(raw, {
1178
- data: context.data,
1179
- event: restoreDehydrated(context.event)
1180
- }, {
1181
- isReEvaluation: true,
1182
- evaluationId: id
1183
- });
1184
- } else if ((payload === null || payload === void 0 ? void 0 : payload.type) === TRANSFORMATION_EDIT) {
1185
- var {
1186
- data,
1187
- transform,
1188
- id: _id,
1189
- options: {
1190
- from,
1191
- mapArray,
1192
- allowInject
1205
+ switch (payload === null || payload === void 0 ? void 0 : payload.type) {
1206
+ case EVALUATION_EDIT:
1207
+ {
1208
+ var {
1209
+ raw,
1210
+ context,
1211
+ id
1212
+ } = payload;
1213
+ evaluate(raw, {
1214
+ data: context.data,
1215
+ event: restoreDehydrated(context.event)
1216
+ }, {
1217
+ isReEvaluation: true,
1218
+ evaluationId: id
1219
+ });
1220
+ break;
1221
+ }
1222
+
1223
+ case TRANSFORMATION_EDIT:
1224
+ {
1225
+ var {
1226
+ data: _data,
1227
+ transform,
1228
+ id: _id,
1229
+ options: {
1230
+ from,
1231
+ mapArray,
1232
+ allowInject
1233
+ }
1234
+ } = payload;
1235
+ reTransformForDevtools(_id, _data, transform, from, mapArray, allowInject);
1236
+ break;
1193
1237
  }
1194
- } = payload;
1195
- reTransformForDevtools(_id, data, transform, from, mapArray, allowInject);
1196
1238
  }
1197
1239
  });
1198
1240
  }
@@ -1593,10 +1635,14 @@
1593
1635
  case "location":
1594
1636
  return collectCoverage ? {
1595
1637
  href: "http://localhost:3000/functions/test",
1596
- origin: "http://localhost:3000"
1638
+ origin: "http://localhost:3000",
1639
+ host: "localhost:3000",
1640
+ hostname: "localhost"
1597
1641
  } : {
1598
1642
  href: location.href,
1599
- origin: location.origin
1643
+ origin: location.origin,
1644
+ host: location.host,
1645
+ hostname: location.hostname
1600
1646
  };
1601
1647
  }
1602
1648
  }
@@ -2965,30 +3011,30 @@
2965
3011
  return _constructMenu.apply(this, arguments);
2966
3012
  }
2967
3013
 
2968
- function constructMenuByMenusList(_x4, _x5, _x6) {
2969
- return _constructMenuByMenusList.apply(this, arguments);
3014
+ function preConstructMenus(_x4, _x5, _x6) {
3015
+ return _preConstructMenus.apply(this, arguments);
2970
3016
  }
2971
3017
 
2972
- function _constructMenuByMenusList() {
2973
- _constructMenuByMenusList = _asyncToGenerator__default["default"](function* (menus, context, kernel) {
2974
- var data = yield Promise.all(menus.map(menuId => processMenu(menuId, context, kernel)));
3018
+ function _preConstructMenus() {
3019
+ _preConstructMenus = _asyncToGenerator__default["default"](function* (menus, context, kernel) {
3020
+ var data = yield Promise.all(menus.map(menuId => processMenu(menuId, context, kernel, undefined, true)));
2975
3021
  data.forEach((item, index) => processMenuCache.set(menus[index], item));
2976
3022
  });
2977
- return _constructMenuByMenusList.apply(this, arguments);
3023
+ return _preConstructMenus.apply(this, arguments);
2978
3024
  }
2979
3025
 
2980
3026
  var getMenu = menuId => processMenuCache.get(menuId);
2981
- function fetchMenuById(_x7, _x8) {
3027
+ function fetchMenuById(_x7, _x8, _x9) {
2982
3028
  return _fetchMenuById.apply(this, arguments);
2983
3029
  }
2984
3030
 
2985
3031
  function _fetchMenuById() {
2986
- _fetchMenuById = _asyncToGenerator__default["default"](function* (menuId, kernel) {
3032
+ _fetchMenuById = _asyncToGenerator__default["default"](function* (menuId, kernel, isPreFetch) {
2987
3033
  if (menuCache.has(menuId)) {
2988
3034
  return menuCache.get(menuId);
2989
3035
  }
2990
3036
 
2991
- var menuList = window.STANDALONE_MICRO_APPS ? kernel.getStandaloneMenus(menuId) : (yield InstanceApi_postSearch("EASYOPS_STORYBOARD_MENU", {
3037
+ var menuList = window.STANDALONE_MICRO_APPS ? kernel.getStandaloneMenus(menuId, isPreFetch) : (yield InstanceApi_postSearch("EASYOPS_STORYBOARD_MENU", {
2992
3038
  page: 1,
2993
3039
  page_size: 200,
2994
3040
  fields: {
@@ -3084,7 +3130,7 @@
3084
3130
  });
3085
3131
  }
3086
3132
 
3087
- function loadDynamicMenuItems(_x9) {
3133
+ function loadDynamicMenuItems(_x10) {
3088
3134
  return _loadDynamicMenuItems.apply(this, arguments);
3089
3135
  }
3090
3136
 
@@ -3102,13 +3148,13 @@
3102
3148
  return _loadDynamicMenuItems.apply(this, arguments);
3103
3149
  }
3104
3150
 
3105
- function processMenu(_x10, _x11, _x12, _x13) {
3151
+ function processMenu(_x11, _x12, _x13, _x14, _x15) {
3106
3152
  return _processMenu.apply(this, arguments);
3107
3153
  }
3108
3154
 
3109
3155
  function _processMenu() {
3110
- _processMenu = _asyncToGenerator__default["default"](function* (menuId, context, kernel, hasSubMenu) {
3111
- var _yield$fetchMenuById = yield fetchMenuById(menuId, kernel),
3156
+ _processMenu = _asyncToGenerator__default["default"](function* (menuId, context, kernel, hasSubMenu, isPreFetch) {
3157
+ var _yield$fetchMenuById = yield fetchMenuById(menuId, kernel, isPreFetch),
3112
3158
  {
3113
3159
  items,
3114
3160
  app
@@ -3161,19 +3207,19 @@
3161
3207
  });
3162
3208
  });
3163
3209
 
3164
- return function (_x14) {
3210
+ return function (_x16) {
3165
3211
  return _ref2.apply(this, arguments);
3166
3212
  };
3167
3213
  }()));
3168
3214
  }
3169
3215
 
3170
- function processMenuTitle(_x15) {
3216
+ function processMenuTitle(_x17) {
3171
3217
  return _processMenuTitle.apply(this, arguments);
3172
3218
  }
3173
3219
 
3174
3220
  function _processMenuTitle() {
3175
3221
  _processMenuTitle = _asyncToGenerator__default["default"](function* (menuData) {
3176
- if (menuData.title || !menuData.titleDataSource) {
3222
+ if (menuData.title || _.isEmpty(menuData.titleDataSource)) {
3177
3223
  return menuData.title;
3178
3224
  }
3179
3225
 
@@ -3262,7 +3308,7 @@
3262
3308
  return false;
3263
3309
  }
3264
3310
 
3265
- function computeRealValueWithOverrideApp(_x16, _x17, _x18, _x19) {
3311
+ function computeRealValueWithOverrideApp(_x18, _x19, _x20, _x21) {
3266
3312
  return _computeRealValueWithOverrideApp.apply(this, arguments);
3267
3313
  }
3268
3314
 
@@ -8791,6 +8837,7 @@
8791
8837
  return _asyncToGenerator__default["default"](function* () {
8792
8838
  var _this2$bootstrapData$, _this2$bootstrapData$2;
8793
8839
 
8840
+ listenDevtoolsEagerly();
8794
8841
  _this2.mountPoints = mountPoints;
8795
8842
  yield Promise.all([_this2.loadCheckLogin(), _this2.loadMicroApps()]);
8796
8843
 
@@ -9474,10 +9521,11 @@
9474
9521
  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);
9475
9522
  }
9476
9523
 
9477
- getStandaloneMenus(menuId) {
9524
+ getStandaloneMenus(menuId, isPreFetch) {
9478
9525
  var _currentStoryboard$me, _currentStoryboard$me2;
9479
9526
 
9480
- var currentAppId = this.currentApp.id;
9527
+ var app = isPreFetch ? this.nextApp : this.currentApp;
9528
+ var currentAppId = app.id;
9481
9529
  var currentStoryboard = this.bootstrapData.storyboards.find(storyboard => storyboard.app.id === currentAppId);
9482
9530
  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) : [];
9483
9531
  return menus.filter(menu => menu.menuId === menuId).map(menu => {
@@ -10908,7 +10956,7 @@
10908
10956
  var useMenus = brickUtils.scanAppGetMenuInAny(data);
10909
10957
 
10910
10958
  if (useMenus.length) {
10911
- yield constructMenuByMenusList(useMenus, _this7.getCurrentContext(), _this7.kernel);
10959
+ yield preConstructMenus(useMenus, _this7.getCurrentContext(), _this7.kernel);
10912
10960
  }
10913
10961
  })();
10914
10962
  }