@next-core/brick-kit 2.100.0 → 2.102.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.
@@ -512,6 +512,24 @@
512
512
  return _ref.apply(this, arguments);
513
513
  };
514
514
  }();
515
+ /**
516
+ * @description 搜索实例V3 (支持多属性排序)
517
+ * @endpoint POST /v3/object/:objectId/instance/_search
518
+ */
519
+
520
+
521
+ var InstanceApi_postSearchV3 = /*#__PURE__*/function () {
522
+ var _ref = _asyncToGenerator$3(function* (objectId, data, options) {
523
+ return (
524
+ /**! @contract easyops.api.cmdb.instance.PostSearchV3 */
525
+ (yield brickHttp.http.post("api/gateway/cmdb.instance.PostSearchV3/v3/object/".concat(objectId, "/instance/_search"), data, options)).data
526
+ );
527
+ });
528
+
529
+ return function InstanceApi_postSearchV3(_x, _x2, _x3) {
530
+ return _ref.apply(this, arguments);
531
+ };
532
+ }();
515
533
 
516
534
  function supply(attemptToVisitGlobals, providedGlobalVariables) {
517
535
  var globalVariables = _objectSpread__default["default"]({}, providedGlobalVariables); // Allow limited browser builtin values.
@@ -1527,6 +1545,11 @@
1527
1545
  return {
1528
1546
  check: collectCoverage ? fakeCheckPermissions : checkPermissions
1529
1547
  };
1548
+
1549
+ case "THEME":
1550
+ return {
1551
+ getTheme: collectCoverage ? () => "light" : getTheme
1552
+ };
1530
1553
  }
1531
1554
  }
1532
1555
 
@@ -1893,39 +1916,16 @@
1893
1916
  });
1894
1917
 
1895
1918
  case "QUERY":
1896
- return getDynamicReadOnlyProxy({
1897
- get(target, key) {
1898
- return query.has(key) ? query.get(key) : undefined;
1899
- },
1900
-
1901
- ownKeys() {
1902
- return Array.from(query.keys());
1903
- }
1904
-
1905
- });
1919
+ return Object.fromEntries(Array.from(query.keys()).map(key => [key, query.get(key)]));
1906
1920
 
1907
1921
  case "QUERY_ARRAY":
1908
- return getDynamicReadOnlyProxy({
1909
- get(target, key) {
1910
- return query.has(key) ? query.getAll(key) : undefined;
1911
- },
1912
-
1913
- ownKeys() {
1914
- return Array.from(query.keys());
1915
- }
1916
-
1917
- });
1922
+ return Object.fromEntries(Array.from(query.keys()).map(key => [key, query.getAll(key)]));
1918
1923
 
1919
1924
  case "SEGUE":
1920
1925
  return {
1921
1926
  getUrl: getUrlBySegueFactory(app, segues)
1922
1927
  };
1923
1928
 
1924
- case "THEME":
1925
- return {
1926
- getTheme
1927
- };
1928
-
1929
1929
  case "SESSION_STORAGE":
1930
1930
  return {
1931
1931
  getItem: getItemFactory("session")
@@ -5036,6 +5036,39 @@
5036
5036
  };
5037
5037
  }();
5038
5038
 
5039
+ var mocks = {
5040
+ mockId: null,
5041
+ mockList: []
5042
+ };
5043
+ function registerMock(useMocks) {
5044
+ var _useMocks$mockList;
5045
+
5046
+ if (useMocks) mocks = _objectSpread__default["default"](_objectSpread__default["default"]({}, useMocks), {}, {
5047
+ mockList: (_useMocks$mockList = useMocks.mockList) === null || _useMocks$mockList === void 0 ? void 0 : _useMocks$mockList.map(item => _objectSpread__default["default"](_objectSpread__default["default"]({}, item), {}, {
5048
+ uri: item.uri.replace(/(easyops\.api\.)(.+?)\/(.+)/, (_match, p1, p2, p3) => {
5049
+ return "(".concat(p1, ")?").concat(p2, "(@\\d+\\.\\d+\\.\\d+)?/").concat(p3, "$");
5050
+ }).replace(/:\w+/g, "([^/]+)")
5051
+ }))
5052
+ });
5053
+ }
5054
+ function getMockList() {
5055
+ return mocks.mockList;
5056
+ }
5057
+ var getMockInfo = requestUrl => {
5058
+ var item = mocks.mockList.find(item => new RegExp(item.uri).test(requestUrl));
5059
+
5060
+ if (item) {
5061
+ return {
5062
+ url: requestUrl.replace(/(api\/gateway\/.+?)(@\d+\.\d+\.\d+)?\/(.+)/, (_match, p1, _p2, p3) => {
5063
+ return "".concat(p1, "/").concat(p3);
5064
+ }).replace(/(api\/gateway)/, "api/gateway/mock_server.proxy.".concat(mocks.mockId)),
5065
+ mockId: mocks.mockId
5066
+ };
5067
+ }
5068
+
5069
+ return;
5070
+ };
5071
+
5039
5072
  var flowApiDefinitionPromiseMap = new Map(); // Legacy Custom API: `${namespace}@${name}`
5040
5073
  // Flow API: `${namespace}@${name}:${version}`
5041
5074
 
