mirror of
https://github.com/niklasvh/html2canvas.git
synced 2023-08-10 21:13:10 +03:00
deps: update dependencies with lint fixes (#2565)
This commit is contained in:
committed by
GitHub
parent
e7a021ab93
commit
b2902ec31c
@@ -289,7 +289,6 @@ const parse = (descriptor: CSSPropertyDescriptor<any>, style?: string | null) =>
|
||||
const value = parser.parseComponentValue();
|
||||
return isLengthPercentage(value) ? value : ZERO_LENGTH;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
throw new Error(`Attempting to parse unsupported css format type ${descriptor.format}`);
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export const {Bounds} = jest.requireActual('../bounds');
|
||||
export const parseBounds = () => {
|
||||
export const parseBounds = (): typeof Bounds => {
|
||||
return new Bounds(0, 0, 200, 50);
|
||||
};
|
||||
|
||||
@@ -18,7 +18,7 @@ export const parseTextBounds = (value: string, styles: CSSParsedDeclaration, nod
|
||||
const textList = breakText(value, styles);
|
||||
const textBounds: TextBounds[] = [];
|
||||
let offset = 0;
|
||||
textList.forEach(text => {
|
||||
textList.forEach((text) => {
|
||||
if (styles.textDecorationLine.length || text.trim().length > 0) {
|
||||
if (FEATURES.SUPPORT_RANGE_BOUNDS) {
|
||||
textBounds.push(new TextBounds(text, getRangeBounds(node, offset, text.length)));
|
||||
@@ -67,7 +67,7 @@ const getRangeBounds = (node: Text, offset: number, length: number): Bounds => {
|
||||
};
|
||||
|
||||
const breakText = (value: string, styles: CSSParsedDeclaration): string[] => {
|
||||
return styles.letterSpacing !== 0 ? toCodePoints(value).map(i => fromCodePoint(i)) : breakWords(value, styles);
|
||||
return styles.letterSpacing !== 0 ? toCodePoints(value).map((i) => fromCodePoint(i)) : breakWords(value, styles);
|
||||
};
|
||||
|
||||
const breakWords = (str: string, styles: CSSParsedDeclaration): string[] => {
|
||||
|
||||
@@ -32,7 +32,10 @@ describe('property-descriptors', () => {
|
||||
{
|
||||
angle: deg(180),
|
||||
type: CSSImageType.LINEAR_GRADIENT,
|
||||
stops: [{color: pack(255, 255, 0, 0.5), stop: null}, {color: pack(0, 0, 255, 0.5), stop: null}]
|
||||
stops: [
|
||||
{color: pack(255, 255, 0, 0.5), stop: null},
|
||||
{color: pack(0, 0, 255, 0.5), stop: null}
|
||||
]
|
||||
},
|
||||
{url: 'https://html2canvas.hertzen.com', type: CSSImageType.URL}
|
||||
]
|
||||
|
||||
@@ -9,13 +9,9 @@ describe('property-descriptors', () => {
|
||||
it('matrix(1.0, 2.0, 3.0, 4.0, 5.0, 6.0)', () =>
|
||||
deepStrictEqual(parseValue('matrix(1.0, 2.0, 3.0, 4.0, 5.0, 6.0)'), [1, 2, 3, 4, 5, 6]));
|
||||
it('matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)', () =>
|
||||
deepStrictEqual(parseValue('matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'), [
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0
|
||||
]));
|
||||
deepStrictEqual(
|
||||
parseValue('matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'),
|
||||
[1, 0, 0, 1, 0, 0]
|
||||
));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -14,7 +14,7 @@ export const backgroundClip: IPropertyListDescriptor<BackgroundClip> = {
|
||||
prefix: false,
|
||||
type: PropertyDescriptorParsingType.LIST,
|
||||
parse: (tokens: CSSValue[]): BackgroundClip => {
|
||||
return tokens.map(token => {
|
||||
return tokens.map((token) => {
|
||||
if (isIdentToken(token)) {
|
||||
switch (token.value) {
|
||||
case 'padding-box':
|
||||
|
||||
@@ -19,6 +19,6 @@ export const backgroundImage: IPropertyListDescriptor<ICSSImage[]> = {
|
||||
return [];
|
||||
}
|
||||
|
||||
return tokens.filter(value => nonFunctionArgSeparator(value) && isSupportedImage(value)).map(image.parse);
|
||||
return tokens.filter((value) => nonFunctionArgSeparator(value) && isSupportedImage(value)).map(image.parse);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -15,7 +15,7 @@ export const backgroundOrigin: IPropertyListDescriptor<BackgroundOrigin> = {
|
||||
prefix: false,
|
||||
type: PropertyDescriptorParsingType.LIST,
|
||||
parse: (tokens: CSSValue[]): BackgroundOrigin => {
|
||||
return tokens.map(token => {
|
||||
return tokens.map((token) => {
|
||||
if (isIdentToken(token)) {
|
||||
switch (token.value) {
|
||||
case 'padding-box':
|
||||
|
||||
@@ -16,10 +16,10 @@ export const backgroundRepeat: IPropertyListDescriptor<BackgroundRepeat> = {
|
||||
type: PropertyDescriptorParsingType.LIST,
|
||||
parse: (tokens: CSSValue[]): BackgroundRepeat => {
|
||||
return parseFunctionArgs(tokens)
|
||||
.map(values =>
|
||||
.map((values) =>
|
||||
values
|
||||
.filter(isIdentToken)
|
||||
.map(token => token.value)
|
||||
.map((token) => token.value)
|
||||
.join(' ')
|
||||
)
|
||||
.map(parseBackgroundRepeat);
|
||||
|
||||
@@ -18,7 +18,7 @@ export const backgroundSize: IPropertyListDescriptor<BackgroundSize> = {
|
||||
prefix: false,
|
||||
type: PropertyDescriptorParsingType.LIST,
|
||||
parse: (tokens: CSSValue[]): BackgroundSize => {
|
||||
return parseFunctionArgs(tokens).map(values => values.filter(isBackgroundSizeInfoToken));
|
||||
return parseFunctionArgs(tokens).map((values) => values.filter(isBackgroundSizeInfoToken));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ export const fontFamily: IPropertyListDescriptor<FontFamily> = {
|
||||
parse: (tokens: CSSValue[]) => {
|
||||
const accumulator: string[] = [];
|
||||
const results: string[] = [];
|
||||
tokens.forEach(token => {
|
||||
tokens.forEach((token) => {
|
||||
switch (token.type) {
|
||||
case TokenType.IDENT_TOKEN:
|
||||
case TokenType.STRING_TOKEN:
|
||||
@@ -32,6 +32,6 @@ export const fontFamily: IPropertyListDescriptor<FontFamily> = {
|
||||
if (accumulator.length) {
|
||||
results.push(accumulator.join(' '));
|
||||
}
|
||||
return results.map(result => (result.indexOf(' ') === -1 ? result : `'${result}'`));
|
||||
return results.map((result) => (result.indexOf(' ') === -1 ? result : `'${result}'`));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -6,6 +6,6 @@ export const fontVariant: IPropertyListDescriptor<string[]> = {
|
||||
type: PropertyDescriptorParsingType.LIST,
|
||||
prefix: false,
|
||||
parse: (tokens: CSSValue[]): string[] => {
|
||||
return tokens.filter(isIdentToken).map(token => token.value);
|
||||
return tokens.filter(isIdentToken).map((token) => token.value);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -13,7 +13,7 @@ export const overflow: IPropertyListDescriptor<OVERFLOW[]> = {
|
||||
prefix: false,
|
||||
type: PropertyDescriptorParsingType.LIST,
|
||||
parse: (tokens: CSSValue[]): OVERFLOW[] => {
|
||||
return tokens.filter(isIdentToken).map(overflow => {
|
||||
return tokens.filter(isIdentToken).map((overflow) => {
|
||||
switch (overflow.value) {
|
||||
case 'hidden':
|
||||
return OVERFLOW.HIDDEN;
|
||||
|
||||
@@ -19,7 +19,7 @@ export const textDecorationLine: IPropertyListDescriptor<TextDecorationLine> = {
|
||||
parse: (tokens: CSSValue[]): TextDecorationLine => {
|
||||
return tokens
|
||||
.filter(isIdentToken)
|
||||
.map(token => {
|
||||
.map((token) => {
|
||||
switch (token.value) {
|
||||
case 'underline':
|
||||
return TEXT_DECORATION_LINE.UNDERLINE;
|
||||
@@ -32,6 +32,6 @@ export const textDecorationLine: IPropertyListDescriptor<TextDecorationLine> = {
|
||||
}
|
||||
return TEXT_DECORATION_LINE.NONE;
|
||||
})
|
||||
.filter(line => line !== TEXT_DECORATION_LINE.NONE);
|
||||
.filter((line) => line !== TEXT_DECORATION_LINE.NONE);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -27,14 +27,14 @@ export const transform: IPropertyValueDescriptor<Transform> = {
|
||||
};
|
||||
|
||||
const matrix = (args: CSSValue[]): Transform => {
|
||||
const values = args.filter(arg => arg.type === TokenType.NUMBER_TOKEN).map((arg: NumberValueToken) => arg.number);
|
||||
const values = args.filter((arg) => arg.type === TokenType.NUMBER_TOKEN).map((arg: NumberValueToken) => arg.number);
|
||||
|
||||
return values.length === 6 ? (values as Matrix) : null;
|
||||
};
|
||||
|
||||
// doesn't support 3D transforms at the moment
|
||||
const matrix3d = (args: CSSValue[]): Transform => {
|
||||
const values = args.filter(arg => arg.type === TokenType.NUMBER_TOKEN).map((arg: NumberValueToken) => arg.number);
|
||||
const values = args.filter((arg) => arg.type === TokenType.NUMBER_TOKEN).map((arg: NumberValueToken) => arg.number);
|
||||
|
||||
const [a1, b1, {}, {}, a2, b2, {}, {}, {}, {}, {}, {}, a4, b4, {}, {}] = values;
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ export class Parser {
|
||||
parseComponentValues(): CSSValue[] {
|
||||
const values = [];
|
||||
while (true) {
|
||||
let value = this.consumeComponentValue();
|
||||
const value = this.consumeComponentValue();
|
||||
if (value.type === TokenType.EOF_TOKEN) {
|
||||
return values;
|
||||
}
|
||||
@@ -148,14 +148,14 @@ export const isStringToken = (token: CSSValue): token is StringValueToken => tok
|
||||
export const isIdentWithValue = (token: CSSValue, value: string): boolean =>
|
||||
isIdentToken(token) && token.value === value;
|
||||
|
||||
export const nonWhiteSpace = (token: CSSValue) => token.type !== TokenType.WHITESPACE_TOKEN;
|
||||
export const nonFunctionArgSeparator = (token: CSSValue) =>
|
||||
export const nonWhiteSpace = (token: CSSValue): boolean => token.type !== TokenType.WHITESPACE_TOKEN;
|
||||
export const nonFunctionArgSeparator = (token: CSSValue): boolean =>
|
||||
token.type !== TokenType.WHITESPACE_TOKEN && token.type !== TokenType.COMMA_TOKEN;
|
||||
|
||||
export const parseFunctionArgs = (tokens: CSSValue[]): CSSValue[][] => {
|
||||
const args: CSSValue[][] = [];
|
||||
let arg: CSSValue[] = [];
|
||||
tokens.forEach(token => {
|
||||
tokens.forEach((token) => {
|
||||
if (token.type === TokenType.COMMA_TOKEN) {
|
||||
if (arg.length === 0) {
|
||||
throw new Error(`Error parsing function args, zero tokens for arg`);
|
||||
|
||||
@@ -315,7 +315,7 @@ export class Tokenizer {
|
||||
this._value = [];
|
||||
}
|
||||
|
||||
write(chunk: string) {
|
||||
write(chunk: string): void {
|
||||
this._value = this._value.concat(toCodePoints(chunk));
|
||||
}
|
||||
|
||||
@@ -542,8 +542,11 @@ export class Tokenizer {
|
||||
}
|
||||
|
||||
if (questionMarks) {
|
||||
const start = parseInt(fromCodePoint(...digits.map(digit => (digit === QUESTION_MARK ? ZERO : digit))), 16);
|
||||
const end = parseInt(fromCodePoint(...digits.map(digit => (digit === QUESTION_MARK ? F : digit))), 16);
|
||||
const start = parseInt(
|
||||
fromCodePoint(...digits.map((digit) => (digit === QUESTION_MARK ? ZERO : digit))),
|
||||
16
|
||||
);
|
||||
const end = parseInt(fromCodePoint(...digits.map((digit) => (digit === QUESTION_MARK ? F : digit))), 16);
|
||||
return {type: TokenType.UNICODE_RANGE_TOKEN, start, end};
|
||||
}
|
||||
|
||||
@@ -642,7 +645,7 @@ export class Tokenizer {
|
||||
|
||||
private consumeBadUrlRemnants(): void {
|
||||
while (true) {
|
||||
let codePoint = this.consumeCodePoint();
|
||||
const codePoint = this.consumeCodePoint();
|
||||
if (codePoint === RIGHT_PARENTHESIS || codePoint === EOF) {
|
||||
return;
|
||||
}
|
||||
@@ -702,7 +705,7 @@ export class Tokenizer {
|
||||
}
|
||||
|
||||
private consumeNumber() {
|
||||
let repr = [];
|
||||
const repr = [];
|
||||
let type = FLAG_INTEGER;
|
||||
let c1 = this.peekCodePoint(0);
|
||||
if (c1 === PLUS_SIGN || c1 === HYPHEN_MINUS) {
|
||||
@@ -724,7 +727,7 @@ export class Tokenizer {
|
||||
|
||||
c1 = this.peekCodePoint(0);
|
||||
c2 = this.peekCodePoint(1);
|
||||
let c3 = this.peekCodePoint(2);
|
||||
const c3 = this.peekCodePoint(2);
|
||||
if ((c1 === E || c1 === e) && (((c2 === PLUS_SIGN || c2 === HYPHEN_MINUS) && isDigit(c3)) || isDigit(c2))) {
|
||||
repr.push(this.consumeCodePoint(), this.consumeCodePoint());
|
||||
type = FLAG_NUMBER;
|
||||
@@ -743,7 +746,7 @@ export class Tokenizer {
|
||||
const c3 = this.peekCodePoint(2);
|
||||
|
||||
if (isIdentifierStart(c1, c2, c3)) {
|
||||
let unit = this.consumeName();
|
||||
const unit = this.consumeName();
|
||||
return {type: TokenType.DIMENSION_TOKEN, number, flags, unit};
|
||||
}
|
||||
|
||||
|
||||
@@ -40,25 +40,37 @@ describe('types', () => {
|
||||
deepStrictEqual(parse('linear-gradient(yellow, blue)'), {
|
||||
angle: deg(180),
|
||||
type: CSSImageType.LINEAR_GRADIENT,
|
||||
stops: [{color: colorParse('yellow'), stop: null}, {color: colorParse('blue'), stop: null}]
|
||||
stops: [
|
||||
{color: colorParse('yellow'), stop: null},
|
||||
{color: colorParse('blue'), stop: null}
|
||||
]
|
||||
}));
|
||||
it('linear-gradient(to bottom, yellow, blue)', () =>
|
||||
deepStrictEqual(parse('linear-gradient(to bottom, yellow, blue)'), {
|
||||
angle: deg(180),
|
||||
type: CSSImageType.LINEAR_GRADIENT,
|
||||
stops: [{color: colorParse('yellow'), stop: null}, {color: colorParse('blue'), stop: null}]
|
||||
stops: [
|
||||
{color: colorParse('yellow'), stop: null},
|
||||
{color: colorParse('blue'), stop: null}
|
||||
]
|
||||
}));
|
||||
it('linear-gradient(180deg, yellow, blue)', () =>
|
||||
deepStrictEqual(parse('linear-gradient(180deg, yellow, blue)'), {
|
||||
angle: deg(180),
|
||||
type: CSSImageType.LINEAR_GRADIENT,
|
||||
stops: [{color: colorParse('yellow'), stop: null}, {color: colorParse('blue'), stop: null}]
|
||||
stops: [
|
||||
{color: colorParse('yellow'), stop: null},
|
||||
{color: colorParse('blue'), stop: null}
|
||||
]
|
||||
}));
|
||||
it('linear-gradient(to top, blue, yellow)', () =>
|
||||
deepStrictEqual(parse('linear-gradient(to top, blue, yellow)'), {
|
||||
angle: 0,
|
||||
type: CSSImageType.LINEAR_GRADIENT,
|
||||
stops: [{color: colorParse('blue'), stop: null}, {color: colorParse('yellow'), stop: null}]
|
||||
stops: [
|
||||
{color: colorParse('blue'), stop: null},
|
||||
{color: colorParse('yellow'), stop: null}
|
||||
]
|
||||
}));
|
||||
it('linear-gradient(to top right, blue, yellow)', () =>
|
||||
deepStrictEqual(parse('linear-gradient(to top right, blue, yellow)'), {
|
||||
@@ -67,7 +79,10 @@ describe('types', () => {
|
||||
{type: TokenType.NUMBER_TOKEN, number: 0, flags: 4}
|
||||
],
|
||||
type: CSSImageType.LINEAR_GRADIENT,
|
||||
stops: [{color: colorParse('blue'), stop: null}, {color: colorParse('yellow'), stop: null}]
|
||||
stops: [
|
||||
{color: colorParse('blue'), stop: null},
|
||||
{color: colorParse('yellow'), stop: null}
|
||||
]
|
||||
}));
|
||||
it('linear-gradient(to bottom, yellow 0%, blue 100%)', () =>
|
||||
deepStrictEqual(parse('linear-gradient(to bottom, yellow 0%, blue 100%)'), {
|
||||
|
||||
@@ -41,7 +41,7 @@ export const isAngle = (value: CSSValue): boolean => {
|
||||
export const parseNamedSide = (tokens: CSSValue[]): number | GradientCorner => {
|
||||
const sideOrCorner = tokens
|
||||
.filter(isIdentToken)
|
||||
.map(ident => ident.value)
|
||||
.map((ident) => ident.value)
|
||||
.join(' ');
|
||||
|
||||
switch (sideOrCorner) {
|
||||
|
||||
@@ -59,9 +59,9 @@ export const color: ITypeDescriptor<Color> = {
|
||||
}
|
||||
};
|
||||
|
||||
export const isTransparent = (color: Color) => (0xff & color) === 0;
|
||||
export const isTransparent = (color: Color): boolean => (0xff & color) === 0;
|
||||
|
||||
export const asString = (color: Color) => {
|
||||
export const asString = (color: Color): string => {
|
||||
const alpha = 0xff & color;
|
||||
const blue = 0xff & (color >> 8);
|
||||
const green = 0xff & (color >> 16);
|
||||
|
||||
@@ -14,11 +14,11 @@ import {color as colorType} from '../color';
|
||||
import {HUNDRED_PERCENT, LengthPercentage, ZERO_LENGTH} from '../length-percentage';
|
||||
|
||||
export const webkitGradient = (tokens: CSSValue[]): CSSLinearGradientImage | CSSRadialGradientImage => {
|
||||
let angle = deg(180);
|
||||
const angle = deg(180);
|
||||
const stops: UnprocessedGradientColorStop[] = [];
|
||||
let type = CSSImageType.LINEAR_GRADIENT;
|
||||
let shape: CSSRadialShape = CSSRadialShape.CIRCLE;
|
||||
let size: CSSRadialSize = CSSRadialExtent.FARTHEST_CORNER;
|
||||
const shape: CSSRadialShape = CSSRadialShape.CIRCLE;
|
||||
const size: CSSRadialSize = CSSRadialExtent.FARTHEST_CORNER;
|
||||
const position: LengthPercentage[] = [];
|
||||
parseFunctionArgs(tokens).forEach((arg, i) => {
|
||||
const firstToken = arg[0];
|
||||
|
||||
@@ -55,7 +55,10 @@ describe('functions', () => {
|
||||
shape: CSSRadialShape.CIRCLE,
|
||||
size: [{type: TokenType.DIMENSION_TOKEN, number: 20, flags: 4, unit: 'px'}],
|
||||
position: [],
|
||||
stops: [{color: colorParse('red'), stop: null}, {color: colorParse('blue'), stop: null}]
|
||||
stops: [
|
||||
{color: colorParse('red'), stop: null},
|
||||
{color: colorParse('blue'), stop: null}
|
||||
]
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -9,7 +9,7 @@ export class CounterState {
|
||||
this.counters = {};
|
||||
}
|
||||
|
||||
getCounterValue(name: string) {
|
||||
getCounterValue(name: string): number {
|
||||
const counter = this.counters[name];
|
||||
|
||||
if (counter && counter.length) {
|
||||
@@ -23,8 +23,8 @@ export class CounterState {
|
||||
return counter ? counter : [];
|
||||
}
|
||||
|
||||
pop(counters: string[]) {
|
||||
counters.forEach(counter => this.counters[counter].pop());
|
||||
pop(counters: string[]): void {
|
||||
counters.forEach((counter) => this.counters[counter].pop());
|
||||
}
|
||||
|
||||
parse(style: CSSParsedCounterDeclaration): string[] {
|
||||
@@ -33,7 +33,7 @@ export class CounterState {
|
||||
let canReset = true;
|
||||
|
||||
if (counterIncrement !== null) {
|
||||
counterIncrement.forEach(entry => {
|
||||
counterIncrement.forEach((entry) => {
|
||||
const counter = this.counters[entry.counter];
|
||||
if (counter && entry.increment !== 0) {
|
||||
canReset = false;
|
||||
@@ -44,7 +44,7 @@ export class CounterState {
|
||||
|
||||
const counterNames: string[] = [];
|
||||
if (canReset) {
|
||||
counterReset.forEach(entry => {
|
||||
counterReset.forEach((entry) => {
|
||||
let counter = this.counters[entry.counter];
|
||||
counterNames.push(entry.counter);
|
||||
if (!counter) {
|
||||
@@ -70,42 +70,8 @@ const ROMAN_UPPER: CounterSymbols = {
|
||||
|
||||
const ARMENIAN: CounterSymbols = {
|
||||
integers: [
|
||||
9000,
|
||||
8000,
|
||||
7000,
|
||||
6000,
|
||||
5000,
|
||||
4000,
|
||||
3000,
|
||||
2000,
|
||||
1000,
|
||||
900,
|
||||
800,
|
||||
700,
|
||||
600,
|
||||
500,
|
||||
400,
|
||||
300,
|
||||
200,
|
||||
100,
|
||||
90,
|
||||
80,
|
||||
70,
|
||||
60,
|
||||
50,
|
||||
40,
|
||||
30,
|
||||
20,
|
||||
10,
|
||||
9,
|
||||
8,
|
||||
7,
|
||||
6,
|
||||
5,
|
||||
4,
|
||||
3,
|
||||
2,
|
||||
1
|
||||
9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 90, 80, 70,
|
||||
60, 50, 40, 30, 20, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1
|
||||
],
|
||||
values: [
|
||||
'Ք',
|
||||
@@ -149,43 +115,8 @@ const ARMENIAN: CounterSymbols = {
|
||||
|
||||
const HEBREW: CounterSymbols = {
|
||||
integers: [
|
||||
10000,
|
||||
9000,
|
||||
8000,
|
||||
7000,
|
||||
6000,
|
||||
5000,
|
||||
4000,
|
||||
3000,
|
||||
2000,
|
||||
1000,
|
||||
400,
|
||||
300,
|
||||
200,
|
||||
100,
|
||||
90,
|
||||
80,
|
||||
70,
|
||||
60,
|
||||
50,
|
||||
40,
|
||||
30,
|
||||
20,
|
||||
19,
|
||||
18,
|
||||
17,
|
||||
16,
|
||||
15,
|
||||
10,
|
||||
9,
|
||||
8,
|
||||
7,
|
||||
6,
|
||||
5,
|
||||
4,
|
||||
3,
|
||||
2,
|
||||
1
|
||||
10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000, 400, 300, 200, 100, 90, 80, 70, 60, 50, 40, 30, 20,
|
||||
19, 18, 17, 16, 15, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1
|
||||
],
|
||||
values: [
|
||||
'י׳',
|
||||
@@ -230,43 +161,8 @@ const HEBREW: CounterSymbols = {
|
||||
|
||||
const GEORGIAN: CounterSymbols = {
|
||||
integers: [
|
||||
10000,
|
||||
9000,
|
||||
8000,
|
||||
7000,
|
||||
6000,
|
||||
5000,
|
||||
4000,
|
||||
3000,
|
||||
2000,
|
||||
1000,
|
||||
900,
|
||||
800,
|
||||
700,
|
||||
600,
|
||||
500,
|
||||
400,
|
||||
300,
|
||||
200,
|
||||
100,
|
||||
90,
|
||||
80,
|
||||
70,
|
||||
60,
|
||||
50,
|
||||
40,
|
||||
30,
|
||||
20,
|
||||
10,
|
||||
9,
|
||||
8,
|
||||
7,
|
||||
6,
|
||||
5,
|
||||
4,
|
||||
3,
|
||||
2,
|
||||
1
|
||||
10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 90,
|
||||
80, 70, 60, 50, 40, 30, 20, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1
|
||||
],
|
||||
values: [
|
||||
'ჵ',
|
||||
@@ -362,21 +258,21 @@ const createCounterStyleFromRange = (
|
||||
|
||||
return (
|
||||
(value < 0 ? '-' : '') +
|
||||
(createCounterStyleWithSymbolResolver(Math.abs(value), codePointRangeLength, isNumeric, codePoint =>
|
||||
(createCounterStyleWithSymbolResolver(Math.abs(value), codePointRangeLength, isNumeric, (codePoint) =>
|
||||
fromCodePoint(Math.floor(codePoint % codePointRangeLength) + codePointRangeStart)
|
||||
) +
|
||||
suffix)
|
||||
);
|
||||
};
|
||||
|
||||
const createCounterStyleFromSymbols = (value: number, symbols: string, suffix: string = '. '): string => {
|
||||
const createCounterStyleFromSymbols = (value: number, symbols: string, suffix = '. '): string => {
|
||||
const codePointRangeLength = symbols.length;
|
||||
return (
|
||||
createCounterStyleWithSymbolResolver(
|
||||
Math.abs(value),
|
||||
codePointRangeLength,
|
||||
false,
|
||||
codePoint => symbols[Math.floor(codePoint % codePointRangeLength)]
|
||||
(codePoint) => symbols[Math.floor(codePoint % codePointRangeLength)]
|
||||
) + suffix
|
||||
);
|
||||
};
|
||||
@@ -405,7 +301,7 @@ const createCJKCounter = (
|
||||
}
|
||||
|
||||
for (let digit = 0; tmp > 0 && digit <= 4; digit++) {
|
||||
let coefficient = tmp % 10;
|
||||
const coefficient = tmp % 10;
|
||||
|
||||
if (coefficient === 0 && contains(flags, CJK_ZEROS) && string !== '') {
|
||||
string = numbers[coefficient] + string;
|
||||
|
||||
@@ -98,7 +98,12 @@ export const calculateGradientDirection = (
|
||||
const distance = (a: number, b: number): number => Math.sqrt(a * a + b * b);
|
||||
|
||||
const findCorner = (width: number, height: number, x: number, y: number, closest: boolean): [number, number] => {
|
||||
const corners = [[0, 0], [0, height], [width, 0], [width, height]];
|
||||
const corners = [
|
||||
[0, 0],
|
||||
[0, height],
|
||||
[width, 0],
|
||||
[width, height]
|
||||
];
|
||||
|
||||
return corners.reduce(
|
||||
(stat, corner) => {
|
||||
|
||||
@@ -98,8 +98,8 @@ export const image: ITypeDescriptor<ICSSImage> = {
|
||||
}
|
||||
};
|
||||
|
||||
export function isSupportedImage(value: CSSValue) {
|
||||
return value.type !== TokenType.FUNCTION || SUPPORTED_IMAGE_FUNCTIONS[value.name];
|
||||
export function isSupportedImage(value: CSSValue): boolean {
|
||||
return value.type !== TokenType.FUNCTION || !!SUPPORTED_IMAGE_FUNCTIONS[value.name];
|
||||
}
|
||||
|
||||
const SUPPORTED_IMAGE_FUNCTIONS: Record<string, (args: CSSValue[]) => ICSSImage> = {
|
||||
|
||||
@@ -31,10 +31,10 @@ export const getAbsoluteValueForTuple = (
|
||||
width: number,
|
||||
height: number
|
||||
): [number, number] => {
|
||||
let [x, y] = tuple;
|
||||
const [x, y] = tuple;
|
||||
return [getAbsoluteValue(x, width), getAbsoluteValue(typeof y !== 'undefined' ? y : x, height)];
|
||||
};
|
||||
export const getAbsoluteValue = (token: LengthPercentage, parent: number) => {
|
||||
export const getAbsoluteValue = (token: LengthPercentage, parent: number): number => {
|
||||
if (token.type === TokenType.PERCENTAGE_TOKEN) {
|
||||
return (token.number / 100) * parent;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user