@next-core/brick-kit 2.184.0 → 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.
package/dist/index.esm.js CHANGED
@@ -3,7 +3,7 @@ import _objectSpread from '@babel/runtime/helpers/objectSpread2';
3
3
  import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
4
4
  import _defineProperty$1 from '@babel/runtime/helpers/defineProperty';
5
5
  import _asyncToGenerator$3 from '@babel/runtime/helpers/asyncToGenerator';
6
- import _, { set, get, difference, identity, uniqueId, cloneDeep, clamp, isNil, isEmpty, merge, sortBy, orderBy, isObject as isObject$1, uniq, pick, omit, findLastIndex, noop, isString as isString$1 } from 'lodash';
6
+ import _, { set, get, difference, identity, uniqueId, cloneDeep, clamp, isNil, isEmpty, merge, sortBy, orderBy, pick, isObject as isObject$1, uniq, omit, findLastIndex, noop, isString as isString$1 } from 'lodash';
7
7
  import { JsonStorage, toPath, computeRealRoutePath, hasOwnProperty, isObject, isEvaluable, isTrackAll, trackAll, trackContext, trackState, trackFormState, transformAndInject, transform, scanPermissionActionsInStoryboard, precookFunction, cook, collectContextUsage, deferResolveContextConcurrently, resolveContextConcurrently, syncResolveContextConcurrently, trackUsedFormState, trackUsedState, trackUsedContext, shouldAllowRecursiveEvaluations, preevaluate, inject, scanPermissionActionsInAny, deepFreeze, scanProcessorsInAny, matchPath, asyncProcessBrick, createProviderClass, removeDeadConditionsInTpl, getTemplateDepsOfStoryboard, getDllAndDepsOfStoryboard, asyncProcessStoryboard, getDllAndDepsByResource, scanRouteAliasInStoryboard, snippetEvaluate, scanCustomApisInStoryboard, prefetchScript, scanBricksInBrickConf, loadScript, scanAppGetMenuInAny, scanInstalledAppsInStoryboard, removeDeadConditions, restoreDynamicTemplates, scanStoryboard, mapCustomApisToNameAndNamespace } from '@next-core/brick-utils';
8
8
  import React, { useState, useEffect, useMemo, useContext, createContext, useRef, useReducer, useCallback } from 'react';
9
9
  import { http, HttpResponseError, HttpAbortError, HttpFetchError } from '@next-core/brick-http';
@@ -5802,21 +5802,23 @@ class MessageDispatcher {
5802
5802
  }
5803
5803
 
5804
5804
  var timeoutIdList = new Set();
