@next-core/brick-kit 2.204.2 → 2.206.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 +155 -61
- package/dist/index.bundle.js.map +1 -1
- package/dist/index.esm.js +155 -62
- package/dist/index.esm.js.map +1 -1
- package/dist/types/BrickAsComponent.d.ts.map +1 -1
- package/dist/types/auth.d.ts +4 -0
- package/dist/types/auth.d.ts.map +1 -1
- package/dist/types/core/Kernel.d.ts.map +1 -1
- package/dist/types/core/Router.d.ts.map +1 -1
- package/package.json +7 -7
package/dist/index.bundle.js
CHANGED
|
@@ -1175,9 +1175,11 @@
|
|
|
1175
1175
|
}();
|
|
1176
1176
|
|
|
1177
1177
|
var auth = {};
|
|
1178
|
+
var pathBlackListSet = new Set();
|
|
1178
1179
|
|
|
1179
1180
|
/** @internal */
|
|
1180
1181
|
function authenticate(newAuth) {
|
|
1182
|
+
var _newAuth$license;
|
|
1181
1183
|
Object.assign(auth, {
|
|
1182
1184
|
org: newAuth.org,
|
|
1183
1185
|
username: newAuth.username,
|
|
@@ -1190,6 +1192,7 @@
|
|
|
1190
1192
|
accessToken: newAuth.accessToken,
|
|
1191
1193
|
userShowValue: newAuth.userShowValue
|
|
1192
1194
|
});
|
|
1195
|
+
pathBlackListSet = new Set((_newAuth$license = newAuth.license) === null || _newAuth$license === void 0 ? void 0 : _newAuth$license.blackList);
|
|
1193
1196
|
|
|
1194
1197
|
// re-init analytics to set user_id
|
|
1195
1198
|
if (easyopsAnalytics.userAnalytics.initialized) {
|
|
@@ -1226,14 +1229,20 @@
|
|
|
1226
1229
|
return auth.username !== undefined;
|
|
1227
1230
|
}
|
|
1228
1231
|
|
|
1232
|
+
/**
|
|
1233
|
+
* 增加路径黑名单
|
|
1234
|
+
*/
|
|
1235
|
+
function addPathToBlackList(path) {
|
|
1236
|
+
pathBlackListSet.add(path);
|
|
1237
|
+
}
|
|
1238
|
+
|
|
1229
1239
|
/**
|
|
1230
1240
|
* 判断一个内部 URL 路径是否被屏蔽。
|
|
1231
1241
|
*/
|
|
1232
1242
|
function isBlockedPath(pathname) {
|
|
1233
|
-
|
|
1234
|
-
return !!((_auth$license = auth.license) !== null && _auth$license !== void 0 && (_auth$license$blackLi = _auth$license.blackList) !== null && _auth$license$blackLi !== void 0 && _auth$license$blackLi.some(path => brickUtils.matchPath(pathname, {
|
|
1243
|
+
return [...pathBlackListSet].some(path => brickUtils.matchPath(pathname, {
|
|
1235
1244
|
path
|
|
1236
|
-
}))
|
|
1245
|
+
}));
|
|
1237
1246
|
}
|
|
1238
1247
|
|
|
1239
1248
|
/**
|
|
@@ -7382,12 +7391,13 @@
|
|
|
7382
7391
|
* @endpoint GET /api/v1/micro_app_standalone/runtime/:appId
|
|
7383
7392
|
*/
|
|
7384
7393
|
var RuntimeApi_runtimeMicroAppStandalone = /*#__PURE__*/function () {
|
|
7385
|
-
var _ref = _asyncToGenerator__default["default"](function* (appId, options) {
|
|
7386
|
-
return (/**! @contract easyops.api.micro_app_standalone.runtime.RuntimeMicroAppStandalone@1.0.1 */
|
|
7387
|
-
|
|
7394
|
+
var _ref = _asyncToGenerator__default["default"](function* (appId, params, options) {
|
|
7395
|
+
return (/**! @contract easyops.api.micro_app_standalone.runtime.RuntimeMicroAppStandalone@1.0.1 */(yield brickHttp.http.get("api/gateway/logic.micro_app_standalone_service/api/v1/micro_app_standalone/runtime/".concat(appId), _objectSpread__default["default"](_objectSpread__default["default"]({}, options), {}, {
|
|
7396
|
+
params
|
|
7397
|
+
}))).data
|
|
7388
7398
|
);
|
|
7389
7399
|
});
|
|
7390
|
-
return function RuntimeApi_runtimeMicroAppStandalone(_x, _x2) {
|
|
7400
|
+
return function RuntimeApi_runtimeMicroAppStandalone(_x, _x2, _x3) {
|
|
7391
7401
|
return _ref.apply(this, arguments);
|
|
7392
7402
|
};
|
|
7393
7403
|
}();
|
|
@@ -7398,8 +7408,7 @@
|
|
|
7398
7408
|
*/
|
|
7399
7409
|
var RuntimeApi_searchMicroAppStandalone = /*#__PURE__*/function () {
|
|
7400
7410
|
var _ref = _asyncToGenerator__default["default"](function* (data, options) {
|
|
7401
|
-
return (/**! @contract easyops.api.micro_app_standalone.runtime.SearchMicroAppStandalone@1.0.1 */
|
|
7402
|
-
(yield brickHttp.http.post("api/gateway/micro_app_standalone.runtime.SearchMicroAppStandalone/api/v1/micro_app_standalone/search", data, options)).data
|
|
7411
|
+
return (/**! @contract easyops.api.micro_app_standalone.runtime.SearchMicroAppStandalone@1.0.1 */(yield brickHttp.http.post("api/gateway/logic.micro_app_standalone_service/api/v1/micro_app_standalone/search", data, options)).data
|
|
7403
7412
|
);
|
|
7404
7413
|
});
|
|
7405
7414
|
return function RuntimeApi_searchMicroAppStandalone(_x, _x2) {
|
|
@@ -7523,9 +7532,7 @@
|
|
|
7523
7532
|
return appRuntimeDataMap.get(appId);
|
|
7524
7533
|
}
|
|
7525
7534
|
var promise = RuntimeApi_runtimeMicroAppStandalone(appId, {
|
|
7526
|
-
|
|
7527
|
-
version
|
|
7528
|
-
}
|
|
7535
|
+
version
|
|
7529
7536
|
}).catch(function (error) {
|
|
7530
7537
|
// make it not crash when the backend service is not updated.
|
|
7531
7538
|
// eslint-disable-next-line no-console
|
|
@@ -9376,7 +9383,8 @@
|
|
|
9376
9383
|
initializeAppConfig(storyboard.app);
|
|
9377
9384
|
// get inject menus (Actually, appRuntimeData contains both main and inject menus)
|
|
9378
9385
|
storyboard.meta = _objectSpread__default["default"](_objectSpread__default["default"]({}, storyboard.meta), {}, {
|
|
9379
|
-
injectMenus: appRuntimeData.injectMenus
|
|
9386
|
+
injectMenus: appRuntimeData.injectMenus,
|
|
9387
|
+
blackList: appRuntimeData.blackList
|
|
9380
9388
|
});
|
|
9381
9389
|
}
|
|
9382
9390
|
}
|
|
@@ -12296,51 +12304,72 @@
|
|
|
12296
12304
|
/** Pending task for loading bricks */
|
|
12297
12305
|
var pendingTask;
|
|
12298
12306
|
if (storyboard) {
|
|
12299
|
-
var _storyboard$meta, _storyboard$
|
|
12307
|
+
var _storyboard$meta, _storyboard$meta$blac, _storyboard$meta$blac2;
|
|
12300
12308
|
yield _this3.kernel.fulfilStoryboard(storyboard);
|
|
12301
|
-
setAppLocales(storyboard.app);
|
|
12302
12309
|
_this3.kernel.nextApp = storyboard.app;
|
|
12303
|
-
|
|
12304
|
-
|
|
12305
|
-
|
|
12306
|
-
|
|
12310
|
+
(_storyboard$meta = storyboard.meta) === null || _storyboard$meta === void 0 ? void 0 : (_storyboard$meta$blac = _storyboard$meta.blackList) === null || _storyboard$meta$blac === void 0 ? void 0 : (_storyboard$meta$blac2 = _storyboard$meta$blac.forEach) === null || _storyboard$meta$blac2 === void 0 ? void 0 : _storyboard$meta$blac2.call(_storyboard$meta$blac, item => {
|
|
12311
|
+
var path = item && (item.to || item.url);
|
|
12312
|
+
if (!path || typeof path !== "string") return;
|
|
12313
|
+
path = path.split("?")[0].replace(/\${\s*(?:(?:PATH|CTX)\.)?(\w+)\s*}/g, ":$1");
|
|
12314
|
+
if (item.to) {
|
|
12315
|
+
try {
|
|
12316
|
+
path = computeRealValue(path, _this3.locationContext.getCurrentContext());
|
|
12317
|
+
} catch (e) /* istanbul ignore next */{
|
|
12318
|
+
// eslint-disable-next-line no-console
|
|
12319
|
+
console.error(e);
|
|
12320
|
+
}
|
|
12321
|
+
} else {
|
|
12322
|
+
path = path.replace(/^\/next\//, "/");
|
|
12323
|
+
}
|
|
12324
|
+
path && addPathToBlackList(path);
|
|
12307
12325
|
});
|
|
12326
|
+
if (isBlockedPath(location.pathname)) {
|
|
12327
|
+
blocked = true;
|
|
12328
|
+
} else {
|
|
12329
|
+
var _storyboard$meta2, _storyboard$meta3, _storyboard$meta4;
|
|
12330
|
+
setAppLocales(storyboard.app);
|
|
12331
|
+
setWatermark();
|
|
12332
|
+
brickUtils.removeDeadConditions(storyboard, {
|
|
12333
|
+
constantFeatureFlags: true,
|
|
12334
|
+
featureFlags: _this3.kernel.getFeatureFlags()
|
|
12335
|
+
});
|
|
12308
12336
|
|
|
12309
|
-
|
|
12310
|
-
|
|
12311
|
-
|
|
12337
|
+
// 将动态解析后的模板还原,以便重新动态解析。
|
|
12338
|
+
brickUtils.restoreDynamicTemplates(storyboard);
|
|
12339
|
+
var parallelRequests = [];
|
|
12312
12340
|
|
|
12313
|
-
|
|
12314
|
-
|
|
12315
|
-
|
|
12316
|
-
|
|
12341
|
+
// 预加载权限信息
|
|
12342
|
+
if (isLoggedIn() && !getAuth().isAdmin) {
|
|
12343
|
+
parallelRequests.push(preCheckPermissions(storyboard));
|
|
12344
|
+
}
|
|
12317
12345
|
|
|
12318
|
-
|
|
12319
|
-
|
|
12320
|
-
|
|
12321
|
-
|
|
12322
|
-
|
|
12323
|
-
|
|
12324
|
-
|
|
12346
|
+
// Standalone App 需要额外读取 Installed App 信息
|
|
12347
|
+
if (window.STANDALONE_MICRO_APPS && !window.NO_AUTH_GUARD) {
|
|
12348
|
+
// TODO: get standalone apps when NO_AUTH_GUARD, maybe from conf.yaml
|
|
12349
|
+
parallelRequests.push(preFetchStandaloneInstalledApps(storyboard).then(() => {
|
|
12350
|
+
_this3.kernel.bootstrapData.offSiteStandaloneApps = getStandaloneInstalledApps();
|
|
12351
|
+
}));
|
|
12352
|
+
}
|
|
12325
12353
|
|
|
12326
|
-
|
|
12327
|
-
|
|
12354
|
+
// `loadDepsOfStoryboard()` may requires these data.
|
|
12355
|
+
yield Promise.all(parallelRequests);
|
|
12328
12356
|
|
|
12329
|
-
|
|
12330
|
-
|
|
12331
|
-
|
|
12332
|
-
|
|
12333
|
-
|
|
12357
|
+
// 如果找到匹配的 storyboard,那么根据路由匹配得到的 sub-storyboard 加载它的依赖库。
|
|
12358
|
+
var subStoryboard = yield _this3.locationContext.getSubStoryboardByRoute(storyboard);
|
|
12359
|
+
({
|
|
12360
|
+
pendingTask
|
|
12361
|
+
} = yield _this3.kernel.loadDepsOfStoryboard(subStoryboard));
|
|
12334
12362
|
|
|
12335
|
-
|
|
12336
|
-
|
|
12337
|
-
|
|
12338
|
-
|
|
12339
|
-
|
|
12340
|
-
|
|
12363
|
+
// 注册 Storyboard 中定义的自定义模板和函数。
|
|
12364
|
+
_this3.kernel.registerCustomTemplatesInStoryboard(storyboard);
|
|
12365
|
+
registerStoryboardFunctions((_storyboard$meta2 = storyboard.meta) === null || _storyboard$meta2 === void 0 ? void 0 : _storyboard$meta2.functions, storyboard.app);
|
|
12366
|
+
registerMock((_storyboard$meta3 = storyboard.meta) === null || _storyboard$meta3 === void 0 ? void 0 : _storyboard$meta3.mocks);
|
|
12367
|
+
registerFormRenderer();
|
|
12368
|
+
collectContract((_storyboard$meta4 = storyboard.meta) === null || _storyboard$meta4 === void 0 ? void 0 : _storyboard$meta4.contracts);
|
|
12341
12369
|
|
|
12342
|
-
|
|
12343
|
-
|
|
12370
|
+
// `app` maybe fulfilled
|
|
12371
|
+
currentApp = storyboard.app;
|
|
12372
|
+
}
|
|
12344
12373
|
}
|
|
12345
12374
|
var mountPoints = _this3.kernel.mountPoints;
|
|
12346
12375
|
var legacy = currentApp ? currentApp.legacy : undefined;
|
|
@@ -12376,7 +12405,7 @@
|
|
|
12376
12405
|
from: location
|
|
12377
12406
|
});
|
|
12378
12407
|
};
|
|
12379
|
-
if (storyboard) {
|
|
12408
|
+
if (storyboard && !blocked) {
|
|
12380
12409
|
var _currentApp$breadcrum, _currentApp$breadcrum2, _currentApp$breadcrum3, _currentApp$breadcrum4;
|
|
12381
12410
|
var {
|
|
12382
12411
|
bricks,
|
|
@@ -13281,6 +13310,7 @@
|
|
|
13281
13310
|
}
|
|
13282
13311
|
})();
|
|
13283
13312
|
}, [runtimeBrick, updateBrick]);
|
|
13313
|
+
var previousObserverRef = React.useRef();
|
|
13284
13314
|
innerRefCallbackRef.current = /*#__PURE__*/function () {
|
|
13285
13315
|
var _ref6 = _asyncToGenerator__default["default"](function* (element) {
|
|
13286
13316
|
immediatelyRefCallback === null || immediatelyRefCallback === void 0 ? void 0 : immediatelyRefCallback(element);
|
|
@@ -13294,15 +13324,46 @@
|
|
|
13294
13324
|
// sub-brick rendering is ignored.
|
|
13295
13325
|
if (brick) {
|
|
13296
13326
|
if (element) {
|
|
13297
|
-
var _useBrick$lifeCycle;
|
|
13327
|
+
var _useBrick$lifeCycle, _useBrick$lifeCycle2;
|
|
13298
13328
|
updateBrick(brick, element);
|
|
13299
|
-
|
|
13300
|
-
|
|
13329
|
+
var onMount = (_useBrick$lifeCycle = useBrick.lifeCycle) === null || _useBrick$lifeCycle === void 0 ? void 0 : _useBrick$lifeCycle.onMount;
|
|
13330
|
+
if (onMount) {
|
|
13331
|
+
dispatchLifeCycleEvent(new CustomEvent("mount"), transformEvents(data, {
|
|
13332
|
+
onMount
|
|
13333
|
+
}).onMount, brick);
|
|
13334
|
+
}
|
|
13335
|
+
var onScrollIntoView = (_useBrick$lifeCycle2 = useBrick.lifeCycle) === null || _useBrick$lifeCycle2 === void 0 ? void 0 : _useBrick$lifeCycle2.onScrollIntoView;
|
|
13336
|
+
if (onScrollIntoView) {
|
|
13337
|
+
var _onScrollIntoView$thr;
|
|
13338
|
+
var threshold = (_onScrollIntoView$thr = onScrollIntoView.threshold) !== null && _onScrollIntoView$thr !== void 0 ? _onScrollIntoView$thr : 0.1;
|
|
13339
|
+
var observer = new IntersectionObserver((entries, observer) => {
|
|
13340
|
+
entries.forEach(entry => {
|
|
13341
|
+
if (entry.isIntersecting) {
|
|
13342
|
+
if (entry.intersectionRatio >= threshold) {
|
|
13343
|
+
dispatchLifeCycleEvent(new CustomEvent("scroll.into.view"), transformEvents(data, {
|
|
13344
|
+
onScrollIntoView: onScrollIntoView.handlers
|
|
13345
|
+
}).onScrollIntoView, brick);
|
|
13346
|
+
observer.disconnect();
|
|
13347
|
+
}
|
|
13348
|
+
}
|
|
13349
|
+
});
|
|
13350
|
+
}, {
|
|
13351
|
+
threshold
|
|
13352
|
+
});
|
|
13353
|
+
observer.observe(element);
|
|
13354
|
+
previousObserverRef.current = observer;
|
|
13301
13355
|
}
|
|
13302
13356
|
} else {
|
|
13303
|
-
var _useBrick$
|
|
13304
|
-
|
|
13305
|
-
|
|
13357
|
+
var _useBrick$lifeCycle3;
|
|
13358
|
+
var onUnmount = (_useBrick$lifeCycle3 = useBrick.lifeCycle) === null || _useBrick$lifeCycle3 === void 0 ? void 0 : _useBrick$lifeCycle3.onUnmount;
|
|
13359
|
+
if (onUnmount) {
|
|
13360
|
+
dispatchLifeCycleEvent(new CustomEvent("unmount"), transformEvents(data, {
|
|
13361
|
+
onUnmount
|
|
13362
|
+
}).onUnmount, brick);
|
|
13363
|
+
}
|
|
13364
|
+
if (previousObserverRef.current) {
|
|
13365
|
+
previousObserverRef.current.disconnect();
|
|
13366
|
+
previousObserverRef.current = undefined;
|
|
13306
13367
|
}
|
|
13307
13368
|
}
|
|
13308
13369
|
}
|
|
@@ -13559,6 +13620,7 @@
|
|
|
13559
13620
|
}
|
|
13560
13621
|
})();
|
|
13561
13622
|
}, [runtimeBrick, updateBrick]);
|
|
13623
|
+
var previousObserverRef = React.useRef();
|
|
13562
13624
|
innerRefCallbackRef.current = /*#__PURE__*/function () {
|
|
13563
13625
|
var _ref14 = _asyncToGenerator__default["default"](function* (element) {
|
|
13564
13626
|
elementRef.current = element;
|
|
@@ -13571,15 +13633,46 @@
|
|
|
13571
13633
|
// sub-brick rendering is ignored.
|
|
13572
13634
|
if (brick) {
|
|
13573
13635
|
if (element) {
|
|
13574
|
-
var _useBrick$
|
|
13636
|
+
var _useBrick$lifeCycle4, _useBrick$lifeCycle5;
|
|
13575
13637
|
updateBrick(brick, element);
|
|
13576
|
-
|
|
13577
|
-
|
|
13638
|
+
var onMount = (_useBrick$lifeCycle4 = useBrick.lifeCycle) === null || _useBrick$lifeCycle4 === void 0 ? void 0 : _useBrick$lifeCycle4.onMount;
|
|
13639
|
+
if (onMount) {
|
|
13640
|
+
dispatchLifeCycleEvent(new CustomEvent("mount"), transformEvents(data, {
|
|
13641
|
+
onMount
|
|
13642
|
+
}).onMount, brick);
|
|
13643
|
+
}
|
|
13644
|
+
var onScrollIntoView = (_useBrick$lifeCycle5 = useBrick.lifeCycle) === null || _useBrick$lifeCycle5 === void 0 ? void 0 : _useBrick$lifeCycle5.onScrollIntoView;
|
|
13645
|
+
if (onScrollIntoView) {
|
|
13646
|
+
var _onScrollIntoView$thr2;
|
|
13647
|
+
var threshold = (_onScrollIntoView$thr2 = onScrollIntoView.threshold) !== null && _onScrollIntoView$thr2 !== void 0 ? _onScrollIntoView$thr2 : 0.1;
|
|
13648
|
+
var observer = new IntersectionObserver((entries, observer) => {
|
|
13649
|
+
entries.forEach(entry => {
|
|
13650
|
+
if (entry.isIntersecting) {
|
|
13651
|
+
if (entry.intersectionRatio >= threshold) {
|
|
13652
|
+
dispatchLifeCycleEvent(new CustomEvent("scroll.into.view"), transformEvents(data, {
|
|
13653
|
+
onScrollIntoView: onScrollIntoView.handlers
|
|
13654
|
+
}).onScrollIntoView, brick);
|
|
13655
|
+
observer.disconnect();
|
|
13656
|
+
}
|
|
13657
|
+
}
|
|
13658
|
+
});
|
|
13659
|
+
}, {
|
|
13660
|
+
threshold
|
|
13661
|
+
});
|
|
13662
|
+
observer.observe(element);
|
|
13663
|
+
previousObserverRef.current = observer;
|
|
13578
13664
|
}
|
|
13579
13665
|
} else {
|
|
13580
|
-
var _useBrick$
|
|
13581
|
-
|
|
13582
|
-
|
|
13666
|
+
var _useBrick$lifeCycle6;
|
|
13667
|
+
var onUnmount = (_useBrick$lifeCycle6 = useBrick.lifeCycle) === null || _useBrick$lifeCycle6 === void 0 ? void 0 : _useBrick$lifeCycle6.onUnmount;
|
|
13668
|
+
if (onUnmount) {
|
|
13669
|
+
dispatchLifeCycleEvent(new CustomEvent("unmount"), transformEvents(data, {
|
|
13670
|
+
onUnmount
|
|
13671
|
+
}).onUnmount, brick);
|
|
13672
|
+
}
|
|
13673
|
+
if (previousObserverRef.current) {
|
|
13674
|
+
previousObserverRef.current.disconnect();
|
|
13675
|
+
previousObserverRef.current = undefined;
|
|
13583
13676
|
}
|
|
13584
13677
|
}
|
|
13585
13678
|
}
|
|
@@ -17039,6 +17132,7 @@
|
|
|
17039
17132
|
exports.WebsocketMessageRequest = WebsocketMessageRequest;
|
|
17040
17133
|
exports.WebsocketMessageResponse = WebsocketMessageResponse;
|
|
17041
17134
|
exports.abortController = abortController;
|
|
17135
|
+
exports.addPathToBlackList = addPathToBlackList;
|
|
17042
17136
|
exports.applyTheme = applyTheme;
|
|
17043
17137
|
exports.authenticate = authenticate;
|
|
17044
17138
|
exports.batchSetAppsLocalTheme = batchSetAppsLocalTheme;
|