@next-core/brick-kit 2.93.1 → 2.94.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/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
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.94.0](https://github.com/easyops-cn/next-core/compare/@next-core/brick-kit@2.93.1...@next-core/brick-kit@2.94.0) (2021-12-24)
7
+
8
+
9
+ ### Features
10
+
11
+ * support request use mock ([#1293](https://github.com/easyops-cn/next-core/issues/1293)) ([9989c66](https://github.com/easyops-cn/next-core/commit/9989c663f1e5340c68853d4b158dc169484a7e1a))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [2.93.1](https://github.com/easyops-cn/next-core/compare/@next-core/brick-kit@2.93.0...@next-core/brick-kit@2.93.1) (2021-12-23)
7
18
 
8
19
  **Note:** Version bump only for package @next-core/brick-kit
@@ -9072,6 +9072,23 @@
9072
9072
  return defaultCollapsed || defaultCollapsedBreakpoint && document.documentElement.clientWidth < defaultCollapsedBreakpoint;
9073
9073
  }
9074
9074
 
9075
+ var useMockList = [];
9076
+ function registerMock(mockList) {
9077
+ if (mockList) useMockList = mockList;
9078
+ }
9079
+
9080
+ function getUrlRegExp(str) {
9081
+ return new RegExp("".concat(str.replace(/:\w+/g, "[\\w|-]+"), "$"));
9082
+ }
9083
+
9084
+ var isMatchMockUrl = (requestUrl, uri) => {
9085
+ var reg = getUrlRegExp(uri);
9086
+ return reg.test(requestUrl);
9087
+ };
9088
+ var getMockRule = requestUrl => {
9089
+ return useMockList.find(item => isMatchMockUrl(requestUrl, item.uri));
9090
+ };
9091
+
9075
9092
  class Router {
9076
9093
  constructor(kernel) {
9077
9094
  _defineProperty__default["default"](this, "defaultCollapsed", false);
@@ -9257,7 +9274,7 @@
9257
9274
  var storyboard = locationContext.matchStoryboard(_this3.kernel.bootstrapData.storyboards);
9258
9275
 
9259
9276
  if (storyboard) {
9260
- var _storyboard$meta;
9277
+ var _storyboard$meta, _storyboard$meta2;
9261
9278
 
9262
9279
  yield _this3.kernel.fulfilStoryboard(storyboard); // 将动态解析后的模板还原,以便重新动态解析。
9263
9280
 
@@ -9275,6 +9292,7 @@
9275
9292
  _this3.kernel.registerCustomTemplatesInStoryboard(storyboard);
9276
9293
 
9277
9294
  registerStoryboardFunctions((_storyboard$meta = storyboard.meta) === null || _storyboard$meta === void 0 ? void 0 : _storyboard$meta.functions, storyboard.app);
9295
+ registerMock((_storyboard$meta2 = storyboard.meta) === null || _storyboard$meta2 === void 0 ? void 0 : _storyboard$meta2.mocks);
9278
9296
  }
9279
9297
 
9280
9298
  var {
@@ -11284,6 +11302,7 @@
11284
11302
  exports.event = event;
11285
11303
  exports.getAuth = getAuth;
11286
11304
  exports.getHistory = getHistory;
11305
+ exports.getMockRule = getMockRule;
11287
11306
  exports.getRuntime = getRuntime;
11288
11307
  exports.handleHttpError = handleHttpError;
11289
11308
  exports.httpErrorToString = httpErrorToString;