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