完成世界书、骰子、apiconfig页面处理

This commit is contained in:
2026-04-30 01:35:10 +08:00
parent a3e3711b2b
commit ba9b925c32
4602 changed files with 785225 additions and 23 deletions

89
frontend/node_modules/khroma/test/methods/adjust.js generated vendored Normal file
View File

@@ -0,0 +1,89 @@
/* IMPORT */
import {describe} from 'fava';
import {adjust} from '../../dist/index.js';
import Color from '../../dist/color/index.js';
/* MAIN */
describe ( 'adjust', it => {
it ( 'increases or decreases the value of any RGB channel of the color', t => {
const tests = [
[['rgb(0, 0, 0)', { r: 100 }], 'rgb(100, 0, 0)'],
[['rgb(0, 0, 0)', { g: 100 }], 'rgb(0, 100, 0)'],
[['rgb(0, 0, 0)', { b: 100 }], 'rgb(0, 0, 100)'],
[['rgb(0, 0, 0)', { r: 100, g: 100 }], 'rgb(100, 100, 0)'],
[['rgb(0, 0, 0)', { r: 100, g: 100, b: 100 }], 'rgb(100, 100, 100)'],
[['rgb(255, 255, 255)', { r: -100 }], 'rgb(155, 255, 255)'],
[['rgb(255, 255, 255)', { g: -100 }], 'rgb(255, 155, 255)'],
[['rgb(255, 255, 255)', { b: -100 }], 'rgb(255, 255, 155)'],
[['rgb(200, 0, 0)', { r: 100 }], 'rgb(255, 0, 0)'],
[['rgb(100, 0, 0)', { r: -200 }], 'rgb(0, 0, 0)']
];
tests.forEach ( ([ args, output ]) => {
t.is ( Color.format.rgb.stringify ( Color.parse ( adjust ( ...args ) ) ), output );
});
});
it ( 'increases or decreases the value of any HSL channel of the color', t => {
const tests = [
[['hsl(0, 50%, 50%)', { h: 100 }], 'hsl(100, 50%, 50%)'],
[['hsl(0, 50%, 50%)', { s: 25 }], 'hsl(0, 75%, 50%)'],
[['hsl(0, 50%, 50%)', { l: 25 }], 'hsl(0, 50%, 75%)'],
[['hsl(0, 50%, 50%)', { h: 100, s: 25 }], 'hsl(100, 75%, 50%)'],
[['hsl(0, 50%, 50%)', { h: 100, s: 25, l: 25 }], 'hsl(100, 75%, 75%)'],
[['hsl(100, 50%, 50%)', { h: -100 }], 'hsl(0, 50%, 50%)'],
[['hsl(0, 50%, 50%)', { s: -25 }], 'hsl(0, 25%, 50%)'],
[['hsl(0, 50%, 50%)', { l: -25 }], 'hsl(0, 50%, 25%)'],
[['hsl(300, 50%, 50%)', { h: 100 }], 'hsl(40, 50%, 50%)'],
[['hsl(0, 50%, 50%)', { h: -100 }], 'hsl(-100, 50%, 50%)'],
[['hsl(0, 100%, 50%)', { s: 25 }], 'hsl(0, 100%, 50%)'],
[['hsl(0, 0%, 50%)', { s: -25 }], 'hsl(0, 0%, 50%)'],
[['hsla(0, 0%, 50%, .5)', { s: -25 }], 'hsla(0, 0%, 50%, 0.5)']
];
tests.forEach ( ([ args, output ]) => {
t.is ( Color.format.hsl.stringify ( Color.parse ( adjust ( ...args ) ) ), output );
});
});
it ( 'increases or decreases the value of the alpha channel of the color', t => {
const tests = [
[['rgba(0, 0, 0, 0)', { a: 0.5 }], 'rgba(0, 0, 0, 0.5)'],
[['hsla(0, 0%, 0%, 0)', { a: 0.5 }], 'hsla(0, 0%, 0%, 0.5)'],
[['rgba(0, 0, 0, 0)', { a: 1 }], '#000000'],
[['rgba(0, 0, 0, 1)', { a: -0.5 }], 'rgba(0, 0, 0, 0.5)'],
[['rgba(0, 0, 0, 1)', { a: -1 }], 'rgba(0, 0, 0, 0)'],
[['rgba(0, 0, 0, 0.5)', { a: 1 }], '#000000'],
[['rgba(0, 0, 0, 0.5)', { a: -1 }], 'rgba(0, 0, 0, 0)']
];
tests.forEach ( ([ args, output ]) => {
t.is ( adjust ( ...args ), output );
});
});
it ( 'throws when setting RGB and HSL channels at the same time', t => {
const tests = [
['#000', { r: 10, h: 10 }],
['#000', { g: 10, l: 10 }],
['#000', { b: 10, s: 10 }]
];
tests.forEach ( args => {
t.throws ( () => adjust ( ...args ), /cannot.*at the same time/i );
});
});
});

