@markuplint/types 3.10.0 → 3.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/check-multi-types.d.ts +4 -1
- package/lib/defs.js +1 -1
- package/lib/get-candidate.d.ts +4 -1
- package/lib/match-result.d.ts +21 -8
- package/lib/primitive/is-quantity.d.ts +5 -1
- package/lib/primitive/is-uint.d.ts +6 -3
- package/lib/primitive/split-unit.d.ts +2 -2
- package/lib/token/token-collection.d.ts +66 -55
- package/lib/token/token.d.ts +57 -52
- package/lib/types.d.ts +80 -56
- package/lib/types.schema.d.ts +1087 -31
- package/lib/whatwg/check-datetime/datetime-tokens.d.ts +21 -1
- package/lib/whatwg/check-datetime/time-zone-offset-string.d.ts +1 -1
- package/lib/whatwg/check-mime-type.d.ts +4 -4
- package/package.json +6 -6
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
import type { CustomSyntaxCheck, UnmatchedResult } from './types';
|
|
2
|
-
export declare function checkMultiTypes(
|
|
2
|
+
export declare function checkMultiTypes(
|
|
3
|
+
value: string,
|
|
4
|
+
checks: readonly CustomSyntaxCheck[],
|
|
5
|
+
): UnmatchedResult | import('./types').MatchedResult;
|
package/lib/defs.js
CHANGED
|
@@ -753,7 +753,7 @@ exports.types = {
|
|
|
753
753
|
syntax: {
|
|
754
754
|
apply: '<view-box>',
|
|
755
755
|
def: {
|
|
756
|
-
'view-box': '<min-x> [,]? <min-y> [,]? <width> [,]? <height>',
|
|
756
|
+
'view-box': '<min-x> [,]? <min-y> [,]? <width> [,]? <height>', // As '[<min-x>,? <min-y>,? <width>,? <height>]',
|
|
757
757
|
'min-x': '<number>',
|
|
758
758
|
'min-y': '<number>',
|
|
759
759
|
width: '<number>',
|
package/lib/get-candidate.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
type NullableString = string | null | undefined;
|
|
2
|
-
export declare function getCandidate(
|
|
2
|
+
export declare function getCandidate(
|
|
3
|
+
value: NullableString,
|
|
4
|
+
...candidates: readonly (NullableString | readonly NullableString[])[]
|
|
5
|
+
): string | undefined;
|
|
3
6
|
export {};
|
package/lib/match-result.d.ts
CHANGED
|
@@ -1,9 +1,22 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import type {
|
|
2
|
+
FormattedPrimitiveTypeCheck,
|
|
3
|
+
MatchedResult,
|
|
4
|
+
UnmatchedResult,
|
|
5
|
+
UnmatchedResultOptions,
|
|
6
|
+
UnmatchedResultReason,
|
|
7
|
+
} from './types';
|
|
8
|
+
export declare function matches(
|
|
9
|
+
checker: FormattedPrimitiveTypeCheck,
|
|
10
|
+
options?: UnmatchedResultOptions & {
|
|
11
|
+
readonly ref?: string;
|
|
12
|
+
readonly reason?: UnmatchedResultReason;
|
|
13
|
+
},
|
|
14
|
+
): (value: string) => UnmatchedResult | MatchedResult;
|
|
6
15
|
export declare function matched(): MatchedResult;
|
|
7
|
-
export declare function unmatched(
|
|
8
|
-
|
|
9
|
-
|
|
16
|
+
export declare function unmatched(
|
|
17
|
+
value: string,
|
|
18
|
+
reason?: UnmatchedResultReason,
|
|
19
|
+
options?: UnmatchedResultOptions & {
|
|
20
|
+
readonly ref?: string;
|
|
21
|
+
},
|
|
22
|
+
): UnmatchedResult;
|
|
@@ -4,4 +4,8 @@
|
|
|
4
4
|
* @param units
|
|
5
5
|
* @param numberType
|
|
6
6
|
*/
|
|
7
|
-
export declare function isQuantity(
|
|
7
|
+
export declare function isQuantity(
|
|
8
|
+
value: string,
|
|
9
|
+
units: readonly string[],
|
|
10
|
+
numberType?: 'int' | 'uint' | 'float',
|
|
11
|
+
): boolean;
|
|
@@ -2,62 +2,73 @@ import type { TokenValue } from './types';
|
|
|
2
2
|
import type { UnmatchedResult } from '..';
|
|
3
3
|
import type { Expect, Result, List } from '../types';
|
|
4
4
|
import { Token } from './token';
|
|
5
|
-
type TokenCollectionOptions = Partial<
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
type TokenCollectionOptions = Partial<
|
|
6
|
+
Omit<List, 'token'> & {
|
|
7
|
+
specificSeparator: string | string[];
|
|
8
|
+
}
|
|
9
|
+
>;
|
|
8
10
|
export type TokenEachCheck = (head: Readonly<Token> | null, tail: TokenCollection) => Result | void;
|
|
9
11
|
export declare class TokenCollection extends Array<Token> {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
12
|
+
static fromPatterns(
|
|
13
|
+
value: Readonly<Token> | string,
|
|
14
|
+
patterns: readonly Readonly<RegExp>[],
|
|
15
|
+
typeOptions?: Omit<TokenCollectionOptions, 'specificSeparator'> & {
|
|
16
|
+
repeat?: boolean;
|
|
17
|
+
},
|
|
18
|
+
): TokenCollection;
|
|
19
|
+
static get [Symbol.species](): ArrayConstructor;
|
|
20
|
+
readonly allowEmpty: NonNullable<List['allowEmpty']>;
|
|
21
|
+
readonly caseInsensitive: NonNullable<List['caseInsensitive']>;
|
|
22
|
+
readonly disallowToSurroundBySpaces: NonNullable<List['disallowToSurroundBySpaces']>;
|
|
23
|
+
readonly number: List['number'];
|
|
24
|
+
readonly ordered: NonNullable<List['ordered']>;
|
|
25
|
+
readonly separator: NonNullable<List['separator']>;
|
|
26
|
+
readonly unique: NonNullable<List['unique']>;
|
|
27
|
+
constructor(value?: string, typeOptions?: TokenCollectionOptions);
|
|
28
|
+
constructor(value?: number);
|
|
29
|
+
get value(): string;
|
|
30
|
+
check(options?: {
|
|
31
|
+
expects?: Expect[];
|
|
32
|
+
ref?: string;
|
|
33
|
+
cache?: boolean;
|
|
34
|
+
}): UnmatchedResult | import('..').MatchedResult;
|
|
35
|
+
chunk(split: number): TokenCollection[];
|
|
36
|
+
compareTokens(
|
|
37
|
+
callback: (prev: Readonly<Token>, current: Readonly<Token>) => Readonly<Token> | null | void,
|
|
38
|
+
): Readonly<Token> | null | undefined;
|
|
39
|
+
divide(position: number): readonly [TokenCollection, TokenCollection];
|
|
40
|
+
eachCheck(...callbacks: readonly TokenEachCheck[]): Result;
|
|
41
|
+
filter(callback: Parameters<Array<Token>['filter']>[0]): TokenCollection;
|
|
42
|
+
getConsecutiveToken(tokenType: number): Readonly<Token> | null;
|
|
43
|
+
getDuplicated(): Token | null;
|
|
44
|
+
getIdentTokens(): TokenCollection;
|
|
45
|
+
/**
|
|
46
|
+
*
|
|
47
|
+
* @param value The token value or the token type or its list
|
|
48
|
+
*/
|
|
49
|
+
has(value: TokenValue): boolean;
|
|
50
|
+
headAndTail(): {
|
|
51
|
+
head: Token | null;
|
|
52
|
+
tail: TokenCollection;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
*
|
|
56
|
+
* @param value The token value or the token type or its list
|
|
57
|
+
*/
|
|
58
|
+
search(value: TokenValue): Token | null;
|
|
59
|
+
takeTurns(
|
|
60
|
+
tokenNumbers: ReadonlyArray<number>,
|
|
61
|
+
lastTokenNumber?: number,
|
|
62
|
+
): {
|
|
63
|
+
unexpectedLastToken: boolean;
|
|
64
|
+
expectedTokenNumber: number | undefined;
|
|
65
|
+
token: Token;
|
|
66
|
+
} | null;
|
|
67
|
+
toJSON(): {
|
|
68
|
+
type: number;
|
|
69
|
+
value: string;
|
|
70
|
+
offset: number;
|
|
71
|
+
}[];
|
|
72
|
+
private static _new;
|
|
62
73
|
}
|
|
63
74
|
export {};
|
package/lib/token/token.d.ts
CHANGED
|
@@ -1,56 +1,61 @@
|
|
|
1
1
|
import type { TokenValue } from './types';
|
|
2
2
|
import type { UnmatchedResult, UnmatchedResultOptions, UnmatchedResultReason } from '../types';
|
|
3
3
|
export declare class Token {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
4
|
+
/**
|
|
5
|
+
* @see https://github.com/csstree/csstree/blob/master/lib/tokenizer/types.js
|
|
6
|
+
*/
|
|
7
|
+
static readonly Comma = 18;
|
|
8
|
+
static readonly Ident = 1;
|
|
9
|
+
static readonly WhiteSpace = 13;
|
|
10
|
+
/**
|
|
11
|
+
* ASCII whitespace is
|
|
12
|
+
* - U+0009 TAB
|
|
13
|
+
* - U+000A LF
|
|
14
|
+
* - U+000C FF
|
|
15
|
+
* - U+000D CR
|
|
16
|
+
* - U+0020 SPACE.
|
|
17
|
+
*
|
|
18
|
+
* @see https://infra.spec.whatwg.org/#ascii-whitespace
|
|
19
|
+
*/
|
|
20
|
+
static readonly whitespace: ReadonlyArray<string>;
|
|
21
|
+
static getCol(value: string, offset: number): number;
|
|
22
|
+
static getLine(value: string, offset: number): number;
|
|
23
|
+
static getType(value: string, separators?: readonly string[]): 1 | 13 | 18;
|
|
24
|
+
static shiftLocation(
|
|
25
|
+
token: Readonly<Token>,
|
|
26
|
+
offset: number,
|
|
27
|
+
): {
|
|
28
|
+
offset: number;
|
|
29
|
+
line: number;
|
|
30
|
+
column: number;
|
|
31
|
+
};
|
|
32
|
+
readonly offset: number;
|
|
33
|
+
readonly originalValue: string;
|
|
34
|
+
readonly type: number;
|
|
35
|
+
readonly value: string;
|
|
36
|
+
constructor(value: string, offset: number, originalValue: string, separators?: readonly string[]);
|
|
37
|
+
get length(): number;
|
|
38
|
+
clone(): Token;
|
|
39
|
+
/**
|
|
40
|
+
*
|
|
41
|
+
* @param value The token value or the token type or its list
|
|
42
|
+
*/
|
|
43
|
+
includes(value: TokenValue, caseInsensitive?: boolean): boolean;
|
|
44
|
+
/**
|
|
45
|
+
*
|
|
46
|
+
* @param value The token value or the token type or its list
|
|
47
|
+
*/
|
|
48
|
+
match(value: TokenValue, caseInsensitive?: boolean): boolean;
|
|
49
|
+
toJSON(): {
|
|
50
|
+
type: number;
|
|
51
|
+
value: string;
|
|
52
|
+
offset: number;
|
|
53
|
+
};
|
|
54
|
+
toNumber(): number;
|
|
55
|
+
unmatched(
|
|
56
|
+
options?: UnmatchedResultOptions & {
|
|
57
|
+
readonly ref?: string;
|
|
58
|
+
readonly reason?: UnmatchedResultReason;
|
|
59
|
+
},
|
|
60
|
+
): UnmatchedResult;
|
|
56
61
|
}
|
package/lib/types.d.ts
CHANGED
|
@@ -2,78 +2,102 @@ import type { cssSyntaxMatch } from './css-syntax';
|
|
|
2
2
|
export type { Type, List, Enum, CssSyntax, KeywordDefinedType, Number } from './types.schema';
|
|
3
3
|
export type Result = UnmatchedResult | MatchedResult;
|
|
4
4
|
export type UnmatchedResult = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
readonly matched: false;
|
|
6
|
+
readonly ref: string | null;
|
|
7
|
+
readonly raw: string;
|
|
8
|
+
readonly length: number;
|
|
9
|
+
readonly offset: number;
|
|
10
|
+
readonly line: number;
|
|
11
|
+
readonly column: number;
|
|
12
|
+
readonly reason: UnmatchedResultReason;
|
|
13
|
+
readonly passCount?: number;
|
|
14
14
|
} & UnmatchedResultOptions;
|
|
15
15
|
export type UnmatchedResultOptions = {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
};
|
|
22
|
-
export type UnmatchedResultReason = 'syntax-error' | 'typo' | 'missing-token' | 'missing-comma' | 'unexpected-token' | 'unexpected-space' | 'unexpected-newline' | 'unexpected-comma' | 'empty-token' | 'out-of-range' | 'doesnt-exist-in-enum' | 'duplicated' | 'illegal-combination' | 'illegal-order' | 'extra-token' | 'must-be-percent-encoded' | 'must-be-serialized' | {
|
|
23
|
-
readonly type: 'out-of-range';
|
|
24
|
-
readonly gt?: number;
|
|
25
|
-
readonly gte?: number;
|
|
26
|
-
readonly lt?: number;
|
|
27
|
-
readonly lte?: number;
|
|
28
|
-
} | {
|
|
29
|
-
readonly type: 'out-of-range-length-char';
|
|
30
|
-
readonly gte: number;
|
|
31
|
-
readonly lte?: number;
|
|
32
|
-
} | {
|
|
33
|
-
readonly type: 'out-of-range-length-digit';
|
|
34
|
-
readonly gte: number;
|
|
35
|
-
readonly lte?: number;
|
|
16
|
+
readonly partName?: string;
|
|
17
|
+
readonly expects?: readonly Expect[];
|
|
18
|
+
readonly extra?: Expect;
|
|
19
|
+
readonly candidate?: string;
|
|
20
|
+
readonly fallbackTo?: string;
|
|
36
21
|
};
|
|
22
|
+
export type UnmatchedResultReason =
|
|
23
|
+
| 'syntax-error'
|
|
24
|
+
| 'typo'
|
|
25
|
+
| 'missing-token'
|
|
26
|
+
| 'missing-comma'
|
|
27
|
+
| 'unexpected-token'
|
|
28
|
+
| 'unexpected-space'
|
|
29
|
+
| 'unexpected-newline'
|
|
30
|
+
| 'unexpected-comma'
|
|
31
|
+
| 'empty-token'
|
|
32
|
+
| 'out-of-range'
|
|
33
|
+
| 'doesnt-exist-in-enum'
|
|
34
|
+
| 'duplicated'
|
|
35
|
+
| 'illegal-combination'
|
|
36
|
+
| 'illegal-order'
|
|
37
|
+
| 'extra-token'
|
|
38
|
+
| 'must-be-percent-encoded'
|
|
39
|
+
| 'must-be-serialized'
|
|
40
|
+
| {
|
|
41
|
+
readonly type: 'out-of-range';
|
|
42
|
+
readonly gt?: number;
|
|
43
|
+
readonly gte?: number;
|
|
44
|
+
readonly lt?: number;
|
|
45
|
+
readonly lte?: number;
|
|
46
|
+
}
|
|
47
|
+
| {
|
|
48
|
+
readonly type: 'out-of-range-length-char';
|
|
49
|
+
readonly gte: number;
|
|
50
|
+
readonly lte?: number;
|
|
51
|
+
}
|
|
52
|
+
| {
|
|
53
|
+
readonly type: 'out-of-range-length-digit';
|
|
54
|
+
readonly gte: number;
|
|
55
|
+
readonly lte?: number;
|
|
56
|
+
};
|
|
37
57
|
export type MatchedResult = {
|
|
38
|
-
|
|
58
|
+
readonly matched: true;
|
|
39
59
|
};
|
|
40
60
|
export type Expect = {
|
|
41
|
-
|
|
42
|
-
|
|
61
|
+
readonly type: 'const' | 'format' | 'syntax' | 'regexp' | 'common';
|
|
62
|
+
readonly value: string;
|
|
43
63
|
};
|
|
44
64
|
export type FormattedPrimitiveTypeCheck = (value: string) => boolean;
|
|
45
65
|
export type FormattedPrimitiveTypeCreator<O = never> = (options?: O) => FormattedPrimitiveTypeCheck;
|
|
46
66
|
export type Defs = Record<string, CustomCssSyntax | CustomSyntax>;
|
|
47
67
|
export type CustomSyntax = {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
68
|
+
readonly ref: string;
|
|
69
|
+
readonly expects?: readonly Expect[];
|
|
70
|
+
readonly is: CustomSyntaxCheck;
|
|
51
71
|
};
|
|
52
72
|
export type CustomSyntaxCheck = (value: string) => Result;
|
|
53
73
|
export type CustomSyntaxChecker<O = {}> = (options?: O) => CustomSyntaxCheck;
|
|
54
74
|
export type CustomCssSyntax = {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
75
|
+
readonly ref: string;
|
|
76
|
+
readonly caseSensitive?: boolean;
|
|
77
|
+
readonly expects?: readonly Expect[];
|
|
78
|
+
readonly syntax: {
|
|
79
|
+
readonly apply: `<${string}>`;
|
|
80
|
+
readonly def: Readonly<Record<string, string | CssSyntaxTokenizer>>;
|
|
81
|
+
/**
|
|
82
|
+
* @deprecated
|
|
83
|
+
*/
|
|
84
|
+
readonly ebnf?: Readonly<Record<string, string | readonly string[]>>;
|
|
85
|
+
/**
|
|
86
|
+
* @deprecated
|
|
87
|
+
*/
|
|
88
|
+
readonly properties?: Readonly<Record<string, string>>;
|
|
89
|
+
};
|
|
70
90
|
};
|
|
71
91
|
export type CSSSyntaxToken = {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
92
|
+
readonly type: number;
|
|
93
|
+
readonly value: string;
|
|
94
|
+
readonly index: number;
|
|
95
|
+
readonly balance: number;
|
|
96
|
+
readonly node?: any;
|
|
77
97
|
};
|
|
78
|
-
export type CssSyntaxTokenizer = (
|
|
98
|
+
export type CssSyntaxTokenizer = (
|
|
99
|
+
token: Readonly<CSSSyntaxToken> | null,
|
|
100
|
+
getNextToken: GetNextToken,
|
|
101
|
+
match: typeof cssSyntaxMatch,
|
|
102
|
+
) => number;
|
|
79
103
|
export type GetNextToken = (length: number) => CSSSyntaxToken | null;
|