@next-core/brick-kit 2.181.2 → 2.183.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 +110 -33
- package/dist/index.bundle.js.map +1 -1
- package/dist/index.esm.js +110 -33
- package/dist/index.esm.js.map +1 -1
- package/dist/types/core/Kernel.d.ts.map +1 -1
- package/dist/types/core/Router.d.ts.map +1 -1
- package/dist/types/core/StoryboardContext.d.ts +1 -0
- package/dist/types/core/StoryboardContext.d.ts.map +1 -1
- package/dist/types/core/standaloneBootstrap.d.ts.map +1 -1
- package/dist/types/setAppVariable.d.ts +7 -0
- package/dist/types/setAppVariable.d.ts.map +1 -0
- package/package.json +6 -6
package/dist/index.esm.js
CHANGED
|
@@ -1934,7 +1934,7 @@ class StoryboardContextWrapper {
|
|
|
1934
1934
|
return;
|
|
1935
1935
|
}
|
|
1936
1936
|
updateValue(name, value, method, callback) {
|
|
1937
|
-
var _item$
|
|
1937
|
+
var _item$eventTarget;
|
|
1938
1938
|
if (!this.data.has(name)) {
|
|
1939
1939
|
if (this.tplContextId) {
|
|
1940
1940
|
throw new Error("State not found: ".concat(name));
|
|
@@ -1955,8 +1955,8 @@ class StoryboardContextWrapper {
|
|
|
1955
1955
|
return;
|
|
1956
1956
|
}
|
|
1957
1957
|
if (method === "refresh" || method === "load") {
|
|
1958
|
-
if (!item.
|
|
1959
|
-
throw new Error("You can not ".concat(method, " the storyboard context \"").concat(name, "\" which
|
|
1958
|
+
if (!item.useResolve) {
|
|
1959
|
+
throw new Error("You can not ".concat(method, " the storyboard context \"").concat(name, "\" which is not using resolve."));
|
|
1960
1960
|
}
|
|
1961
1961
|
var promise;
|
|
1962
1962
|
if (method === "load") {
|
|
@@ -1980,12 +1980,7 @@ class StoryboardContextWrapper {
|
|
|
1980
1980
|
}, value));
|
|
1981
1981
|
// Do not use the chained promise, since the callbacks need the original promise.
|
|
1982
1982
|
promise.then(val => {
|
|
1983
|
-
|
|
1984
|
-
item.loaded = true;
|
|
1985
|
-
item.value = val;
|
|
1986
|
-
(_item$eventTarget = item.eventTarget) === null || _item$eventTarget === void 0 ? void 0 : _item$eventTarget.dispatchEvent(new CustomEvent(this.eventName, {
|
|
1987
|
-
detail: item.value
|
|
1988
|
-
}));
|
|
1983
|
+
this.finishLoad(item, val);
|
|
1989
1984
|
}, err => {
|
|
1990
1985
|
// Let users to override error handling.
|
|
1991
1986
|
if (!shouldDismiss(err) && !(callback !== null && callback !== void 0 && callback.error)) {
|
|
@@ -2021,10 +2016,24 @@ class StoryboardContextWrapper {
|
|
|
2021
2016
|
}
|
|
2022
2017
|
}
|
|
2023
2018
|
if (this.batchUpdate) return;
|
|
2024
|
-
(_item$
|
|
2019
|
+
(_item$eventTarget = item.eventTarget) === null || _item$eventTarget === void 0 ? void 0 : _item$eventTarget.dispatchEvent(new CustomEvent(this.eventName, {
|
|
2025
2020
|
detail: item.value
|
|
2026
2021
|
}));
|
|
2027
2022
|
}
|
|
2023
|
+
finishLoad(item, value) {
|
|
2024
|
+
var _item$eventTarget2;
|
|
2025
|
+
if (!item.useResolve) {
|
|
2026
|
+
// This happens when a tracked conditional resolve switches from
|
|
2027
|
+
// resolve to fallback after an dep update triggered refresh but
|
|
2028
|
+
// before it's been resolved.
|
|
2029
|
+
return;
|
|
2030
|
+
}
|
|
2031
|
+
item.loaded = true;
|
|
2032
|
+
item.value = value;
|
|
2033
|
+
(_item$eventTarget2 = item.eventTarget) === null || _item$eventTarget2 === void 0 ? void 0 : _item$eventTarget2.dispatchEvent(new CustomEvent(this.eventName, {
|
|
2034
|
+
detail: value
|
|
2035
|
+
}));
|
|
2036
|
+
}
|
|
2028
2037
|
waitForUsedContext(data) {
|
|
2029
2038
|
var _this = this;
|
|
2030
2039
|
return _asyncToGenerator$3(function* () {
|
|
@@ -2067,11 +2076,7 @@ class StoryboardContextWrapper {
|
|
|
2067
2076
|
// An async data always has `loading`
|
|
2068
2077
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
2069
2078
|
item.loading.then(value => {
|
|
2070
|
-
item
|
|
2071
|
-
item.value = value;
|
|
2072
|
-
item.eventTarget.dispatchEvent(new CustomEvent(this.eventName, {
|
|
2073
|
-
detail: value
|
|
2074
|
-
}));
|
|
2079
|
+
this.finishLoad(item, value);
|
|
2075
2080
|
});
|
|
2076
2081
|
}
|
|
2077
2082
|
});
|
|
@@ -2160,14 +2165,24 @@ function _resolveNormalStoryboardContext() {
|
|
|
2160
2165
|
return false;
|
|
2161
2166
|
}
|
|
2162
2167
|
var isTemplateState = !!storyboardContextWrapper.tplContextId;
|
|
2168
|
+
var isFormState = !!storyboardContextWrapper.formContextId;
|
|
2163
2169
|
var value = getDefinedTemplateState(isTemplateState, contextConf, brick);
|
|
2164
2170
|
var load = null;
|
|
2165
2171
|
var loading;
|
|
2166
|
-
var
|
|
2172
|
+
var useResolve;
|
|
2173
|
+
var trackConditionalResolve;
|
|
2174
|
+
var resolvePolicy;
|
|
2167
2175
|
if (value === undefined) {
|
|
2168
2176
|
if (contextConf.resolve) {
|
|
2177
|
+
var hasFallbackValue = hasOwnProperty(contextConf, "value");
|
|
2178
|
+
// Track conditional resolve only if all matches:
|
|
2179
|
+
// - Track enabled
|
|
2180
|
+
// - Has fallback value
|
|
2181
|
+
// - Referencing other data in `resolve.if`
|
|
2182
|
+
trackConditionalResolve = contextConf.track && hasFallbackValue && hasOwnProperty(contextConf.resolve, "if") && collectContextUsage(contextConf.resolve.if, isTemplateState ? "STATE" : isFormState ? "FORM_STATE" : "CTX").usedContexts.length > 0;
|
|
2169
2183
|
yield storyboardContextWrapper.waitForUsedContext(contextConf.resolve.if);
|
|
2170
|
-
|
|
2184
|
+
useResolve = looseCheckIf$1(contextConf.resolve, mergedContext);
|
|
2185
|
+
if (useResolve || trackConditionalResolve) {
|
|
2171
2186
|
load = /*#__PURE__*/function () {
|
|
2172
2187
|
var _ref = _asyncToGenerator$3(function* (options) {
|
|
2173
2188
|
var valueConf = {};
|
|
@@ -2181,6 +2196,8 @@ function _resolveNormalStoryboardContext() {
|
|
|
2181
2196
|
return _ref.apply(this, arguments);
|
|
2182
2197
|
};
|
|
2183
2198
|
}();
|
|
2199
|
+
}
|
|
2200
|
+
if (useResolve) {
|
|
2184
2201
|
// `async` take precedence over `lazy`
|
|
2185
2202
|
resolvePolicy = contextConf.resolve.async && !isTemplateState ? "async" : contextConf.resolve.lazy ? "lazy" : "eager";
|
|
2186
2203
|
if (resolvePolicy === "eager") {
|
|
@@ -2202,18 +2219,18 @@ function _resolveNormalStoryboardContext() {
|
|
|
2202
2219
|
console.error("unsupported lifecycle: \"".concat(lifecycleName, "\""));
|
|
2203
2220
|
}
|
|
2204
2221
|
}
|
|
2205
|
-
} else if (!
|
|
2222
|
+
} else if (!hasFallbackValue) {
|
|
2206
2223
|
return false;
|
|
2207
2224
|
}
|
|
2208
2225
|
}
|
|
2209
|
-
if ((!
|
|
2226
|
+
if ((!useResolve || resolvePolicy !== "eager") && contextConf.value !== undefined) {
|
|
2210
2227
|
yield storyboardContextWrapper.waitForUsedContext(contextConf.value);
|
|
2211
2228
|
// If the context has no resolve, just use its `value`.
|
|
2212
2229
|
// Or if the resolve is ignored or lazy, use its `value` as a fallback.
|
|
2213
2230
|
value = computeRealValue(contextConf.value, mergedContext, true);
|
|
2214
2231
|
}
|
|
2215
2232
|
}
|
|
2216
|
-
resolveFreeVariableValue(value, contextConf, mergedContext, storyboardContextWrapper, brick, load, resolvePolicy === "eager", loading, resolvePolicy === "async");
|
|
2233
|
+
resolveFreeVariableValue(value, contextConf, mergedContext, storyboardContextWrapper, brick, load, resolvePolicy === "eager", loading, resolvePolicy === "async", useResolve, trackConditionalResolve);
|
|
2217
2234
|
return true;
|
|
2218
2235
|
});
|
|
2219
2236
|
return _resolveNormalStoryboardContext.apply(this, arguments);
|
|
@@ -2237,12 +2254,13 @@ function getDefinedTemplateState(isTemplateState, contextConf, brick) {
|
|
|
2237
2254
|
return brick.properties[contextConf.name];
|
|
2238
2255
|
}
|
|
2239
2256
|
}
|
|
2240
|
-
function resolveFreeVariableValue(value, contextConf, mergedContext, storyboardContextWrapper, brick, load, loaded, loading, async) {
|
|
2257
|
+
function resolveFreeVariableValue(value, contextConf, mergedContext, storyboardContextWrapper, brick, load, loaded, loading, async, useResolve, trackConditionalResolve) {
|
|
2241
2258
|
var newContext = {
|
|
2242
2259
|
type: "free-variable",
|
|
2243
2260
|
value,
|
|
2244
2261
|
// This is required for tracking context, even if no `onChange` is specified.
|
|
2245
2262
|
eventTarget: new EventTarget$1(),
|
|
2263
|
+
useResolve,
|
|
2246
2264
|
load,
|
|
2247
2265
|
loaded,
|
|
2248
2266
|
loading,
|
|
@@ -2262,13 +2280,14 @@ function resolveFreeVariableValue(value, contextConf, mergedContext, storyboardC
|
|
|
2262
2280
|
var isTemplateState = !!storyboardContextWrapper.tplContextId;
|
|
2263
2281
|
var isFormState = !!storyboardContextWrapper.formContextId;
|
|
2264
2282
|
// Track its dependencies and auto update when each of them changed.
|
|
2265
|
-
var deps = (isFormState ? trackUsedFormState : isTemplateState ? trackUsedState : trackUsedContext)(load ? contextConf.resolve : contextConf.value);
|
|
2283
|
+
var deps = (isFormState ? trackUsedFormState : isTemplateState ? trackUsedState : trackUsedContext)(trackConditionalResolve ? [contextConf.resolve, contextConf.value] : load ? contextConf.resolve : contextConf.value);
|
|
2266
2284
|
!load && (newContext.deps = deps);
|
|
2267
2285
|
for (var dep of deps) {
|
|
2268
2286
|
var _eventTarget;
|
|
2269
2287
|
var ctx = storyboardContextWrapper.get().get(dep);
|
|
2270
2288
|
ctx === null || ctx === void 0 ? void 0 : (_eventTarget = ctx.eventTarget) === null || _eventTarget === void 0 ? void 0 : _eventTarget.addEventListener(eventName, batchAddListener(() => {
|
|
2271
|
-
|
|
2289
|
+
newContext.useResolve = trackConditionalResolve ? looseCheckIf$1(contextConf.resolve, mergedContext) : !!load;
|
|
2290
|
+
if (newContext.useResolve) {
|
|
2272
2291
|
storyboardContextWrapper.updateValue(contextConf.name, {
|
|
2273
2292
|
cache: "default"
|
|
2274
2293
|
}, "refresh");
|
|
@@ -7209,14 +7228,14 @@ function standaloneBootstrap() {
|
|
|
7209
7228
|
}
|
|
7210
7229
|
function _standaloneBootstrap() {
|
|
7211
7230
|
_standaloneBootstrap = _asyncToGenerator$3(function* () {
|
|
7212
|
-
var requests = [http.get(window.BOOTSTRAP_FILE), http.get("".concat(window.APP_ROOT, "conf.yaml"), {
|
|
7231
|
+
var requests = [window.BOOTSTRAP_UNION_FILE ? http.get(window.BOOTSTRAP_UNION_FILE) : http.get(window.BOOTSTRAP_FILE), window.BOOTSTRAP_UNION_FILE ? Promise.resolve("") : http.get("".concat(window.APP_ROOT, "conf.yaml"), {
|
|
7213
7232
|
responseType: "text"
|
|
7214
7233
|
}), BootstrapStandaloneApi_runtimeStandalone().catch(function (error) {
|
|
7215
7234
|
// make it not crash when the backend service is not updated.
|
|
7216
7235
|
// eslint-disable-next-line no-console
|
|
7217
7236
|
console.warn("request runtime api from api-gateway failed: ", error, ", something might went wrong running standalone micro app");
|
|
7218
7237
|
return;
|
|
7219
|
-
})];
|
|
7238
|
+
}), window.BOOTSTRAP_UNION_FILE ? http.get(window.BOOTSTRAP_FILE) : Promise.resolve(undefined)];
|
|
7220
7239
|
if (!window.NO_AUTH_GUARD) {
|
|
7221
7240
|
var matches;
|
|
7222
7241
|
var appId = window.APP_ID || (window.APP_ROOT && (matches = window.APP_ROOT.match(/^(?:(?:\/next)?\/)?sa-static\/([^/]+)\/versions\//)) ? matches[1] : null);
|
|
@@ -7225,7 +7244,7 @@ function _standaloneBootstrap() {
|
|
|
7225
7244
|
safeGetRuntimeMicroAppStandalone(appId);
|
|
7226
7245
|
}
|
|
7227
7246
|
}
|
|
7228
|
-
var [bootstrapResult, confString, runtimeData] = yield Promise.all(requests);
|
|
7247
|
+
var [bootstrapResult, confString, runtimeData, fullBootstrapDetail] = yield Promise.all(requests);
|
|
7229
7248
|
var conf;
|
|
7230
7249
|
try {
|
|
7231
7250
|
conf = confString ? yaml.safeLoad(confString, {
|
|
@@ -7280,12 +7299,34 @@ function _standaloneBootstrap() {
|
|
|
7280
7299
|
}
|
|
7281
7300
|
}
|
|
7282
7301
|
}
|
|
7302
|
+
mergeFullBootstrapDetail(bootstrapResult, fullBootstrapDetail);
|
|
7283
7303
|
return _objectSpread(_objectSpread({}, bootstrapResult), {}, {
|
|
7284
7304
|
settings
|
|
7285
7305
|
});
|
|
7286
7306
|
});
|
|
7287
7307
|
return _standaloneBootstrap.apply(this, arguments);
|
|
7288
7308
|
}
|
|
7309
|
+
function mergeFullBootstrapDetail(bootstrapResult, fullBootstrapDetail) {
|
|
7310
|
+
if (fullBootstrapDetail) {
|
|
7311
|
+
var {
|
|
7312
|
+
storyboards
|
|
7313
|
+
} = fullBootstrapDetail;
|
|
7314
|
+
var {
|
|
7315
|
+
routes,
|
|
7316
|
+
meta,
|
|
7317
|
+
app
|
|
7318
|
+
} = storyboards[0];
|
|
7319
|
+
var matchedStoryboard = bootstrapResult.storyboards.find(item => item.app.id === app.id);
|
|
7320
|
+
if (matchedStoryboard) {
|
|
7321
|
+
Object.assign(matchedStoryboard, {
|
|
7322
|
+
routes,
|
|
7323
|
+
meta,
|
|
7324
|
+
app: _objectSpread(_objectSpread({}, matchedStoryboard.app), app),
|
|
7325
|
+
$$fullMerged: true
|
|
7326
|
+
});
|
|
7327
|
+
}
|
|
7328
|
+
}
|
|
7329
|
+
}
|
|
7289
7330
|
var appRuntimeDataMap = new Map();
|
|
7290
7331
|
function safeGetRuntimeMicroAppStandalone(_x) {
|
|
7291
7332
|
return _safeGetRuntimeMicroAppStandalone.apply(this, arguments);
|
|
@@ -8983,6 +9024,23 @@ class Kernel {
|
|
|
8983
9024
|
$$fulfilled: true,
|
|
8984
9025
|
$$fulfilling: null
|
|
8985
9026
|
});
|
|
9027
|
+
if (window.BOOTSTRAP_UNION_FILE && !storyboard.$$fullMerged) {
|
|
9028
|
+
var fullBootstrapPath = "".concat(window.APP_ROOT, "-/").concat(storyboard.bootstrapFile);
|
|
9029
|
+
var {
|
|
9030
|
+
storyboards
|
|
9031
|
+
} = yield http.get(fullBootstrapPath);
|
|
9032
|
+
var {
|
|
9033
|
+
routes,
|
|
9034
|
+
meta,
|
|
9035
|
+
app
|
|
9036
|
+
} = storyboards[0];
|
|
9037
|
+
Object.assign(storyboard, {
|
|
9038
|
+
routes,
|
|
9039
|
+
meta,
|
|
9040
|
+
app: _objectSpread(_objectSpread({}, storyboard.app), app),
|
|
9041
|
+
$$fullMerged: true
|
|
9042
|
+
});
|
|
9043
|
+
}
|
|
8986
9044
|
if (!window.NO_AUTH_GUARD) {
|
|
8987
9045
|
var appRuntimeData;
|
|
8988
9046
|
try {
|
|
@@ -9005,14 +9063,14 @@ class Kernel {
|
|
|
9005
9063
|
}
|
|
9006
9064
|
} else {
|
|
9007
9065
|
var {
|
|
9008
|
-
routes,
|
|
9009
|
-
meta,
|
|
9010
|
-
app
|
|
9066
|
+
routes: _routes,
|
|
9067
|
+
meta: _meta,
|
|
9068
|
+
app: _app
|
|
9011
9069
|
} = yield BootstrapV2Api_getAppStoryboardV2(storyboard.app.id, {});
|
|
9012
9070
|
Object.assign(storyboard, {
|
|
9013
|
-
routes,
|
|
9014
|
-
meta,
|
|
9015
|
-
app: _objectSpread(_objectSpread({}, storyboard.app),
|
|
9071
|
+
routes: _routes,
|
|
9072
|
+
meta: _meta,
|
|
9073
|
+
app: _objectSpread(_objectSpread({}, storyboard.app), _app),
|
|
9016
9074
|
$$fulfilled: true,
|
|
9017
9075
|
$$fulfilling: null
|
|
9018
9076
|
});
|
|
@@ -11604,6 +11662,17 @@ function setUIVersion(version) {
|
|
|
11604
11662
|
document.documentElement.dataset.ui = ui;
|
|
11605
11663
|
}
|
|
11606
11664
|
|
|
11665
|
+
function setAppVariable(params) {
|
|
11666
|
+
var {
|
|
11667
|
+
appId,
|
|
11668
|
+
version
|
|
11669
|
+
} = params;
|
|
11670
|
+
if (window.APP_ROOT_TPL) {
|
|
11671
|
+
window.APP_ID = appId;
|
|
11672
|
+
window.APP_ROOT = window.APP_ROOT_TPL.replace("{id}", appId).replace("{version}", version);
|
|
11673
|
+
}
|
|
11674
|
+
}
|
|
11675
|
+
|
|
11607
11676
|
class Router {
|
|
11608
11677
|
constructor(kernel) {
|
|
11609
11678
|
_defineProperty$1(this, "defaultCollapsed", false);
|
|
@@ -11748,7 +11817,7 @@ class Router {
|
|
|
11748
11817
|
render(location) {
|
|
11749
11818
|
var _this3 = this;
|
|
11750
11819
|
return _asyncToGenerator$3(function* () {
|
|
11751
|
-
var _apiAnalyzer$getInsta, _currentApp$config, _currentApp$config$_e, _this3$kernel$bootstr, _this3$kernel$bootstr2, _getLocalAppsTheme;
|
|
11820
|
+
var _apiAnalyzer$getInsta, _storyboard$app, _this3$kernel$previou, _currentApp$config, _currentApp$config$_e, _this3$kernel$bootstr, _this3$kernel$bootstr2, _getLocalAppsTheme;
|
|
11752
11821
|
_this3.state = "initial";
|
|
11753
11822
|
var renderId = _this3.renderId = uniqueId("render-id-");
|
|
11754
11823
|
resetAllInjected();
|
|
@@ -11769,6 +11838,14 @@ class Router {
|
|
|
11769
11838
|
return;
|
|
11770
11839
|
}
|
|
11771
11840
|
var storyboard = locationContext.matchStoryboard(_this3.kernel.bootstrapData.storyboards);
|
|
11841
|
+
var currentAppId = storyboard === null || storyboard === void 0 ? void 0 : (_storyboard$app = storyboard.app) === null || _storyboard$app === void 0 ? void 0 : _storyboard$app.id;
|
|
11842
|
+
// dynamically change the value of the APP variable, if it's union app
|
|
11843
|
+
if (window.BOOTSTRAP_UNION_FILE && currentAppId && currentAppId !== ((_this3$kernel$previou = _this3.kernel.previousApp) === null || _this3$kernel$previou === void 0 ? void 0 : _this3$kernel$previou.id)) {
|
|
11844
|
+
setAppVariable({
|
|
11845
|
+
appId: currentAppId,
|
|
11846
|
+
version: storyboard.app.currentVersion
|
|
11847
|
+
});
|
|
11848
|
+
}
|
|
11772
11849
|
|
|
11773
11850
|
/** Pending task for loading bricks */
|
|
11774
11851
|
var pendingTask;
|