View File

@@ -0,0 +1,25 @@
/* IMPORT */
import {describe} from 'fava';
import {complement} from '../../dist/index.js';
/* MAIN */
describe ( 'complement', it => {
it ( 'gets the complement of the color', t => {
const tests = [
['#6b717f', 'hsl(42, 8.547008547%, 45.8823529412%)'],
['#d2e1dd', 'hsl(344, 20%, 85.2941176471%)'],
['#036', 'hsl(30, 100%, 20%)']
];
tests.forEach ( ([ color, output ]) => {
t.is ( complement ( color ), output );
});
});
});

28
frontend/node_modules/khroma/test/methods/contrast.js generated vendored Normal file
View File

@@ -0,0 +1,28 @@
/* IMPORT */
import {describe} from 'fava';
import {contrast} from '../../dist/index.js';
/* MAIN */
describe ( 'contrast', it => {
it ( 'gets the contrast ratio between two colors', t => {
const tests = [
['#000000', '#000000', 1],
['#ffffff', '#ffffff', 1],
['#000000', '#ffffff', 10],
['#ffffff', '#000000', 10],
['#888888', '#ffffff', 4.0617165366],
['#ffffff', '#888888', 4.0617165366]
];
tests.forEach ( ([ color1, color2, output ]) => {
t.is ( contrast ( color1, color2 ), output );
});
});
});

27
frontend/node_modules/khroma/test/methods/darken.js generated vendored Normal file
View File

@@ -0,0 +1,27 @@
/* IMPORT */
import {describe} from 'fava';
import {darken} from '../../dist/index.js';
/* MAIN */
describe ( 'darken', it => {
it ( 'decreases the lightness channel of the color', t => {
const tests = [
[['hsl(0, 0%, 100%)', 0], 'hsl(0, 0%, 100%)'],
[['hsl(0, 0%, 100%)', 50], 'hsl(0, 0%, 50%)'],
[['hsl(0, 0%, 100%)', 75], 'hsl(0, 0%, 25%)'],
[['hsl(0, 0%, 100%)', 100], 'hsl(0, 0%, 0%)'],
[['hsl(0, 0%, 50%)', 100], 'hsl(0, 0%, 0%)']
];
tests.forEach ( ([ args, output ]) => {
t.is ( darken ( ...args ), output );
});
});
});

View File

@@ -0,0 +1,28 @@
/* IMPORT */
import {describe} from 'fava';
import {desaturate} from '../../dist/index.js';
/* MAIN */
describe ( 'desaturate', it => {
it ( 'decreases the saturation channel of the color', t => {
const tests = [
[['hsl(0, 100%, 50%)', 0], 'hsl(0, 100%, 50%)'],
[['hsl(0, 100%, 50%)', 50], 'hsl(0, 50%, 50%)'],
[['hsl(0, 100%, 50%)', 75], 'hsl(0, 25%, 50%)'],
[['hsl(0, 100%, 50%)', 100], 'hsl(0, 0%, 50%)'],
[['hsl(0, 50%, 50%)', 100], 'hsl(0, 0%, 50%)'],
[['hsl(0, 0%, 50%)', 100], 'hsl(0, 0%, 50%)']
];
tests.forEach ( ([ args, output ]) => {
t.is ( desaturate ( ...args ), output );
});
});
});

