@next-core/brick-kit 2.175.1 → 2.177.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/dist/index.esm.js CHANGED
@@ -1993,6 +1993,23 @@ class StoryboardContextWrapper {
1993
1993
  }
1994
1994
  })();
1995
1995
  }
1996
+
1997
+ /** After mount, dispatch the change event when an async data is loaded */
1998
+ handleAsyncAfterMount() {
1999
+ this.data.forEach(item => {
2000
+ if (item.type === "free-variable" && item.async) {
2001
+ // An async data always has `loading`
2002
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
2003
+ item.loading.then(value => {
2004
+ item.loaded = true;
2005
+ item.value = value;
2006
+ item.eventTarget.dispatchEvent(new CustomEvent(this.eventName, {
2007
+ detail: value
2008
+ }));
2009
+ });
2010
+ }
2011
+ });
2012
+ }
1996
2013
  deferDefine(contextConfs, coreContext, brick) {
1997
2014
  var {
1998
2015
  mergedContext,
@@ -2079,7 +2096,8 @@ function _resolveNormalStoryboardContext() {
2079
2096
  var isTemplateState = !!storyboardContextWrapper.tplContextId;
2080
2097
  var value = getDefinedTemplateState(isTemplateState, contextConf, brick);
2081
2098
  var load = null;
2082
- var isLazyResolve = false;
2099
+ var loading;
2100
+ var resolvePolicy = "eager";
2083
2101
  if (value === undefined) {
2084
2102
  if (contextConf.resolve) {
2085
2103
  yield storyboardContextWrapper.waitForUsedContext(contextConf.resolve.if);
@@ -2097,10 +2115,13 @@ function _resolveNormalStoryboardContext() {
2097
2115
  return _ref.apply(this, arguments);
2098
2116
  };
2099
2117
  }();
2100
- isLazyResolve = contextConf.resolve.lazy;
2101
- if (!isLazyResolve) {
2118
+ // `async` take precedence over `lazy`
2119
+ resolvePolicy = contextConf.resolve.async && !isTemplateState ? "async" : contextConf.resolve.lazy ? "lazy" : "eager";
2120
+ if (resolvePolicy === "eager") {
2102
2121
  value = yield load();
2103
- } else if (isLazyResolve && contextConf.resolve.trigger) {
2122
+ } else if (resolvePolicy === "async") {
2123
+ loading = load();
2124
+ } else if (contextConf.resolve.trigger) {
2104
2125
  var lifecycleName = contextConf.resolve.trigger;
2105
2126
  if (supportContextResolveTriggerBrickLifeCycle.includes(lifecycleName)) {
2106
2127
  var contextNameArray = storyboardContextWrapper.batchTriggerContextsNamesMap.get(lifecycleName) || [];
@@ -2119,14 +2140,14 @@ function _resolveNormalStoryboardContext() {
2119
2140
  return false;
2120
2141
  }
2121
2142
  }
2122
- if ((!load || isLazyResolve) && contextConf.value !== undefined) {
2143
+ if ((!load || resolvePolicy !== "eager") && contextConf.value !== undefined) {
2123
2144
  yield storyboardContextWrapper.waitForUsedContext(contextConf.value);
2124
2145
  // If the context has no resolve, just use its `value`.
2125
2146
  // Or if the resolve is ignored or lazy, use its `value` as a fallback.
2126
2147
  value = computeRealValue(contextConf.value, mergedContext, true);
2127
2148
  }
2128
2149
  }
2129
- resolveFreeVariableValue(value, contextConf, mergedContext, storyboardContextWrapper, brick, load, !isLazyResolve);
2150
+ resolveFreeVariableValue(value, contextConf, mergedContext, storyboardContextWrapper, brick, load, resolvePolicy === "eager", loading, resolvePolicy === "async");
2130
2151
  return true;
2131
2152
  });
2132
2153
  return _resolveNormalStoryboardContext.apply(this, arguments);
@@ -2150,7 +2171,7 @@ function getDefinedTemplateState(isTemplateState, contextConf, brick) {
2150
2171
  return brick.properties[contextConf.name];
2151
2172
  }
2152
2173
  }
2153
- function resolveFreeVariableValue(value, contextConf, mergedContext, storyboardContextWrapper, brick, load, loaded) {
2174
+ function resolveFreeVariableValue(value, contextConf, mergedContext, storyboardContextWrapper, brick, load, loaded, loading, async) {
2154
2175
  var newContext = {
2155
2176
  type: "free-variable",
2156
2177
  value,
@@ -2158,6 +2179,8 @@ function resolveFreeVariableValue(value, contextConf, mergedContext, storyboardC
2158
2179
  eventTarget: new EventTarget$1(),
2159
2180
  load,
2160
2181
  loaded,
2182
+ loading,
2183
+ async,
2161
2184
  deps: []
2162
2185
  };
2163
2186
  var eventName = storyboardContextWrapper.formContextId ? "formstate.change" : storyboardContextWrapper.tplContextId ? "state.change" : "context.change";
@@ -3309,6 +3332,10 @@ function _computeRealValueWithOverrideApp() {
3309
3332
  if ("if" in data && data.if === null) {
3310
3333
  delete data.if;
3311
3334
  }
3335
+ if ("to" in data) {
3336
+ var _pipes$yaml;
3337
+ data.to = data.to ? (_pipes$yaml = pipes.yaml(data.to)) !== null && _pipes$yaml !== void 0 ? _pipes$yaml : "" : "";
3338
+ }
3312
3339
  var newContext = context;
3313
3340
  if (overrideAppId !== context.app.id && attemptToVisit(data, ["APP", "I18N", "IMG"])) {
3314
3341
  if (window.STANDALONE_MICRO_APPS) {
@@ -12064,6 +12091,7 @@ class Router {
12064
12091
  // See https://github.com/ReactTraining/react-router/blob/master/packages/react-router-dom/docs/guides/scroll-restoration.md
12065
12092
  window.scrollTo(0, 0);
12066
12093
  if (!failed) {
12094
+ locationContext.storyboardContextWrapper.handleAsyncAfterMount();
12067
12095
  _this3.locationContext.handleBrickBindObserver();
12068
12096
  _this3.locationContext.handlePageLoad();
12069
12097
  _this3.locationContext.handleAnchorLoad();