@next-core/brick-kit 2.179.0 → 2.179.2
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 +85 -52
- package/dist/index.bundle.js.map +1 -1
- package/dist/index.esm.js +85 -52
- package/dist/index.esm.js.map +1 -1
- package/dist/types/core/CustomForms/CustomFormContext.d.ts +1 -1
- package/dist/types/core/CustomForms/CustomFormContext.d.ts.map +1 -1
- package/dist/types/core/CustomTemplates/CustomTemplateContext.d.ts +1 -1
- package/dist/types/core/CustomTemplates/CustomTemplateContext.d.ts.map +1 -1
- package/dist/types/core/CustomTemplates/expandCustomTemplate.d.ts.map +1 -1
- package/dist/types/core/FlowApi.d.ts.map +1 -1
- package/dist/types/core/LocationContext.d.ts +2 -1
- package/dist/types/core/LocationContext.d.ts.map +1 -1
- package/dist/types/core/Router.d.ts.map +1 -1
- package/dist/types/core/StoryboardContext.d.ts +2 -1
- package/dist/types/core/StoryboardContext.d.ts.map +1 -1
- package/package.json +7 -7
package/dist/index.esm.js
CHANGED
|
@@ -1800,7 +1800,7 @@ function _checkIf(rawIf, ctx, fn) {
|
|
|
1800
1800
|
}
|
|
1801
1801
|
|
|
1802
1802
|
class StoryboardContextWrapper {
|
|
1803
|
-
constructor(tplContextId, formContextId) {
|
|
1803
|
+
constructor(tplContextId, formContextId, renderId) {
|
|
1804
1804
|
_defineProperty$1(this, "data", new Map());
|
|
1805
1805
|
_defineProperty$1(this, "batchUpdate", false);
|
|
1806
1806
|
_defineProperty$1(this, "batchUpdateContextsNames", []);
|
|
@@ -1809,9 +1809,11 @@ class StoryboardContextWrapper {
|
|
|
1809
1809
|
_defineProperty$1(this, "formContextId", void 0);
|
|
1810
1810
|
_defineProperty$1(this, "eventName", void 0);
|
|
1811
1811
|
_defineProperty$1(this, "pendingStack", []);
|
|
1812
|
+
_defineProperty$1(this, "renderId", void 0);
|
|
1812
1813
|
this.tplContextId = tplContextId;
|
|
1813
1814
|
this.formContextId = formContextId;
|
|
1814
1815
|
this.eventName = this.formContextId ? "formstate.change" : this.tplContextId ? "state.change" : "context.change";
|
|
1816
|
+
this.renderId = renderId;
|
|
1815
1817
|
}
|
|
1816
1818
|
set(name, item) {
|
|
1817
1819
|
if (this.data.has(name)) {
|
|
@@ -1911,6 +1913,13 @@ class StoryboardContextWrapper {
|
|
|
1911
1913
|
promise = item.loading;
|
|
1912
1914
|
}
|
|
1913
1915
|
}
|
|
1916
|
+
var shouldDismiss = error => {
|
|
1917
|
+
// If render twice immediately, flow API contracts maybe cleared before
|
|
1918
|
+
// the second rendering, while the page load handlers of the first
|
|
1919
|
+
// rendering can't be cancelled, which throws `FlowApiNotFoundError`.
|
|
1920
|
+
// So we ignore error reporting for this case.
|
|
1921
|
+
return (error === null || error === void 0 ? void 0 : error.name) === "FlowApiNotFoundError" && this.renderId && this.renderId !== _internalApiGetRouterRenderId();
|
|
1922
|
+
};
|
|
1914
1923
|
if (!promise) {
|
|
1915
1924
|
promise = item.loading = item.load(_objectSpread({
|
|
1916
1925
|
cache: method === "load" ? "default" : "reload"
|
|
@@ -1925,7 +1934,7 @@ class StoryboardContextWrapper {
|
|
|
1925
1934
|
}));
|
|
1926
1935
|
}, err => {
|
|
1927
1936
|
// Let users to override error handling.
|
|
1928
|
-
if (!(callback !== null && callback !== void 0 && callback.error)) {
|
|
1937
|
+
if (!shouldDismiss(err) && !(callback !== null && callback !== void 0 && callback.error)) {
|
|
1929
1938
|
handleHttpError(err);
|
|
1930
1939
|
}
|
|
1931
1940
|
});
|
|
@@ -1938,7 +1947,9 @@ class StoryboardContextWrapper {
|
|
|
1938
1947
|
});
|
|
1939
1948
|
callbackFactory("finally")();
|
|
1940
1949
|
}, err => {
|
|
1941
|
-
|
|
1950
|
+
if (!shouldDismiss(err) && callback.error) {
|
|
1951
|
+
callbackFactory("error")(err);
|
|
1952
|
+
}
|
|
1942
1953
|
callbackFactory("finally")();
|
|
1943
1954
|
});
|
|
1944
1955
|
}
|
|
@@ -2223,13 +2234,13 @@ function batchAddListener(listener, contextConf, storyboardContextWrapper) {
|
|
|
2223
2234
|
|
|
2224
2235
|
var tplContextMap = new Map();
|
|
2225
2236
|
class CustomTemplateContext {
|
|
2226
|
-
constructor(brick) {
|
|
2237
|
+
constructor(brick, renderId) {
|
|
2227
2238
|
_defineProperty$1(this, "variables", void 0);
|
|
2228
2239
|
_defineProperty$1(this, "state", void 0);
|
|
2229
2240
|
_defineProperty$1(this, "id", uniqueId("tpl-ctx-"));
|
|
2230
2241
|
this.brick = brick;
|
|
2231
2242
|
tplContextMap.set(this.id, this);
|
|
2232
|
-
this.state = new StoryboardContextWrapper(this.id);
|
|
2243
|
+
this.state = new StoryboardContextWrapper(this.id, undefined, renderId);
|
|
2233
2244
|
brick.tplContextId = this.id;
|
|
2234
2245
|
}
|
|
2235
2246
|
setVariables(variables) {
|
|
@@ -2301,11 +2312,11 @@ var getMedia = () => MEDIA;
|
|
|
2301
2312
|
|
|
2302
2313
|
var FormContextMap = new Map();
|
|
2303
2314
|
class CustomFormContext {
|
|
2304
|
-
constructor() {
|
|
2315
|
+
constructor(renderId) {
|
|
2305
2316
|
_defineProperty$1(this, "formState", void 0);
|
|
2306
2317
|
_defineProperty$1(this, "id", uniqueId("form-ctx-"));
|
|
2307
2318
|
FormContextMap.set(this.id, this);
|
|
2308
|
-
this.formState = new StoryboardContextWrapper(undefined, this.id);
|
|
2319
|
+
this.formState = new StoryboardContextWrapper(undefined, this.id, renderId);
|
|
2309
2320
|
}
|
|
2310
2321
|
}
|
|
2311
2322
|
function getCustomFormContext(formContextId) {
|
|
@@ -5893,7 +5904,7 @@ function getContract(name) {
|
|
|
5893
5904
|
return contractsMap.get(name) || widgetContractMap.get(name);
|
|
5894
5905
|
}
|
|
5895
5906
|
|
|
5896
|
-
var
|
|
5907
|
+
var remoteContractCache = new Map();
|
|
5897
5908
|
|
|
5898
5909
|
// Legacy Custom API: `${namespace}@${name}`
|
|
5899
5910
|
// Flow API: `${namespace}@${name}:${version}`
|
|
@@ -5911,7 +5922,7 @@ function _getArgsOfCustomApi() {
|
|
|
5911
5922
|
var isFlowApi = provider.includes(":");
|
|
5912
5923
|
var apiDefinition = isFlowApi ? yield fetchFlowApiDefinition(provider) : (yield _internalApiGetMicroAppApiOrchestrationMap()).get(provider);
|
|
5913
5924
|
if (!apiDefinition) {
|
|
5914
|
-
throw new
|
|
5925
|
+
throw new FlowApiNotFoundError("".concat(isFlowApi ? "Flow" : "Legacy Custom", " API not found: \"").concat(provider, "\""));
|
|
5915
5926
|
}
|
|
5916
5927
|
var apiProfile = getApiProfileFromApiDefinition(provider, apiDefinition);
|
|
5917
5928
|
return getApiArgsFromApiProfile(apiProfile, originalArgs, method);
|
|
@@ -5987,23 +5998,18 @@ function getApiProfileFromApiDefinition(provider, api) {
|
|
|
5987
5998
|
request: contract.request
|
|
5988
5999
|
};
|
|
5989
6000
|
}
|
|
5990
|
-
function fetchFlowApiDefinition(
|
|
5991
|
-
|
|
5992
|
-
if (!promise) {
|
|
5993
|
-
promise = _fetchFlowApiDefinition(provider);
|
|
5994
|
-
flowApiDefinitionPromiseMap.set(provider, promise);
|
|
5995
|
-
}
|
|
5996
|
-
return promise;
|
|
5997
|
-
}
|
|
5998
|
-
function _fetchFlowApiDefinition(_x4) {
|
|
5999
|
-
return _fetchFlowApiDefinition2.apply(this, arguments);
|
|
6001
|
+
function fetchFlowApiDefinition(_x4) {
|
|
6002
|
+
return _fetchFlowApiDefinition.apply(this, arguments);
|
|
6000
6003
|
}
|
|
6001
|
-
function
|
|
6002
|
-
|
|
6004
|
+
function _fetchFlowApiDefinition() {
|
|
6005
|
+
_fetchFlowApiDefinition = _asyncToGenerator$3(function* (provider) {
|
|
6003
6006
|
var [namespaceName, nameWithVersion] = provider.split("@");
|
|
6004
6007
|
var [name, version] = nameWithVersion.split(":");
|
|
6005
|
-
|
|
6006
|
-
|
|
6008
|
+
|
|
6009
|
+
// Do not cache the result of `geContract`, which will lead to no contract
|
|
6010
|
+
// will be found when render twice immediately.
|
|
6011
|
+
var contract = getContract("".concat(namespaceName, ".").concat(name));
|
|
6012
|
+
if (contract) {
|
|
6007
6013
|
return {
|
|
6008
6014
|
name: contract.name,
|
|
6009
6015
|
namespace: contract.namespaceId,
|
|
@@ -6015,32 +6021,56 @@ function _fetchFlowApiDefinition2() {
|
|
|
6015
6021
|
request: contract.request
|
|
6016
6022
|
}
|
|
6017
6023
|
};
|
|
6018
|
-
} else {
|
|
6019
|
-
var {
|
|
6020
|
-
contractData
|
|
6021
|
-
} = yield ContractApi_searchSingleContract({
|
|
6022
|
-
contractName: "".concat(namespaceName, ".").concat(name),
|
|
6023
|
-
version
|
|
6024
|
-
});
|
|
6025
|
-
|
|
6026
|
-
// return undefined if don't found contract
|
|
6027
|
-
if (contractData) {
|
|
6028
|
-
var _contractData$namespa, _contractData$namespa2;
|
|
6029
|
-
return {
|
|
6030
|
-
name: contractData.name,
|
|
6031
|
-
namespace: (_contractData$namespa = contractData.namespace) === null || _contractData$namespa === void 0 ? void 0 : (_contractData$namespa2 = _contractData$namespa[0]) === null || _contractData$namespa2 === void 0 ? void 0 : _contractData$namespa2.name,
|
|
6032
|
-
serviceName: contractData.serviceName,
|
|
6033
|
-
version: contractData.version,
|
|
6034
|
-
contract: {
|
|
6035
|
-
endpoint: contractData.endpoint,
|
|
6036
|
-
response: contractData.response,
|
|
6037
|
-
request: contractData.request
|
|
6038
|
-
}
|
|
6039
|
-
};
|
|
6040
|
-
}
|
|
6041
6024
|
}
|
|
6025
|
+
var promise = remoteContractCache.get(provider);
|
|
6026
|
+
if (!promise) {
|
|
6027
|
+
promise = fetchFlowApiDefinitionFromRemote(namespaceName, name, version);
|
|
6028
|
+
remoteContractCache.set(provider, promise);
|
|
6029
|
+
}
|
|
6030
|
+
return promise;
|
|
6031
|
+
});
|
|
6032
|
+
return _fetchFlowApiDefinition.apply(this, arguments);
|
|
6033
|
+
}
|
|
6034
|
+
function fetchFlowApiDefinitionFromRemote(_x5, _x6, _x7) {
|
|
6035
|
+
return _fetchFlowApiDefinitionFromRemote.apply(this, arguments);
|
|
6036
|
+
}
|
|
6037
|
+
function _fetchFlowApiDefinitionFromRemote() {
|
|
6038
|
+
_fetchFlowApiDefinitionFromRemote = _asyncToGenerator$3(function* (namespace, name, version) {
|
|
6039
|
+
var _contractData$namespa, _contractData$namespa2;
|
|
6040
|
+
var {
|
|
6041
|
+
contractData
|
|
6042
|
+
} = yield ContractApi_searchSingleContract({
|
|
6043
|
+
contractName: "".concat(namespace, ".").concat(name),
|
|
6044
|
+
version
|
|
6045
|
+
});
|
|
6046
|
+
|
|
6047
|
+
// return null if didn't find contract
|
|
6048
|
+
return contractData ? {
|
|
6049
|
+
name: contractData.name,
|
|
6050
|
+
namespace: (_contractData$namespa = contractData.namespace) === null || _contractData$namespa === void 0 ? void 0 : (_contractData$namespa2 = _contractData$namespa[0]) === null || _contractData$namespa2 === void 0 ? void 0 : _contractData$namespa2.name,
|
|
6051
|
+
serviceName: contractData.serviceName,
|
|
6052
|
+
version: contractData.version,
|
|
6053
|
+
contract: {
|
|
6054
|
+
endpoint: contractData.endpoint,
|
|
6055
|
+
response: contractData.response,
|
|
6056
|
+
request: contractData.request
|
|
6057
|
+
}
|
|
6058
|
+
} : null;
|
|
6042
6059
|
});
|
|
6043
|
-
return
|
|
6060
|
+
return _fetchFlowApiDefinitionFromRemote.apply(this, arguments);
|
|
6061
|
+
}
|
|
6062
|
+
class FlowApiNotFoundError extends Error {
|
|
6063
|
+
constructor(message) {
|
|
6064
|
+
// Pass remaining arguments (including vendor specific ones) to parent constructor
|
|
6065
|
+
super(message);
|
|
6066
|
+
this.name = "FlowApiNotFoundError";
|
|
6067
|
+
|
|
6068
|
+
// Maintains proper stack trace for where our error was thrown (only available on V8)
|
|
6069
|
+
// istanbul ignore else
|
|
6070
|
+
if (Error.captureStackTrace) {
|
|
6071
|
+
Error.captureStackTrace(this, FlowApiNotFoundError);
|
|
6072
|
+
}
|
|
6073
|
+
}
|
|
6044
6074
|
}
|
|
6045
6075
|
|
|
6046
6076
|
function bindListeners(brick, eventsMap, context) {
|
|
@@ -8191,7 +8221,7 @@ function asyncExpandCustomTemplate(_x, _x2, _x3, _x4) {
|
|
|
8191
8221
|
}
|
|
8192
8222
|
function _asyncExpandCustomTemplate() {
|
|
8193
8223
|
_asyncExpandCustomTemplate = _asyncToGenerator$3(function* (brickConf, proxyBrick, context, locationContext) {
|
|
8194
|
-
var tplContext = new CustomTemplateContext(proxyBrick);
|
|
8224
|
+
var tplContext = new CustomTemplateContext(proxyBrick, locationContext === null || locationContext === void 0 ? void 0 : locationContext.renderId);
|
|
8195
8225
|
var template = customTemplateRegistry.get(brickConf.brick);
|
|
8196
8226
|
if (template.contracts) {
|
|
8197
8227
|
collectWidgetContract(template.contracts);
|
|
@@ -9812,7 +9842,7 @@ function AsyncExpandCustomForm(_x, _x2, _x3, _x4, _x5) {
|
|
|
9812
9842
|
}
|
|
9813
9843
|
function _AsyncExpandCustomForm() {
|
|
9814
9844
|
_AsyncExpandCustomForm = _asyncToGenerator$3(function* (formData, brickConf, isPreview, context, locationContext) {
|
|
9815
|
-
var formContext = new CustomFormContext();
|
|
9845
|
+
var formContext = new CustomFormContext(locationContext === null || locationContext === void 0 ? void 0 : locationContext.renderId);
|
|
9816
9846
|
formData = initFormContext(formData, brickConf, isPreview);
|
|
9817
9847
|
if (Array.isArray(formData.context)) {
|
|
9818
9848
|
if (locationContext) {
|
|
@@ -10194,7 +10224,7 @@ function getFinalStoryBoard(formData, brickConf, isPreview, formContext) {
|
|
|
10194
10224
|
}
|
|
10195
10225
|
|
|
10196
10226
|
class LocationContext {
|
|
10197
|
-
constructor(kernel, location) {
|
|
10227
|
+
constructor(kernel, location, renderId) {
|
|
10198
10228
|
_defineProperty$1(this, "query", void 0);
|
|
10199
10229
|
_defineProperty$1(this, "resolver", void 0);
|
|
10200
10230
|
_defineProperty$1(this, "messageDispatcher", void 0);
|
|
@@ -10212,11 +10242,14 @@ class LocationContext {
|
|
|
10212
10242
|
_defineProperty$1(this, "currentMatch", void 0);
|
|
10213
10243
|
_defineProperty$1(this, "storyboardContextWrapper", new StoryboardContextWrapper());
|
|
10214
10244
|
_defineProperty$1(this, "observersList", []);
|
|
10245
|
+
_defineProperty$1(this, "renderId", void 0);
|
|
10215
10246
|
this.kernel = kernel;
|
|
10216
10247
|
this.location = location;
|
|
10217
10248
|
this.resolver = new Resolver(kernel, this);
|
|
10218
10249
|
this.query = new URLSearchParams(location.search);
|
|
10219
10250
|
this.messageDispatcher = getMessageDispatcher();
|
|
10251
|
+
this.storyboardContextWrapper = new StoryboardContextWrapper(undefined, undefined, renderId);
|
|
10252
|
+
this.renderId = renderId;
|
|
10220
10253
|
}
|
|
10221
10254
|
getContext(_ref) {
|
|
10222
10255
|
var {
|
|
@@ -11661,7 +11694,7 @@ class Router {
|
|
|
11661
11694
|
return _asyncToGenerator$3(function* () {
|
|
11662
11695
|
var _apiAnalyzer$getInsta, _currentApp$config, _currentApp$config$_e, _this3$kernel$bootstr, _this3$kernel$bootstr2, _getLocalAppsTheme;
|
|
11663
11696
|
_this3.state = "initial";
|
|
11664
|
-
_this3.renderId = uniqueId("render-id-");
|
|
11697
|
+
var renderId = _this3.renderId = uniqueId("render-id-");
|
|
11665
11698
|
resetAllInjected();
|
|
11666
11699
|
clearPollTimeout();
|
|
11667
11700
|
clearCollectWidgetContract();
|
|
@@ -11675,7 +11708,7 @@ class Router {
|
|
|
11675
11708
|
// Create the page tracker before page load.
|
|
11676
11709
|
// And the API Analyzer maybe disabled.
|
|
11677
11710
|
var tracePageEnd = (_apiAnalyzer$getInsta = apiAnalyzer.getInstance()) === null || _apiAnalyzer$getInsta === void 0 ? void 0 : _apiAnalyzer$getInsta.tracePage();
|
|
11678
|
-
var locationContext = _this3.locationContext = new LocationContext(_this3.kernel, location);
|
|
11711
|
+
var locationContext = _this3.locationContext = new LocationContext(_this3.kernel, location, renderId);
|
|
11679
11712
|
if (window.DEVELOPER_PREVIEW) {
|
|
11680
11713
|
return;
|
|
11681
11714
|
}
|