@next-core/brick-kit 2.137.1 → 2.139.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,39 @@
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.139.0](https://github.com/easyops-cn/next-core/compare/@next-core/brick-kit@2.138.0...@next-core/brick-kit@2.139.0) (2022-09-13)
7
+
8
+
9
+ ### Features
10
+
11
+ * support noCurrentApp evalute ([73a0662](https://github.com/easyops-cn/next-core/commit/73a06628ad66625fa8be18edf48819179ea931b4))
12
+
13
+
14
+
15
+
16
+
17
+ # [2.138.0](https://github.com/easyops-cn/next-core/compare/@next-core/brick-kit@2.137.2...@next-core/brick-kit@2.138.0) (2022-09-08)
18
+
19
+
20
+ ### Features
21
+
22
+ * support history callback ([ca1d42e](https://github.com/easyops-cn/next-core/commit/ca1d42ee0bef5ab0cacf811c60b1324c1bd14837))
23
+
24
+
25
+
26
+
27
+
28
+ ## [2.137.2](https://github.com/easyops-cn/next-core/compare/@next-core/brick-kit@2.137.1...@next-core/brick-kit@2.137.2) (2022-09-07)
29
+
30
+
31
+ ### Bug Fixes
32
+
33
+ * to collect contracts before state define ([3d7cd86](https://github.com/easyops-cn/next-core/commit/3d7cd86441b33494c387bc2053c8698a688abf71))
34
+
35
+
36
+
37
+
38
+
6
39
  ## [2.137.1](https://github.com/easyops-cn/next-core/compare/@next-core/brick-kit@2.137.0...@next-core/brick-kit@2.137.1) (2022-09-07)
7
40
 
8
41
  **Note:** Version bump only for package @next-core/brick-kit
@@ -3924,15 +3924,33 @@
3924
3924
  }
3925
3925
 
3926
3926
  var _excluded$5 = ["extraQuery", "clear", "keepHash"];
3927
+ var blocked = false;
3928
+ function getUserConfirmation(message, callback) {
3929
+ blocked = !confirm(message);
3930
+ callback(!blocked);
3931
+ }
3927
3932
  function historyExtended(browserHistory) {
3928
3933
  var {
3929
3934
  push: originalPush,
3930
3935
  replace: originalReplace
3931
3936
  } = browserHistory;
3932
3937
 
3938
+ function push(location, state, callback) {
3939
+ blocked = false;
3940
+ originalPush(location, state);
3941
+ callback === null || callback === void 0 ? void 0 : callback(blocked);
3942
+ }
3943
+
3944
+ function replace(location, state, callback) {
3945
+ blocked = false;
3946
+ originalReplace(location, state);
3947
+ callback === null || callback === void 0 ? void 0 : callback(blocked);
3948
+ }
3949
+
3933
3950
  function updateQueryFactory(method) {
3934
3951
  return function updateQuery(query) {
3935
3952
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3953
+ var callback = arguments.length > 2 ? arguments[2] : undefined;
3936
3954
 
3937
3955
  var {
3938
3956
  extraQuery,
@@ -3959,30 +3977,28 @@
3959
3977
  }
3960
3978
  }
3961
3979
 
3962
- (method === "push" ? originalPush : originalReplace)("?".concat(urlSearchParams.toString()).concat(keepHash ? browserHistory.location.hash : ""), state);
3980
+ (method === "push" ? push : replace)("?".concat(urlSearchParams.toString()).concat(keepHash ? browserHistory.location.hash : ""), state, callback);
3963
3981
  };
3964
3982
  }
3965
3983
 
3966
- function updateAnchorFactory(method) {
3967
- return function updateAnchor(hash, state) {
3968
- (method === "push" ? originalPush : originalReplace)(_objectSpread__default["default"](_objectSpread__default["default"]({}, browserHistory.location), {}, {
3969
- key: undefined,
3970
- hash,
3971
- state: _objectSpread__default["default"]({
3972
- // The default notify is false
3973
- notify: false
3974
- }, state)
3975
- }));
3976
- };
3984
+ function pushAnchor(hash, state, callback) {
3985
+ push(_objectSpread__default["default"](_objectSpread__default["default"]({}, browserHistory.location), {}, {
3986
+ key: undefined,
3987
+ hash,
3988
+ state: _objectSpread__default["default"]({
3989
+ // The default notify is false
3990
+ notify: false
3991
+ }, state)
3992
+ }), undefined, callback);
3977
3993
  }
3978
3994
 
3979
- function reload() {
3980
- originalReplace(_objectSpread__default["default"](_objectSpread__default["default"]({}, browserHistory.location), {}, {
3995
+ function reload(callback) {
3996
+ replace(_objectSpread__default["default"](_objectSpread__default["default"]({}, browserHistory.location), {}, {
3981
3997
  state: _objectSpread__default["default"](_objectSpread__default["default"]({}, browserHistory.location.state), {}, {
3982
3998
  // Always notify
3983
3999
  notify: true
3984
4000
  })
3985
- }));
4001
+ }), undefined, callback);
3986
4002
  }
3987
4003
 
3988
4004
  var blockMessage;
@@ -4002,13 +4018,17 @@
4002
4018
  return _objectSpread__default["default"]({
4003
4019
  pushQuery: updateQueryFactory("push"),
4004
4020
  replaceQuery: updateQueryFactory("replace"),
4005
- pushAnchor: updateAnchorFactory("push"),
4006
- // replaceAnchor: updateAnchorFactory("replace"),
4021
+ pushAnchor: pushAnchor,
4007
4022
  reload,
4008
4023
  setBlockMessage,
4009
4024
  getBlockMessage,
4010
- unblock
4011
- }, window.STANDALONE_MICRO_APPS ? standaloneHistoryOverridden(browserHistory) : null);
4025
+ unblock,
4026
+ push,
4027
+ replace
4028
+ }, window.STANDALONE_MICRO_APPS ? standaloneHistoryOverridden(_objectSpread__default["default"](_objectSpread__default["default"]({}, browserHistory), {}, {
4029
+ push,
4030
+ replace
4031
+ })) : {});
4012
4032
  }
4013
4033
  /**
4014
4034
  * Override history for standalone micro apps.
@@ -4023,7 +4043,7 @@
4023
4043
  } = browserHistory;
4024
4044
 
4025
4045
  function updateFactory(method) {
4026
- return function update(path, state) {
4046
+ return function update(path, state, callback) {
4027
4047
  var pathname;
4028
4048
  var pathIsString = typeof path === "string";
4029
4049
 
@@ -4034,7 +4054,7 @@
4034
4054
  }
4035
4055
 
4036
4056
  if (pathname === "" || _internalApiHasMatchedApp(pathname)) {
4037
- return (method === "push" ? originalPush : originalReplace)(path, state);
4057
+ return (method === "push" ? originalPush : originalReplace)(path, state, callback);
4038
4058
  } // Going to outside apps.
4039
4059
 
4040
4060
 
@@ -4053,7 +4073,8 @@
4053
4073
 
4054
4074
  function createHistory() {
4055
4075
  var browserHistory = history$1.createBrowserHistory({
4056
- basename: getBasePath().replace(/\/$/, "")
4076
+ basename: getBasePath().replace(/\/$/, ""),
4077
+ getUserConfirmation
4057
4078
  });
4058
4079
  Object.assign(browserHistory, historyExtended(browserHistory));
4059
4080
  history = browserHistory;
@@ -6303,17 +6324,15 @@
6303
6324
  case "history.replaceQuery":
6304
6325
  case "history.pushAnchor":
6305
6326
  case "history.block":
6306
- return builtinHistoryListenerFactory(method, handler.args, handler, context);
6307
-
6308
6327
  case "history.goBack":
6309
6328
  case "history.goForward":
6310
6329
  case "history.reload":
6311
6330
  case "history.unblock":
6312
- return builtinHistoryWithoutArgsListenerFactory(method, handler, context);
6331
+ return builtinHistoryListenerFactory(method, handler.args, handler, handler.callback, context);
6313
6332
 
6314
6333
  case "segue.push":
6315
6334
  case "segue.replace":
6316
- return builtinSegueListenerFactory(method, handler.args, handler, context);
6335
+ return builtinSegueListenerFactory(method, handler.args, handler, handler.callback, context);
6317
6336
 
6318
6337
  case "alias.push":
6319
6338
  case "alias.replace":
@@ -6555,7 +6574,7 @@
6555
6574
  };
6556
6575
  }
6557
6576
 
6558
- function builtinSegueListenerFactory(method, args, ifContainer, context) {
6577
+ function builtinSegueListenerFactory(method, args, ifContainer, callback, context) {
6559
6578
  return function (event) {
6560
6579
  if (!looseCheckIf(ifContainer, _objectSpread__default["default"](_objectSpread__default["default"]({}, context), {}, {
6561
6580
  event
@@ -6568,7 +6587,15 @@
6568
6587
  segues
6569
6588
  } = _internalApiGetCurrentContext();
6570
6589
 
6571
- getHistory()[method](getUrlBySegueFactory(app, segues)(...argsFactory(args, context, event)));
6590
+ getHistory()[method](getUrlBySegueFactory(app, segues)(...argsFactory(args, context, event)), undefined, callback ? blocked => {
6591
+ var callbackFactory = eventCallbackFactory(callback, () => context, null);
6592
+ callbackFactory(blocked ? "error" : "success")({
6593
+ blocked
6594
+ });
6595
+ callbackFactory("finally")({
6596
+ blocked
6597
+ });
6598
+ } : undefined);
6572
6599
  };
6573
6600
  }
6574
6601
 
@@ -6831,7 +6858,7 @@
6831
6858
  return _brickCallback.apply(this, arguments);
6832
6859
  }
6833
6860
 
6834
- function builtinHistoryListenerFactory(method, args, ifContainer, context) {
6861
+ function builtinHistoryListenerFactory(method, args, ifContainer, callback, context) {
6835
6862
  return function (event) {
6836
6863
  if (!looseCheckIf(ifContainer, _objectSpread__default["default"](_objectSpread__default["default"]({}, context), {}, {
6837
6864
  event
@@ -6839,21 +6866,52 @@
6839
6866
  return;
6840
6867
  }
6841
6868
 
6842
- getHistory()[method === "block" ? "setBlockMessage" : method](...argsFactory(args, context, event, {
6843
- useEventDetailAsDefault: true
6844
- }));
6845
- };
6846
- }
6869
+ var baseArgsLength = 0;
6870
+ var hasCallback = false;
6871
+ var overrideMethod = method;
6847
6872
 
6848
- function builtinHistoryWithoutArgsListenerFactory(method, ifContainer, context) {
6849
- return function (event) {
6850
- if (!looseCheckIf(ifContainer, _objectSpread__default["default"](_objectSpread__default["default"]({}, context), {}, {
6851
- event
6852
- }))) {
6853
- return;
6873
+ switch (method) {
6874
+ case "push":
6875
+ case "replace":
6876
+ case "pushQuery":
6877
+ case "replaceQuery":
6878
+ case "pushAnchor":
6879
+ baseArgsLength = 2;
6880
+ hasCallback = true;
6881
+ break;
6882
+
6883
+ case "reload":
6884
+ hasCallback = true;
6885
+ break;
6886
+
6887
+ case "block":
6888
+ baseArgsLength = 1;
6889
+ overrideMethod = "setBlockMessage";
6890
+ break;
6891
+ }
6892
+
6893
+ var computedArgs = [];
6894
+
6895
+ if (baseArgsLength > 0) {
6896
+ computedArgs = argsFactory(args, context, event, {
6897
+ useEventDetailAsDefault: true
6898
+ });
6899
+ computedArgs.length = baseArgsLength;
6900
+ }
6901
+
6902
+ if (hasCallback && callback) {
6903
+ var callbackFactory = eventCallbackFactory(callback, () => context, null);
6904
+ computedArgs.push(blocked => {
6905
+ callbackFactory(blocked ? "error" : "success")({
6906
+ blocked
6907
+ });
6908
+ callbackFactory("finally")({
6909
+ blocked
6910
+ });
6911
+ });
6854
6912
  }
6855
6913
 
6856
- getHistory()[method]();
6914
+ getHistory()[overrideMethod](...computedArgs);
6857
6915
  };
6858
6916
  }
6859
6917
 
@@ -8389,6 +8447,10 @@
8389
8447
  var tplContext = new CustomTemplateContext(proxyBrick);
8390
8448
  var template = customTemplateRegistry.get(brickConf.brick);
8391
8449
 
8450
+ if (template.contracts) {
8451
+ collectWidgetContract(template.contracts);
8452
+ }
8453
+
8392
8454
  if (Array.isArray(template.state)) {
8393
8455
  tplContext.state.syncDefine(template.state, context, proxyBrick);
8394
8456
  }
@@ -8404,6 +8466,10 @@
8404
8466
  var tplContext = new CustomTemplateContext(proxyBrick);
8405
8467
  var template = customTemplateRegistry.get(brickConf.brick);
8406
8468
 
8469
+ if (template.contracts) {
8470
+ collectWidgetContract(template.contracts);
8471
+ }
8472
+
8407
8473
  if (Array.isArray(template.state)) {
8408
8474
  yield tplContext.state.define(template.state, context, proxyBrick);
8409
8475
  }
@@ -8417,8 +8483,7 @@
8417
8483
  var {
8418
8484
  bricks,
8419
8485
  proxy,
8420
- state,
8421
- contracts
8486
+ state
8422
8487
  } = template;
8423
8488
 
8424
8489
  var {
@@ -8434,11 +8499,6 @@
8434
8499
  proxyBrick.proxy = proxyCopy;
8435
8500
  proxyBrick.proxyRefs = new Map();
8436
8501
  proxyBrick.stateNames = state === null || state === void 0 ? void 0 : state.map(item => item.name);
8437
-
8438
- if (contracts) {
8439
- collectWidgetContract(contracts);
8440
- }
8441
-
8442
8502
  var refToBrickConf = collectRefsInTemplate(template); // Reversed proxies are used for expand storyboard before rendering page.
8443
8503
 
8444
8504
  var reversedProxies = {
@@ -12021,7 +12081,7 @@
12021
12081
  };
12022
12082
 
12023
12083
  if (storyboard) {
12024
- var _currentApp$breadcrum, _currentApp$breadcrum2;
12084
+ var _currentApp$breadcrum, _currentApp$breadcrum2, _currentApp$breadcrum3, _currentApp$breadcrum4;
12025
12085
 
12026
12086
  var {
12027
12087
  bricks,
@@ -12045,7 +12105,7 @@
12045
12105
  appBar: {
12046
12106
  breadcrumb: [],
12047
12107
  documentId: null,
12048
- noCurrentApp: (_currentApp$breadcrum = (_currentApp$breadcrum2 = currentApp.breadcrumb) === null || _currentApp$breadcrum2 === void 0 ? void 0 : _currentApp$breadcrum2.noCurrentApp) !== null && _currentApp$breadcrum !== void 0 ? _currentApp$breadcrum : false
12108
+ noCurrentApp: typeof ((_currentApp$breadcrum = currentApp.breadcrumb) === null || _currentApp$breadcrum === void 0 ? void 0 : _currentApp$breadcrum.noCurrentApp) === "string" ? computeRealValue((_currentApp$breadcrum2 = currentApp.breadcrumb) === null || _currentApp$breadcrum2 === void 0 ? void 0 : _currentApp$breadcrum2.noCurrentApp, _this3.locationContext.getCurrentContext()) : (_currentApp$breadcrum3 = (_currentApp$breadcrum4 = currentApp.breadcrumb) === null || _currentApp$breadcrum4 === void 0 ? void 0 : _currentApp$breadcrum4.noCurrentApp) !== null && _currentApp$breadcrum3 !== void 0 ? _currentApp$breadcrum3 : false
12049
12109
  },
12050
12110
  flags: {
12051
12111
  redirect: undefined,