25
frontend/node_modules/khroma/test/methods/grayscale.js generated vendored Normal file
View File

@@ -0,0 +1,25 @@
/* IMPORT */
import {describe} from 'fava';
import {grayscale} from '../../dist/index.js';
/* MAIN */
describe ( 'grayscale', it => {
it ( 'gets the grayscale version of the color', t => {
const tests = [
['#6b717f', 'hsl(222, 0%, 45.8823529412%)'],
['#d2e1dd', 'hsl(164, 0%, 85.2941176471%)'],
['#036', 'hsl(210, 0%, 20%)']
];
tests.forEach ( ([ color, output ]) => {
t.is ( grayscale ( color ), output );
});
});
});

41
frontend/node_modules/khroma/test/methods/hex.js generated vendored Normal file
View File

@@ -0,0 +1,41 @@
/* IMPORT */
import {describe} from 'fava';
import {hex} from '../../dist/index.js';
/* MAIN */
describe ( 'hex', it => {
it ( 'creates a new color given its rgba channels', t => {
const tests = [
[[0, 0, 0, 0], 'rgba(0, 0, 0, 0)'],
[[255, 255, 255, 0.5], 'rgba(255, 255, 255, 0.5)'],
[[0, 0, 0, 1], '#000000'],
[[128, 128, 128, 1], '#808080'],
[[-1, -1, -1, -1], 'rgba(0, 0, 0, 0)'],
[[1000, 1000, 1000, 1000], '#ffffff']
];
tests.forEach ( ([ args, output ]) => {
t.is ( hex ( ...args ), output );
});
});
it ( 'allows ommiting the alpha channel', t => {
const tests = [
[[0, 0, 0], '#000000'],
[[255, 255, 255], '#ffffff']
];
tests.forEach ( ([ args, output ]) => {
t.is ( hex ( ...args ), output );
});
});
});

28
frontend/node_modules/khroma/test/methods/is_light.js generated vendored Normal file
View File

@@ -0,0 +1,28 @@
/* IMPORT */
import {describe} from 'fava';
import {isLight} from '../../dist/index.js';
/* MAIN */
describe ( 'isLight', it => {
it ( 'checks if the provided color is a light color', t => {
const tests = [
['#000000', false],
['#8a8a8a', false],
['#bbbbbb', false],
['#ffcc00', true],
['#e0e0e0', true],
['#ffffff', true]
];
tests.forEach ( ([ color, output ]) => {
t.is ( isLight ( color ), output );
});
});
});

View File

@@ -0,0 +1,33 @@
/* IMPORT */
import {describe} from 'fava';
import {isTransparent} from '../../dist/index.js';
/* MAIN */
describe ( 'isTransparent', it => {
it ( 'checks if the provided color is a transparent color', t => {
const tests = [
['transparent', true],
['#00000000', true],
['#ffffff00', true],
['black', false],
['#00000001', false],
['#ffffffff', false],
['#8a8a8a', false],
['#bbbbbb', false],
['#ffcc00', false],
['#e0e0e0', false],
['#ffffff', false]
];
tests.forEach ( ([ color, output ]) => {
t.is ( isTransparent ( color ), output );
});
});
});

28
frontend/node_modules/khroma/test/methods/lighten.js generated vendored Normal file
View File

