@abtnode/core 1.16.51 → 1.16.52-beta-20250909-073849-4e392ab1
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/lib/api/team.js +24 -0
- package/lib/blocklet/migration-dist/migration.cjs +456 -456
- package/lib/index.js +3 -0
- package/lib/states/user.js +78 -4
- package/lib/util/docker/generate-cluster-node-script.js +53 -0
- package/lib/util/docker/parse-docker-options-from-pm2.js +22 -0
- package/package.json +27 -27
package/lib/api/team.js
CHANGED
|
@@ -699,6 +699,30 @@ class TeamAPI extends EventEmitter {
|
|
|
699
699
|
return state.isFollowing(followerDid, userDids);
|
|
700
700
|
}
|
|
701
701
|
|
|
702
|
+
async getUserInvites({ teamDid, userDid, paging, sort, options = {} }, context = {}) {
|
|
703
|
+
try {
|
|
704
|
+
if (paging?.pageSize > MAX_USER_PAGE_SIZE) {
|
|
705
|
+
throw new CustomError(400, `Length of users should not exceed ${MAX_USER_PAGE_SIZE} per page`);
|
|
706
|
+
}
|
|
707
|
+
const state = await this.getUserState(teamDid);
|
|
708
|
+
const { users, paging: resultPaging } = await state.getInvitees(userDid, { paging, sort, ...options }, context);
|
|
709
|
+
// 处理头像
|
|
710
|
+
const blocklet = await getBlocklet({ did: teamDid, states: this.states, dataDirs: this.dataDirs });
|
|
711
|
+
users.forEach((user) => {
|
|
712
|
+
if (user && user?.avatar && user?.avatar?.startsWith(USER_AVATAR_URL_PREFIX)) {
|
|
713
|
+
user.avatar = `${getFederatedUserAvatarUrl(user.avatar, blocklet)}?imageFilter=resize&w=48&h=48`;
|
|
714
|
+
}
|
|
715
|
+
});
|
|
716
|
+
return {
|
|
717
|
+
users,
|
|
718
|
+
paging: resultPaging,
|
|
719
|
+
};
|
|
720
|
+
} catch (error) {
|
|
721
|
+
logger.error('Failed to get user invites', { teamDid, userDid, error });
|
|
722
|
+
throw error;
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
|
|
702
726
|
async updateUser({ teamDid, user }) {
|
|
703
727
|
const state = await this.getUserState(teamDid);
|
|
704
728
|
const exist = await state.getUserByDid(user.did);
|
|
@@ -5429,457 +5429,11 @@ SafeBuffer.allocUnsafeSlow = function (size) {
|
|
|
5429
5429
|
|
|
5430
5430
|
/***/ }),
|
|
5431
5431
|
|
|
5432
|
-
/***/
|
|
5433
|
-
/***/ ((module) => {
|
|
5434
|
-
|
|
5435
|
-
"use strict";
|
|
5436
|
-
|
|
5437
|
-
|
|
5438
|
-
module.exports = {
|
|
5439
|
-
"aliceblue": [240, 248, 255],
|
|
5440
|
-
"antiquewhite": [250, 235, 215],
|
|
5441
|
-
"aqua": [0, 255, 255],
|
|
5442
|
-
"aquamarine": [127, 255, 212],
|
|
5443
|
-
"azure": [240, 255, 255],
|
|
5444
|
-
"beige": [245, 245, 220],
|
|
5445
|
-
"bisque": [255, 228, 196],
|
|
5446
|
-
"black": [0, 0, 0],
|
|
5447
|
-
"blanchedalmond": [255, 235, 205],
|
|
5448
|
-
"blue": [0, 0, 255],
|
|
5449
|
-
"blueviolet": [138, 43, 226],
|
|
5450
|
-
"brown": [165, 42, 42],
|
|
5451
|
-
"burlywood": [222, 184, 135],
|
|
5452
|
-
"cadetblue": [95, 158, 160],
|
|
5453
|
-
"chartreuse": [127, 255, 0],
|
|
5454
|
-
"chocolate": [210, 105, 30],
|
|
5455
|
-
"coral": [255, 127, 80],
|
|
5456
|
-
"cornflowerblue": [100, 149, 237],
|
|
5457
|
-
"cornsilk": [255, 248, 220],
|
|
5458
|
-
"crimson": [220, 20, 60],
|
|
5459
|
-
"cyan": [0, 255, 255],
|
|
5460
|
-
"darkblue": [0, 0, 139],
|
|
5461
|
-
"darkcyan": [0, 139, 139],
|
|
5462
|
-
"darkgoldenrod": [184, 134, 11],
|
|
5463
|
-
"darkgray": [169, 169, 169],
|
|
5464
|
-
"darkgreen": [0, 100, 0],
|
|
5465
|
-
"darkgrey": [169, 169, 169],
|
|
5466
|
-
"darkkhaki": [189, 183, 107],
|
|
5467
|
-
"darkmagenta": [139, 0, 139],
|
|
5468
|
-
"darkolivegreen": [85, 107, 47],
|
|
5469
|
-
"darkorange": [255, 140, 0],
|
|
5470
|
-
"darkorchid": [153, 50, 204],
|
|
5471
|
-
"darkred": [139, 0, 0],
|
|
5472
|
-
"darksalmon": [233, 150, 122],
|
|
5473
|
-
"darkseagreen": [143, 188, 143],
|
|
5474
|
-
"darkslateblue": [72, 61, 139],
|
|
5475
|
-
"darkslategray": [47, 79, 79],
|
|
5476
|
-
"darkslategrey": [47, 79, 79],
|
|
5477
|
-
"darkturquoise": [0, 206, 209],
|
|
5478
|
-
"darkviolet": [148, 0, 211],
|
|
5479
|
-
"deeppink": [255, 20, 147],
|
|
5480
|
-
"deepskyblue": [0, 191, 255],
|
|
5481
|
-
"dimgray": [105, 105, 105],
|
|
5482
|
-
"dimgrey": [105, 105, 105],
|
|
5483
|
-
"dodgerblue": [30, 144, 255],
|
|
5484
|
-
"firebrick": [178, 34, 34],
|
|
5485
|
-
"floralwhite": [255, 250, 240],
|
|
5486
|
-
"forestgreen": [34, 139, 34],
|
|
5487
|
-
"fuchsia": [255, 0, 255],
|
|
5488
|
-
"gainsboro": [220, 220, 220],
|
|
5489
|
-
"ghostwhite": [248, 248, 255],
|
|
5490
|
-
"gold": [255, 215, 0],
|
|
5491
|
-
"goldenrod": [218, 165, 32],
|
|
5492
|
-
"gray": [128, 128, 128],
|
|
5493
|
-
"green": [0, 128, 0],
|
|
5494
|
-
"greenyellow": [173, 255, 47],
|
|
5495
|
-
"grey": [128, 128, 128],
|
|
5496
|
-
"honeydew": [240, 255, 240],
|
|
5497
|
-
"hotpink": [255, 105, 180],
|
|
5498
|
-
"indianred": [205, 92, 92],
|
|
5499
|
-
"indigo": [75, 0, 130],
|
|
5500
|
-
"ivory": [255, 255, 240],
|
|
5501
|
-
"khaki": [240, 230, 140],
|
|
5502
|
-
"lavender": [230, 230, 250],
|
|
5503
|
-
"lavenderblush": [255, 240, 245],
|
|
5504
|
-
"lawngreen": [124, 252, 0],
|
|
5505
|
-
"lemonchiffon": [255, 250, 205],
|
|
5506
|
-
"lightblue": [173, 216, 230],
|
|
5507
|
-
"lightcoral": [240, 128, 128],
|
|
5508
|
-
"lightcyan": [224, 255, 255],
|
|
5509
|
-
"lightgoldenrodyellow": [250, 250, 210],
|
|
5510
|
-
"lightgray": [211, 211, 211],
|
|
5511
|
-
"lightgreen": [144, 238, 144],
|
|
5512
|
-
"lightgrey": [211, 211, 211],
|
|
5513
|
-
"lightpink": [255, 182, 193],
|
|
5514
|
-
"lightsalmon": [255, 160, 122],
|
|
5515
|
-
"lightseagreen": [32, 178, 170],
|
|
5516
|
-
"lightskyblue": [135, 206, 250],
|
|
5517
|
-
"lightslategray": [119, 136, 153],
|
|
5518
|
-
"lightslategrey": [119, 136, 153],
|
|
5519
|
-
"lightsteelblue": [176, 196, 222],
|
|
5520
|
-
"lightyellow": [255, 255, 224],
|
|
5521
|
-
"lime": [0, 255, 0],
|
|
5522
|
-
"limegreen": [50, 205, 50],
|
|
5523
|
-
"linen": [250, 240, 230],
|
|
5524
|
-
"magenta": [255, 0, 255],
|
|
5525
|
-
"maroon": [128, 0, 0],
|
|
5526
|
-
"mediumaquamarine": [102, 205, 170],
|
|
5527
|
-
"mediumblue": [0, 0, 205],
|
|
5528
|
-
"mediumorchid": [186, 85, 211],
|
|
5529
|
-
"mediumpurple": [147, 112, 219],
|
|
5530
|
-
"mediumseagreen": [60, 179, 113],
|
|
5531
|
-
"mediumslateblue": [123, 104, 238],
|
|
5532
|
-
"mediumspringgreen": [0, 250, 154],
|
|
5533
|
-
"mediumturquoise": [72, 209, 204],
|
|
5534
|
-
"mediumvioletred": [199, 21, 133],
|
|
5535
|
-
"midnightblue": [25, 25, 112],
|
|
5536
|
-
"mintcream": [245, 255, 250],
|
|
5537
|
-
"mistyrose": [255, 228, 225],
|
|
5538
|
-
"moccasin": [255, 228, 181],
|
|
5539
|
-
"navajowhite": [255, 222, 173],
|
|
5540
|
-
"navy": [0, 0, 128],
|
|
5541
|
-
"oldlace": [253, 245, 230],
|
|
5542
|
-
"olive": [128, 128, 0],
|
|
5543
|
-
"olivedrab": [107, 142, 35],
|
|
5544
|
-
"orange": [255, 165, 0],
|
|
5545
|
-
"orangered": [255, 69, 0],
|
|
5546
|
-
"orchid": [218, 112, 214],
|
|
5547
|
-
"palegoldenrod": [238, 232, 170],
|
|
5548
|
-
"palegreen": [152, 251, 152],
|
|
5549
|
-
"paleturquoise": [175, 238, 238],
|
|
5550
|
-
"palevioletred": [219, 112, 147],
|
|
5551
|
-
"papayawhip": [255, 239, 213],
|
|
5552
|
-
"peachpuff": [255, 218, 185],
|
|
5553
|
-
"peru": [205, 133, 63],
|
|
5554
|
-
"pink": [255, 192, 203],
|
|
5555
|
-
"plum": [221, 160, 221],
|
|
5556
|
-
"powderblue": [176, 224, 230],
|
|
5557
|
-
"purple": [128, 0, 128],
|
|
5558
|
-
"rebeccapurple": [102, 51, 153],
|
|
5559
|
-
"red": [255, 0, 0],
|
|
5560
|
-
"rosybrown": [188, 143, 143],
|
|
5561
|
-
"royalblue": [65, 105, 225],
|
|
5562
|
-
"saddlebrown": [139, 69, 19],
|
|
5563
|
-
"salmon": [250, 128, 114],
|
|
5564
|
-
"sandybrown": [244, 164, 96],
|
|
5565
|
-
"seagreen": [46, 139, 87],
|
|
5566
|
-
"seashell": [255, 245, 238],
|
|
5567
|
-
"sienna": [160, 82, 45],
|
|
5568
|
-
"silver": [192, 192, 192],
|
|
5569
|
-
"skyblue": [135, 206, 235],
|
|
5570
|
-
"slateblue": [106, 90, 205],
|
|
5571
|
-
"slategray": [112, 128, 144],
|
|
5572
|
-
"slategrey": [112, 128, 144],
|
|
5573
|
-
"snow": [255, 250, 250],
|
|
5574
|
-
"springgreen": [0, 255, 127],
|
|
5575
|
-
"steelblue": [70, 130, 180],
|
|
5576
|
-
"tan": [210, 180, 140],
|
|
5577
|
-
"teal": [0, 128, 128],
|
|
5578
|
-
"thistle": [216, 191, 216],
|
|
5579
|
-
"tomato": [255, 99, 71],
|
|
5580
|
-
"turquoise": [64, 224, 208],
|
|
5581
|
-
"violet": [238, 130, 238],
|
|
5582
|
-
"wheat": [245, 222, 179],
|
|
5583
|
-
"white": [255, 255, 255],
|
|
5584
|
-
"whitesmoke": [245, 245, 245],
|
|
5585
|
-
"yellow": [255, 255, 0],
|
|
5586
|
-
"yellowgreen": [154, 205, 50]
|
|
5587
|
-
};
|
|
5588
|
-
|
|
5589
|
-
|
|
5590
|
-
/***/ }),
|
|
5591
|
-
|
|
5592
|
-
/***/ 9407:
|
|
5593
|
-
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
5594
|
-
|
|
5595
|
-
/* MIT license */
|
|
5596
|
-
var colorNames = __nccwpck_require__(4953);
|
|
5597
|
-
var swizzle = __nccwpck_require__(4421);
|
|
5598
|
-
var hasOwnProperty = Object.hasOwnProperty;
|
|
5599
|
-
|
|
5600
|
-
var reverseNames = Object.create(null);
|
|
5601
|
-
|
|
5602
|
-
// create a list of reverse color names
|
|
5603
|
-
for (var name in colorNames) {
|
|
5604
|
-
if (hasOwnProperty.call(colorNames, name)) {
|
|
5605
|
-
reverseNames[colorNames[name]] = name;
|
|
5606
|
-
}
|
|
5607
|
-
}
|
|
5608
|
-
|
|
5609
|
-
var cs = module.exports = {
|
|
5610
|
-
to: {},
|
|
5611
|
-
get: {}
|
|
5612
|
-
};
|
|
5613
|
-
|
|
5614
|
-
cs.get = function (string) {
|
|
5615
|
-
var prefix = string.substring(0, 3).toLowerCase();
|
|
5616
|
-
var val;
|
|
5617
|
-
var model;
|
|
5618
|
-
switch (prefix) {
|
|
5619
|
-
case 'hsl':
|
|
5620
|
-
val = cs.get.hsl(string);
|
|
5621
|
-
model = 'hsl';
|
|
5622
|
-
break;
|
|
5623
|
-
case 'hwb':
|
|
5624
|
-
val = cs.get.hwb(string);
|
|
5625
|
-
model = 'hwb';
|
|
5626
|
-
break;
|
|
5627
|
-
default:
|
|
5628
|
-
val = cs.get.rgb(string);
|
|
5629
|
-
model = 'rgb';
|
|
5630
|
-
break;
|
|
5631
|
-
}
|
|
5632
|
-
|
|
5633
|
-
if (!val) {
|
|
5634
|
-
return null;
|
|
5635
|
-
}
|
|
5636
|
-
|
|
5637
|
-
return {model: model, value: val};
|
|
5638
|
-
};
|
|
5639
|
-
|
|
5640
|
-
cs.get.rgb = function (string) {
|
|
5641
|
-
if (!string) {
|
|
5642
|
-
return null;
|
|
5643
|
-
}
|
|
5644
|
-
|
|
5645
|
-
var abbr = /^#([a-f0-9]{3,4})$/i;
|
|
5646
|
-
var hex = /^#([a-f0-9]{6})([a-f0-9]{2})?$/i;
|
|
5647
|
-
var rgba = /^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/;
|
|
5648
|
-
var per = /^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/;
|
|
5649
|
-
var keyword = /^(\w+)$/;
|
|
5650
|
-
|
|
5651
|
-
var rgb = [0, 0, 0, 1];
|
|
5652
|
-
var match;
|
|
5653
|
-
var i;
|
|
5654
|
-
var hexAlpha;
|
|
5655
|
-
|
|
5656
|
-
if (match = string.match(hex)) {
|
|
5657
|
-
hexAlpha = match[2];
|
|
5658
|
-
match = match[1];
|
|
5659
|
-
|
|
5660
|
-
for (i = 0; i < 3; i++) {
|
|
5661
|
-
// https://jsperf.com/slice-vs-substr-vs-substring-methods-long-string/19
|
|
5662
|
-
var i2 = i * 2;
|
|
5663
|
-
rgb[i] = parseInt(match.slice(i2, i2 + 2), 16);
|
|
5664
|
-
}
|
|
5665
|
-
|
|
5666
|
-
if (hexAlpha) {
|
|
5667
|
-
rgb[3] = parseInt(hexAlpha, 16) / 255;
|
|
5668
|
-
}
|
|
5669
|
-
} else if (match = string.match(abbr)) {
|
|
5670
|
-
match = match[1];
|
|
5671
|
-
hexAlpha = match[3];
|
|
5672
|
-
|
|
5673
|
-
for (i = 0; i < 3; i++) {
|
|
5674
|
-
rgb[i] = parseInt(match[i] + match[i], 16);
|
|
5675
|
-
}
|
|
5676
|
-
|
|
5677
|
-
if (hexAlpha) {
|
|
5678
|
-
rgb[3] = parseInt(hexAlpha + hexAlpha, 16) / 255;
|
|
5679
|
-
}
|
|
5680
|
-
} else if (match = string.match(rgba)) {
|
|
5681
|
-
for (i = 0; i < 3; i++) {
|
|
5682
|
-
rgb[i] = parseInt(match[i + 1], 0);
|
|
5683
|
-
}
|
|
5684
|
-
|
|
5685
|
-
if (match[4]) {
|
|
5686
|
-
if (match[5]) {
|
|
5687
|
-
rgb[3] = parseFloat(match[4]) * 0.01;
|
|
5688
|
-
} else {
|
|
5689
|
-
rgb[3] = parseFloat(match[4]);
|
|
5690
|
-
}
|
|
5691
|
-
}
|
|
5692
|
-
} else if (match = string.match(per)) {
|
|
5693
|
-
for (i = 0; i < 3; i++) {
|
|
5694
|
-
rgb[i] = Math.round(parseFloat(match[i + 1]) * 2.55);
|
|
5695
|
-
}
|
|
5696
|
-
|
|
5697
|
-
if (match[4]) {
|
|
5698
|
-
if (match[5]) {
|
|
5699
|
-
rgb[3] = parseFloat(match[4]) * 0.01;
|
|
5700
|
-
} else {
|
|
5701
|
-
rgb[3] = parseFloat(match[4]);
|
|
5702
|
-
}
|
|
5703
|
-
}
|
|
5704
|
-
} else if (match = string.match(keyword)) {
|
|
5705
|
-
if (match[1] === 'transparent') {
|
|
5706
|
-
return [0, 0, 0, 0];
|
|
5707
|
-
}
|
|
5708
|
-
|
|
5709
|
-
if (!hasOwnProperty.call(colorNames, match[1])) {
|
|
5710
|
-
return null;
|
|
5711
|
-
}
|
|
5712
|
-
|
|
5713
|
-
rgb = colorNames[match[1]];
|
|
5714
|
-
rgb[3] = 1;
|
|
5715
|
-
|
|
5716
|
-
return rgb;
|
|
5717
|
-
} else {
|
|
5718
|
-
return null;
|
|
5719
|
-
}
|
|
5720
|
-
|
|
5721
|
-
for (i = 0; i < 3; i++) {
|
|
5722
|
-
rgb[i] = clamp(rgb[i], 0, 255);
|
|
5723
|
-
}
|
|
5724
|
-
rgb[3] = clamp(rgb[3], 0, 1);
|
|
5725
|
-
|
|
5726
|
-
return rgb;
|
|
5727
|
-
};
|
|
5728
|
-
|
|
5729
|
-
cs.get.hsl = function (string) {
|
|
5730
|
-
if (!string) {
|
|
5731
|
-
return null;
|
|
5732
|
-
}
|
|
5733
|
-
|
|
5734
|
-
var hsl = /^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d\.]+)%\s*,?\s*([+-]?[\d\.]+)%\s*(?:[,|\/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/;
|
|
5735
|
-
var match = string.match(hsl);
|
|
5736
|
-
|
|
5737
|
-
if (match) {
|
|
5738
|
-
var alpha = parseFloat(match[4]);
|
|
5739
|
-
var h = ((parseFloat(match[1]) % 360) + 360) % 360;
|
|
5740
|
-
var s = clamp(parseFloat(match[2]), 0, 100);
|
|
5741
|
-
var l = clamp(parseFloat(match[3]), 0, 100);
|
|
5742
|
-
var a = clamp(isNaN(alpha) ? 1 : alpha, 0, 1);
|
|
5743
|
-
|
|
5744
|
-
return [h, s, l, a];
|
|
5745
|
-
}
|
|
5746
|
-
|
|
5747
|
-
return null;
|
|
5748
|
-
};
|
|
5749
|
-
|
|
5750
|
-
cs.get.hwb = function (string) {
|
|
5751
|
-
if (!string) {
|
|
5752
|
-
return null;
|
|
5753
|
-
}
|
|
5754
|
-
|
|
5755
|
-
var hwb = /^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/;
|
|
5756
|
-
var match = string.match(hwb);
|
|
5757
|
-
|
|
5758
|
-
if (match) {
|
|
5759
|
-
var alpha = parseFloat(match[4]);
|
|
5760
|
-
var h = ((parseFloat(match[1]) % 360) + 360) % 360;
|
|
5761
|
-
var w = clamp(parseFloat(match[2]), 0, 100);
|
|
5762
|
-
var b = clamp(parseFloat(match[3]), 0, 100);
|
|
5763
|
-
var a = clamp(isNaN(alpha) ? 1 : alpha, 0, 1);
|
|
5764
|
-
return [h, w, b, a];
|
|
5765
|
-
}
|
|
5766
|
-
|
|
5767
|
-
return null;
|
|
5768
|
-
};
|
|
5769
|
-
|
|
5770
|
-
cs.to.hex = function () {
|
|
5771
|
-
var rgba = swizzle(arguments);
|
|
5772
|
-
|
|
5773
|
-
return (
|
|
5774
|
-
'#' +
|
|
5775
|
-
hexDouble(rgba[0]) +
|
|
5776
|
-
hexDouble(rgba[1]) +
|
|
5777
|
-
hexDouble(rgba[2]) +
|
|
5778
|
-
(rgba[3] < 1
|
|
5779
|
-
? (hexDouble(Math.round(rgba[3] * 255)))
|
|
5780
|
-
: '')
|
|
5781
|
-
);
|
|
5782
|
-
};
|
|
5783
|
-
|
|
5784
|
-
cs.to.rgb = function () {
|
|
5785
|
-
var rgba = swizzle(arguments);
|
|
5786
|
-
|
|
5787
|
-
return rgba.length < 4 || rgba[3] === 1
|
|
5788
|
-
? 'rgb(' + Math.round(rgba[0]) + ', ' + Math.round(rgba[1]) + ', ' + Math.round(rgba[2]) + ')'
|
|
5789
|
-
: 'rgba(' + Math.round(rgba[0]) + ', ' + Math.round(rgba[1]) + ', ' + Math.round(rgba[2]) + ', ' + rgba[3] + ')';
|
|
5790
|
-
};
|
|
5791
|
-
|
|
5792
|
-
cs.to.rgb.percent = function () {
|
|
5793
|
-
var rgba = swizzle(arguments);
|
|
5794
|
-
|
|
5795
|
-
var r = Math.round(rgba[0] / 255 * 100);
|
|
5796
|
-
var g = Math.round(rgba[1] / 255 * 100);
|
|
5797
|
-
var b = Math.round(rgba[2] / 255 * 100);
|
|
5798
|
-
|
|
5799
|
-
return rgba.length < 4 || rgba[3] === 1
|
|
5800
|
-
? 'rgb(' + r + '%, ' + g + '%, ' + b + '%)'
|
|
5801
|
-
: 'rgba(' + r + '%, ' + g + '%, ' + b + '%, ' + rgba[3] + ')';
|
|
5802
|
-
};
|
|
5803
|
-
|
|
5804
|
-
cs.to.hsl = function () {
|
|
5805
|
-
var hsla = swizzle(arguments);
|
|
5806
|
-
return hsla.length < 4 || hsla[3] === 1
|
|
5807
|
-
? 'hsl(' + hsla[0] + ', ' + hsla[1] + '%, ' + hsla[2] + '%)'
|
|
5808
|
-
: 'hsla(' + hsla[0] + ', ' + hsla[1] + '%, ' + hsla[2] + '%, ' + hsla[3] + ')';
|
|
5809
|
-
};
|
|
5810
|
-
|
|
5811
|
-
// hwb is a bit different than rgb(a) & hsl(a) since there is no alpha specific syntax
|
|
5812
|
-
// (hwb have alpha optional & 1 is default value)
|
|
5813
|
-
cs.to.hwb = function () {
|
|
5814
|
-
var hwba = swizzle(arguments);
|
|
5815
|
-
|
|
5816
|
-
var a = '';
|
|
5817
|
-
if (hwba.length >= 4 && hwba[3] !== 1) {
|
|
5818
|
-
a = ', ' + hwba[3];
|
|
5819
|
-
}
|
|
5820
|
-
|
|
5821
|
-
return 'hwb(' + hwba[0] + ', ' + hwba[1] + '%, ' + hwba[2] + '%' + a + ')';
|
|
5822
|
-
};
|
|
5823
|
-
|
|
5824
|
-
cs.to.keyword = function (rgb) {
|
|
5825
|
-
return reverseNames[rgb.slice(0, 3)];
|
|
5826
|
-
};
|
|
5827
|
-
|
|
5828
|
-
// helpers
|
|
5829
|
-
function clamp(num, min, max) {
|
|
5830
|
-
return Math.min(Math.max(min, num), max);
|
|
5831
|
-
}
|
|
5832
|
-
|
|
5833
|
-
function hexDouble(num) {
|
|
5834
|
-
var str = Math.round(num).toString(16).toUpperCase();
|
|
5835
|
-
return (str.length < 2) ? '0' + str : str;
|
|
5836
|
-
}
|
|
5837
|
-
|
|
5838
|
-
|
|
5839
|
-
/***/ }),
|
|
5840
|
-
|
|
5841
|
-
/***/ 8107:
|
|
5842
|
-
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
5843
|
-
|
|
5844
|
-
"use strict";
|
|
5845
|
-
|
|
5846
|
-
|
|
5847
|
-
var color = __nccwpck_require__(1696)
|
|
5848
|
-
, hex = __nccwpck_require__(5143);
|
|
5849
|
-
|
|
5850
|
-
/**
|
|
5851
|
-
* Generate a color for a given name. But be reasonably smart about it by
|
|
5852
|
-
* understanding name spaces and coloring each namespace a bit lighter so they
|
|
5853
|
-
* still have the same base color as the root.
|
|
5854
|
-
*
|
|
5855
|
-
* @param {string} namespace The namespace
|
|
5856
|
-
* @param {string} [delimiter] The delimiter
|
|
5857
|
-
* @returns {string} color
|
|
5858
|
-
*/
|
|
5859
|
-
module.exports = function colorspace(namespace, delimiter) {
|
|
5860
|
-
var split = namespace.split(delimiter || ':');
|
|
5861
|
-
var base = hex(split[0]);
|
|
5862
|
-
|
|
5863
|
-
if (!split.length) return base;
|
|
5864
|
-
|
|
5865
|
-
for (var i = 0, l = split.length - 1; i < l; i++) {
|
|
5866
|
-
base = color(base)
|
|
5867
|
-
.mix(color(hex(split[i + 1])))
|
|
5868
|
-
.saturate(1)
|
|
5869
|
-
.hex();
|
|
5870
|
-
}
|
|
5871
|
-
|
|
5872
|
-
return base;
|
|
5873
|
-
};
|
|
5874
|
-
|
|
5875
|
-
|
|
5876
|
-
/***/ }),
|
|
5877
|
-
|
|
5878
|
-
/***/ 4618:
|
|
5432
|
+
/***/ 6872:
|
|
5879
5433
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
5880
5434
|
|
|
5881
5435
|
/* MIT license */
|
|
5882
|
-
var cssKeywords = __nccwpck_require__(
|
|
5436
|
+
var cssKeywords = __nccwpck_require__(7888);
|
|
5883
5437
|
|
|
5884
5438
|
// NOTE: conversions should only return primitive values (i.e. arrays, or
|
|
5885
5439
|
// values that give correct `typeof` results).
|
|
@@ -6750,11 +6304,11 @@ convert.rgb.gray = function (rgb) {
|
|
|
6750
6304
|
|
|
6751
6305
|
/***/ }),
|
|
6752
6306
|
|
|
6753
|
-
/***/
|
|
6307
|
+
/***/ 4185:
|
|
6754
6308
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
6755
6309
|
|
|
6756
|
-
var conversions = __nccwpck_require__(
|
|
6757
|
-
var route = __nccwpck_require__(
|
|
6310
|
+
var conversions = __nccwpck_require__(6872);
|
|
6311
|
+
var route = __nccwpck_require__(4200);
|
|
6758
6312
|
|
|
6759
6313
|
var convert = {};
|
|
6760
6314
|
|
|
@@ -6835,10 +6389,170 @@ module.exports = convert;
|
|
|
6835
6389
|
|
|
6836
6390
|
/***/ }),
|
|
6837
6391
|
|
|
6838
|
-
/***/
|
|
6392
|
+
/***/ 7888:
|
|
6393
|
+
/***/ ((module) => {
|
|
6394
|
+
|
|
6395
|
+
"use strict";
|
|
6396
|
+
|
|
6397
|
+
|
|
6398
|
+
module.exports = {
|
|
6399
|
+
"aliceblue": [240, 248, 255],
|
|
6400
|
+
"antiquewhite": [250, 235, 215],
|
|
6401
|
+
"aqua": [0, 255, 255],
|
|
6402
|
+
"aquamarine": [127, 255, 212],
|
|
6403
|
+
"azure": [240, 255, 255],
|
|
6404
|
+
"beige": [245, 245, 220],
|
|
6405
|
+
"bisque": [255, 228, 196],
|
|
6406
|
+
"black": [0, 0, 0],
|
|
6407
|
+
"blanchedalmond": [255, 235, 205],
|
|
6408
|
+
"blue": [0, 0, 255],
|
|
6409
|
+
"blueviolet": [138, 43, 226],
|
|
6410
|
+
"brown": [165, 42, 42],
|
|
6411
|
+
"burlywood": [222, 184, 135],
|
|
6412
|
+
"cadetblue": [95, 158, 160],
|
|
6413
|
+
"chartreuse": [127, 255, 0],
|
|
6414
|
+
"chocolate": [210, 105, 30],
|
|
6415
|
+
"coral": [255, 127, 80],
|
|
6416
|
+
"cornflowerblue": [100, 149, 237],
|
|
6417
|
+
"cornsilk": [255, 248, 220],
|
|
6418
|
+
"crimson": [220, 20, 60],
|
|
6419
|
+
"cyan": [0, 255, 255],
|
|
6420
|
+
"darkblue": [0, 0, 139],
|
|
6421
|
+
"darkcyan": [0, 139, 139],
|
|
6422
|
+
"darkgoldenrod": [184, 134, 11],
|
|
6423
|
+
"darkgray": [169, 169, 169],
|
|
6424
|
+
"darkgreen": [0, 100, 0],
|
|
6425
|
+
"darkgrey": [169, 169, 169],
|
|
6426
|
+
"darkkhaki": [189, 183, 107],
|
|
6427
|
+
"darkmagenta": [139, 0, 139],
|
|
6428
|
+
"darkolivegreen": [85, 107, 47],
|
|
6429
|
+
"darkorange": [255, 140, 0],
|
|
6430
|
+
"darkorchid": [153, 50, 204],
|
|
6431
|
+
"darkred": [139, 0, 0],
|
|
6432
|
+
"darksalmon": [233, 150, 122],
|
|
6433
|
+
"darkseagreen": [143, 188, 143],
|
|
6434
|
+
"darkslateblue": [72, 61, 139],
|
|
6435
|
+
"darkslategray": [47, 79, 79],
|
|
6436
|
+
"darkslategrey": [47, 79, 79],
|
|
6437
|
+
"darkturquoise": [0, 206, 209],
|
|
6438
|
+
"darkviolet": [148, 0, 211],
|
|
6439
|
+
"deeppink": [255, 20, 147],
|
|
6440
|
+
"deepskyblue": [0, 191, 255],
|
|
6441
|
+
"dimgray": [105, 105, 105],
|
|
6442
|
+
"dimgrey": [105, 105, 105],
|
|
6443
|
+
"dodgerblue": [30, 144, 255],
|
|
6444
|
+
"firebrick": [178, 34, 34],
|
|
6445
|
+
"floralwhite": [255, 250, 240],
|
|
6446
|
+
"forestgreen": [34, 139, 34],
|
|
6447
|
+
"fuchsia": [255, 0, 255],
|
|
6448
|
+
"gainsboro": [220, 220, 220],
|
|
6449
|
+
"ghostwhite": [248, 248, 255],
|
|
6450
|
+
"gold": [255, 215, 0],
|
|
6451
|
+
"goldenrod": [218, 165, 32],
|
|
6452
|
+
"gray": [128, 128, 128],
|
|
6453
|
+
"green": [0, 128, 0],
|
|
6454
|
+
"greenyellow": [173, 255, 47],
|
|
6455
|
+
"grey": [128, 128, 128],
|
|
6456
|
+
"honeydew": [240, 255, 240],
|
|
6457
|
+
"hotpink": [255, 105, 180],
|
|
6458
|
+
"indianred": [205, 92, 92],
|
|
6459
|
+
"indigo": [75, 0, 130],
|
|
6460
|
+
"ivory": [255, 255, 240],
|
|
6461
|
+
"khaki": [240, 230, 140],
|
|
6462
|
+
"lavender": [230, 230, 250],
|
|
6463
|
+
"lavenderblush": [255, 240, 245],
|
|
6464
|
+
"lawngreen": [124, 252, 0],
|
|
6465
|
+
"lemonchiffon": [255, 250, 205],
|
|
6466
|
+
"lightblue": [173, 216, 230],
|
|
6467
|
+
"lightcoral": [240, 128, 128],
|
|
6468
|
+
"lightcyan": [224, 255, 255],
|
|
6469
|
+
"lightgoldenrodyellow": [250, 250, 210],
|
|
6470
|
+
"lightgray": [211, 211, 211],
|
|
6471
|
+
"lightgreen": [144, 238, 144],
|
|
6472
|
+
"lightgrey": [211, 211, 211],
|
|
6473
|
+
"lightpink": [255, 182, 193],
|
|
6474
|
+
"lightsalmon": [255, 160, 122],
|
|
6475
|
+
"lightseagreen": [32, 178, 170],
|
|
6476
|
+
"lightskyblue": [135, 206, 250],
|
|
6477
|
+
"lightslategray": [119, 136, 153],
|
|
6478
|
+
"lightslategrey": [119, 136, 153],
|
|
6479
|
+
"lightsteelblue": [176, 196, 222],
|
|
6480
|
+
"lightyellow": [255, 255, 224],
|
|
6481
|
+
"lime": [0, 255, 0],
|
|
6482
|
+
"limegreen": [50, 205, 50],
|
|
6483
|
+
"linen": [250, 240, 230],
|
|
6484
|
+
"magenta": [255, 0, 255],
|
|
6485
|
+
"maroon": [128, 0, 0],
|
|
6486
|
+
"mediumaquamarine": [102, 205, 170],
|
|
6487
|
+
"mediumblue": [0, 0, 205],
|
|
6488
|
+
"mediumorchid": [186, 85, 211],
|
|
6489
|
+
"mediumpurple": [147, 112, 219],
|
|
6490
|
+
"mediumseagreen": [60, 179, 113],
|
|
6491
|
+
"mediumslateblue": [123, 104, 238],
|
|
6492
|
+
"mediumspringgreen": [0, 250, 154],
|
|
6493
|
+
"mediumturquoise": [72, 209, 204],
|
|
6494
|
+
"mediumvioletred": [199, 21, 133],
|
|
6495
|
+
"midnightblue": [25, 25, 112],
|
|
6496
|
+
"mintcream": [245, 255, 250],
|
|
6497
|
+
"mistyrose": [255, 228, 225],
|
|
6498
|
+
"moccasin": [255, 228, 181],
|
|
6499
|
+
"navajowhite": [255, 222, 173],
|
|
6500
|
+
"navy": [0, 0, 128],
|
|
6501
|
+
"oldlace": [253, 245, 230],
|
|
6502
|
+
"olive": [128, 128, 0],
|
|
6503
|
+
"olivedrab": [107, 142, 35],
|
|
6504
|
+
"orange": [255, 165, 0],
|
|
6505
|
+
"orangered": [255, 69, 0],
|
|
6506
|
+
"orchid": [218, 112, 214],
|
|
6507
|
+
"palegoldenrod": [238, 232, 170],
|
|
6508
|
+
"palegreen": [152, 251, 152],
|
|
6509
|
+
"paleturquoise": [175, 238, 238],
|
|
6510
|
+
"palevioletred": [219, 112, 147],
|
|
6511
|
+
"papayawhip": [255, 239, 213],
|
|
6512
|
+
"peachpuff": [255, 218, 185],
|
|
6513
|
+
"peru": [205, 133, 63],
|
|
6514
|
+
"pink": [255, 192, 203],
|
|
6515
|
+
"plum": [221, 160, 221],
|
|
6516
|
+
"powderblue": [176, 224, 230],
|
|
6517
|
+
"purple": [128, 0, 128],
|
|
6518
|
+
"rebeccapurple": [102, 51, 153],
|
|
6519
|
+
"red": [255, 0, 0],
|
|
6520
|
+
"rosybrown": [188, 143, 143],
|
|
6521
|
+
"royalblue": [65, 105, 225],
|
|
6522
|
+
"saddlebrown": [139, 69, 19],
|
|
6523
|
+
"salmon": [250, 128, 114],
|
|
6524
|
+
"sandybrown": [244, 164, 96],
|
|
6525
|
+
"seagreen": [46, 139, 87],
|
|
6526
|
+
"seashell": [255, 245, 238],
|
|
6527
|
+
"sienna": [160, 82, 45],
|
|
6528
|
+
"silver": [192, 192, 192],
|
|
6529
|
+
"skyblue": [135, 206, 235],
|
|
6530
|
+
"slateblue": [106, 90, 205],
|
|
6531
|
+
"slategray": [112, 128, 144],
|
|
6532
|
+
"slategrey": [112, 128, 144],
|
|
6533
|
+
"snow": [255, 250, 250],
|
|
6534
|
+
"springgreen": [0, 255, 127],
|
|
6535
|
+
"steelblue": [70, 130, 180],
|
|
6536
|
+
"tan": [210, 180, 140],
|
|
6537
|
+
"teal": [0, 128, 128],
|
|
6538
|
+
"thistle": [216, 191, 216],
|
|
6539
|
+
"tomato": [255, 99, 71],
|
|
6540
|
+
"turquoise": [64, 224, 208],
|
|
6541
|
+
"violet": [238, 130, 238],
|
|
6542
|
+
"wheat": [245, 222, 179],
|
|
6543
|
+
"white": [255, 255, 255],
|
|
6544
|
+
"whitesmoke": [245, 245, 245],
|
|
6545
|
+
"yellow": [255, 255, 0],
|
|
6546
|
+
"yellowgreen": [154, 205, 50]
|
|
6547
|
+
};
|
|
6548
|
+
|
|
6549
|
+
|
|
6550
|
+
/***/ }),
|
|
6551
|
+
|
|
6552
|
+
/***/ 4200:
|
|
6839
6553
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
6840
6554
|
|
|
6841
|
-
var conversions = __nccwpck_require__(
|
|
6555
|
+
var conversions = __nccwpck_require__(6872);
|
|
6842
6556
|
|
|
6843
6557
|
/*
|
|
6844
6558
|
this function routes a model to all other models.
|
|
@@ -6939,7 +6653,7 @@ module.exports = function (fromModel) {
|
|
|
6939
6653
|
|
|
6940
6654
|
/***/ }),
|
|
6941
6655
|
|
|
6942
|
-
/***/
|
|
6656
|
+
/***/ 4953:
|
|
6943
6657
|
/***/ ((module) => {
|
|
6944
6658
|
|
|
6945
6659
|
"use strict";
|
|
@@ -7097,6 +6811,292 @@ module.exports = {
|
|
|
7097
6811
|
};
|
|
7098
6812
|
|
|
7099
6813
|
|
|
6814
|
+
/***/ }),
|
|
6815
|
+
|
|
6816
|
+
/***/ 9407:
|
|
6817
|
+
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
6818
|
+
|
|
6819
|
+
/* MIT license */
|
|
6820
|
+
var colorNames = __nccwpck_require__(4953);
|
|
6821
|
+
var swizzle = __nccwpck_require__(4421);
|
|
6822
|
+
var hasOwnProperty = Object.hasOwnProperty;
|
|
6823
|
+
|
|
6824
|
+
var reverseNames = Object.create(null);
|
|
6825
|
+
|
|
6826
|
+
// create a list of reverse color names
|
|
6827
|
+
for (var name in colorNames) {
|
|
6828
|
+
if (hasOwnProperty.call(colorNames, name)) {
|
|
6829
|
+
reverseNames[colorNames[name]] = name;
|
|
6830
|
+
}
|
|
6831
|
+
}
|
|
6832
|
+
|
|
6833
|
+
var cs = module.exports = {
|
|
6834
|
+
to: {},
|
|
6835
|
+
get: {}
|
|
6836
|
+
};
|
|
6837
|
+
|
|
6838
|
+
cs.get = function (string) {
|
|
6839
|
+
var prefix = string.substring(0, 3).toLowerCase();
|
|
6840
|
+
var val;
|
|
6841
|
+
var model;
|
|
6842
|
+
switch (prefix) {
|
|
6843
|
+
case 'hsl':
|
|
6844
|
+
val = cs.get.hsl(string);
|
|
6845
|
+
model = 'hsl';
|
|
6846
|
+
break;
|
|
6847
|
+
case 'hwb':
|
|
6848
|
+
val = cs.get.hwb(string);
|
|
6849
|
+
model = 'hwb';
|
|
6850
|
+
break;
|
|
6851
|
+
default:
|
|
6852
|
+
val = cs.get.rgb(string);
|
|
6853
|
+
model = 'rgb';
|
|
6854
|
+
break;
|
|
6855
|
+
}
|
|
6856
|
+
|
|
6857
|
+
if (!val) {
|
|
6858
|
+
return null;
|
|
6859
|
+
}
|
|
6860
|
+
|
|
6861
|
+
return {model: model, value: val};
|
|
6862
|
+
};
|
|
6863
|
+
|
|
6864
|
+
cs.get.rgb = function (string) {
|
|
6865
|
+
if (!string) {
|
|
6866
|
+
return null;
|
|
6867
|
+
}
|
|
6868
|
+
|
|
6869
|
+
var abbr = /^#([a-f0-9]{3,4})$/i;
|
|
6870
|
+
var hex = /^#([a-f0-9]{6})([a-f0-9]{2})?$/i;
|
|
6871
|
+
var rgba = /^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/;
|
|
6872
|
+
var per = /^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/;
|
|
6873
|
+
var keyword = /^(\w+)$/;
|
|
6874
|
+
|
|
6875
|
+
var rgb = [0, 0, 0, 1];
|
|
6876
|
+
var match;
|
|
6877
|
+
var i;
|
|
6878
|
+
var hexAlpha;
|
|
6879
|
+
|
|
6880
|
+
if (match = string.match(hex)) {
|
|
6881
|
+
hexAlpha = match[2];
|
|
6882
|
+
match = match[1];
|
|
6883
|
+
|
|
6884
|
+
for (i = 0; i < 3; i++) {
|
|
6885
|
+
// https://jsperf.com/slice-vs-substr-vs-substring-methods-long-string/19
|
|
6886
|
+
var i2 = i * 2;
|
|
6887
|
+
rgb[i] = parseInt(match.slice(i2, i2 + 2), 16);
|
|
6888
|
+
}
|
|
6889
|
+
|
|
6890
|
+
if (hexAlpha) {
|
|
6891
|
+
rgb[3] = parseInt(hexAlpha, 16) / 255;
|
|
6892
|
+
}
|
|
6893
|
+
} else if (match = string.match(abbr)) {
|
|
6894
|
+
match = match[1];
|
|
6895
|
+
hexAlpha = match[3];
|
|
6896
|
+
|
|
6897
|
+
for (i = 0; i < 3; i++) {
|
|
6898
|
+
rgb[i] = parseInt(match[i] + match[i], 16);
|
|
6899
|
+
}
|
|
6900
|
+
|
|
6901
|
+
if (hexAlpha) {
|
|
6902
|
+
rgb[3] = parseInt(hexAlpha + hexAlpha, 16) / 255;
|
|
6903
|
+
}
|
|
6904
|
+
} else if (match = string.match(rgba)) {
|
|
6905
|
+
for (i = 0; i < 3; i++) {
|
|
6906
|
+
rgb[i] = parseInt(match[i + 1], 0);
|
|
6907
|
+
}
|
|
6908
|
+
|
|
6909
|
+
if (match[4]) {
|
|
6910
|
+
if (match[5]) {
|
|
6911
|
+
rgb[3] = parseFloat(match[4]) * 0.01;
|
|
6912
|
+
} else {
|
|
6913
|
+
rgb[3] = parseFloat(match[4]);
|
|
6914
|
+
}
|
|
6915
|
+
}
|
|
6916
|
+
} else if (match = string.match(per)) {
|
|
6917
|
+
for (i = 0; i < 3; i++) {
|
|
6918
|
+
rgb[i] = Math.round(parseFloat(match[i + 1]) * 2.55);
|
|
6919
|
+
}
|
|
6920
|
+
|
|
6921
|
+
if (match[4]) {
|
|
6922
|
+
if (match[5]) {
|
|
6923
|
+
rgb[3] = parseFloat(match[4]) * 0.01;
|
|
6924
|
+
} else {
|
|
6925
|
+
rgb[3] = parseFloat(match[4]);
|
|
6926
|
+
}
|
|
6927
|
+
}
|
|
6928
|
+
} else if (match = string.match(keyword)) {
|
|
6929
|
+
if (match[1] === 'transparent') {
|
|
6930
|
+
return [0, 0, 0, 0];
|
|
6931
|
+
}
|
|
6932
|
+
|
|
6933
|
+
if (!hasOwnProperty.call(colorNames, match[1])) {
|
|
6934
|
+
return null;
|
|
6935
|
+
}
|
|
6936
|
+
|
|
6937
|
+
rgb = colorNames[match[1]];
|
|
6938
|
+
rgb[3] = 1;
|
|
6939
|
+
|
|
6940
|
+
return rgb;
|
|
6941
|
+
} else {
|
|
6942
|
+
return null;
|
|
6943
|
+
}
|
|
6944
|
+
|
|
6945
|
+
for (i = 0; i < 3; i++) {
|
|
6946
|
+
rgb[i] = clamp(rgb[i], 0, 255);
|
|
6947
|
+
}
|
|
6948
|
+
rgb[3] = clamp(rgb[3], 0, 1);
|
|
6949
|
+
|
|
6950
|
+
return rgb;
|
|
6951
|
+
};
|
|
6952
|
+
|
|
6953
|
+
cs.get.hsl = function (string) {
|
|
6954
|
+
if (!string) {
|
|
6955
|
+
return null;
|
|
6956
|
+
}
|
|
6957
|
+
|
|
6958
|
+
var hsl = /^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d\.]+)%\s*,?\s*([+-]?[\d\.]+)%\s*(?:[,|\/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/;
|
|
6959
|
+
var match = string.match(hsl);
|
|
6960
|
+
|
|
6961
|
+
if (match) {
|
|
6962
|
+
var alpha = parseFloat(match[4]);
|
|
6963
|
+
var h = ((parseFloat(match[1]) % 360) + 360) % 360;
|
|
6964
|
+
var s = clamp(parseFloat(match[2]), 0, 100);
|
|
6965
|
+
var l = clamp(parseFloat(match[3]), 0, 100);
|
|
6966
|
+
var a = clamp(isNaN(alpha) ? 1 : alpha, 0, 1);
|
|
6967
|
+
|
|
6968
|
+
return [h, s, l, a];
|
|
6969
|
+
}
|
|
6970
|
+
|
|
6971
|
+
return null;
|
|
6972
|
+
};
|
|
6973
|
+
|
|
6974
|
+
cs.get.hwb = function (string) {
|
|
6975
|
+
if (!string) {
|
|
6976
|
+
return null;
|
|
6977
|
+
}
|
|
6978
|
+
|
|
6979
|
+
var hwb = /^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/;
|
|
6980
|
+
var match = string.match(hwb);
|
|
6981
|
+
|
|
6982
|
+
if (match) {
|
|
6983
|
+
var alpha = parseFloat(match[4]);
|
|
6984
|
+
var h = ((parseFloat(match[1]) % 360) + 360) % 360;
|
|
6985
|
+
var w = clamp(parseFloat(match[2]), 0, 100);
|
|
6986
|
+
var b = clamp(parseFloat(match[3]), 0, 100);
|
|
6987
|
+
var a = clamp(isNaN(alpha) ? 1 : alpha, 0, 1);
|
|
6988
|
+
return [h, w, b, a];
|
|
6989
|
+
}
|
|
6990
|
+
|
|
6991
|
+
return null;
|
|
6992
|
+
};
|
|
6993
|
+
|
|
6994
|
+
cs.to.hex = function () {
|
|
6995
|
+
var rgba = swizzle(arguments);
|
|
6996
|
+
|
|
6997
|
+
return (
|
|
6998
|
+
'#' +
|
|
6999
|
+
hexDouble(rgba[0]) +
|
|
7000
|
+
hexDouble(rgba[1]) +
|
|
7001
|
+
hexDouble(rgba[2]) +
|
|
7002
|
+
(rgba[3] < 1
|
|
7003
|
+
? (hexDouble(Math.round(rgba[3] * 255)))
|
|
7004
|
+
: '')
|
|
7005
|
+
);
|
|
7006
|
+
};
|
|
7007
|
+
|
|
7008
|
+
cs.to.rgb = function () {
|
|
7009
|
+
var rgba = swizzle(arguments);
|
|
7010
|
+
|
|
7011
|
+
return rgba.length < 4 || rgba[3] === 1
|
|
7012
|
+
? 'rgb(' + Math.round(rgba[0]) + ', ' + Math.round(rgba[1]) + ', ' + Math.round(rgba[2]) + ')'
|
|
7013
|
+
: 'rgba(' + Math.round(rgba[0]) + ', ' + Math.round(rgba[1]) + ', ' + Math.round(rgba[2]) + ', ' + rgba[3] + ')';
|
|
7014
|
+
};
|
|
7015
|
+
|
|
7016
|
+
cs.to.rgb.percent = function () {
|
|
7017
|
+
var rgba = swizzle(arguments);
|
|
7018
|
+
|
|
7019
|
+
var r = Math.round(rgba[0] / 255 * 100);
|
|
7020
|
+
var g = Math.round(rgba[1] / 255 * 100);
|
|
7021
|
+
var b = Math.round(rgba[2] / 255 * 100);
|
|
7022
|
+
|
|
7023
|
+
return rgba.length < 4 || rgba[3] === 1
|
|
7024
|
+
? 'rgb(' + r + '%, ' + g + '%, ' + b + '%)'
|
|
7025
|
+
: 'rgba(' + r + '%, ' + g + '%, ' + b + '%, ' + rgba[3] + ')';
|
|
7026
|
+
};
|
|
7027
|
+
|
|
7028
|
+
cs.to.hsl = function () {
|
|
7029
|
+
var hsla = swizzle(arguments);
|
|
7030
|
+
return hsla.length < 4 || hsla[3] === 1
|
|
7031
|
+
? 'hsl(' + hsla[0] + ', ' + hsla[1] + '%, ' + hsla[2] + '%)'
|
|
7032
|
+
: 'hsla(' + hsla[0] + ', ' + hsla[1] + '%, ' + hsla[2] + '%, ' + hsla[3] + ')';
|
|
7033
|
+
};
|
|
7034
|
+
|
|
7035
|
+
// hwb is a bit different than rgb(a) & hsl(a) since there is no alpha specific syntax
|
|
7036
|
+
// (hwb have alpha optional & 1 is default value)
|
|
7037
|
+
cs.to.hwb = function () {
|
|
7038
|
+
var hwba = swizzle(arguments);
|
|
7039
|
+
|
|
7040
|
+
var a = '';
|
|
7041
|
+
if (hwba.length >= 4 && hwba[3] !== 1) {
|
|
7042
|
+
a = ', ' + hwba[3];
|
|
7043
|
+
}
|
|
7044
|
+
|
|
7045
|
+
return 'hwb(' + hwba[0] + ', ' + hwba[1] + '%, ' + hwba[2] + '%' + a + ')';
|
|
7046
|
+
};
|
|
7047
|
+
|
|
7048
|
+
cs.to.keyword = function (rgb) {
|
|
7049
|
+
return reverseNames[rgb.slice(0, 3)];
|
|
7050
|
+
};
|
|
7051
|
+
|
|
7052
|
+
// helpers
|
|
7053
|
+
function clamp(num, min, max) {
|
|
7054
|
+
return Math.min(Math.max(min, num), max);
|
|
7055
|
+
}
|
|
7056
|
+
|
|
7057
|
+
function hexDouble(num) {
|
|
7058
|
+
var str = Math.round(num).toString(16).toUpperCase();
|
|
7059
|
+
return (str.length < 2) ? '0' + str : str;
|
|
7060
|
+
}
|
|
7061
|
+
|
|
7062
|
+
|
|
7063
|
+
/***/ }),
|
|
7064
|
+
|
|
7065
|
+
/***/ 8107:
|
|
7066
|
+
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
7067
|
+
|
|
7068
|
+
"use strict";
|
|
7069
|
+
|
|
7070
|
+
|
|
7071
|
+
var color = __nccwpck_require__(1696)
|
|
7072
|
+
, hex = __nccwpck_require__(5143);
|
|
7073
|
+
|
|
7074
|
+
/**
|
|
7075
|
+
* Generate a color for a given name. But be reasonably smart about it by
|
|
7076
|
+
* understanding name spaces and coloring each namespace a bit lighter so they
|
|
7077
|
+
* still have the same base color as the root.
|
|
7078
|
+
*
|
|
7079
|
+
* @param {string} namespace The namespace
|
|
7080
|
+
* @param {string} [delimiter] The delimiter
|
|
7081
|
+
* @returns {string} color
|
|
7082
|
+
*/
|
|
7083
|
+
module.exports = function colorspace(namespace, delimiter) {
|
|
7084
|
+
var split = namespace.split(delimiter || ':');
|
|
7085
|
+
var base = hex(split[0]);
|
|
7086
|
+
|
|
7087
|
+
if (!split.length) return base;
|
|
7088
|
+
|
|
7089
|
+
for (var i = 0, l = split.length - 1; i < l; i++) {
|
|
7090
|
+
base = color(base)
|
|
7091
|
+
.mix(color(hex(split[i + 1])))
|
|
7092
|
+
.saturate(1)
|
|
7093
|
+
.hex();
|
|
7094
|
+
}
|
|
7095
|
+
|
|
7096
|
+
return base;
|
|
7097
|
+
};
|
|
7098
|
+
|
|
7099
|
+
|
|
7100
7100
|
/***/ }),
|
|
7101
7101
|
|
|
7102
7102
|
/***/ 1696:
|
|
@@ -7106,7 +7106,7 @@ module.exports = {
|
|
|
7106
7106
|
|
|
7107
7107
|
|
|
7108
7108
|
var colorString = __nccwpck_require__(9407);
|
|
7109
|
-
var convert = __nccwpck_require__(
|
|
7109
|
+
var convert = __nccwpck_require__(4185);
|
|
7110
7110
|
|
|
7111
7111
|
var _slice = [].slice;
|
|
7112
7112
|
|
|
@@ -38946,7 +38946,7 @@ module.exports = require("zlib");
|
|
|
38946
38946
|
/***/ ((module) => {
|
|
38947
38947
|
|
|
38948
38948
|
"use strict";
|
|
38949
|
-
module.exports = /*#__PURE__*/JSON.parse('{"name":"@abtnode/core","publishConfig":{"access":"public"},"version":"1.16.
|
|
38949
|
+
module.exports = /*#__PURE__*/JSON.parse('{"name":"@abtnode/core","publishConfig":{"access":"public"},"version":"1.16.51","description":"","main":"lib/index.js","files":["lib"],"scripts":{"lint":"eslint tests lib --ignore-pattern \'tests/assets/*\'","lint:fix":"eslint --fix tests lib","test":"node tools/jest.js","coverage":"npm run test -- --coverage"},"keywords":[],"author":"wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)","license":"Apache-2.0","dependencies":{"@abtnode/analytics":"1.16.51","@abtnode/auth":"1.16.51","@abtnode/certificate-manager":"1.16.51","@abtnode/constant":"1.16.51","@abtnode/cron":"1.16.51","@abtnode/db-cache":"1.16.51","@abtnode/docker-utils":"1.16.51","@abtnode/logger":"1.16.51","@abtnode/models":"1.16.51","@abtnode/queue":"1.16.51","@abtnode/rbac":"1.16.51","@abtnode/router-provider":"1.16.51","@abtnode/static-server":"1.16.51","@abtnode/timemachine":"1.16.51","@abtnode/util":"1.16.51","@aigne/aigne-hub":"^0.8.10","@arcblock/did":"1.24.0","@arcblock/did-connect-js":"1.24.0","@arcblock/did-ext":"1.24.0","@arcblock/did-motif":"^1.1.14","@arcblock/did-util":"1.24.0","@arcblock/event-hub":"1.24.0","@arcblock/jwt":"1.24.0","@arcblock/pm2-events":"^0.0.5","@arcblock/validator":"1.24.0","@arcblock/vc":"1.24.0","@blocklet/constant":"1.16.51","@blocklet/did-space-js":"^1.1.23","@blocklet/env":"1.16.51","@blocklet/error":"^0.2.5","@blocklet/meta":"1.16.51","@blocklet/resolver":"1.16.51","@blocklet/sdk":"1.16.51","@blocklet/server-js":"1.16.51","@blocklet/store":"1.16.51","@blocklet/theme":"^3.1.37","@fidm/x509":"^1.2.1","@ocap/mcrypto":"1.24.0","@ocap/util":"1.24.0","@ocap/wallet":"1.24.0","@slack/webhook":"^5.0.4","archiver":"^7.0.1","axios":"^1.7.9","axon":"^2.0.3","chalk":"^4.1.2","cross-spawn":"^7.0.3","dayjs":"^1.11.13","deep-diff":"^1.0.2","detect-port":"^1.5.1","envfile":"^7.1.0","escape-string-regexp":"^4.0.0","fast-glob":"^3.3.2","filesize":"^10.1.1","flat":"^5.0.2","fs-extra":"^11.2.0","get-port":"^5.1.1","hasha":"^5.2.2","is-base64":"^1.1.0","is-cidr":"4","is-ip":"3","is-url":"^1.2.4","joi":"17.12.2","joi-extension-semver":"^5.0.0","js-yaml":"^4.1.0","kill-port":"^2.0.1","lodash":"^4.17.21","node-stream-zip":"^1.15.0","p-all":"^3.0.0","p-limit":"^3.1.0","p-map":"^4.0.0","p-retry":"^4.6.2","p-wait-for":"^3.2.0","private-ip":"^2.3.4","rate-limiter-flexible":"^5.0.5","read-last-lines":"^1.8.0","semver":"^7.6.3","sequelize":"^6.35.0","shelljs":"^0.8.5","slugify":"^1.6.6","ssri":"^8.0.1","stream-throttle":"^0.1.3","stream-to-promise":"^3.0.0","systeminformation":"^5.23.3","tail":"^2.2.4","tar":"^6.1.11","transliteration":"^2.3.5","ua-parser-js":"^1.0.2","ufo":"^1.5.3","uuid":"^11.1.0","valid-url":"^1.0.9","which":"^2.0.2","xbytes":"^1.8.0"},"devDependencies":{"expand-tilde":"^2.0.2","express":"^4.18.2","jest":"^29.7.0","unzipper":"^0.10.11"},"gitHead":"e5764f753181ed6a7c615cd4fc6682aacf0cb7cd"}');
|
|
38950
38950
|
|
|
38951
38951
|
/***/ }),
|
|
38952
38952
|
|
package/lib/index.js
CHANGED
|
@@ -542,6 +542,9 @@ function ABTNode(options) {
|
|
|
542
542
|
getUserFollowStats: teamAPI.getUserFollowStats.bind(teamAPI),
|
|
543
543
|
checkFollowing: teamAPI.checkFollowing.bind(teamAPI),
|
|
544
544
|
|
|
545
|
+
// invite
|
|
546
|
+
getUserInvites: teamAPI.getUserInvites.bind(teamAPI),
|
|
547
|
+
|
|
545
548
|
// Tagging
|
|
546
549
|
createTag: teamAPI.createTag.bind(teamAPI),
|
|
547
550
|
updateTag: teamAPI.updateTag.bind(teamAPI),
|
package/lib/states/user.js
CHANGED
|
@@ -1094,7 +1094,7 @@ SELECT did,inviter,generation FROM UserTree`.trim();
|
|
|
1094
1094
|
return userDids.reduce(
|
|
1095
1095
|
(acc, userDid) => ({
|
|
1096
1096
|
...acc,
|
|
1097
|
-
[userDid]: { followers: 0, following: 0 },
|
|
1097
|
+
[userDid]: { followers: 0, following: 0, invitees: 0 },
|
|
1098
1098
|
}),
|
|
1099
1099
|
{}
|
|
1100
1100
|
);
|
|
@@ -1130,14 +1130,23 @@ SELECT did,inviter,generation FROM UserTree`.trim();
|
|
|
1130
1130
|
GROUP BY "followerDid"
|
|
1131
1131
|
`;
|
|
1132
1132
|
|
|
1133
|
-
const
|
|
1133
|
+
const inviteesQuery = `
|
|
1134
|
+
SELECT "inviter", COUNT(*) as count
|
|
1135
|
+
FROM users
|
|
1136
|
+
WHERE "inviter" IN (:userDids) AND "inviter" IS NOT NULL
|
|
1137
|
+
GROUP BY "inviter"
|
|
1138
|
+
`;
|
|
1139
|
+
|
|
1140
|
+
const [followersResults, followingResults, inviteesResults] = await Promise.all([
|
|
1134
1141
|
this.model.sequelize.query(followersQuery, { replacements: { userDids }, type: Sequelize.QueryTypes.SELECT }),
|
|
1135
1142
|
this.model.sequelize.query(followingQuery, { replacements: { userDids }, type: Sequelize.QueryTypes.SELECT }),
|
|
1143
|
+
this.model.sequelize.query(inviteesQuery, { replacements: { userDids }, type: Sequelize.QueryTypes.SELECT }),
|
|
1136
1144
|
]);
|
|
1137
1145
|
|
|
1138
1146
|
// 使用 Map 构造函数和数组映射优化数据结构构建
|
|
1139
1147
|
const followersMap = new Map(followersResults.map((row) => [row.userDid, Number(row.count)]));
|
|
1140
1148
|
const followingMap = new Map(followingResults.map((row) => [row.followerDid, Number(row.count)]));
|
|
1149
|
+
const inviteesMap = new Map(inviteesResults.map((row) => [row.inviter, Number(row.count)]));
|
|
1141
1150
|
|
|
1142
1151
|
// 使用 Object.fromEntries 优化结果对象构建,并进行隐私判断
|
|
1143
1152
|
const result = Object.fromEntries(
|
|
@@ -1147,7 +1156,7 @@ SELECT did,inviter,generation FROM UserTree`.trim();
|
|
|
1147
1156
|
|
|
1148
1157
|
// 如果用户设置了隐私且查看者不是用户本人,返回 0
|
|
1149
1158
|
if (isPrivate && !isOwner) {
|
|
1150
|
-
return [userDid, { followers: 0, following: 0 }];
|
|
1159
|
+
return [userDid, { followers: 0, following: 0, invitees: 0 }];
|
|
1151
1160
|
}
|
|
1152
1161
|
|
|
1153
1162
|
return [
|
|
@@ -1155,6 +1164,7 @@ SELECT did,inviter,generation FROM UserTree`.trim();
|
|
|
1155
1164
|
{
|
|
1156
1165
|
followers: followersMap.get(userDid) || 0,
|
|
1157
1166
|
following: followingMap.get(userDid) || 0,
|
|
1167
|
+
invitees: inviteesMap.get(userDid) || 0,
|
|
1158
1168
|
},
|
|
1159
1169
|
];
|
|
1160
1170
|
})
|
|
@@ -1167,12 +1177,76 @@ SELECT did,inviter,generation FROM UserTree`.trim();
|
|
|
1167
1177
|
return userDids.reduce(
|
|
1168
1178
|
(acc, userDid) => ({
|
|
1169
1179
|
...acc,
|
|
1170
|
-
[userDid]: { followers: 0, following: 0 },
|
|
1180
|
+
[userDid]: { followers: 0, following: 0, invitees: 0 },
|
|
1171
1181
|
}),
|
|
1172
1182
|
{}
|
|
1173
1183
|
);
|
|
1174
1184
|
}
|
|
1175
1185
|
}
|
|
1186
|
+
|
|
1187
|
+
/**
|
|
1188
|
+
* 获取用户的受邀者列表
|
|
1189
|
+
* @param {string} userDid - 用户的 DID
|
|
1190
|
+
* @param {object} options - 选项
|
|
1191
|
+
* @param {object} options.paging - 分页参数
|
|
1192
|
+
* @param {object} options.sort - 排序参数
|
|
1193
|
+
* @param {boolean} options.includeFollowStatus - 是否包含当前用户的关注状态,默认 true
|
|
1194
|
+
* @param {object} context - 上下文,包含当前用户信息
|
|
1195
|
+
* @private
|
|
1196
|
+
*/
|
|
1197
|
+
async getInvitees(userDid, options = {}, context = {}) {
|
|
1198
|
+
try {
|
|
1199
|
+
const { paging, sort, includeFollowStatus = true } = options;
|
|
1200
|
+
const { user: contextUser } = context;
|
|
1201
|
+
|
|
1202
|
+
const contextUserDid = contextUser?.userInfo?.did || contextUser?.did;
|
|
1203
|
+
|
|
1204
|
+
// 验证邀请者用户是否存在
|
|
1205
|
+
await this._validateUsersExist([userDid]);
|
|
1206
|
+
|
|
1207
|
+
// 查询被邀请的用户列表
|
|
1208
|
+
const where = { inviter: userDid };
|
|
1209
|
+
|
|
1210
|
+
// 设置排序
|
|
1211
|
+
const order = sort?.createdAt === -1 ? 'DESC' : 'ASC';
|
|
1212
|
+
const sorting = [['createdAt', sort?.createdAt ? order : 'DESC']];
|
|
1213
|
+
|
|
1214
|
+
// 分页查询
|
|
1215
|
+
const result = await this.paginate(
|
|
1216
|
+
{ where, attributes: ['did', 'fullName', 'avatar', 'createdAt', 'inviter'] },
|
|
1217
|
+
sorting,
|
|
1218
|
+
paging
|
|
1219
|
+
);
|
|
1220
|
+
|
|
1221
|
+
// 准备关注状态映射
|
|
1222
|
+
let followingStatusMap = {};
|
|
1223
|
+
if (includeFollowStatus && contextUserDid && this.userFollowers) {
|
|
1224
|
+
const inviteeDids = result.list.map((user) => user.did);
|
|
1225
|
+
if (inviteeDids.length > 0) {
|
|
1226
|
+
followingStatusMap = await this.isFollowing(contextUserDid, inviteeDids);
|
|
1227
|
+
}
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1230
|
+
// 构建增强的列表
|
|
1231
|
+
const enrichedList = result.list.map((user) => {
|
|
1232
|
+
const enrichedUser = { ...user };
|
|
1233
|
+
|
|
1234
|
+
// 添加关注状态
|
|
1235
|
+
if (includeFollowStatus && contextUserDid && contextUserDid !== user.did) {
|
|
1236
|
+
enrichedUser.isFollowing = followingStatusMap[user.did] || false;
|
|
1237
|
+
}
|
|
1238
|
+
|
|
1239
|
+
return enrichedUser;
|
|
1240
|
+
});
|
|
1241
|
+
|
|
1242
|
+
result.users = enrichedList;
|
|
1243
|
+
|
|
1244
|
+
return result;
|
|
1245
|
+
} catch (error) {
|
|
1246
|
+
logger.error('Failed to get invitees:', error);
|
|
1247
|
+
throw error;
|
|
1248
|
+
}
|
|
1249
|
+
}
|
|
1176
1250
|
}
|
|
1177
1251
|
|
|
1178
1252
|
module.exports = User;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
const generateClusterNodeScript = (scriptPath, instances) => `
|
|
2
|
+
// Auto-generated cluster script
|
|
3
|
+
const cluster = require('cluster');
|
|
4
|
+
const os = require('os');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
|
|
7
|
+
const numCPUs = os.cpus().length;
|
|
8
|
+
const workerCount = Math.min(${instances}, numCPUs);
|
|
9
|
+
|
|
10
|
+
// Restart protection: maximum restarts & time window, if 5 restarts in 60s, exit the entire program
|
|
11
|
+
const MAX_RESTARTS = 5;
|
|
12
|
+
const RESTART_WINDOW_MS = 60_000;
|
|
13
|
+
const restartTimestamps = [];
|
|
14
|
+
|
|
15
|
+
if (cluster.isMaster) {
|
|
16
|
+
console.log(\`[Master] PID=\${process.pid}, starting \${workerCount} workers...\`);
|
|
17
|
+
|
|
18
|
+
for (let i = 0; i < workerCount; i++) {
|
|
19
|
+
cluster.fork();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
cluster.on('exit', (worker, code, signal) => {
|
|
23
|
+
console.error(\`[Master] Worker \${worker.process.pid} died (code=\${code}, signal=\${signal})\`);
|
|
24
|
+
|
|
25
|
+
const now = Date.now();
|
|
26
|
+
restartTimestamps.push(now);
|
|
27
|
+
|
|
28
|
+
// Clean up old records that exceed the window period
|
|
29
|
+
while (restartTimestamps.length > 0 && restartTimestamps[0] < now - RESTART_WINDOW_MS) {
|
|
30
|
+
restartTimestamps.shift();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (restartTimestamps.length > MAX_RESTARTS) {
|
|
34
|
+
console.error('[Master] Too many worker restarts in short time, shutting down the cluster...');
|
|
35
|
+
// ⚠️ Exit the entire program, including master
|
|
36
|
+
process.exit(1);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
console.log('[Master] Restarting a new worker...');
|
|
41
|
+
setTimeout(() => cluster.fork(), 1000);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
cluster.on('online', (worker) => {
|
|
45
|
+
console.log(\`[Master] Worker \${worker.process.pid} is online\`);
|
|
46
|
+
});
|
|
47
|
+
} else {
|
|
48
|
+
console.log(\`[Worker] PID=\${process.pid} running: ${scriptPath}\`);
|
|
49
|
+
require(path.resolve('./', '${scriptPath}'));
|
|
50
|
+
}
|
|
51
|
+
`;
|
|
52
|
+
|
|
53
|
+
module.exports = generateClusterNodeScript;
|
|
@@ -15,11 +15,13 @@ const { dockerCmdValidator } = require('@abtnode/docker-utils');
|
|
|
15
15
|
const { getBlockletEngine } = require('@blocklet/meta/lib/engine');
|
|
16
16
|
const { isExternalBlocklet } = require('@blocklet/meta/lib/util');
|
|
17
17
|
|
|
18
|
+
const { isNumber } = require('lodash');
|
|
18
19
|
const parseDockerName = require('./parse-docker-name');
|
|
19
20
|
const { createDockerImage } = require('./create-docker-image');
|
|
20
21
|
const checkNeedRunDocker = require('./check-need-run-docker');
|
|
21
22
|
const replaceEnvValue = require('./replace-env-value');
|
|
22
23
|
const parseDockerCpVolume = require('./parse-docker-cp-volume');
|
|
24
|
+
const generateClusterNodeScript = require('./generate-cluster-node-script');
|
|
23
25
|
|
|
24
26
|
const getSystemResources = (() => {
|
|
25
27
|
let cachedResources = null;
|
|
@@ -205,9 +207,20 @@ async function parseDockerOptionsFromPm2({
|
|
|
205
207
|
await fsp.writeFile(dockerEnvFile, envVars);
|
|
206
208
|
|
|
207
209
|
let runScript = dockerInfo.script || '';
|
|
210
|
+
|
|
208
211
|
if (!runScript && dockerInfo.installNodeModules) {
|
|
212
|
+
if (!overrideScript && nextOptions.script && isNumber(nextOptions.instances) && nextOptions.instances > 1) {
|
|
213
|
+
createClusterScripts({
|
|
214
|
+
appDir: nextOptions.env.BLOCKLET_APP_DIR,
|
|
215
|
+
scriptPath: nextOptions.script.replace(/(npm|yarn|pnpm|bun)/, '').trim(),
|
|
216
|
+
instances: nextOptions.instances,
|
|
217
|
+
});
|
|
218
|
+
nextOptions.script = 'index-cluster.js';
|
|
219
|
+
}
|
|
220
|
+
|
|
209
221
|
const maxOldSpaceSize = Math.floor(Number(dockerEnv.BLOCKLET_DOCKER_MEMORY.replace('g', '')) * 0.85 * 1024);
|
|
210
222
|
const nodeInterpreter = `node ${process.env.ABT_NODE_BLOCKLET_MODE === ABT_NODE_KERNEL_OR_BLOCKLET_MODE.PERFORMANT ? '' : '--optimize_for_size'} --max-old-space-size=${maxOldSpaceSize} --max-http-header-size=16384 ${nextOptions.script} -- BLOCKLET_NAME=${options.name}`;
|
|
223
|
+
|
|
211
224
|
const bunInterpreter = `bun run ${nextOptions.script} -- BLOCKLET_NAME=${options.name}`;
|
|
212
225
|
const engine = getBlockletEngine(meta);
|
|
213
226
|
const runCommand = engine.interpreter === 'bun' ? bunInterpreter : nodeInterpreter;
|
|
@@ -386,6 +399,8 @@ async function parseDockerOptionsFromPm2({
|
|
|
386
399
|
await promiseSpawn(`docker pull ${meta.docker.image}`, {}, { timeout: 120 * 1000, retry: 0 });
|
|
387
400
|
}
|
|
388
401
|
|
|
402
|
+
delete nextOptions.instances;
|
|
403
|
+
|
|
389
404
|
return nextOptions;
|
|
390
405
|
}
|
|
391
406
|
|
|
@@ -421,4 +436,11 @@ ${userCommands.filter(Boolean).join('\n')}
|
|
|
421
436
|
writeFileSync(userScriptPath, userScriptContent, { mode: 0o755 });
|
|
422
437
|
}
|
|
423
438
|
|
|
439
|
+
function createClusterScripts({ appDir, scriptPath, instances }) {
|
|
440
|
+
const clusterScriptPath = path.join(appDir, 'index-cluster.js');
|
|
441
|
+
const rootScriptContent = generateClusterNodeScript(scriptPath, instances);
|
|
442
|
+
writeFileSync(clusterScriptPath, rootScriptContent, { mode: 0o755 });
|
|
443
|
+
return clusterScriptPath;
|
|
444
|
+
}
|
|
445
|
+
|
|
424
446
|
module.exports = parseDockerOptionsFromPm2;
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.16.
|
|
6
|
+
"version": "1.16.52-beta-20250909-073849-4e392ab1",
|
|
7
7
|
"description": "",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -19,22 +19,22 @@
|
|
|
19
19
|
"author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
|
|
20
20
|
"license": "Apache-2.0",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@abtnode/analytics": "1.16.
|
|
23
|
-
"@abtnode/auth": "1.16.
|
|
24
|
-
"@abtnode/certificate-manager": "1.16.
|
|
25
|
-
"@abtnode/constant": "1.16.
|
|
26
|
-
"@abtnode/cron": "1.16.
|
|
27
|
-
"@abtnode/db-cache": "1.16.
|
|
28
|
-
"@abtnode/docker-utils": "1.16.
|
|
29
|
-
"@abtnode/logger": "1.16.
|
|
30
|
-
"@abtnode/models": "1.16.
|
|
31
|
-
"@abtnode/queue": "1.16.
|
|
32
|
-
"@abtnode/rbac": "1.16.
|
|
33
|
-
"@abtnode/router-provider": "1.16.
|
|
34
|
-
"@abtnode/static-server": "1.16.
|
|
35
|
-
"@abtnode/timemachine": "1.16.
|
|
36
|
-
"@abtnode/util": "1.16.
|
|
37
|
-
"@aigne/aigne-hub": "^0.8.
|
|
22
|
+
"@abtnode/analytics": "1.16.52-beta-20250909-073849-4e392ab1",
|
|
23
|
+
"@abtnode/auth": "1.16.52-beta-20250909-073849-4e392ab1",
|
|
24
|
+
"@abtnode/certificate-manager": "1.16.52-beta-20250909-073849-4e392ab1",
|
|
25
|
+
"@abtnode/constant": "1.16.52-beta-20250909-073849-4e392ab1",
|
|
26
|
+
"@abtnode/cron": "1.16.52-beta-20250909-073849-4e392ab1",
|
|
27
|
+
"@abtnode/db-cache": "1.16.52-beta-20250909-073849-4e392ab1",
|
|
28
|
+
"@abtnode/docker-utils": "1.16.52-beta-20250909-073849-4e392ab1",
|
|
29
|
+
"@abtnode/logger": "1.16.52-beta-20250909-073849-4e392ab1",
|
|
30
|
+
"@abtnode/models": "1.16.52-beta-20250909-073849-4e392ab1",
|
|
31
|
+
"@abtnode/queue": "1.16.52-beta-20250909-073849-4e392ab1",
|
|
32
|
+
"@abtnode/rbac": "1.16.52-beta-20250909-073849-4e392ab1",
|
|
33
|
+
"@abtnode/router-provider": "1.16.52-beta-20250909-073849-4e392ab1",
|
|
34
|
+
"@abtnode/static-server": "1.16.52-beta-20250909-073849-4e392ab1",
|
|
35
|
+
"@abtnode/timemachine": "1.16.52-beta-20250909-073849-4e392ab1",
|
|
36
|
+
"@abtnode/util": "1.16.52-beta-20250909-073849-4e392ab1",
|
|
37
|
+
"@aigne/aigne-hub": "^0.8.10",
|
|
38
38
|
"@arcblock/did": "1.24.0",
|
|
39
39
|
"@arcblock/did-connect-js": "1.24.0",
|
|
40
40
|
"@arcblock/did-ext": "1.24.0",
|
|
@@ -45,16 +45,16 @@
|
|
|
45
45
|
"@arcblock/pm2-events": "^0.0.5",
|
|
46
46
|
"@arcblock/validator": "1.24.0",
|
|
47
47
|
"@arcblock/vc": "1.24.0",
|
|
48
|
-
"@blocklet/constant": "1.16.
|
|
49
|
-
"@blocklet/did-space-js": "^1.1.
|
|
50
|
-
"@blocklet/env": "1.16.
|
|
48
|
+
"@blocklet/constant": "1.16.52-beta-20250909-073849-4e392ab1",
|
|
49
|
+
"@blocklet/did-space-js": "^1.1.23",
|
|
50
|
+
"@blocklet/env": "1.16.52-beta-20250909-073849-4e392ab1",
|
|
51
51
|
"@blocklet/error": "^0.2.5",
|
|
52
|
-
"@blocklet/meta": "1.16.
|
|
53
|
-
"@blocklet/resolver": "1.16.
|
|
54
|
-
"@blocklet/sdk": "1.16.
|
|
55
|
-
"@blocklet/server-js": "1.16.
|
|
56
|
-
"@blocklet/store": "1.16.
|
|
57
|
-
"@blocklet/theme": "^3.1.
|
|
52
|
+
"@blocklet/meta": "1.16.52-beta-20250909-073849-4e392ab1",
|
|
53
|
+
"@blocklet/resolver": "1.16.52-beta-20250909-073849-4e392ab1",
|
|
54
|
+
"@blocklet/sdk": "1.16.52-beta-20250909-073849-4e392ab1",
|
|
55
|
+
"@blocklet/server-js": "1.16.52-beta-20250909-073849-4e392ab1",
|
|
56
|
+
"@blocklet/store": "1.16.52-beta-20250909-073849-4e392ab1",
|
|
57
|
+
"@blocklet/theme": "^3.1.37",
|
|
58
58
|
"@fidm/x509": "^1.2.1",
|
|
59
59
|
"@ocap/mcrypto": "1.24.0",
|
|
60
60
|
"@ocap/util": "1.24.0",
|
|
@@ -118,5 +118,5 @@
|
|
|
118
118
|
"jest": "^29.7.0",
|
|
119
119
|
"unzipper": "^0.10.11"
|
|
120
120
|
},
|
|
121
|
-
"gitHead": "
|
|
121
|
+
"gitHead": "3b4b1551b181606f84799ba8b294fb36b483c9c3"
|
|
122
122
|
}
|