5805
- function startPoll(task, _ref, _ref2) {
5805
+ function startPoll(task, _ref, pollOptions, context) {
5806
5806
  var {
5807
5807
  progress,
5808
5808
  success,
5809
5809
  error,
5810
5810
  finally: finallyCallback
5811
5811
  } = _ref;
5812
+ var {
5813
+ expectPollStopImmediately,
5814
+ expectPollEnd
5815
+ } = pollOptions;
5812
5816
  var {
5813
5817
  interval,
5814
5818
  leadingRequestDelay,
5815
5819
  continueOnError,
5816
- delegateLoadingBar,
5817
- expectPollEnd,
5818
- expectPollStopImmediately
5819
- } = _ref2;
5820
+ delegateLoadingBar
5821
+ } = computeRealValue(pick(pollOptions, ["interval", "leadingRequestDelay", "continueOnError", "delegateLoadingBar"]), context);
5820
5822
  var currentRenderId = _internalApiGetRouterRenderId();
5821
5823
  var currentTimeoutId;
5822
5824
  function poll() {
@@ -5827,16 +5829,20 @@ function startPoll(task, _ref, _ref2) {
5827
5829
  timeoutIdList.delete(currentTimeoutId);
5828
5830
  var shouldStop;
5829
5831
  try {
5830
- shouldStop = expectPollStopImmediately === null || expectPollStopImmediately === void 0 ? void 0 : expectPollStopImmediately();
5832
+ var _computeRealValue;
5833
+ shouldStop = (_computeRealValue = computeRealValue(expectPollStopImmediately, context)) === null || _computeRealValue === void 0 ? void 0 : _computeRealValue();
5831
5834
  // Stop polling immediately when the expectation is match before task.
5832
5835
  if (!shouldStop) {
5836
+ var _computeRealValue2;
5833
5837
  var _result = yield task();
5834
5838
  // Stop polling immediately when the expectation is match or a different router
5835
5839
  // is rendering after the task processed.
5836
- shouldStop = (expectPollStopImmediately === null || expectPollStopImmediately === void 0 ? void 0 : expectPollStopImmediately()) || currentRenderId !== _internalApiGetRouterRenderId();
5840
+ shouldStop = ((_computeRealValue2 = computeRealValue(expectPollStopImmediately, context)) === null || _computeRealValue2 === void 0 ? void 0 : _computeRealValue2()) || currentRenderId !== _internalApiGetRouterRenderId();
5837
5841
  if (!shouldStop) {
5842
+ var _computeRealValue3;
5838
5843
  progress === null || progress === void 0 ? void 0 : progress(_result);
5839
- if (expectPollEnd !== null && expectPollEnd !== void 0 && expectPollEnd(_result)) {
5844
+ var value = (_computeRealValue3 = computeRealValue(expectPollEnd, context)) === null || _computeRealValue3 === void 0 ? void 0 : _computeRealValue3(_result);
5845
+ if (value) {
5840
5846
  if (delegateLoadingBar) {
5841
5847
  window.dispatchEvent(new CustomEvent("request.end"));
5842
5848
  }
@@ -5848,9 +5854,10 @@ function startPoll(task, _ref, _ref2) {
5848
5854
  }
5849
5855
  }
5850
5856
  } catch (e) {
5857
+ var _computeRealValue4;
5851
5858
  // Stop polling immediately when the expectation is match or a different router
5852
5859
  // is rendering after the task processed.
5853
- shouldStop = (expectPollStopImmediately === null || expectPollStopImmediately === void 0 ? void 0 : expectPollStopImmediately()) || currentRenderId !== _internalApiGetRouterRenderId();
5860
+ shouldStop = ((_computeRealValue4 = computeRealValue(expectPollStopImmediately, context)) === null || _computeRealValue4 === void 0 ? void 0 : _computeRealValue4()) || currentRenderId !== _internalApiGetRouterRenderId();
5854
5861
  if (!shouldStop) {
5855
5862
  error === null || error === void 0 ? void 0 : error(e);
5856
5863
  if (continueOnError) {
@@ -6705,7 +6712,6 @@ function brickCallback(_x2, _x3, _x4, _x5, _x6, _x7, _x8) {
6705
6712
  }
6706
6713
  function _brickCallback() {
6707
6714
  _brickCallback = _asyncToGenerator$3(function* (target, handler, method, context, runtimeBrick, event, options) {
6708
- var _poll;
6709
6715
  if (typeof target[method] !== "function") {
6710
6716
  // eslint-disable-next-line no-console
6711
6717
  console.error("target has no method:", {
@@ -6737,25 +6743,26 @@ function _brickCallback() {
6737
6743
  error: callbackFactory("error"),
6738
6744
  finally: callbackFactory("finally")
6739
6745
  };
6740
- var poll;
6741
6746
  if (isUseProviderHandler(handler)) {
6742
- poll = computeRealValue(handler.poll, _objectSpread(_objectSpread({}, context), {}, {
6747
+ var _handler$poll;
6748
+ var runtimeContext = _objectSpread(_objectSpread({}, context), {}, {
6743
6749
  event
6744
- }), true);
6745
- }
6746
- if ((_poll = poll) !== null && _poll !== void 0 && _poll.enabled) {
6747
- startPoll(task, pollableCallback, poll);
6748
- } else {
6749
- try {
6750
- // Try to catch synchronized tasks too.
6751
- var result = yield task();
6752
- pollableCallback.success(result);
6753
- } catch (err) {
6754
- pollableCallback.error(err);
6755
- } finally {
6756
- pollableCallback["finally"]();
6750
+ });
6751
+ var pollEnabled = computeRealValue((_handler$poll = handler.poll) === null || _handler$poll === void 0 ? void 0 : _handler$poll.enabled, runtimeContext, true);
6752
+ if (pollEnabled) {
6753
+ startPoll(task, pollableCallback, handler.poll, runtimeContext);
6754
+ return;
6757
6755
  }
6758
6756
  }
6757
+ try {
6758
+ // Try to catch synchronized tasks too.
6759
+ var result = yield task();
6760
+ pollableCallback.success(result);
6761
+ } catch (err) {
6762
+ pollableCallback.error(err);
6763
+ } finally {
6764
+ pollableCallback["finally"]();
6765
+ }
6759
6766
  });
6760
6767
  return _brickCallback.apply(this, arguments);
6761
6768
  }