@xcpcio/core 0.33.0 → 0.33.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +6 -3
- package/dist/index.mjs +6 -3
- package/package.json +2 -2
- package/src/problem.ts +4 -2
- package/src/utils/color.ts +4 -1
package/dist/index.cjs
CHANGED
|
@@ -468,7 +468,10 @@ function calcDirt(attemptedNum, solvedNum) {
|
|
|
468
468
|
function getWhiteOrBlackColor(background) {
|
|
469
469
|
const [R, G, B] = chroma__default(background).rgb();
|
|
470
470
|
const color = { R, G, B };
|
|
471
|
-
const palette = [
|
|
471
|
+
const palette = [
|
|
472
|
+
{ R: 0, G: 0, B: 0 },
|
|
473
|
+
{ R: 255, G: 255, B: 255 }
|
|
474
|
+
];
|
|
472
475
|
const f = colorDiff.furthest(color, palette);
|
|
473
476
|
if (f.R === 0 && f.G === 0 && f.B === 0) {
|
|
474
477
|
return "#000";
|
|
@@ -525,7 +528,7 @@ function createProblem(problemJSON) {
|
|
|
525
528
|
p.timeLimit = problemJSON.time_limit;
|
|
526
529
|
p.memoryLimit = problemJSON.memory_limit;
|
|
527
530
|
if (problemJSON.balloon_color) {
|
|
528
|
-
p.balloonColor = problemJSON.balloon_color;
|
|
531
|
+
p.balloonColor = ___default.cloneDeep(problemJSON.balloon_color);
|
|
529
532
|
}
|
|
530
533
|
p.balloonColor.color = getWhiteOrBlackColor(p.balloonColor.background_color);
|
|
531
534
|
return p;
|
|
@@ -542,7 +545,7 @@ function createProblemsByProblemIds(problemIds, balloonColors) {
|
|
|
542
545
|
});
|
|
543
546
|
if (balloonColors !== void 0 && balloonColors !== null) {
|
|
544
547
|
for (const index in balloonColors) {
|
|
545
|
-
problems[index].balloonColor = balloonColors[index];
|
|
548
|
+
problems[index].balloonColor = ___default.cloneDeep(balloonColors[index]);
|
|
546
549
|
}
|
|
547
550
|
}
|
|
548
551
|
problems.forEach((p) => {
|
package/dist/index.mjs
CHANGED
|
@@ -437,7 +437,10 @@ function calcDirt(attemptedNum, solvedNum) {
|
|
|
437
437
|
function getWhiteOrBlackColor(background) {
|
|
438
438
|
const [R, G, B] = chroma(background).rgb();
|
|
439
439
|
const color = { R, G, B };
|
|
440
|
-
const palette = [
|
|
440
|
+
const palette = [
|
|
441
|
+
{ R: 0, G: 0, B: 0 },
|
|
442
|
+
{ R: 255, G: 255, B: 255 }
|
|
443
|
+
];
|
|
441
444
|
const f = furthest(color, palette);
|
|
442
445
|
if (f.R === 0 && f.G === 0 && f.B === 0) {
|
|
443
446
|
return "#000";
|
|
@@ -494,7 +497,7 @@ function createProblem(problemJSON) {
|
|
|
494
497
|
p.timeLimit = problemJSON.time_limit;
|
|
495
498
|
p.memoryLimit = problemJSON.memory_limit;
|
|
496
499
|
if (problemJSON.balloon_color) {
|
|
497
|
-
p.balloonColor = problemJSON.balloon_color;
|
|
500
|
+
p.balloonColor = _.cloneDeep(problemJSON.balloon_color);
|
|
498
501
|
}
|
|
499
502
|
p.balloonColor.color = getWhiteOrBlackColor(p.balloonColor.background_color);
|
|
500
503
|
return p;
|
|
@@ -511,7 +514,7 @@ function createProblemsByProblemIds(problemIds, balloonColors) {
|
|
|
511
514
|
});
|
|
512
515
|
if (balloonColors !== void 0 && balloonColors !== null) {
|
|
513
516
|
for (const index in balloonColors) {
|
|
514
|
-
problems[index].balloonColor = balloonColors[index];
|
|
517
|
+
problems[index].balloonColor = _.cloneDeep(balloonColors[index]);
|
|
515
518
|
}
|
|
516
519
|
}
|
|
517
520
|
problems.forEach((p) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xcpcio/core",
|
|
3
|
-
"version": "0.33.
|
|
3
|
+
"version": "0.33.1",
|
|
4
4
|
"description": "XCPCIO Core",
|
|
5
5
|
"author": "Dup4 <lyuzhi.pan@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"lodash": "^4.17.21",
|
|
47
47
|
"string-width": "^6.1.0",
|
|
48
48
|
"xlsx-js-style": "^1.2.0",
|
|
49
|
-
"@xcpcio/types": "0.33.
|
|
49
|
+
"@xcpcio/types": "0.33.1"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@babel/types": "^7.22.4",
|
package/src/problem.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import _ from "lodash";
|
|
2
|
+
|
|
1
3
|
import type { BalloonColor, Problem as IProblem, Problems as IProblems } from "@xcpcio/types";
|
|
2
4
|
|
|
3
5
|
import type { Submissions } from "./submission";
|
|
@@ -92,7 +94,7 @@ export function createProblem(problemJSON: IProblem): Problem {
|
|
|
92
94
|
p.memoryLimit = problemJSON.memory_limit;
|
|
93
95
|
|
|
94
96
|
if (problemJSON.balloon_color) {
|
|
95
|
-
p.balloonColor = problemJSON.balloon_color;
|
|
97
|
+
p.balloonColor = _.cloneDeep(problemJSON.balloon_color);
|
|
96
98
|
}
|
|
97
99
|
|
|
98
100
|
p.balloonColor.color = getWhiteOrBlackColor(p.balloonColor.background_color as string);
|
|
@@ -115,7 +117,7 @@ export function createProblemsByProblemIds(problemIds: string[], balloonColors?:
|
|
|
115
117
|
|
|
116
118
|
if (balloonColors !== undefined && balloonColors !== null) {
|
|
117
119
|
for (const index in balloonColors) {
|
|
118
|
-
problems[index].balloonColor = balloonColors[index];
|
|
120
|
+
problems[index].balloonColor = _.cloneDeep(balloonColors[index]);
|
|
119
121
|
}
|
|
120
122
|
}
|
|
121
123
|
|
package/src/utils/color.ts
CHANGED
|
@@ -4,7 +4,10 @@ import chroma from "chroma-js";
|
|
|
4
4
|
export function getWhiteOrBlackColor(background: string) {
|
|
5
5
|
const [R, G, B] = chroma(background).rgb();
|
|
6
6
|
const color = { R, G, B };
|
|
7
|
-
const palette = [
|
|
7
|
+
const palette = [
|
|
8
|
+
{ R: 0, G: 0, B: 0 },
|
|
9
|
+
{ R: 255, G: 255, B: 255 },
|
|
10
|
+
];
|
|
8
11
|
|
|
9
12
|
const f = furthest(color, palette);
|
|
10
13
|
|