@@ -0,0 +1,28 @@
/* IMPORT */
import {describe} from 'fava';
import {lighten} from '../../dist/index.js';
/* MAIN */
describe ( 'lighten', it => {
it ( 'increases the lightness channel of the color', t => {
const tests = [
[['hsl(0, 0%, 0%)', 0], 'hsl(0, 0%, 0%)'],
[['hsl(0, 0%, 0%)', 50], 'hsl(0, 0%, 50%)'],
[['hsl(0, 0%, 0%)', 75], 'hsl(0, 0%, 75%)'],
[['hsl(0, 0%, 0%)', 100], 'hsl(0, 0%, 100%)'],
[['hsl(0, 0%, 50%)', 100], 'hsl(0, 0%, 100%)'],
[['hsl(0, 0%, 100%)', 100], 'hsl(0, 0%, 100%)']
];
tests.forEach ( ([ args, output ]) => {
t.is ( lighten ( ...args ), output );
});
});
});

26
frontend/node_modules/khroma/test/methods/mix.js generated vendored Normal file
View File

@@ -0,0 +1,26 @@
/* IMPORT */
import {describe} from 'fava';
import {mix} from '../../dist/index.js';
/* MAIN */
describe ( 'mix', it => {
it ( 'mixes two colors together', t => {
const tests = [
[['#036', '#d2e1dd'], 'rgb(105, 138, 161.5)'],
[['#036', '#d2e1dd', 75 ], 'rgb(52.5, 94.5, 131.75)'],
[['#036', '#d2e1dd', 25 ], 'rgb(157.5, 181.5, 191.25)'],
[['rgba(242, 236, 228, 0.5)', '#6b717f'], 'rgba(140.75, 143.75, 152.25, 0.75)']
];
tests.forEach ( ([ args, output ]) => {
t.is ( mix ( ...args ), output );
});
});
});

25
frontend/node_modules/khroma/test/methods/opacify.js generated vendored Normal file
View File

@@ -0,0 +1,25 @@
/* IMPORT */
import {describe} from 'fava';
import {opacify} from '../../dist/index.js';
/* MAIN */
describe ( 'opacify', it => {
it ( 'increases the opacity channel of the color', t => {
const tests = [
[['#000000', 1], '#000000'],
[['rgba(0, 0, 0, 0.5)', 0.5], '#000000'],
[['rgba(0, 0, 0, 0.5)', 0.1], 'rgba(0, 0, 0, 0.6)']
];
tests.forEach ( ([ args, output ]) => {
t.is ( opacify ( ...args ), output );
});
});
});

28
frontend/node_modules/khroma/test/methods/saturate.js generated vendored Normal file
View File

@@ -0,0 +1,28 @@
/* IMPORT */
import {describe} from 'fava';
import {saturate} from '../../dist/index.js';
/* MAIN */
describe ( 'saturate', it => {
it ( 'increases the saturation channel of the color', t => {
const tests = [
[['hsl(0, 0%, 50%)', 0], 'hsl(0, 0%, 50%)'],
[['hsl(0, 0%, 50%)', 50], 'hsl(0, 50%, 50%)'],
[['hsl(0, 0%, 50%)', 75], 'hsl(0, 75%, 50%)'],
[['hsl(0, 0%, 50%)', 100], 'hsl(0, 100%, 50%)'],
[['hsl(0, 50%, 50%)', 100], 'hsl(0, 100%, 50%)'],
[['hsl(0, 100%, 50%)', 100], 'hsl(0, 100%, 50%)']
];
tests.forEach ( ([ args, output ]) => {
t.is ( saturate ( ...args ), output );
});
});
});

View File

@@ -0,0 +1,26 @@
/* IMPORT */
import {describe} from 'fava';
import {transparentize} from '../../dist/index.js';
/* MAIN */
describe ( 'transparentize', it => {
it ( 'decreases the opacity channel of the color', t => {
const tests = [
[['#000000', 1], 'rgba(0, 0, 0, 0)'],
[['rgba(0, 0, 0, 0.5)', 0.5], 'rgba(0, 0, 0, 0)'],
[['rgba(0, 0, 0, 0.5)', 1], 'rgba(0, 0, 0, 0)'],
[['rgba(0, 0, 0, 0.5)', 0.1], 'rgba(0, 0, 0, 0.4)']
];
tests.forEach ( ([ args, output ]) => {
t.is ( transparentize ( ...args ), output );
});
});
});