@@ -5155,25 +5188,59 @@
5155
5188
  _fetchFlowApiDefinition2 = _asyncToGenerator__default["default"](function* (provider) {
5156
5189
  var [namespaceName, nameWithVersion] = provider.split("@");
5157
5190
  var [name, version] = nameWithVersion.split(":");
5158
- var {
5159
- contractData
5160
- } = yield ContractApi_searchSingleContract({
5161
- contractName: "".concat(namespaceName, ".").concat(name),
5162
- version
5163
- }); // return undefined if don't found contract
5191
+ var isUseMock = getMockList().find(item => item.provider === "".concat(namespaceName, "@").concat(name));
5164
5192
 
5165
- if (contractData) {
5166
- var _contractData$namespa, _contractData$namespa2;
5193
+ if (isUseMock) {
5194
+ var _list$;
5167
5195
 
5168
- return {
5169
- name: contractData.name,
5170
- 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,
5171
- version: contractData.version,
5172
- contract: {
5173
- endpoint: contractData.endpoint,
5174
- response: contractData.response
5196
+ var {
5197
+ list
5198
+ } = yield InstanceApi_postSearchV3("FLOW_BUILDER_API_CONTRACT@EASYOPS", {
5199
+ fields: ["name", "namespaceId", "endpoint", "response", "version"],
5200
+ query: {
5201
+ namespaceId: {
5202
+ $eq: namespaceName
5203
+ },
5204
+ name: {
5205
+ $eq: name
5206
+ }
5175
5207
  }
5176
- };
5208
+ });
5209
+
5210
+ if ((_list$ = list[0]) !== null && _list$ !== void 0 && _list$.instanceId) {
5211
+ var _list$2;
5212
+
5213
+ return {
5214
+ name: list[0].name,
5215
+ namespace: (_list$2 = list[0]) === null || _list$2 === void 0 ? void 0 : _list$2.namespaceId,
5216
+ version: list[0].version,
5217
+ contract: {
5218
+ endpoint: list[0].endpoint,
5219
+ response: list[0].response
5220
+ }
5221
+ };
5222
+ }
5223
+ } else {
5224
+ var {
5225
+ contractData
5226
+ } = yield ContractApi_searchSingleContract({
5227
+ contractName: "".concat(namespaceName, ".").concat(name),
5228
+ version
5229
+ }); // return undefined if don't found contract
5230
+
5231
+ if (contractData) {
5232
+ var _contractData$namespa, _contractData$namespa2;
5233
+
5234
+ return {
5235
+ name: contractData.name,
5236
+ 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,
5237
+ version: contractData.version,
5238
+ contract: {
5239
+ endpoint: contractData.endpoint,
5240
+ response: contractData.response
5241
+ }
5242
+ };
5243
+ }
5177
5244
  }
5178
5245
  });
5179
5246
  return _fetchFlowApiDefinition2.apply(this, arguments);
@@ -6208,6 +6275,892 @@
6208
6275
  return _standaloneBootstrap.apply(this, arguments);
6209
6276
  }
6210
6277
 
6278
+ /**
6279
+ * Take input from [0, n] and return it as [0, 1]
6280
+ * @hidden
6281
+ */
6282
+ function bound01(n, max) {
6283
+ if (isOnePointZero(n)) {
6284
+ n = '100%';
6285
+ }
6286
+ var isPercent = isPercentage(n);
6287
+ n = max === 360 ? n : Math.min(max, Math.max(0, parseFloat(n)));
6288
+ // Automatically convert percentage into number
6289
+ if (isPercent) {
6290
+ n = parseInt(String(n * max), 10) / 100;
6291
+ }
6292
+ // Handle floating point rounding errors
6293
+ if (Math.abs(n - max) < 0.000001) {
6294
+ return 1;
6295
+ }
6296
+ // Convert into [0, 1] range if it isn't already
6297
+ if (max === 360) {
6298
+ // If n is a hue given in degrees,
6299
+ // wrap around out-of-range values into [0, 360] range
6300
+ // then convert into [0, 1].
6301
+ n = (n < 0 ? (n % max) + max : n % max) / parseFloat(String(max));
6302
+ }
6303
+ else {
6304
+ // If n not a hue given in degrees
6305
+ // Convert into [0, 1] range if it isn't already.
6306
+ n = (n % max) / parseFloat(String(max));
6307
+ }
6308
+ return n;
6309
+ }
6310
+ /**
6311
+ * Need to handle 1.0 as 100%, since once it is a number, there is no difference between it and 1
6312
+ * <http://stackoverflow.com/questions/7422072/javascript-how-to-detect-number-as-a-decimal-including-1-0>
6313
+ * @hidden
6314
+ */
6315
+ function isOnePointZero(n) {
6316
+ return typeof n === 'string' && n.indexOf('.') !== -1 && parseFloat(n) === 1;
6317
+ }
6318
+ /**
6319
+ * Check to see if string passed in is a percentage
6320
+ * @hidden
6321
+ */
6322
+ function isPercentage(n) {
6323
+ return typeof n === 'string' && n.indexOf('%') !== -1;
6324
+ }
6325
+ /**
6326
+ * Return a valid alpha value [0,1] with all invalid values being set to 1
6327
+ * @hidden
6328
+ */
6329
+ function boundAlpha(a) {
6330
+ a = parseFloat(a);
6331
+ if (isNaN(a) || a < 0 || a > 1) {
6332
+ a = 1;
6333
+ }
6334
+ return a;
6335
+ }
6336
+ /**
6337
+ * Replace a decimal with it's percentage value
6338
+ * @hidden
6339
+ */
6340
+ function convertToPercentage(n) {
6341
+ if (n <= 1) {
6342
+ return Number(n) * 100 + "%";
6343
+ }
6344
+ return n;
6345
+ }
6346
+ /**
6347
+ * Force a hex value to have 2 characters
6348
+ * @hidden
6349
+ */
6350
+ function pad2(c) {
6351
+ return c.length === 1 ? '0' + c : String(c);
6352
+ }
6353
+
6354
+ // `rgbToHsl`, `rgbToHsv`, `hslToRgb`, `hsvToRgb` modified from:
6355
+ // <http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript>
6356
+ /**
6357
+ * Handle bounds / percentage checking to conform to CSS color spec
6358
+ * <http://www.w3.org/TR/css3-color/>
6359
+ * *Assumes:* r, g, b in [0, 255] or [0, 1]
6360
+ * *Returns:* { r, g, b } in [0, 255]
6361
+ */
6362
+ function rgbToRgb(r, g, b) {
6363
+ return {
6364
+ r: bound01(r, 255) * 255,
6365
+ g: bound01(g, 255) * 255,
6366
+ b: bound01(b, 255) * 255,
6367
+ };
6368
+ }
6369
+ function hue2rgb(p, q, t) {
6370
+ if (t < 0) {
6371
+ t += 1;
6372
+ }
6373
+ if (t > 1) {
6374
+ t -= 1;
6375
+ }
6376
+ if (t < 1 / 6) {
6377
+ return p + (q - p) * (6 * t);
6378
+ }
6379
+ if (t < 1 / 2) {
6380
+ return q;
6381
+ }
6382
+ if (t < 2 / 3) {
6383
+ return p + (q - p) * (2 / 3 - t) * 6;
6384
+ }
6385
+ return p;
6386
+ }
6387
+ /**
6388
+ * Converts an HSL color value to RGB.
6389
+ *
6390
+ * *Assumes:* h is contained in [0, 1] or [0, 360] and s and l are contained [0, 1] or [0, 100]
6391
+ * *Returns:* { r, g, b } in the set [0, 255]
6392
+ */
6393
+ function hslToRgb(h, s, l) {
6394
+ var r;
6395
+ var g;
6396
+ var b;
6397
+ h = bound01(h, 360);
6398
+ s = bound01(s, 100);
6399
+ l = bound01(l, 100);
6400
+ if (s === 0) {
6401
+ // achromatic
6402
+ g = l;
6403
+ b = l;
6404
+ r = l;
6405
+ }
6406
+ else {
6407
+ var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
6408
+ var p = 2 * l - q;
6409
+ r = hue2rgb(p, q, h + 1 / 3);
6410
+ g = hue2rgb(p, q, h);
6411
+ b = hue2rgb(p, q, h - 1 / 3);
6412
+ }
6413
+ return { r: r * 255, g: g * 255, b: b * 255 };
6414
+ }
6415
+ /**
6416
+ * Converts an RGB color value to HSV
6417
+ *
6418
+ * *Assumes:* r, g, and b are contained in the set [0, 255] or [0, 1]
6419
+ * *Returns:* { h, s, v } in [0,1]
6420
+ */
6421
+ function rgbToHsv(r, g, b) {
6422
+ r = bound01(r, 255);
6423
+ g = bound01(g, 255);
6424
+ b = bound01(b, 255);
6425
+ var max = Math.max(r, g, b);
6426
+ var min = Math.min(r, g, b);
6427
+ var h = 0;
6428
+ var v = max;
6429
+ var d = max - min;
6430
+ var s = max === 0 ? 0 : d / max;
6431
+ if (max === min) {
6432
+ h = 0; // achromatic
6433
+ }
6434
+ else {
6435
+ switch (max) {
6436
+ case r:
6437
+ h = (g - b) / d + (g < b ? 6 : 0);
6438
+ break;
6439
+ case g:
6440
+ h = (b - r) / d + 2;
6441
+ break;
6442
+ case b:
6443
+ h = (r - g) / d + 4;
6444
+ break;
6445
+ }
6446
+ h /= 6;
6447
+ }
6448
+ return { h: h, s: s, v: v };
6449
+ }
6450
+ /**
6451
+ * Converts an HSV color value to RGB.
6452
+ *
6453
+ * *Assumes:* h is contained in [0, 1] or [0, 360] and s and v are contained in [0, 1] or [0, 100]
6454
+ * *Returns:* { r, g, b } in the set [0, 255]
6455
+ */
6456
+ function hsvToRgb(h, s, v) {
6457
+ h = bound01(h, 360) * 6;
6458
+ s = bound01(s, 100);
6459
+ v = bound01(v, 100);
6460
+ var i = Math.floor(h);
6461
+ var f = h - i;
6462
+ var p = v * (1 - s);
6463
+ var q = v * (1 - f * s);
6464
+ var t = v * (1 - (1 - f) * s);
6465
+ var mod = i % 6;
6466
+ var r = [v, q, p, p, t, v][mod];
6467
+ var g = [t, v, v, q, p, p][mod];
6468
+ var b = [p, p, t, v, v, q][mod];
6469
+ return { r: r * 255, g: g * 255, b: b * 255 };
6470
+ }
6471
+ /**
6472
+ * Converts an RGB color to hex
6473
+ *
6474
+ * Assumes r, g, and b are contained in the set [0, 255]
6475
+ * Returns a 3 or 6 character hex
6476
+ */
6477
+ function rgbToHex(r, g, b, allow3Char) {
6478
+ var hex = [
6479
+ pad2(Math.round(r).toString(16)),
6480
+ pad2(Math.round(g).toString(16)),
6481
+ pad2(Math.round(b).toString(16)),
6482
+ ];
6483
+ // Return a 3 character hex if possible
6484
+ if (allow3Char &&
6485
+ hex[0].startsWith(hex[0].charAt(1)) &&
6486
+ hex[1].startsWith(hex[1].charAt(1)) &&
6487
+ hex[2].startsWith(hex[2].charAt(1))) {
6488
+ return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0);
6489
+ }
6490
+ return hex.join('');
6491
+ }
6492
+ /** Converts a hex value to a decimal */
6493
+ function convertHexToDecimal(h) {
6494
+ return parseIntFromHex(h) / 255;
6495
+ }
6496
+ /** Parse a base-16 hex value into a base-10 integer */
6497
+ function parseIntFromHex(val) {
6498
+ return parseInt(val, 16);
6499
+ }
6500
+
6501
+ // https://github.com/bahamas10/css-color-names/blob/master/css-color-names.json
6502
+ /**
6503
+ * @hidden
6504
+ */
6505
+ var names = {
6506
+ aliceblue: '#f0f8ff',
6507
+ antiquewhite: '#faebd7',
6508
+ aqua: '#00ffff',
6509
+ aquamarine: '#7fffd4',
6510
+ azure: '#f0ffff',
6511
+ beige: '#f5f5dc',
6512
+ bisque: '#ffe4c4',
6513
+ black: '#000000',
6514
+ blanchedalmond: '#ffebcd',
6515
+ blue: '#0000ff',
6516
+ blueviolet: '#8a2be2',
6517
+ brown: '#a52a2a',
6518
+ burlywood: '#deb887',
6519
+ cadetblue: '#5f9ea0',
6520
+ chartreuse: '#7fff00',
6521
+ chocolate: '#d2691e',
6522
+ coral: '#ff7f50',
6523
+ cornflowerblue: '#6495ed',
6524
+ cornsilk: '#fff8dc',
6525
+ crimson: '#dc143c',
6526
+ cyan: '#00ffff',
6527
+ darkblue: '#00008b',
6528
+ darkcyan: '#008b8b',
6529
+ darkgoldenrod: '#b8860b',
6530
+ darkgray: '#a9a9a9',
6531
+ darkgreen: '#006400',
6532
+ darkgrey: '#a9a9a9',
6533
+ darkkhaki: '#bdb76b',
6534
+ darkmagenta: '#8b008b',
6535
+ darkolivegreen: '#556b2f',
6536
+ darkorange: '#ff8c00',
6537
+ darkorchid: '#9932cc',
6538
+ darkred: '#8b0000',
6539
+ darksalmon: '#e9967a',
6540
+ darkseagreen: '#8fbc8f',
6541
+ darkslateblue: '#483d8b',
6542
+ darkslategray: '#2f4f4f',
6543
+ darkslategrey: '#2f4f4f',
6544
+ darkturquoise: '#00ced1',
6545
+ darkviolet: '#9400d3',
6546
+ deeppink: '#ff1493',
6547
+ deepskyblue: '#00bfff',
6548
+ dimgray: '#696969',
6549
+ dimgrey: '#696969',
6550
+ dodgerblue: '#1e90ff',
6551
+ firebrick: '#b22222',
6552
+ floralwhite: '#fffaf0',
6553
+ forestgreen: '#228b22',
6554
+ fuchsia: '#ff00ff',
6555
+ gainsboro: '#dcdcdc',
6556
+ ghostwhite: '#f8f8ff',
6557
+ goldenrod: '#daa520',
6558
+ gold: '#ffd700',
6559
+ gray: '#808080',
6560
+ green: '#008000',
6561
+ greenyellow: '#adff2f',
6562
+ grey: '#808080',
6563
+ honeydew: '#f0fff0',
6564
+ hotpink: '#ff69b4',
6565
+ indianred: '#cd5c5c',
6566
+ indigo: '#4b0082',
6567
+ ivory: '#fffff0',
6568
+ khaki: '#f0e68c',
6569
+ lavenderblush: '#fff0f5',
6570
+ lavender: '#e6e6fa',
6571
+ lawngreen: '#7cfc00',
6572
+ lemonchiffon: '#fffacd',
6573
+ lightblue: '#add8e6',
6574
+ lightcoral: '#f08080',
6575
+ lightcyan: '#e0ffff',
6576
+ lightgoldenrodyellow: '#fafad2',
6577
+ lightgray: '#d3d3d3',
6578
+ lightgreen: '#90ee90',
6579
+ lightgrey: '#d3d3d3',
6580
+ lightpink: '#ffb6c1',
6581
+ lightsalmon: '#ffa07a',
6582
+ lightseagreen: '#20b2aa',
6583
+ lightskyblue: '#87cefa',
6584
+ lightslategray: '#778899',
6585
+ lightslategrey: '#778899',
6586
+ lightsteelblue: '#b0c4de',
6587
+ lightyellow: '#ffffe0',
6588
+ lime: '#00ff00',
6589
+ limegreen: '#32cd32',
6590
+ linen: '#faf0e6',
6591
+ magenta: '#ff00ff',
6592
+ maroon: '#800000',
6593
+ mediumaquamarine: '#66cdaa',
6594
+ mediumblue: '#0000cd',
6595
+ mediumorchid: '#ba55d3',
6596
+ mediumpurple: '#9370db',
6597
+ mediumseagreen: '#3cb371',
6598
+ mediumslateblue: '#7b68ee',
6599
+ mediumspringgreen: '#00fa9a',
6600
+ mediumturquoise: '#48d1cc',
6601
+ mediumvioletred: '#c71585',
6602
+ midnightblue: '#191970',
6603
+ mintcream: '#f5fffa',
6604
+ mistyrose: '#ffe4e1',
6605
+ moccasin: '#ffe4b5',
6606
+ navajowhite: '#ffdead',
6607
+ navy: '#000080',
6608
+ oldlace: '#fdf5e6',
6609
+ olive: '#808000',
6610
+ olivedrab: '#6b8e23',
6611
+ orange: '#ffa500',
6612
+ orangered: '#ff4500',
6613
+ orchid: '#da70d6',
6614
+ palegoldenrod: '#eee8aa',
6615
+ palegreen: '#98fb98',
6616
+ paleturquoise: '#afeeee',
6617
+ palevioletred: '#db7093',
6618
+ papayawhip: '#ffefd5',
6619
+ peachpuff: '#ffdab9',
6620
+ peru: '#cd853f',
6621
+ pink: '#ffc0cb',
6622
+ plum: '#dda0dd',
6623
+ powderblue: '#b0e0e6',
6624
+ purple: '#800080',
6625
+ rebeccapurple: '#663399',
6626
+ red: '#ff0000',
6627
+ rosybrown: '#bc8f8f',
6628
+ royalblue: '#4169e1',
6629
+ saddlebrown: '#8b4513',
6630
+ salmon: '#fa8072',
6631
+ sandybrown: '#f4a460',
6632
+ seagreen: '#2e8b57',
6633
+ seashell: '#fff5ee',
6634
+ sienna: '#a0522d',
6635
+ silver: '#c0c0c0',
6636
+ skyblue: '#87ceeb',
6637
+ slateblue: '#6a5acd',
6638
+ slategray: '#708090',
6639
+ slategrey: '#708090',
6640
+ snow: '#fffafa',
6641
+ springgreen: '#00ff7f',
6642
+ steelblue: '#4682b4',
6643
+ tan: '#d2b48c',
6644
+ teal: '#008080',
6645
+ thistle: '#d8bfd8',
6646
+ tomato: '#ff6347',
6647
+ turquoise: '#40e0d0',
6648
+ violet: '#ee82ee',
6649
+ wheat: '#f5deb3',
6650
+ white: '#ffffff',
6651
+ whitesmoke: '#f5f5f5',
6652
+ yellow: '#ffff00',
6653
+ yellowgreen: '#9acd32',
6654
+ };
6655
+
6656
+ /**
6657
+ * Given a string or object, convert that input to RGB
6658
+ *
6659
+ * Possible string inputs:
6660
+ * ```
6661
+ * "red"
6662
+ * "#f00" or "f00"
6663
+ * "#ff0000" or "ff0000"
6664
+ * "#ff000000" or "ff000000"
6665
+ * "rgb 255 0 0" or "rgb (255, 0, 0)"
6666
+ * "rgb 1.0 0 0" or "rgb (1, 0, 0)"
6667
+ * "rgba (255, 0, 0, 1)" or "rgba 255, 0, 0, 1"
6668
+ * "rgba (1.0, 0, 0, 1)" or "rgba 1.0, 0, 0, 1"
6669
+ * "hsl(0, 100%, 50%)" or "hsl 0 100% 50%"
6670
+ * "hsla(0, 100%, 50%, 1)" or "hsla 0 100% 50%, 1"
6671
+ * "hsv(0, 100%, 100%)" or "hsv 0 100% 100%"
6672
+ * ```
6673
+ */
6674
+ function inputToRGB(color) {
6675
+ var rgb = { r: 0, g: 0, b: 0 };
6676
+ var a = 1;
6677
+ var s = null;
6678
+ var v = null;
6679
+ var l = null;
6680
+ var ok = false;
6681
+ var format = false;
6682
+ if (typeof color === 'string') {
6683
+ color = stringInputToObject(color);
6684
+ }
6685
+ if (typeof color === 'object') {
6686
+ if (isValidCSSUnit(color.r) && isValidCSSUnit(color.g) && isValidCSSUnit(color.b)) {
6687
+ rgb = rgbToRgb(color.r, color.g, color.b);
6688
+ ok = true;
6689
+ format = String(color.r).substr(-1) === '%' ? 'prgb' : 'rgb';
6690
+ }
6691
+ else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.v)) {
6692
+ s = convertToPercentage(color.s);
6693
+ v = convertToPercentage(color.v);
6694
+ rgb = hsvToRgb(color.h, s, v);
6695
+ ok = true;
6696
+ format = 'hsv';
6697
+ }
6698
+ else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.l)) {
6699
+ s = convertToPercentage(color.s);
6700
+ l = convertToPercentage(color.l);
6701
+ rgb = hslToRgb(color.h, s, l);
6702
+ ok = true;
6703
+ format = 'hsl';
6704
+ }
6705
+ if (Object.prototype.hasOwnProperty.call(color, 'a')) {
6706
+ a = color.a;
6707
+ }
6708
+ }
6709
+ a = boundAlpha(a);
6710
+ return {
6711
+ ok: ok,
6712
+ format: color.format || format,
6713
+ r: Math.min(255, Math.max(rgb.r, 0)),
6714
+ g: Math.min(255, Math.max(rgb.g, 0)),
6715
+ b: Math.min(255, Math.max(rgb.b, 0)),
6716
+ a: a,
6717
+ };
6718
+ }
6719
+ // <http://www.w3.org/TR/css3-values/#integers>
6720
+ var CSS_INTEGER = '[-\\+]?\\d+%?';
6721
+ // <http://www.w3.org/TR/css3-values/#number-value>
6722
+ var CSS_NUMBER = '[-\\+]?\\d*\\.\\d+%?';
6723
+ // Allow positive/negative integer/number. Don't capture the either/or, just the entire outcome.
6724
+ var CSS_UNIT = "(?:" + CSS_NUMBER + ")|(?:" + CSS_INTEGER + ")";
6725
+ // Actual matching.
6726
+ // Parentheses and commas are optional, but not required.
6727
+ // Whitespace can take the place of commas or opening paren
6728
+ var PERMISSIVE_MATCH3 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?";
6729
+ var PERMISSIVE_MATCH4 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?";
6730
+ var matchers = {
6731
+ CSS_UNIT: new RegExp(CSS_UNIT),
6732
+ rgb: new RegExp('rgb' + PERMISSIVE_MATCH3),
6733
+ rgba: new RegExp('rgba' + PERMISSIVE_MATCH4),
6734
+ hsl: new RegExp('hsl' + PERMISSIVE_MATCH3),
6735
+ hsla: new RegExp('hsla' + PERMISSIVE_MATCH4),
6736
+ hsv: new RegExp('hsv' + PERMISSIVE_MATCH3),
6737
+ hsva: new RegExp('hsva' + PERMISSIVE_MATCH4),
6738
+ hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
6739
+ hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
6740
+ hex4: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
6741
+ hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
6742
+ };
6743
+ /**
6744
+ * Permissive string parsing. Take in a number of formats, and output an object
6745
+ * based on detected format. Returns `{ r, g, b }` or `{ h, s, l }` or `{ h, s, v}`
6746
+ */
6747
+ function stringInputToObject(color) {
6748
+ color = color.trim().toLowerCase();
6749
+ if (color.length === 0) {
6750
+ return false;
6751
+ }
6752
+ var named = false;
6753
+ if (names[color]) {
6754
+ color = names[color];
6755
+ named = true;
6756
+ }
6757
+ else if (color === 'transparent') {
6758
+ return { r: 0, g: 0, b: 0, a: 0, format: 'name' };
6759
+ }
6760
+ // Try to match string input using regular expressions.
6761
+ // Keep most of the number bounding out of this function - don't worry about [0,1] or [0,100] or [0,360]
6762
+ // Just return an object and let the conversion functions handle that.
6763
+ // This way the result will be the same whether the tinycolor is initialized with string or object.
6764
+ var match = matchers.rgb.exec(color);
6765
+ if (match) {
6766
+ return { r: match[1], g: match[2], b: match[3] };
6767
+ }
6768
+ match = matchers.rgba.exec(color);
6769
+ if (match) {
6770
+ return { r: match[1], g: match[2], b: match[3], a: match[4] };
6771
+ }
6772
+ match = matchers.hsl.exec(color);
6773
+ if (match) {
6774
+ return { h: match[1], s: match[2], l: match[3] };
6775
+ }
6776
+ match = matchers.hsla.exec(color);
6777
+ if (match) {
6778
+ return { h: match[1], s: match[2], l: match[3], a: match[4] };
6779
+ }
6780
+ match = matchers.hsv.exec(color);
6781
+ if (match) {
6782
+ return { h: match[1], s: match[2], v: match[3] };
6783
+ }
6784
+ match = matchers.hsva.exec(color);
6785
+ if (match) {
6786
+ return { h: match[1], s: match[2], v: match[3], a: match[4] };
6787
+ }
6788
+ match = matchers.hex8.exec(color);
6789
+ if (match) {
6790
+ return {
6791
+ r: parseIntFromHex(match[1]),
6792
+ g: parseIntFromHex(match[2]),
6793
+ b: parseIntFromHex(match[3]),
6794
+ a: convertHexToDecimal(match[4]),
6795
+ format: named ? 'name' : 'hex8',
6796
+ };
6797
+ }
6798
+ match = matchers.hex6.exec(color);
6799
+ if (match) {
6800
+ return {
6801
+ r: parseIntFromHex(match[1]),
6802
+ g: parseIntFromHex(match[2]),
6803
+ b: parseIntFromHex(match[3]),
6804
+ format: named ? 'name' : 'hex',
6805
+ };
6806
+ }
6807
+ match = matchers.hex4.exec(color);
6808
+ if (match) {
6809
+ return {
6810
+ r: parseIntFromHex(match[1] + match[1]),
6811
+ g: parseIntFromHex(match[2] + match[2]),
6812
+ b: parseIntFromHex(match[3] + match[3]),
6813
+ a: convertHexToDecimal(match[4] + match[4]),
6814
+ format: named ? 'name' : 'hex8',
6815
+ };
6816
+ }
6817
+ match = matchers.hex3.exec(color);
6818
+ if (match) {
6819
+ return {
6820
+ r: parseIntFromHex(match[1] + match[1]),
6821
+ g: parseIntFromHex(match[2] + match[2]),
6822
+ b: parseIntFromHex(match[3] + match[3]),
6823
+ format: named ? 'name' : 'hex',
6824
+ };
6825
+ }
6826
+ return false;
6827
+ }
6828
+ /**
6829
+ * Check to see if it looks like a CSS unit
6830
+ * (see `matchers` above for definition).
6831
+ */
6832
+ function isValidCSSUnit(color) {
6833
+ return Boolean(matchers.CSS_UNIT.exec(String(color)));
6834
+ }
6835
+
6836
+ var hueStep = 2; // 色相阶梯
6837
+
6838
+ var saturationStep = 0.16; // 饱和度阶梯,浅色部分
6839
+
6840
+ var saturationStep2 = 0.05; // 饱和度阶梯,深色部分
6841
+
6842
+ var brightnessStep1 = 0.05; // 亮度阶梯,浅色部分
6843
+
6844
+ var brightnessStep2 = 0.15; // 亮度阶梯,深色部分
6845
+
6846
+ var lightColorCount = 5; // 浅色数量,主色上
6847
+
6848
+ var darkColorCount = 4; // 深色数量,主色下
6849
+ // 暗色主题颜色映射关系表
6850
+
6851
+ var darkColorMap = [{
6852
+ index: 7,
6853
+ opacity: 0.15
6854
+ }, {
6855
+ index: 6,
6856
+ opacity: 0.25
6857
+ }, {
6858
+ index: 5,
6859
+ opacity: 0.3
6860
+ }, {
6861
+ index: 5,
6862
+ opacity: 0.45
6863
+ }, {
6864
+ index: 5,
6865
+ opacity: 0.65
6866
+ }, {
6867
+ index: 5,
6868
+ opacity: 0.85
6869
+ }, {
6870
+ index: 4,
6871
+ opacity: 0.9
6872
+ }, {
6873
+ index: 3,
6874
+ opacity: 0.95
6875
+ }, {
6876
+ index: 2,
6877
+ opacity: 0.97
6878
+ }, {
6879
+ index: 1,
6880
+ opacity: 0.98
6881
+ }]; // Wrapper function ported from TinyColor.prototype.toHsv
6882
+ // Keep it here because of `hsv.h * 360`
6883
+
6884
+ function toHsv(_ref) {
6885
+ var r = _ref.r,
6886
+ g = _ref.g,
6887
+ b = _ref.b;
6888
+ var hsv = rgbToHsv(r, g, b);
6889
+ return {
6890
+ h: hsv.h * 360,
6891
+ s: hsv.s,
6892
+ v: hsv.v
6893
+ };
6894
+ } // Wrapper function ported from TinyColor.prototype.toHexString
6895
+ // Keep it here because of the prefix `#`
6896
+
6897
+
6898
+ function toHex(_ref2) {
6899
+ var r = _ref2.r,
6900
+ g = _ref2.g,
6901
+ b = _ref2.b;
6902
+ return "#".concat(rgbToHex(r, g, b, false));
6903
+ } // Wrapper function ported from TinyColor.prototype.mix, not treeshakable.
6904
+ // Amount in range [0, 1]
6905
+ // Assume color1 & color2 has no alpha, since the following src code did so.
6906
+
6907
+
6908
+ function mix(rgb1, rgb2, amount) {
6909
+ var p = amount / 100;
6910
+ var rgb = {
6911
+ r: (rgb2.r - rgb1.r) * p + rgb1.r,
6912
+ g: (rgb2.g - rgb1.g) * p + rgb1.g,
6913
+ b: (rgb2.b - rgb1.b) * p + rgb1.b
6914
+ };
6915
+ return rgb;
6916
+ }
6917
+
6918
+ function getHue(hsv, i, light) {
6919
+ var hue; // 根据色相不同,色相转向不同
6920
+
6921
+ if (Math.round(hsv.h) >= 60 && Math.round(hsv.h) <= 240) {
6922
+ hue = light ? Math.round(hsv.h) - hueStep * i : Math.round(hsv.h) + hueStep * i;
6923
+ } else {
6924
+ hue = light ? Math.round(hsv.h) + hueStep * i : Math.round(hsv.h) - hueStep * i;
6925
+ }
6926
+
6927
+ if (hue < 0) {
6928
+ hue += 360;
6929
+ } else if (hue >= 360) {
6930
+ hue -= 360;
6931
+ }
6932
+
6933
+ return hue;
6934
+ }
6935
+
6936
+ function getSaturation(hsv, i, light) {
6937
+ // grey color don't change saturation
6938
+ if (hsv.h === 0 && hsv.s === 0) {
6939
+ return hsv.s;
6940
+ }
6941
+
6942
+ var saturation;
6943
+
6944
+ if (light) {
6945
+ saturation = hsv.s - saturationStep * i;
6946
+ } else if (i === darkColorCount) {
6947
+ saturation = hsv.s + saturationStep;
6948
+ } else {
6949
+ saturation = hsv.s + saturationStep2 * i;
6950
+ } // 边界值修正
6951
+
6952
+
6953
+ if (saturation > 1) {
6954
+ saturation = 1;
6955
+ } // 第一格的 s 限制在 0.06-0.1 之间
6956
+
6957
+
6958
+ if (light && i === lightColorCount && saturation > 0.1) {
6959
+ saturation = 0.1;
6960
+ }
6961
+
6962
+ if (saturation < 0.06) {
6963
+ saturation = 0.06;
6964
+ }
6965
+
6966
+ return Number(saturation.toFixed(2));
6967
+ }
6968
+
6969
+ function getValue(hsv, i, light) {
6970
+ var value;
6971
+
6972
+ if (light) {
6973
+ value = hsv.v + brightnessStep1 * i;
6974
+ } else {
6975
+ value = hsv.v - brightnessStep2 * i;
6976
+ }
6977
+
6978
+ if (value > 1) {
6979
+ value = 1;
6980
+ }
6981
+
6982
+ return Number(value.toFixed(2));
6983
+ }
6984
+
6985
+ function generate(color) {
6986
+ var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
6987
+ var patterns = [];
6988
+ var pColor = inputToRGB(color);
6989
+
6990
+ for (var i = lightColorCount; i > 0; i -= 1) {
6991
+ var hsv = toHsv(pColor);
6992
+ var colorString = toHex(inputToRGB({
6993
+ h: getHue(hsv, i, true),
6994
+ s: getSaturation(hsv, i, true),
6995
+ v: getValue(hsv, i, true)
6996
+ }));
6997
+ patterns.push(colorString);
6998
+ }
6999
+
7000
+ patterns.push(toHex(pColor));
7001
+
7002
+ for (var _i = 1; _i <= darkColorCount; _i += 1) {
7003
+ var _hsv = toHsv(pColor);
7004
+
7005
+ var _colorString = toHex(inputToRGB({
7006
+ h: getHue(_hsv, _i),
7007
+ s: getSaturation(_hsv, _i),
7008
+ v: getValue(_hsv, _i)
7009
+ }));
7010
+
7011
+ patterns.push(_colorString);
7012
+ } // dark theme patterns
7013
+
7014
+
7015
+ if (opts.theme === 'dark') {
7016
+ return darkColorMap.map(function (_ref3) {
7017
+ var index = _ref3.index,
7018
+ opacity = _ref3.opacity;
7019
+ var darkColorString = toHex(mix(inputToRGB(opts.backgroundColor || '#141414'), inputToRGB(patterns[index]), opacity * 100));
7020
+ return darkColorString;
7021
+ });
7022
+ }
7023
+
7024
+ return patterns;
7025
+ }
7026
+
7027
+ var presetPrimaryColors = {
7028
+ red: '#F5222D',
7029
+ volcano: '#FA541C',
7030
+ orange: '#FA8C16',
7031
+ gold: '#FAAD14',
7032
+ yellow: '#FADB14',
7033
+ lime: '#A0D911',
7034
+ green: '#52C41A',
7035
+ cyan: '#13C2C2',
7036
+ blue: '#1890FF',
7037
+ geekblue: '#2F54EB',
7038
+ purple: '#722ED1',
7039
+ magenta: '#EB2F96',
7040
+ grey: '#666666'
7041
+ };
7042
+ var presetPalettes = {};
7043
+ var presetDarkPalettes = {};
7044
+ Object.keys(presetPrimaryColors).forEach(function (key) {
7045
+ presetPalettes[key] = generate(presetPrimaryColors[key]);
7046
+ presetPalettes[key].primary = presetPalettes[key][5]; // dark presetPalettes
7047
+
7048
+ presetDarkPalettes[key] = generate(presetPrimaryColors[key], {
7049
+ theme: 'dark',
7050
+ backgroundColor: '#141414'
7051
+ });
7052
+ presetDarkPalettes[key].primary = presetDarkPalettes[key][5];
7053
+ });
7054
+ presetPalettes.red;
7055
+ presetPalettes.volcano;
7056
+ presetPalettes.gold;
7057
+ presetPalettes.orange;
7058
+ presetPalettes.yellow;
7059
+ presetPalettes.lime;
7060
+ presetPalettes.green;
7061
+ presetPalettes.cyan;
7062
+ presetPalettes.blue;
7063
+ presetPalettes.geekblue;
7064
+ presetPalettes.purple;
7065
+ presetPalettes.magenta;
7066
+ presetPalettes.grey;
7067
+
7068
+ function getStyleByBaseColors(theme, baseColors, backgroundColor) {
7069
+ return (theme === "dark" ? getDarkStyle : getLightStyle)(getCssVariableDefinitionsByPalettes(generatePalettes(baseColors, theme, backgroundColor)));
7070
+ }
7071
+ function getStyleByBrandColor(theme, brandColor) {
7072
+ return (theme === "dark" ? getDarkStyle : getLightStyle)(getCssVariableDefinitionsByBrand(brandColor));
7073
+ }
7074
+ function getStyleByVariables(theme, variables) {
7075
+ return (theme === "dark" ? getDarkStyle : getLightStyle)(getCssVariableDefinitionsByVariables(variables));
7076
+ }
7077
+
7078
+ function getLightStyle(cssVariableDefinitions) {
7079
+ return ":root,\n[data-override-theme=\"light\"] {\n".concat(cssVariableDefinitions, "}");
7080
+ }
7081
+
7082
+ function getDarkStyle(cssVariableDefinitions) {
7083
+ return "html[data-theme=\"dark-v2\"],\n[data-override-theme=\"dark-v2\"] {\n".concat(cssVariableDefinitions, "}");
7084
+ }
7085
+
7086
+ function getCssVariableDefinitionsByPalettes(palettes) {
7087
+ return Object.entries(palettes).flatMap(_ref => {
7088
+ var [colorName, palette] = _ref;
7089
+ ensureBaseColorName(colorName);
7090
+ return palette.map((color, index) => " --palette-".concat(colorName, "-").concat(index + 1, ": ").concat(color, ";")) // Concat an empty string to make a double-line-break for each group of color name.
7091
+ .concat("");
7092
+ }).join("\n");
7093
+ }
7094
+
7095
+ function generatePalettes(baseColors, theme, backgroundColor) {
7096
+ return Object.fromEntries(Object.entries(baseColors).map(_ref2 => {
7097
+ var [colorName, baseColor] = _ref2;
7098
+ return [colorName, generate(baseColor, theme === "dark" ? {
7099
+ theme,
7100
+ backgroundColor
7101
+ } : undefined)];
7102
+ }));
7103
+ }
7104
+
7105
+ function getCssVariableDefinitionsByBrand(color) {
7106
+ if (typeof color === "string") {
7107
+ return " --color-brand: ".concat(color, ";\n");
7108
+ }
7109
+
7110
+ return [" --color-brand: ".concat(color.default, ";"), " --color-brand-hover: ".concat(color.hover, ";"), " --color-brand-active: ".concat(color.active, ";"), ""].join("\n");
7111
+ }
7112
+
7113
+ function getCssVariableDefinitionsByVariables(variables) {
7114
+ return Object.entries(variables).map(_ref3 => {
7115
+ var [name, color] = _ref3;
7116
+ ensureCssVariableName(name);
7117
+ return " ".concat(name, ": ").concat(color, ";");
7118
+ }).concat("").join("\n");
7119
+ }
7120
+
7121
+ function ensureCssVariableName(name) {
7122
+ if (!/^--[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/.test(name)) {
7123
+ throw new Error("Invalid css variable name: ".concat(JSON.stringify(name)));
7124
+ }
7125
+ }
7126
+
7127
+ function ensureBaseColorName(name) {
7128
+ if (!/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(name)) {
7129
+ throw new Error("Invalid base color name: ".concat(JSON.stringify(name)));
7130
+ }
7131
+ }
7132
+
7133
+ function applyColorTheme(options) {
7134
+ var style = [];
7135
+ var themes = ["light", "dark"];
7136
+ themes.forEach(theme => {
7137
+ if (options[theme]) {
7138
+ switch (options.type) {
7139
+ case "brandColor":
7140
+ style.push(getStyleByBrandColor(theme, options[theme]));
7141
+ break;
7142
+
7143
+ case "baseColors":
7144
+ style.push(getStyleByBaseColors(theme, options[theme], options.backgroundColor));
7145
+ break;
7146
+
7147
+ case "variables":
7148
+ style.push(getStyleByVariables(theme, options[theme]));
7149
+ break;
7150
+ }
7151
+ }
7152
+ });
7153
+
7154
+ if (style.length > 0) {
7155
+ var element = document.createElement("style");
7156
+ element.textContent = style.join("\n\n");
7157
+ document.head.appendChild(element);
7158
+ return () => {
7159
+ element.remove();
7160
+ };
7161
+ }
7162
+ }
7163
+
6211
7164
  class Kernel {
6212
7165
  constructor() {
6213
7166
  _defineProperty__default["default"](this, "mountPoints", void 0);
@@ -6257,6 +7210,8 @@
6257
7210
  var _this = this;
6258
7211
 
6259
7212
  return _asyncToGenerator__default["default"](function* () {
7213
+ var _this$bootstrapData$s, _this$bootstrapData$s2;
7214
+
6260
7215
  _this.mountPoints = mountPoints;
6261
7216
  yield Promise.all([_this.loadCheckLogin(), _this.loadMicroApps()]);
6262
7217
 
@@ -6264,6 +7219,8 @@
6264
7219
  throw new Error("No storyboard were found.");
6265
7220
  }
6266
7221
 
7222
+ generateColorTheme((_this$bootstrapData$s = _this.bootstrapData.settings) === null || _this$bootstrapData$s === void 0 ? void 0 : (_this$bootstrapData$s2 = _this$bootstrapData$s.misc) === null || _this$bootstrapData$s2 === void 0 ? void 0 : _this$bootstrapData$s2.theme);
7223
+
6267
7224
  if (isLoggedIn()) {
6268
7225
  _this.loadSharedData();
6269
7226
  }
@@ -6818,9 +7775,9 @@
6818
7775
  }
6819
7776
 
6820
7777
  getFeatureFlags() {
6821
- var _this$bootstrapData, _this$bootstrapData$s;
7778
+ var _this$bootstrapData, _this$bootstrapData$s3;
6822
7779
 
6823
- return Object.assign({}, (_this$bootstrapData = this.bootstrapData) === null || _this$bootstrapData === void 0 ? void 0 : (_this$bootstrapData$s = _this$bootstrapData.settings) === null || _this$bootstrapData$s === void 0 ? void 0 : _this$bootstrapData$s.featureFlags);
7780
+ return Object.assign({}, (_this$bootstrapData = this.bootstrapData) === null || _this$bootstrapData === void 0 ? void 0 : (_this$bootstrapData$s3 = _this$bootstrapData.settings) === null || _this$bootstrapData$s3 === void 0 ? void 0 : _this$bootstrapData$s3.featureFlags);
6824
7781
  }
6825
7782
 
6826
7783
  getStandaloneMenus(menuId) {
@@ -6889,6 +7846,24 @@
6889
7846
  return brickUtils.loadScript(src, window.PUBLIC_ROOT);
6890
7847
  }
6891
7848
 
7849
+ function generateColorTheme(theme) {
7850
+ if (!theme) {
7851
+ return;
7852
+ } else if (theme.brandColor) {
7853
+ applyColorTheme(_objectSpread__default["default"]({
7854
+ type: "brandColor"
7855
+ }, theme.brandColor));
7856
+ } else if (theme.baseColors) {
7857
+ applyColorTheme(_objectSpread__default["default"]({
7858
+ type: "baseColors"
7859
+ }, theme.baseColors));
7860
+ } else if (theme.variables) {
7861
+ applyColorTheme(_objectSpread__default["default"]({
7862
+ type: "variables"
7863
+ }, theme.variables));
7864
+ }
7865
+ }
7866
+
6892
7867
  /*! (c) Andrea Giammarchi - ISC */
6893
7868
  var self = {};
6894
7869
 
@@ -9194,36 +10169,6 @@
9194
10169
  return defaultCollapsed || defaultCollapsedBreakpoint && document.documentElement.clientWidth < defaultCollapsedBreakpoint;
9195
10170
  }
9196
10171
 
9197
- var mocks = {
9198
- mockId: null,
9199
- mockList: []
9200
- };
9201
- function registerMock(useMocks) {
9202
- var _useMocks$mockList;
9203
-
9204
- if (useMocks) mocks = _objectSpread__default["default"](_objectSpread__default["default"]({}, useMocks), {}, {
9205
- mockList: (_useMocks$mockList = useMocks.mockList) === null || _useMocks$mockList === void 0 ? void 0 : _useMocks$mockList.map(item => _objectSpread__default["default"](_objectSpread__default["default"]({}, item), {}, {
9206
- uri: item.uri.replace(/(easyops\.api\.)(.+?)\/(.+)/, (_match, p1, p2, p3) => {
9207
- return "(".concat(p1, ")?").concat(p2, "(@\\d+\\.\\d+\\.\\d+)?/").concat(p3, "$");
9208
- }).replace(/:\w+/g, "([^/]+)")
9209
- }))
9210
- });
9211
- }
9212
- var getMockInfo = requestUrl => {
9213
- var item = mocks.mockList.find(item => new RegExp(item.uri).test(requestUrl));
9214
-
9215
- if (item) {
9216
- return {
9217
- url: requestUrl.replace(/(api\/gateway\/.+?)(@\d+\.\d+\.\d+)?\/(.+)/, (_match, p1, _p2, p3) => {
9218
- return "".concat(p1, "/").concat(p3);
9219
- }).replace(/(api\/gateway)/, "api/gateway/mock_server.proxy.".concat(mocks.mockId)),
9220
- mockId: mocks.mockId
9221
- };
9222
- }
9223
-
9224
- return;
9225
- };
9226
-
9227
10172
  class Router {
9228
10173
  constructor(kernel) {
9229
10174
  _defineProperty__default["default"](this, "defaultCollapsed", false);
@@ -9389,7 +10334,7 @@
9389
10334
  var _this3 = this;
9390
10335
 
9391
10336
  return _asyncToGenerator__default["default"](function* () {
9392
- var _apiAnalyzer$getInsta;
10337
+ var _apiAnalyzer$getInsta, _currentApp$theme;
9393
10338
 
9394
10339
  _this3.state = "initial";
9395
10340
  _this3.renderId = lodash.uniqueId("render-id-");
@@ -9440,6 +10385,8 @@
9440
10385
  var legacy = currentApp ? currentApp.legacy : undefined;
9441
10386
  _this3.kernel.nextApp = currentApp;
9442
10387
  var layoutType = (currentApp === null || currentApp === void 0 ? void 0 : currentApp.layoutType) || "console";
10388
+ setTheme((_currentApp$theme = currentApp === null || currentApp === void 0 ? void 0 : currentApp.theme) !== null && _currentApp$theme !== void 0 ? _currentApp$theme : "light");
10389
+ setMode("default");
9443
10390
  devtoolsHookEmit("rendering");
9444
10391
  unmountTree(mountPoints.bg);
9445
10392
 
@@ -9450,7 +10397,7 @@
9450
10397
  };
9451
10398
 
9452
10399
  if (storyboard) {
9453
- var _currentApp$breadcrum, _currentApp$breadcrum2, _currentApp$theme;
10400
+ var _currentApp$breadcrum, _currentApp$breadcrum2;
9454
10401
 
9455
10402
  if (appChanged && currentApp.id && isLoggedIn()) {
9456
10403
  var usedCustomApis = brickUtils.mapCustomApisToNameAndNamespace(brickUtils.scanCustomApisInStoryboard(storyboard));
@@ -9547,10 +10494,8 @@
9547
10494
  _this3.kernel.unsetBars({
9548
10495
  appChanged,
9549
10496
  legacy: actualLegacy
9550
- });
10497
+ }); // There is a window to set theme and mode by `lifeCycle.onBeforePageLoad`.
9551
10498
 
9552
- setTheme((_currentApp$theme = currentApp.theme) !== null && _currentApp$theme !== void 0 ? _currentApp$theme : "light");
9553
- setMode("default"); // There is a window to set theme and mode by `lifeCycle.onBeforePageLoad`.
9554
10499
 
9555
10500
  _this3.locationContext.handleBeforePageLoad();
9556
10501