@next-core/brick-kit 2.184.1 → 2.184.2

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.
@@ -5800,21 +5800,23 @@
5800
5800
  }
5801
5801
 
5802
5802
  var timeoutIdList = new Set();
5803
- function startPoll(task, _ref, _ref2) {
5803
+ function startPoll(task, _ref, pollOptions, context) {
5804
5804
  var {
5805
5805
  progress,
5806
5806
  success,
5807
5807
  error,
5808
5808
  finally: finallyCallback
5809
5809
  } = _ref;
5810
+ var {
5811
+ expectPollStopImmediately,
5812
+ expectPollEnd
5813
+ } = pollOptions;
5810
5814
  var {
5811
5815
  interval,
5812
5816
  leadingRequestDelay,
5813
5817
  continueOnError,
5814
- delegateLoadingBar,
5815
- expectPollEnd,
5816
- expectPollStopImmediately
5817
- } = _ref2;
5818
+ delegateLoadingBar
5819
+ } = computeRealValue(_.pick(pollOptions, ["interval", "leadingRequestDelay", "continueOnError", "delegateLoadingBar"]), context);
5818
5820
  var currentRenderId = _internalApiGetRouterRenderId();
5819
5821
  var currentTimeoutId;
5820
5822
  function poll() {
@@ -5825,16 +5827,20 @@
5825
5827
  timeoutIdList.delete(currentTimeoutId);
5826
5828
  var shouldStop;
5827
5829
  try {
5828
- shouldStop = expectPollStopImmediately === null || expectPollStopImmediately === void 0 ? void 0 : expectPollStopImmediately();
5830
+ var _computeRealValue;
5831
+ shouldStop = (_computeRealValue = computeRealValue(expectPollStopImmediately, context)) === null || _computeRealValue === void 0 ? void 0 : _computeRealValue();
5829
5832
  // Stop polling immediately when the expectation is match before task.
5830
5833
  if (!shouldStop) {
5834
+ var _computeRealValue2;
5831
5835
  var _result = yield task();
5832
5836
  // Stop polling immediately when the expectation is match or a different router
5833
5837
  // is rendering after the task processed.
5834
- shouldStop = (expectPollStopImmediately === null || expectPollStopImmediately === void 0 ? void 0 : expectPollStopImmediately()) || currentRenderId !== _internalApiGetRouterRenderId();
5838
+ shouldStop = ((_computeRealValue2 = computeRealValue(expectPollStopImmediately, context)) === null || _computeRealValue2 === void 0 ? void 0 : _computeRealValue2()) || currentRenderId !== _internalApiGetRouterRenderId();
5835
5839
  if (!shouldStop) {
5840
+ var _computeRealValue3;
5836
5841
  progress === null || progress === void 0 ? void 0 : progress(_result);
5837
- if (expectPollEnd !== null && expectPollEnd !== void 0 && expectPollEnd(_result)) {
5842
+ var value = (_computeRealValue3 = computeRealValue(expectPollEnd, context)) === null || _computeRealValue3 === void 0 ? void 0 : _computeRealValue3(_result);
5843
+ if (value) {
5838
5844
  if (delegateLoadingBar) {
5839
5845
  window.dispatchEvent(new CustomEvent("request.end"));
5840
5846
  }
@@ -5846,9 +5852,10 @@
5846
5852
  }
5847
5853
  }
5848
5854
  } catch (e) {
5855
+ var _computeRealValue4;
5849
5856
  // Stop polling immediately when the expectation is match or a different router
5850
5857
  // is rendering after the task processed.
5851
- shouldStop = (expectPollStopImmediately === null || expectPollStopImmediately === void 0 ? void 0 : expectPollStopImmediately()) || currentRenderId !== _internalApiGetRouterRenderId();
5858
+ shouldStop = ((_computeRealValue4 = computeRealValue(expectPollStopImmediately, context)) === null || _computeRealValue4 === void 0 ? void 0 : _computeRealValue4()) || currentRenderId !== _internalApiGetRouterRenderId();
5852
5859
  if (!shouldStop) {
5853
5860
  error === null || error === void 0 ? void 0 : error(e);
5854
5861
  if (continueOnError) {
@@ -6703,7 +6710,6 @@
6703
6710
  }
6704
6711
  function _brickCallback() {
6705
6712
  _brickCallback = _asyncToGenerator__default["default"](function* (target, handler, method, context, runtimeBrick, event, options) {
6706
- var _poll;
6707
6713
  if (typeof target[method] !== "function") {
6708
6714
  // eslint-disable-next-line no-console
6709
6715
  console.error("target has no method:", {
@@ -6735,25 +6741,26 @@
6735
6741
  error: callbackFactory("error"),
6736
6742
  finally: callbackFactory("finally")
6737
6743
  };
6738
- var poll;
6739
6744
  if (isUseProviderHandler(handler)) {
6740
- poll = computeRealValue(handler.poll, _objectSpread__default["default"](_objectSpread__default["default"]({}, context), {}, {
6745
+ var _handler$poll;
6746
+ var runtimeContext = _objectSpread__default["default"](_objectSpread__default["default"]({}, context), {}, {
6741
6747
  event
6742
- }), true);
6743
- }
6744
- if ((_poll = poll) !== null && _poll !== void 0 && _poll.enabled) {
6745
- startPoll(task, pollableCallback, poll);
6746
- } else {
6747
- try {
6748
- // Try to catch synchronized tasks too.
6749
- var result = yield task();
6750
- pollableCallback.success(result);
6751
- } catch (err) {
6752
- pollableCallback.error(err);
6753
- } finally {
6754
- pollableCallback["finally"]();
6748
+ });
6749
+ var pollEnabled = computeRealValue((_handler$poll = handler.poll) === null || _handler$poll === void 0 ? void 0 : _handler$poll.enabled, runtimeContext, true);
6750
+ if (pollEnabled) {
6751
+ startPoll(task, pollableCallback, handler.poll, runtimeContext);
6752
+ return;
6755
6753
  }
6756
6754
  }
6755
+ try {
6756
+ // Try to catch synchronized tasks too.
6757
+ var result = yield task();
6758
+ pollableCallback.success(result);
6759
+ } catch (err) {
6760
+ pollableCallback.error(err);
6761
+ } finally {
6762
+ pollableCallback["finally"]();
6763
+ }
6757
6764
  });
6758
6765
  return _brickCallback.apply(this, arguments);
6759
6766
  }