@next-core/brick-kit 2.175.1 → 2.176.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.bundle.js +31 -7
- package/dist/index.bundle.js.map +1 -1
- package/dist/index.esm.js +31 -7
- package/dist/index.esm.js.map +1 -1
- package/dist/types/core/Router.d.ts.map +1 -1
- package/dist/types/core/StoryboardContext.d.ts +2 -0
- package/dist/types/core/StoryboardContext.d.ts.map +1 -1
- package/package.json +6 -6
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
|
|
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
|
-
|
|
2101
|
-
|
|
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 (
|
|
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 ||
|
|
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,
|
|
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";
|
|
@@ -12064,6 +12087,7 @@ class Router {
|
|
|
12064
12087
|
// See https://github.com/ReactTraining/react-router/blob/master/packages/react-router-dom/docs/guides/scroll-restoration.md
|
|
12065
12088
|
window.scrollTo(0, 0);
|
|
12066
12089
|
if (!failed) {
|
|
12090
|
+
locationContext.storyboardContextWrapper.handleAsyncAfterMount();
|
|
12067
12091
|
_this3.locationContext.handleBrickBindObserver();
|
|
12068
12092
|
_this3.locationContext.handlePageLoad();
|
|
12069
12093
|
_this3.locationContext.handleAnchorLoad();
|