@next-core/brick-kit 2.134.2 → 2.135.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 +17 -0
- package/dist/index.bundle.js +43 -23
- package/dist/index.bundle.js.map +1 -1
- package/dist/index.esm.js +43 -23
- package/dist/index.esm.js.map +1 -1
- package/dist/types/core/Resolver.d.ts +3 -3
- package/dist/types/core/Resolver.d.ts.map +1 -1
- package/dist/types/core/StoryboardContext.d.ts +1 -1
- package/dist/types/core/StoryboardContext.d.ts.map +1 -1
- package/dist/types/internal/bindListeners.d.ts.map +1 -1
- package/package.json +6 -6
package/dist/index.esm.js
CHANGED
|
@@ -1993,23 +1993,38 @@ class StoryboardContextWrapper {
|
|
|
1993
1993
|
|
|
1994
1994
|
if (item.type !== "free-variable") {
|
|
1995
1995
|
// eslint-disable-next-line no-console
|
|
1996
|
-
console.error("
|
|
1996
|
+
console.error("Unexpected storyboard context \"".concat(name, "\", expected \"free-variable\", received \"").concat(item.type, "\"."));
|
|
1997
1997
|
return;
|
|
1998
|
-
}
|
|
1998
|
+
} // Todo(steve): support callback for refresh/load.
|
|
1999
|
+
|
|
1999
2000
|
|
|
2000
|
-
if (method === "refresh") {
|
|
2001
|
-
if (!item.
|
|
2002
|
-
throw new Error("You can not
|
|
2001
|
+
if (method === "refresh" || method === "load") {
|
|
2002
|
+
if (!item.load) {
|
|
2003
|
+
throw new Error("You can not ".concat(method, " the storyboard context \"").concat(name, "\" which has no resolve."));
|
|
2003
2004
|
}
|
|
2004
2005
|
|
|
2005
|
-
item.
|
|
2006
|
+
if ((item.loaded || item.loading) && method === "load") {
|
|
2007
|
+
// Do not load again.
|
|
2008
|
+
return;
|
|
2009
|
+
}
|
|
2010
|
+
|
|
2011
|
+
item.loading = true; // Defaults to ignore cache when refreshing.
|
|
2012
|
+
|
|
2013
|
+
item.load(_objectSpread({
|
|
2014
|
+
cache: method === "load" ? "default" : "reload"
|
|
2015
|
+
}, value)).then(val => {
|
|
2006
2016
|
var _item$eventTarget;
|
|
2007
2017
|
|
|
2018
|
+
item.loading = false;
|
|
2019
|
+
item.loaded = true;
|
|
2008
2020
|
item.value = val;
|
|
2009
2021
|
(_item$eventTarget = item.eventTarget) === null || _item$eventTarget === void 0 ? void 0 : _item$eventTarget.dispatchEvent(new CustomEvent(this.tplContextId ? "state.change" : "context.change", {
|
|
2010
2022
|
detail: item.value
|
|
2011
2023
|
}));
|
|
2012
|
-
},
|
|
2024
|
+
}, err => {
|
|
2025
|
+
item.loading = false;
|
|
2026
|
+
handleHttpError(err);
|
|
2027
|
+
});
|
|
2013
2028
|
return;
|
|
2014
2029
|
}
|
|
2015
2030
|
|
|
@@ -2108,23 +2123,23 @@ function _resolveNormalStoryboardContext() {
|
|
|
2108
2123
|
|
|
2109
2124
|
var isTemplateState = !!storyboardContextWrapper.tplContextId;
|
|
2110
2125
|
var value = getDefinedTemplateState(isTemplateState, contextConf, brick);
|
|
2111
|
-
var
|
|
2126
|
+
var load = null;
|
|
2112
2127
|
var isLazyResolve = false;
|
|
2113
2128
|
|
|
2114
2129
|
if (value === undefined) {
|
|
2115
2130
|
if (contextConf.resolve) {
|
|
2116
2131
|
if (looseCheckIf(contextConf.resolve, mergedContext)) {
|
|
2117
|
-
|
|
2118
|
-
var _ref = _asyncToGenerator$3(function* () {
|
|
2132
|
+
load = /*#__PURE__*/function () {
|
|
2133
|
+
var _ref = _asyncToGenerator$3(function* (options) {
|
|
2119
2134
|
var valueConf = {};
|
|
2120
2135
|
yield _internalApiGetResolver().resolveOne("reference", _objectSpread({
|
|
2121
2136
|
transform: "value",
|
|
2122
2137
|
transformMapArray: false
|
|
2123
|
-
}, contextConf.resolve), valueConf, null, mergedContext);
|
|
2138
|
+
}, contextConf.resolve), valueConf, null, mergedContext, options);
|
|
2124
2139
|
return valueConf.value;
|
|
2125
2140
|
});
|
|
2126
2141
|
|
|
2127
|
-
return function
|
|
2142
|
+
return function load(_x9) {
|
|
2128
2143
|
return _ref.apply(this, arguments);
|
|
2129
2144
|
};
|
|
2130
2145
|
}();
|
|
@@ -2132,14 +2147,14 @@ function _resolveNormalStoryboardContext() {
|
|
|
2132
2147
|
isLazyResolve = contextConf.resolve.lazy;
|
|
2133
2148
|
|
|
2134
2149
|
if (!isLazyResolve) {
|
|
2135
|
-
value = yield
|
|
2150
|
+
value = yield load();
|
|
2136
2151
|
}
|
|
2137
2152
|
} else if (!hasOwnProperty(contextConf, "value")) {
|
|
2138
2153
|
return false;
|
|
2139
2154
|
}
|
|
2140
2155
|
}
|
|
2141
2156
|
|
|
2142
|
-
if ((!
|
|
2157
|
+
if ((!load || isLazyResolve) && contextConf.value !== undefined) {
|
|
2143
2158
|
// If the context has no resolve, just use its `value`.
|
|
2144
2159
|
// Or if the resolve is ignored or lazy, use its `value` as a fallback.
|
|
2145
2160
|
value = computeRealValue(contextConf.value, mergedContext, true);
|
|
@@ -2147,15 +2162,17 @@ function _resolveNormalStoryboardContext() {
|
|
|
2147
2162
|
|
|
2148
2163
|
if (contextConf.track) {
|
|
2149
2164
|
// Track its dependencies and auto update when each of them changed.
|
|
2150
|
-
var deps = (isTemplateState ? trackUsedState : trackUsedContext)(
|
|
2165
|
+
var deps = (isTemplateState ? trackUsedState : trackUsedContext)(load ? contextConf.resolve : contextConf.value);
|
|
2151
2166
|
|
|
2152
2167
|
for (var dep of deps) {
|
|
2153
2168
|
var _eventTarget;
|
|
2154
2169
|
|
|
2155
2170
|
var ctx = storyboardContextWrapper.get().get(dep);
|
|
2156
2171
|
ctx === null || ctx === void 0 ? void 0 : (_eventTarget = ctx.eventTarget) === null || _eventTarget === void 0 ? void 0 : _eventTarget.addEventListener(isTemplateState ? "state.change" : "context.change", () => {
|
|
2157
|
-
if (
|
|
2158
|
-
storyboardContextWrapper.updateValue(contextConf.name,
|
|
2172
|
+
if (load) {
|
|
2173
|
+
storyboardContextWrapper.updateValue(contextConf.name, {
|
|
2174
|
+
cache: "default"
|
|
2175
|
+
}, "refresh");
|
|
2159
2176
|
} else {
|
|
2160
2177
|
storyboardContextWrapper.updateValue(contextConf.name, computeRealValue(contextConf.value, mergedContext, true), "replace");
|
|
2161
2178
|
}
|
|
@@ -2164,7 +2181,7 @@ function _resolveNormalStoryboardContext() {
|
|
|
2164
2181
|
}
|
|
2165
2182
|
}
|
|
2166
2183
|
|
|
2167
|
-
resolveFreeVariableValue(value, contextConf, mergedContext, storyboardContextWrapper, brick,
|
|
2184
|
+
resolveFreeVariableValue(value, contextConf, mergedContext, storyboardContextWrapper, brick, load, !isLazyResolve);
|
|
2168
2185
|
return true;
|
|
2169
2186
|
});
|
|
2170
2187
|
return _resolveNormalStoryboardContext.apply(this, arguments);
|
|
@@ -2195,13 +2212,14 @@ function getDefinedTemplateState(isTemplateState, contextConf, brick) {
|
|
|
2195
2212
|
}
|
|
2196
2213
|
}
|
|
2197
2214
|
|
|
2198
|
-
function resolveFreeVariableValue(value, contextConf, mergedContext, storyboardContextWrapper, brick,
|
|
2215
|
+
function resolveFreeVariableValue(value, contextConf, mergedContext, storyboardContextWrapper, brick, load, loaded) {
|
|
2199
2216
|
var newContext = {
|
|
2200
2217
|
type: "free-variable",
|
|
2201
2218
|
value,
|
|
2202
2219
|
// This is required for tracking context, even if no `onChange` is specified.
|
|
2203
2220
|
eventTarget: new EventTarget$1(),
|
|
2204
|
-
|
|
2221
|
+
load,
|
|
2222
|
+
loaded
|
|
2205
2223
|
};
|
|
2206
2224
|
|
|
2207
2225
|
if (contextConf.onChange) {
|
|
@@ -6292,10 +6310,12 @@ function listenerFactory(handler, context, runtimeBrick) {
|
|
|
6292
6310
|
case "context.assign":
|
|
6293
6311
|
case "context.replace":
|
|
6294
6312
|
case "context.refresh":
|
|
6313
|
+
case "context.load":
|
|
6295
6314
|
return builtinContextListenerFactory(method, handler.args, handler, context);
|
|
6296
6315
|
|
|
6297
6316
|
case "state.update":
|
|
6298
6317
|
case "state.refresh":
|
|
6318
|
+
case "state.load":
|
|
6299
6319
|
return builtinStateListenerFactory(method, handler.args, handler, context);
|
|
6300
6320
|
|
|
6301
6321
|
case "tpl.dispatchEvent":
|
|
@@ -6450,7 +6470,7 @@ function builtinStateListenerFactory(method, args, ifContainer, context) {
|
|
|
6450
6470
|
|
|
6451
6471
|
var tplContext = getTplContext(context.tplContextId);
|
|
6452
6472
|
var [name, value] = argsFactory(args, context, event);
|
|
6453
|
-
tplContext.state.updateValue(name, value, method === "
|
|
6473
|
+
tplContext.state.updateValue(name, value, method === "update" ? "replace" : method);
|
|
6454
6474
|
};
|
|
6455
6475
|
}
|
|
6456
6476
|
|
|
@@ -11265,7 +11285,7 @@ class Resolver {
|
|
|
11265
11285
|
})();
|
|
11266
11286
|
}
|
|
11267
11287
|
|
|
11268
|
-
resolveOne(type, resolveConf, conf, brick, context) {
|
|
11288
|
+
resolveOne(type, resolveConf, conf, brick, context, options) {
|
|
11269
11289
|
var _this2 = this;
|
|
11270
11290
|
|
|
11271
11291
|
return _asyncToGenerator$3(function* () {
|
|
@@ -11370,7 +11390,7 @@ class Resolver {
|
|
|
11370
11390
|
|
|
11371
11391
|
var promise;
|
|
11372
11392
|
|
|
11373
|
-
if (_this2.cache.has(cacheKey)) {
|
|
11393
|
+
if ((options === null || options === void 0 ? void 0 : options.cache) !== "reload" && _this2.cache.has(cacheKey)) {
|
|
11374
11394
|
promise = _this2.cache.get(cacheKey);
|
|
11375
11395
|
} else {
|
|
11376
11396
|
promise = _asyncToGenerator$3(function* () {
|