@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/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,23 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [2.135.0](https://github.com/easyops-cn/next-core/compare/@next-core/brick-kit@2.134.2...@next-core/brick-kit@2.135.0) (2022-09-02)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* ignore cache when refresh context ([a7d5f86](https://github.com/easyops-cn/next-core/commit/a7d5f864475ebff6f6e7ebd1abbf09afb6a77473))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
* support context.load ([bf09ab1](https://github.com/easyops-cn/next-core/commit/bf09ab1aa650a4cd80b83650ad8c2173d8941d14))
|
|
17
|
+
* support context.load ([7056edd](https://github.com/easyops-cn/next-core/commit/7056eddb088e4fa3fd6aadafd8e027eaddcd63db))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
6
23
|
## [2.134.2](https://github.com/easyops-cn/next-core/compare/@next-core/brick-kit@2.134.1...@next-core/brick-kit@2.134.2) (2022-09-01)
|
|
7
24
|
|
|
8
25
|
**Note:** Version bump only for package @next-core/brick-kit
|
package/dist/index.bundle.js
CHANGED
|
@@ -1992,23 +1992,38 @@
|
|
|
1992
1992
|
|
|
1993
1993
|
if (item.type !== "free-variable") {
|
|
1994
1994
|
// eslint-disable-next-line no-console
|
|
1995
|
-
console.error("
|
|
1995
|
+
console.error("Unexpected storyboard context \"".concat(name, "\", expected \"free-variable\", received \"").concat(item.type, "\"."));
|
|
1996
1996
|
return;
|
|
1997
|
-
}
|
|
1997
|
+
} // Todo(steve): support callback for refresh/load.
|
|
1998
|
+
|
|
1998
1999
|
|
|
1999
|
-
if (method === "refresh") {
|
|
2000
|
-
if (!item.
|
|
2001
|
-
throw new Error("You can not
|
|
2000
|
+
if (method === "refresh" || method === "load") {
|
|
2001
|
+
if (!item.load) {
|
|
2002
|
+
throw new Error("You can not ".concat(method, " the storyboard context \"").concat(name, "\" which has no resolve."));
|
|
2002
2003
|
}
|
|
2003
2004
|
|
|
2004
|
-
item.
|
|
2005
|
+
if ((item.loaded || item.loading) && method === "load") {
|
|
2006
|
+
// Do not load again.
|
|
2007
|
+
return;
|
|
2008
|
+
}
|
|
2009
|
+
|
|
2010
|
+
item.loading = true; // Defaults to ignore cache when refreshing.
|
|
2011
|
+
|
|
2012
|
+
item.load(_objectSpread__default["default"]({
|
|
2013
|
+
cache: method === "load" ? "default" : "reload"
|
|
2014
|
+
}, value)).then(val => {
|
|
2005
2015
|
var _item$eventTarget;
|
|
2006
2016
|
|
|
2017
|
+
item.loading = false;
|
|
2018
|
+
item.loaded = true;
|
|
2007
2019
|
item.value = val;
|
|
2008
2020
|
(_item$eventTarget = item.eventTarget) === null || _item$eventTarget === void 0 ? void 0 : _item$eventTarget.dispatchEvent(new CustomEvent(this.tplContextId ? "state.change" : "context.change", {
|
|
2009
2021
|
detail: item.value
|
|
2010
2022
|
}));
|
|
2011
|
-
},
|
|
2023
|
+
}, err => {
|
|
2024
|
+
item.loading = false;
|
|
2025
|
+
handleHttpError(err);
|
|
2026
|
+
});
|
|
2012
2027
|
return;
|
|
2013
2028
|
}
|
|
2014
2029
|
|
|
@@ -2107,23 +2122,23 @@
|
|
|
2107
2122
|
|
|
2108
2123
|
var isTemplateState = !!storyboardContextWrapper.tplContextId;
|
|
2109
2124
|
var value = getDefinedTemplateState(isTemplateState, contextConf, brick);
|
|
2110
|
-
var
|
|
2125
|
+
var load = null;
|
|
2111
2126
|
var isLazyResolve = false;
|
|
2112
2127
|
|
|
2113
2128
|
if (value === undefined) {
|
|
2114
2129
|
if (contextConf.resolve) {
|
|
2115
2130
|
if (looseCheckIf(contextConf.resolve, mergedContext)) {
|
|
2116
|
-
|
|
2117
|
-
var _ref = _asyncToGenerator__default["default"](function* () {
|
|
2131
|
+
load = /*#__PURE__*/function () {
|
|
2132
|
+
var _ref = _asyncToGenerator__default["default"](function* (options) {
|
|
2118
2133
|
var valueConf = {};
|
|
2119
2134
|
yield _internalApiGetResolver().resolveOne("reference", _objectSpread__default["default"]({
|
|
2120
2135
|
transform: "value",
|
|
2121
2136
|
transformMapArray: false
|
|
2122
|
-
}, contextConf.resolve), valueConf, null, mergedContext);
|
|
2137
|
+
}, contextConf.resolve), valueConf, null, mergedContext, options);
|
|
2123
2138
|
return valueConf.value;
|
|
2124
2139
|
});
|
|
2125
2140
|
|
|
2126
|
-
return function
|
|
2141
|
+
return function load(_x9) {
|
|
2127
2142
|
return _ref.apply(this, arguments);
|
|
2128
2143
|
};
|
|
2129
2144
|
}();
|
|
@@ -2131,14 +2146,14 @@
|
|
|
2131
2146
|
isLazyResolve = contextConf.resolve.lazy;
|
|
2132
2147
|
|
|
2133
2148
|
if (!isLazyResolve) {
|
|
2134
|
-
value = yield
|
|
2149
|
+
value = yield load();
|
|
2135
2150
|
}
|
|
2136
2151
|
} else if (!brickUtils.hasOwnProperty(contextConf, "value")) {
|
|
2137
2152
|
return false;
|
|
2138
2153
|
}
|
|
2139
2154
|
}
|
|
2140
2155
|
|
|
2141
|
-
if ((!
|
|
2156
|
+
if ((!load || isLazyResolve) && contextConf.value !== undefined) {
|
|
2142
2157
|
// If the context has no resolve, just use its `value`.
|
|
2143
2158
|
// Or if the resolve is ignored or lazy, use its `value` as a fallback.
|
|
2144
2159
|
value = computeRealValue(contextConf.value, mergedContext, true);
|
|
@@ -2146,15 +2161,17 @@
|
|
|
2146
2161
|
|
|
2147
2162
|
if (contextConf.track) {
|
|
2148
2163
|
// Track its dependencies and auto update when each of them changed.
|
|
2149
|
-
var deps = (isTemplateState ? brickUtils.trackUsedState : brickUtils.trackUsedContext)(
|
|
2164
|
+
var deps = (isTemplateState ? brickUtils.trackUsedState : brickUtils.trackUsedContext)(load ? contextConf.resolve : contextConf.value);
|
|
2150
2165
|
|
|
2151
2166
|
for (var dep of deps) {
|
|
2152
2167
|
var _eventTarget;
|
|
2153
2168
|
|
|
2154
2169
|
var ctx = storyboardContextWrapper.get().get(dep);
|
|
2155
2170
|
ctx === null || ctx === void 0 ? void 0 : (_eventTarget = ctx.eventTarget) === null || _eventTarget === void 0 ? void 0 : _eventTarget.addEventListener(isTemplateState ? "state.change" : "context.change", () => {
|
|
2156
|
-
if (
|
|
2157
|
-
storyboardContextWrapper.updateValue(contextConf.name,
|
|
2171
|
+
if (load) {
|
|
2172
|
+
storyboardContextWrapper.updateValue(contextConf.name, {
|
|
2173
|
+
cache: "default"
|
|
2174
|
+
}, "refresh");
|
|
2158
2175
|
} else {
|
|
2159
2176
|
storyboardContextWrapper.updateValue(contextConf.name, computeRealValue(contextConf.value, mergedContext, true), "replace");
|
|
2160
2177
|
}
|
|
@@ -2163,7 +2180,7 @@
|
|
|
2163
2180
|
}
|
|
2164
2181
|
}
|
|
2165
2182
|
|
|
2166
|
-
resolveFreeVariableValue(value, contextConf, mergedContext, storyboardContextWrapper, brick,
|
|
2183
|
+
resolveFreeVariableValue(value, contextConf, mergedContext, storyboardContextWrapper, brick, load, !isLazyResolve);
|
|
2167
2184
|
return true;
|
|
2168
2185
|
});
|
|
2169
2186
|
return _resolveNormalStoryboardContext.apply(this, arguments);
|
|
@@ -2194,13 +2211,14 @@
|
|
|
2194
2211
|
}
|
|
2195
2212
|
}
|
|
2196
2213
|
|
|
2197
|
-
function resolveFreeVariableValue(value, contextConf, mergedContext, storyboardContextWrapper, brick,
|
|
2214
|
+
function resolveFreeVariableValue(value, contextConf, mergedContext, storyboardContextWrapper, brick, load, loaded) {
|
|
2198
2215
|
var newContext = {
|
|
2199
2216
|
type: "free-variable",
|
|
2200
2217
|
value,
|
|
2201
2218
|
// This is required for tracking context, even if no `onChange` is specified.
|
|
2202
2219
|
eventTarget: new EventTarget$1(),
|
|
2203
|
-
|
|
2220
|
+
load,
|
|
2221
|
+
loaded
|
|
2204
2222
|
};
|
|
2205
2223
|
|
|
2206
2224
|
if (contextConf.onChange) {
|
|
@@ -6291,10 +6309,12 @@
|
|
|
6291
6309
|
case "context.assign":
|
|
6292
6310
|
case "context.replace":
|
|
6293
6311
|
case "context.refresh":
|
|
6312
|
+
case "context.load":
|
|
6294
6313
|
return builtinContextListenerFactory(method, handler.args, handler, context);
|
|
6295
6314
|
|
|
6296
6315
|
case "state.update":
|
|
6297
6316
|
case "state.refresh":
|
|
6317
|
+
case "state.load":
|
|
6298
6318
|
return builtinStateListenerFactory(method, handler.args, handler, context);
|
|
6299
6319
|
|
|
6300
6320
|
case "tpl.dispatchEvent":
|
|
@@ -6449,7 +6469,7 @@
|
|
|
6449
6469
|
|
|
6450
6470
|
var tplContext = getTplContext(context.tplContextId);
|
|
6451
6471
|
var [name, value] = argsFactory(args, context, event);
|
|
6452
|
-
tplContext.state.updateValue(name, value, method === "
|
|
6472
|
+
tplContext.state.updateValue(name, value, method === "update" ? "replace" : method);
|
|
6453
6473
|
};
|
|
6454
6474
|
}
|
|
6455
6475
|
|
|
@@ -11264,7 +11284,7 @@
|
|
|
11264
11284
|
})();
|
|
11265
11285
|
}
|
|
11266
11286
|
|
|
11267
|
-
resolveOne(type, resolveConf, conf, brick, context) {
|
|
11287
|
+
resolveOne(type, resolveConf, conf, brick, context, options) {
|
|
11268
11288
|
var _this2 = this;
|
|
11269
11289
|
|
|
11270
11290
|
return _asyncToGenerator__default["default"](function* () {
|
|
@@ -11369,7 +11389,7 @@
|
|
|
11369
11389
|
|
|
11370
11390
|
var promise;
|
|
11371
11391
|
|
|
11372
|
-
if (_this2.cache.has(cacheKey)) {
|
|
11392
|
+
if ((options === null || options === void 0 ? void 0 : options.cache) !== "reload" && _this2.cache.has(cacheKey)) {
|
|
11373
11393
|
promise = _this2.cache.get(cacheKey);
|
|
11374
11394
|
} else {
|
|
11375
11395
|
promise = _asyncToGenerator__default["default"](function* () {
|