@next-core/brick-kit 2.129.3 → 2.130.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 +16 -0
- package/dist/index.bundle.js +229 -148
- package/dist/index.bundle.js.map +1 -1
- package/dist/index.esm.js +309 -228
- package/dist/index.esm.js.map +1 -1
- package/dist/types/core/Kernel.d.ts +2 -0
- package/dist/types/core/Kernel.d.ts.map +1 -1
- package/dist/types/internal/getGeneralGlobals.d.ts.map +1 -1
- package/dist/types/internal/menu.d.ts +7 -1
- package/dist/types/internal/menu.d.ts.map +1 -1
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
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.130.0](https://github.com/easyops-cn/next-core/compare/@next-core/brick-kit@2.129.3...@next-core/brick-kit@2.130.0) (2022-08-23)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* fulfill i18n only when loading injected menus ([e9f7950](https://github.com/easyops-cn/next-core/commit/e9f7950a3e3208cc2e17a4bec6559baea9da76b6))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
* support MISC variable ([fa13509](https://github.com/easyops-cn/next-core/commit/fa13509301b2c8a1a380c614d1fdd2cf17fa1707))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
6
22
|
## [2.129.3](https://github.com/easyops-cn/next-core/compare/@next-core/brick-kit@2.129.2...@next-core/brick-kit@2.129.3) (2022-08-23)
|
|
7
23
|
|
|
8
24
|
**Note:** Version bump only for package @next-core/brick-kit
|
package/dist/index.bundle.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
2
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('history'), require('@babel/runtime/helpers/objectSpread2'), require('@babel/runtime/helpers/objectWithoutProperties'), require('@babel/runtime/helpers/asyncToGenerator'), require('@babel/runtime/helpers/defineProperty'), require('react'), require('@next-core/brick-utils'), require('lodash'), require('@next-core/brick-http'), require('moment'), require('@next-core/pipes'), require('i18next'), require('@next-core/easyops-analytics'), require('antd'), require('@ant-design/icons'), require('js-yaml'), require('react-i18next'), require('@babel/runtime/helpers/esm/extends'), require('@next-core/illustrations'), require('@babel/runtime/helpers/decorate')) :
|
|
3
3
|
typeof define === 'function' && define.amd ? define(['exports', 'history', '@babel/runtime/helpers/objectSpread2', '@babel/runtime/helpers/objectWithoutProperties', '@babel/runtime/helpers/asyncToGenerator', '@babel/runtime/helpers/defineProperty', 'react', '@next-core/brick-utils', 'lodash', '@next-core/brick-http', 'moment', '@next-core/pipes', 'i18next', '@next-core/easyops-analytics', 'antd', '@ant-design/icons', 'js-yaml', 'react-i18next', '@babel/runtime/helpers/esm/extends', '@next-core/illustrations', '@babel/runtime/helpers/decorate'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.BrickKit = {}, global.history$1, global._objectSpread, global._objectWithoutProperties, global._asyncToGenerator$
|
|
5
|
-
})(this, (function (exports, history$1, _objectSpread, _objectWithoutProperties, _asyncToGenerator$
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.BrickKit = {}, global.history$1, global._objectSpread, global._objectWithoutProperties, global._asyncToGenerator$3, global._defineProperty$1, global.React, global.brickUtils, global._, global.brickHttp, global.moment, global.pipes, global.i18next, global.easyopsAnalytics, global.antd, global.icons, global.yaml, global.reactI18next, global._extends, global.illustrations, global._decorate));
|
|
5
|
+
})(this, (function (exports, history$1, _objectSpread, _objectWithoutProperties, _asyncToGenerator$3, _defineProperty$1, React, brickUtils, _, brickHttp, moment, pipes, i18next, easyopsAnalytics, antd, icons, yaml, reactI18next, _extends, illustrations, _decorate) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
9
9
|
var _objectSpread__default = /*#__PURE__*/_interopDefaultLegacy(_objectSpread);
|
|
10
10
|
var _objectWithoutProperties__default = /*#__PURE__*/_interopDefaultLegacy(_objectWithoutProperties);
|
|
11
|
-
var _asyncToGenerator__default = /*#__PURE__*/_interopDefaultLegacy(_asyncToGenerator$
|
|
11
|
+
var _asyncToGenerator__default = /*#__PURE__*/_interopDefaultLegacy(_asyncToGenerator$3);
|
|
12
12
|
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty$1);
|
|
13
13
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
14
14
|
var ___default = /*#__PURE__*/_interopDefaultLegacy(_);
|
|
@@ -444,7 +444,7 @@
|
|
|
444
444
|
return ((_window$getComputedSt = window.getComputedStyle(el)) === null || _window$getComputedSt === void 0 ? void 0 : _window$getComputedSt.getPropertyValue(name)) || "";
|
|
445
445
|
}
|
|
446
446
|
|
|
447
|
-
function asyncGeneratorStep$
|
|
447
|
+
function asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, key, arg) {
|
|
448
448
|
try {
|
|
449
449
|
var info = gen[key](arg);
|
|
450
450
|
var value = info.value;
|
|
@@ -460,7 +460,7 @@
|
|
|
460
460
|
}
|
|
461
461
|
}
|
|
462
462
|
|
|
463
|
-
function _asyncToGenerator$
|
|
463
|
+
function _asyncToGenerator$2(fn) {
|
|
464
464
|
return function () {
|
|
465
465
|
var self = this,
|
|
466
466
|
args = arguments;
|
|
@@ -468,11 +468,11 @@
|
|
|
468
468
|
var gen = fn.apply(self, args);
|
|
469
469
|
|
|
470
470
|
function _next(value) {
|
|
471
|
-
asyncGeneratorStep$
|
|
471
|
+
asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "next", value);
|
|
472
472
|
}
|
|
473
473
|
|
|
474
474
|
function _throw(err) {
|
|
475
|
-
asyncGeneratorStep$
|
|
475
|
+
asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "throw", err);
|
|
476
476
|
}
|
|
477
477
|
|
|
478
478
|
_next(undefined);
|
|
@@ -535,7 +535,7 @@
|
|
|
535
535
|
|
|
536
536
|
|
|
537
537
|
var InstanceApi_getDetail = /*#__PURE__*/function () {
|
|
538
|
-
var _ref = _asyncToGenerator$
|
|
538
|
+
var _ref = _asyncToGenerator$2(function* (objectId, instanceId, params, options) {
|
|
539
539
|
return (
|
|
540
540
|
/**! @contract easyops.api.cmdb.instance.GetDetail */
|
|
541
541
|
(yield brickHttp.http.get("api/gateway/cmdb.instance.GetDetail/object/".concat(objectId, "/instance/").concat(instanceId), _objectSpread2(_objectSpread2({}, options), {}, {
|
|
@@ -555,7 +555,7 @@
|
|
|
555
555
|
|
|
556
556
|
|
|
557
557
|
var InstanceApi_postSearch = /*#__PURE__*/function () {
|
|
558
|
-
var _ref = _asyncToGenerator$
|
|
558
|
+
var _ref = _asyncToGenerator$2(function* (objectId, data, options) {
|
|
559
559
|
return (
|
|
560
560
|
/**! @contract easyops.api.cmdb.instance.PostSearch */
|
|
561
561
|
(yield brickHttp.http.post("api/gateway/cmdb.instance.PostSearch/object/".concat(objectId, "/instance/_search"), data, options)).data
|
|
@@ -1332,41 +1332,26 @@
|
|
|
1332
1332
|
}
|
|
1333
1333
|
}
|
|
1334
1334
|
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
} catch (error) {
|
|
1340
|
-
reject(error);
|
|
1341
|
-
return;
|
|
1342
|
-
}
|
|
1343
|
-
|
|
1344
|
-
if (info.done) {
|
|
1345
|
-
resolve(value);
|
|
1346
|
-
} else {
|
|
1347
|
-
Promise.resolve(value).then(_next, _throw);
|
|
1348
|
-
}
|
|
1349
|
-
}
|
|
1350
|
-
|
|
1351
|
-
function _asyncToGenerator$2(fn) {
|
|
1352
|
-
return function () {
|
|
1353
|
-
var self = this,
|
|
1354
|
-
args = arguments;
|
|
1355
|
-
return new Promise(function (resolve, reject) {
|
|
1356
|
-
var gen = fn.apply(self, args);
|
|
1335
|
+
/**
|
|
1336
|
+
* @description 获取微应用的i18n数据
|
|
1337
|
+
* @endpoint GET /api/v1/micro-app/i18n
|
|
1338
|
+
*/
|
|
1357
1339
|
|
|
1358
|
-
function _next(value) {
|
|
1359
|
-
asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "next", value);
|
|
1360
|
-
}
|
|
1361
1340
|
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1341
|
+
var InstalledMicroAppApi_getI18NData = /*#__PURE__*/function () {
|
|
1342
|
+
var _ref = _asyncToGenerator__default["default"](function* (params, options) {
|
|
1343
|
+
return (
|
|
1344
|
+
/**! @contract easyops.api.micro_app.installed_micro_app.GetI18NData@1.0.0 */
|
|
1345
|
+
(yield brickHttp.http.get("api/gateway/micro_app.installed_micro_app.GetI18NData/api/v1/micro-app/i18n", _objectSpread__default["default"](_objectSpread__default["default"]({}, options), {}, {
|
|
1346
|
+
params
|
|
1347
|
+
}))).data
|
|
1348
|
+
);
|
|
1349
|
+
});
|
|
1365
1350
|
|
|
1366
|
-
|
|
1367
|
-
|
|
1351
|
+
return function InstalledMicroAppApi_getI18NData(_x, _x2) {
|
|
1352
|
+
return _ref.apply(this, arguments);
|
|
1368
1353
|
};
|
|
1369
|
-
}
|
|
1354
|
+
}();
|
|
1370
1355
|
/**
|
|
1371
1356
|
* @description 查询模型关联小产品列表
|
|
1372
1357
|
* @endpoint LIST /api/micro_app/v1/object_micro_app
|
|
@@ -1374,9 +1359,9 @@
|
|
|
1374
1359
|
|
|
1375
1360
|
|
|
1376
1361
|
var ObjectMicroAppApi_getObjectMicroAppList = /*#__PURE__*/function () {
|
|
1377
|
-
var _ref =
|
|
1362
|
+
var _ref = _asyncToGenerator__default["default"](function* (options) {
|
|
1378
1363
|
return (
|
|
1379
|
-
/**! @contract easyops.api.micro_app.object_micro_app.GetObjectMicroAppList */
|
|
1364
|
+
/**! @contract easyops.api.micro_app.object_micro_app.GetObjectMicroAppList@1.0.0 */
|
|
1380
1365
|
(yield brickHttp.http.get("api/gateway/micro_app.object_micro_app.GetObjectMicroAppList/api/micro_app/v1/object_micro_app", options)).data
|
|
1381
1366
|
);
|
|
1382
1367
|
});
|
|
@@ -1392,9 +1377,9 @@
|
|
|
1392
1377
|
|
|
1393
1378
|
|
|
1394
1379
|
var PermissionApi_validatePermissions = /*#__PURE__*/function () {
|
|
1395
|
-
var _ref =
|
|
1380
|
+
var _ref = _asyncToGenerator__default["default"](function* (data, options) {
|
|
1396
1381
|
return (
|
|
1397
|
-
/**! @contract easyops.api.micro_app.permission.ValidatePermissions */
|
|
1382
|
+
/**! @contract easyops.api.micro_app.permission.ValidatePermissions@1.0.0 */
|
|
1398
1383
|
(yield brickHttp.http.post("api/gateway/micro_app.permission.ValidatePermissions/api/micro_app/v1/permission/validate", data, options)).data
|
|
1399
1384
|
);
|
|
1400
1385
|
});
|
|
@@ -1579,6 +1564,44 @@
|
|
|
1579
1564
|
});
|
|
1580
1565
|
}
|
|
1581
1566
|
|
|
1567
|
+
var misc;
|
|
1568
|
+
function getRuntimeMisc() {
|
|
1569
|
+
if (!misc) {
|
|
1570
|
+
misc = {
|
|
1571
|
+
isInIframe: false,
|
|
1572
|
+
isInIframeOfSameSite: false,
|
|
1573
|
+
isInIframeOfNext: false,
|
|
1574
|
+
isInIframeOfVisualBuilder: false,
|
|
1575
|
+
isInIframeOfLegacyConsole: false
|
|
1576
|
+
};
|
|
1577
|
+
|
|
1578
|
+
if (window !== window.parent) {
|
|
1579
|
+
misc.isInIframe = true;
|
|
1580
|
+
|
|
1581
|
+
try {
|
|
1582
|
+
// Handle:
|
|
1583
|
+
// - Previewing in visual builder by iframe.
|
|
1584
|
+
// - Nesting next in next.
|
|
1585
|
+
// - Nesting console in next.
|
|
1586
|
+
if (window.origin === window.parent.origin) {
|
|
1587
|
+
misc.isInIframeOfSameSite = true;
|
|
1588
|
+
var selfIsNext = getBasePath() === "/next/";
|
|
1589
|
+
var parentPathname = window.parent.location.pathname;
|
|
1590
|
+
var parentIsNext = parentPathname.startsWith("/next/");
|
|
1591
|
+
misc.isInIframeOfNext = (Number(selfIsNext) ^ Number(parentIsNext)) === 0;
|
|
1592
|
+
misc.isInIframeOfVisualBuilder = parentPathname.startsWith("".concat(parentIsNext ? "/next" : "", "/visual-builder/"));
|
|
1593
|
+
misc.isInIframeOfLegacyConsole = selfIsNext && !parentIsNext;
|
|
1594
|
+
}
|
|
1595
|
+
} catch (e) {// do nothing
|
|
1596
|
+
}
|
|
1597
|
+
}
|
|
1598
|
+
|
|
1599
|
+
Object.freeze(misc);
|
|
1600
|
+
}
|
|
1601
|
+
|
|
1602
|
+
return misc;
|
|
1603
|
+
}
|
|
1604
|
+
|
|
1582
1605
|
// `GeneralGlobals` are globals which are page-state-agnostic,
|
|
1583
1606
|
// thus they can be used both in storyboard expressions and functions.
|
|
1584
1607
|
function getGeneralGlobals(attemptToVisitGlobals, options) {
|
|
@@ -1631,6 +1654,9 @@
|
|
|
1631
1654
|
getCssPropertyValue: collectCoverage ? () => "" : getCssPropertyValue
|
|
1632
1655
|
};
|
|
1633
1656
|
|
|
1657
|
+
case "RUNTIME_MISC":
|
|
1658
|
+
return collectCoverage ? fakeRuntimeMisc() : getRuntimeMisc();
|
|
1659
|
+
|
|
1634
1660
|
case "console":
|
|
1635
1661
|
return isStoryboardFunction ? getReadOnlyProxy(console) : undefined;
|
|
1636
1662
|
|
|
@@ -1666,6 +1692,16 @@
|
|
|
1666
1692
|
return true;
|
|
1667
1693
|
}
|
|
1668
1694
|
|
|
1695
|
+
function fakeRuntimeMisc() {
|
|
1696
|
+
return {
|
|
1697
|
+
isInIframe: false,
|
|
1698
|
+
isInIframeOfSameSite: false,
|
|
1699
|
+
isInIframeOfNext: false,
|
|
1700
|
+
isInIframeOfVisualBuilder: false,
|
|
1701
|
+
isInIframeOfLegacyConsole: false
|
|
1702
|
+
};
|
|
1703
|
+
}
|
|
1704
|
+
|
|
1669
1705
|
/** @internal */
|
|
1670
1706
|
|
|
1671
1707
|
/** @internal */
|
|
@@ -2977,7 +3013,8 @@
|
|
|
2977
3013
|
}
|
|
2978
3014
|
|
|
2979
3015
|
var _excluded$6 = ["children"],
|
|
2980
|
-
_excluded2$2 = ["
|
|
3016
|
+
_excluded2$2 = ["children"],
|
|
3017
|
+
_excluded3 = ["items", "app"];
|
|
2981
3018
|
var symbolAppId = Symbol("appId");
|
|
2982
3019
|
// Caching menu requests to avoid flicker.
|
|
2983
3020
|
var menuCache = new Map();
|
|
@@ -3161,10 +3198,13 @@
|
|
|
3161
3198
|
items,
|
|
3162
3199
|
app
|
|
3163
3200
|
} = _yield$fetchMenuById,
|
|
3164
|
-
restMenuData = _objectWithoutProperties__default["default"](_yield$fetchMenuById,
|
|
3201
|
+
restMenuData = _objectWithoutProperties__default["default"](_yield$fetchMenuById, _excluded3);
|
|
3165
3202
|
|
|
3166
|
-
var
|
|
3167
|
-
|
|
3203
|
+
var appIds = collectOverrideApps(items, app[0].appId, context.app.id);
|
|
3204
|
+
yield kernel.fulfilStoryboardI18n(appIds);
|
|
3205
|
+
|
|
3206
|
+
var menuData = _objectSpread__default["default"](_objectSpread__default["default"]({}, computeRealValueWithOverrideApp(restMenuData, app[0].appId, context, kernel)), {}, {
|
|
3207
|
+
items: computeMenuItemsWithOverrideApp(items, context, kernel)
|
|
3168
3208
|
});
|
|
3169
3209
|
|
|
3170
3210
|
return {
|
|
@@ -3196,26 +3236,48 @@
|
|
|
3196
3236
|
return _processMenu.apply(this, arguments);
|
|
3197
3237
|
}
|
|
3198
3238
|
|
|
3199
|
-
function
|
|
3200
|
-
|
|
3201
|
-
|
|
3239
|
+
function collectOverrideApps(items, rootAppId, contextAppId) {
|
|
3240
|
+
var appIds = new Set();
|
|
3241
|
+
|
|
3242
|
+
if (rootAppId !== contextAppId) {
|
|
3243
|
+
appIds.add(rootAppId);
|
|
3244
|
+
}
|
|
3245
|
+
|
|
3246
|
+
function collect(items) {
|
|
3247
|
+
for (var _ref of items) {
|
|
3202
3248
|
var {
|
|
3203
3249
|
children
|
|
3204
3250
|
} = _ref,
|
|
3205
3251
|
rest = _objectWithoutProperties__default["default"](_ref, _excluded$6);
|
|
3206
3252
|
|
|
3207
|
-
|
|
3208
|
-
children: children && (yield computeMenuItemsWithOverrideApp(children, context, kernel))
|
|
3209
|
-
});
|
|
3210
|
-
});
|
|
3253
|
+
var overrideAppId = rest[symbolAppId];
|
|
3211
3254
|
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3255
|
+
if (overrideAppId !== contextAppId && !appIds.has(overrideAppId) && requireOverrideApp(rest)) {
|
|
3256
|
+
appIds.add(overrideAppId);
|
|
3257
|
+
}
|
|
3258
|
+
|
|
3259
|
+
children && collect(children);
|
|
3260
|
+
}
|
|
3261
|
+
}
|
|
3262
|
+
|
|
3263
|
+
collect(items);
|
|
3264
|
+
return [...appIds];
|
|
3216
3265
|
}
|
|
3217
3266
|
|
|
3218
|
-
function
|
|
3267
|
+
function computeMenuItemsWithOverrideApp(items, context, kernel) {
|
|
3268
|
+
return items.map(_ref2 => {
|
|
3269
|
+
var {
|
|
3270
|
+
children
|
|
3271
|
+
} = _ref2,
|
|
3272
|
+
rest = _objectWithoutProperties__default["default"](_ref2, _excluded2$2);
|
|
3273
|
+
|
|
3274
|
+
return _objectSpread__default["default"](_objectSpread__default["default"]({}, computeRealValueWithOverrideApp(rest, rest[symbolAppId], context, kernel)), {}, {
|
|
3275
|
+
children: children && computeMenuItemsWithOverrideApp(children, context, kernel)
|
|
3276
|
+
});
|
|
3277
|
+
});
|
|
3278
|
+
}
|
|
3279
|
+
|
|
3280
|
+
function processMenuTitle(_x16) {
|
|
3219
3281
|
return _processMenuTitle.apply(this, arguments);
|
|
3220
3282
|
}
|
|
3221
3283
|
|
|
@@ -3310,30 +3372,22 @@
|
|
|
3310
3372
|
return false;
|
|
3311
3373
|
}
|
|
3312
3374
|
|
|
3313
|
-
function computeRealValueWithOverrideApp(
|
|
3314
|
-
|
|
3315
|
-
}
|
|
3375
|
+
function computeRealValueWithOverrideApp(data, overrideAppId, context, kernel) {
|
|
3376
|
+
var newContext = context;
|
|
3316
3377
|
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
var newContext = context;
|
|
3378
|
+
if (overrideAppId !== context.app.id && requireOverrideApp(data)) {
|
|
3379
|
+
var storyboard = kernel.bootstrapData.storyboards.find(story => story.app.id === overrideAppId);
|
|
3320
3380
|
|
|
3321
|
-
if (
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
yield kernel.fulfilStoryboard(storyboard);
|
|
3326
|
-
newContext = _objectSpread__default["default"](_objectSpread__default["default"]({}, context), {}, {
|
|
3327
|
-
overrideApp: storyboard.app
|
|
3328
|
-
});
|
|
3329
|
-
}
|
|
3381
|
+
if (storyboard) {
|
|
3382
|
+
newContext = _objectSpread__default["default"](_objectSpread__default["default"]({}, context), {}, {
|
|
3383
|
+
overrideApp: storyboard.app
|
|
3384
|
+
});
|
|
3330
3385
|
}
|
|
3386
|
+
}
|
|
3331
3387
|
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
});
|
|
3388
|
+
return computeRealValue(data, newContext, true, {
|
|
3389
|
+
ignoreSymbols: true
|
|
3335
3390
|
});
|
|
3336
|
-
return _computeRealValueWithOverrideApp.apply(this, arguments);
|
|
3337
3391
|
}
|
|
3338
3392
|
|
|
3339
3393
|
var lazyBrickRegistry = new Map();
|
|
@@ -8987,7 +9041,8 @@
|
|
|
8987
9041
|
return _asyncToGenerator__default["default"](function* () {
|
|
8988
9042
|
if (window.STANDALONE_MICRO_APPS) {
|
|
8989
9043
|
Object.assign(storyboard, {
|
|
8990
|
-
$$fulfilled: true
|
|
9044
|
+
$$fulfilled: true,
|
|
9045
|
+
$$fulfilling: null
|
|
8991
9046
|
});
|
|
8992
9047
|
|
|
8993
9048
|
if (!window.NO_AUTH_GUARD) {
|
|
@@ -9020,7 +9075,8 @@
|
|
|
9020
9075
|
routes,
|
|
9021
9076
|
meta,
|
|
9022
9077
|
app: _objectSpread__default["default"](_objectSpread__default["default"]({}, storyboard.app), app),
|
|
9023
|
-
$$fulfilled: true
|
|
9078
|
+
$$fulfilled: true,
|
|
9079
|
+
$$fulfilling: null
|
|
9024
9080
|
});
|
|
9025
9081
|
}
|
|
9026
9082
|
|
|
@@ -9029,9 +9085,12 @@
|
|
|
9029
9085
|
}
|
|
9030
9086
|
|
|
9031
9087
|
postProcessStoryboard(storyboard) {
|
|
9032
|
-
var _storyboard$meta;
|
|
9033
|
-
|
|
9034
9088
|
storyboard.app.$$routeAliasMap = brickUtils.scanRouteAliasInStoryboard(storyboard);
|
|
9089
|
+
this.postProcessStoryboardI18n(storyboard);
|
|
9090
|
+
}
|
|
9091
|
+
|
|
9092
|
+
postProcessStoryboardI18n(storyboard) {
|
|
9093
|
+
var _storyboard$meta;
|
|
9035
9094
|
|
|
9036
9095
|
if ((_storyboard$meta = storyboard.meta) !== null && _storyboard$meta !== void 0 && _storyboard$meta.i18n) {
|
|
9037
9096
|
// Prefix to avoid conflict between brick package's i18n namespace.
|
|
@@ -9044,10 +9103,70 @@
|
|
|
9044
9103
|
}
|
|
9045
9104
|
}
|
|
9046
9105
|
|
|
9106
|
+
fulfilStoryboardI18n(appIds) {
|
|
9107
|
+
var _this7 = this;
|
|
9108
|
+
|
|
9109
|
+
return _asyncToGenerator__default["default"](function* () {
|
|
9110
|
+
// Ignore already fulfilled apps.
|
|
9111
|
+
var filteredStoryboards = appIds.map(appId => _this7.bootstrapData.storyboards.find(story => story.app.id === appId)).filter(story => story && !story.$$fulfilled && !story.$$i18nFulfilled);
|
|
9112
|
+
|
|
9113
|
+
if (window.STANDALONE_MICRO_APPS) {
|
|
9114
|
+
// Fallback to fullfil whole storyboard for standalone micro-apps.
|
|
9115
|
+
yield Promise.all(filteredStoryboards.map(story => _this7.fulfilStoryboard(story)));
|
|
9116
|
+
return;
|
|
9117
|
+
} // Do not fulfil i18n if the app is doing a whole fulfilling.
|
|
9118
|
+
|
|
9119
|
+
|
|
9120
|
+
var fulfilling = [];
|
|
9121
|
+
var filteredAppIds = [];
|
|
9122
|
+
|
|
9123
|
+
for (var story of filteredStoryboards) {
|
|
9124
|
+
if (story.$$fulfilling) {
|
|
9125
|
+
fulfilling.push(story.$$fulfilling);
|
|
9126
|
+
} else {
|
|
9127
|
+
filteredAppIds.push(story.app.id);
|
|
9128
|
+
}
|
|
9129
|
+
}
|
|
9130
|
+
|
|
9131
|
+
if (filteredAppIds.length === 0) {
|
|
9132
|
+
// Still wait for these whole fulfilling.
|
|
9133
|
+
yield Promise.all(fulfilling);
|
|
9134
|
+
return;
|
|
9135
|
+
}
|
|
9136
|
+
|
|
9137
|
+
var [{
|
|
9138
|
+
i18nInfo
|
|
9139
|
+
}] = yield Promise.all([InstalledMicroAppApi_getI18NData({
|
|
9140
|
+
appIds: filteredAppIds.join(",")
|
|
9141
|
+
}), // Still wait for these whole fulfilling.
|
|
9142
|
+
...fulfilling]);
|
|
9143
|
+
|
|
9144
|
+
var _loop = function (appId, i18n) {
|
|
9145
|
+
var storyboard = _this7.bootstrapData.storyboards.find(story => story.app.id === appId);
|
|
9146
|
+
|
|
9147
|
+
Object.assign(storyboard, {
|
|
9148
|
+
meta: _objectSpread__default["default"](_objectSpread__default["default"]({}, storyboard.meta), {}, {
|
|
9149
|
+
i18n: i18n
|
|
9150
|
+
}),
|
|
9151
|
+
$$i18nFulfilled: true
|
|
9152
|
+
});
|
|
9153
|
+
|
|
9154
|
+
_this7.postProcessStoryboardI18n(storyboard);
|
|
9155
|
+
};
|
|
9156
|
+
|
|
9157
|
+
for (var {
|
|
9158
|
+
appId,
|
|
9159
|
+
i18n
|
|
9160
|
+
} of i18nInfo) {
|
|
9161
|
+
_loop(appId, i18n);
|
|
9162
|
+
}
|
|
9163
|
+
})();
|
|
9164
|
+
}
|
|
9165
|
+
|
|
9047
9166
|
_dev_only_updateStoryboard(appId, storyboardPatch) {
|
|
9048
9167
|
var storyboard = this.bootstrapData.storyboards.find(item => item.app.id === appId);
|
|
9049
9168
|
Object.assign(storyboard, _objectSpread__default["default"](_objectSpread__default["default"]({}, storyboardPatch), {}, {
|
|
9050
|
-
$$fulfilling:
|
|
9169
|
+
$$fulfilling: null,
|
|
9051
9170
|
$$fulfilled: true,
|
|
9052
9171
|
$$registerCustomTemplateProcessed: false,
|
|
9053
9172
|
$$depsProcessed: false
|
|
@@ -9170,7 +9289,7 @@
|
|
|
9170
9289
|
|
|
9171
9290
|
gracefullyLoadDeps(fn) {
|
|
9172
9291
|
var _arguments = arguments,
|
|
9173
|
-
|
|
9292
|
+
_this8 = this;
|
|
9174
9293
|
|
|
9175
9294
|
return _asyncToGenerator__default["default"](function* () {
|
|
9176
9295
|
for (var _len = _arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
@@ -9184,7 +9303,7 @@
|
|
|
9184
9303
|
// The scripts maybe stale when a user stays in page while upgrades been applied.
|
|
9185
9304
|
// So we force reloading again automatically.
|
|
9186
9305
|
// NOTE: reload only once to avoid a infinite loop.
|
|
9187
|
-
yield
|
|
9306
|
+
yield _this8.reloadMicroApps();
|
|
9188
9307
|
yield fn(...args);
|
|
9189
9308
|
} else {
|
|
9190
9309
|
throw e;
|
|
@@ -9233,7 +9352,7 @@
|
|
|
9233
9352
|
}
|
|
9234
9353
|
|
|
9235
9354
|
loadDynamicBricksInBrickConf(brickConf) {
|
|
9236
|
-
var
|
|
9355
|
+
var _this9 = this;
|
|
9237
9356
|
|
|
9238
9357
|
return _asyncToGenerator__default["default"](function* () {
|
|
9239
9358
|
// Notice: `brickConf` contains runtime data,
|
|
@@ -9241,7 +9360,7 @@
|
|
|
9241
9360
|
// which could cause stack overflow while traversing.
|
|
9242
9361
|
var bricks = brickUtils.scanBricksInBrickConf(brickConf);
|
|
9243
9362
|
var processors = brickUtils.scanProcessorsInAny(brickConf);
|
|
9244
|
-
yield
|
|
9363
|
+
yield _this9.loadDynamicBricks(bricks, processors);
|
|
9245
9364
|
})();
|
|
9246
9365
|
}
|
|
9247
9366
|
|
|
@@ -9350,10 +9469,10 @@
|
|
|
9350
9469
|
}
|
|
9351
9470
|
|
|
9352
9471
|
getMicroAppApiOrchestrationMapAsync() {
|
|
9353
|
-
var
|
|
9472
|
+
var _this10 = this;
|
|
9354
9473
|
|
|
9355
9474
|
return _asyncToGenerator__default["default"](function* () {
|
|
9356
|
-
return yield
|
|
9475
|
+
return yield _this10.allMicroAppApiOrchestrationPromise;
|
|
9357
9476
|
})();
|
|
9358
9477
|
}
|
|
9359
9478
|
|
|
@@ -9445,14 +9564,14 @@
|
|
|
9445
9564
|
}
|
|
9446
9565
|
|
|
9447
9566
|
getRelatedAppsAsync(appId) {
|
|
9448
|
-
var
|
|
9567
|
+
var _this11 = this;
|
|
9449
9568
|
|
|
9450
9569
|
return _asyncToGenerator__default["default"](function* () {
|
|
9451
9570
|
if (!appId) {
|
|
9452
9571
|
return [];
|
|
9453
9572
|
}
|
|
9454
9573
|
|
|
9455
|
-
var allRelatedApps = yield
|
|
9574
|
+
var allRelatedApps = yield _this11.allRelatedAppsPromise;
|
|
9456
9575
|
var thisApp = allRelatedApps.find(item => item.microAppId === appId);
|
|
9457
9576
|
|
|
9458
9577
|
if (!thisApp) {
|
|
@@ -9464,38 +9583,38 @@
|
|
|
9464
9583
|
}
|
|
9465
9584
|
|
|
9466
9585
|
updateWorkspaceStack() {
|
|
9467
|
-
var
|
|
9586
|
+
var _this12 = this;
|
|
9468
9587
|
|
|
9469
9588
|
return _asyncToGenerator__default["default"](function* () {
|
|
9470
|
-
if (
|
|
9589
|
+
if (_this12.currentApp && _this12.currentApp.id) {
|
|
9471
9590
|
var workspace = {
|
|
9472
|
-
appId:
|
|
9473
|
-
appName:
|
|
9474
|
-
appLocaleName:
|
|
9475
|
-
url:
|
|
9591
|
+
appId: _this12.currentApp.id,
|
|
9592
|
+
appName: _this12.currentApp.name,
|
|
9593
|
+
appLocaleName: _this12.currentApp.localeName,
|
|
9594
|
+
url: _this12.currentUrl
|
|
9476
9595
|
};
|
|
9477
9596
|
|
|
9478
|
-
if (
|
|
9479
|
-
var previousWorkspace =
|
|
9597
|
+
if (_this12.workspaceStack.length > 0) {
|
|
9598
|
+
var previousWorkspace = _this12.workspaceStack[_this12.workspaceStack.length - 1];
|
|
9480
9599
|
|
|
9481
|
-
var _relatedApps = yield
|
|
9600
|
+
var _relatedApps = yield _this12.getRelatedAppsAsync(previousWorkspace.appId);
|
|
9482
9601
|
|
|
9483
|
-
if (_relatedApps.some(item => item.microAppId ===
|
|
9602
|
+
if (_relatedApps.some(item => item.microAppId === _this12.currentApp.id)) {
|
|
9484
9603
|
Object.assign(previousWorkspace, workspace);
|
|
9485
9604
|
return;
|
|
9486
9605
|
}
|
|
9487
9606
|
}
|
|
9488
9607
|
|
|
9489
|
-
var relatedApps = yield
|
|
9608
|
+
var relatedApps = yield _this12.getRelatedAppsAsync(_this12.currentApp.id);
|
|
9490
9609
|
|
|
9491
9610
|
if (relatedApps.length > 0) {
|
|
9492
|
-
|
|
9611
|
+
_this12.workspaceStack.push(workspace);
|
|
9493
9612
|
|
|
9494
9613
|
return;
|
|
9495
9614
|
}
|
|
9496
9615
|
}
|
|
9497
9616
|
|
|
9498
|
-
|
|
9617
|
+
_this12.workspaceStack = [];
|
|
9499
9618
|
})();
|
|
9500
9619
|
}
|
|
9501
9620
|
|
|
@@ -9542,22 +9661,22 @@
|
|
|
9542
9661
|
}
|
|
9543
9662
|
|
|
9544
9663
|
getProviderBrick(provider) {
|
|
9545
|
-
var
|
|
9664
|
+
var _this13 = this;
|
|
9546
9665
|
|
|
9547
9666
|
return _asyncToGenerator__default["default"](function* () {
|
|
9548
9667
|
if (isCustomApiProvider(provider)) {
|
|
9549
9668
|
provider = CUSTOM_API_PROVIDER;
|
|
9550
9669
|
}
|
|
9551
9670
|
|
|
9552
|
-
if (
|
|
9553
|
-
return
|
|
9671
|
+
if (_this13.providerRepository.has(provider)) {
|
|
9672
|
+
return _this13.providerRepository.get(provider);
|
|
9554
9673
|
}
|
|
9555
9674
|
|
|
9556
9675
|
if (provider === CUSTOM_API_PROVIDER && !customElements.get(provider)) {
|
|
9557
9676
|
registerCustomApi();
|
|
9558
9677
|
}
|
|
9559
9678
|
|
|
9560
|
-
yield
|
|
9679
|
+
yield _this13.loadDynamicBricks([provider]);
|
|
9561
9680
|
|
|
9562
9681
|
if (!customElements.get(provider)) {
|
|
9563
9682
|
throw new Error("Provider not defined: \"".concat(provider, "\"."));
|
|
@@ -9565,7 +9684,7 @@
|
|
|
9565
9684
|
|
|
9566
9685
|
var brick = document.createElement(provider);
|
|
9567
9686
|
|
|
9568
|
-
|
|
9687
|
+
_this13.providerRepository.set(provider, brick);
|
|
9569
9688
|
|
|
9570
9689
|
return brick;
|
|
9571
9690
|
})();
|
|
@@ -9737,44 +9856,6 @@
|
|
|
9737
9856
|
return conf.type === "routes";
|
|
9738
9857
|
}
|
|
9739
9858
|
|
|
9740
|
-
var misc;
|
|
9741
|
-
function getRuntimeMisc() {
|
|
9742
|
-
if (!misc) {
|
|
9743
|
-
misc = {
|
|
9744
|
-
isInIframe: false,
|
|
9745
|
-
isInIframeOfSameSite: false,
|
|
9746
|
-
isInIframeOfNext: false,
|
|
9747
|
-
isInIframeOfVisualBuilder: false,
|
|
9748
|
-
isInIframeOfLegacyConsole: false
|
|
9749
|
-
};
|
|
9750
|
-
|
|
9751
|
-
if (window !== window.parent) {
|
|
9752
|
-
misc.isInIframe = true;
|
|
9753
|
-
|
|
9754
|
-
try {
|
|
9755
|
-
// Handle:
|
|
9756
|
-
// - Previewing in visual builder by iframe.
|
|
9757
|
-
// - Nesting next in next.
|
|
9758
|
-
// - Nesting console in next.
|
|
9759
|
-
if (window.origin === window.parent.origin) {
|
|
9760
|
-
misc.isInIframeOfSameSite = true;
|
|
9761
|
-
var selfIsNext = getBasePath() === "/next/";
|
|
9762
|
-
var parentPathname = window.parent.location.pathname;
|
|
9763
|
-
var parentIsNext = parentPathname.startsWith("/next/");
|
|
9764
|
-
misc.isInIframeOfNext = (Number(selfIsNext) ^ Number(parentIsNext)) === 0;
|
|
9765
|
-
misc.isInIframeOfVisualBuilder = parentPathname.startsWith("".concat(parentIsNext ? "/next" : "", "/visual-builder/"));
|
|
9766
|
-
misc.isInIframeOfLegacyConsole = selfIsNext && !parentIsNext;
|
|
9767
|
-
}
|
|
9768
|
-
} catch (e) {// do nothing
|
|
9769
|
-
}
|
|
9770
|
-
}
|
|
9771
|
-
|
|
9772
|
-
Object.freeze(misc);
|
|
9773
|
-
}
|
|
9774
|
-
|
|
9775
|
-
return misc;
|
|
9776
|
-
}
|
|
9777
|
-
|
|
9778
9859
|
function getSubStoryboardByRoute(storyboard, matcher) {
|
|
9779
9860
|
function getSubRoutes(routes) {
|
|
9780
9861
|
return matcher(routes).map(getSubRoute);
|