@markuplint/types 3.6.0 → 3.7.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 +1 -4
- package/lib/get-candidate.d.ts +1 -4
- package/lib/match-result.d.ts +8 -21
- package/lib/primitive/is-quantity.d.ts +1 -5
- package/lib/primitive/is-uint.d.ts +3 -6
- package/lib/primitive/split-unit.d.ts +2 -2
- package/lib/token/token-collection.d.ts +55 -68
- package/lib/token/token.d.ts +52 -57
- package/lib/types.d.ts +55 -79
- package/lib/types.schema.d.ts +31 -1084
- package/lib/types.schema.js +0 -1
- package/lib/whatwg/check-datetime/datetime-tokens.d.ts +1 -21
- 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 +3 -3
|
@@ -1,5 +1,2 @@
|
|
|
1
1
|
import type { CustomSyntaxCheck, UnmatchedResult } from './types';
|
|
2
|
-
export declare function checkMultiTypes(
|
|
3
|
-
value: string,
|
|
4
|
-
checks: readonly CustomSyntaxCheck[],
|
|
5
|
-
): import('./types').MatchedResult | UnmatchedResult;
|
|
2
|
+
export declare function checkMultiTypes(value: string, checks: readonly CustomSyntaxCheck[]): import("./types").MatchedResult | UnmatchedResult;
|
package/lib/get-candidate.d.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
1
|
type NullableString = string | null | undefined;
|
|
2
|
-
export declare function getCandidate(
|
|
3
|
-
value: NullableString,
|
|
4
|
-
...candidates: readonly (NullableString | readonly NullableString[])[]
|
|
5
|
-
): string | undefined;
|
|
2
|
+
export declare function getCandidate(value: NullableString, ...candidates: readonly (NullableString | readonly NullableString[])[]): string | undefined;
|
|
6
3
|
export {};
|
package/lib/match-result.d.ts
CHANGED
|
@@ -1,22 +1,9 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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) => MatchedResult | UnmatchedResult;
|
|
1
|
+
import type { FormattedPrimitiveTypeCheck, MatchedResult, UnmatchedResult, UnmatchedResultOptions, UnmatchedResultReason } from './types';
|
|
2
|
+
export declare function matches(checker: FormattedPrimitiveTypeCheck, options?: UnmatchedResultOptions & {
|
|
3
|
+
readonly ref?: string;
|
|
4
|
+
readonly reason?: UnmatchedResultReason;
|
|
5
|
+
}): (value: string) => MatchedResult | UnmatchedResult;
|
|
15
6
|
export declare function matched(): MatchedResult;
|
|
16
|
-
export declare function unmatched(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
options?: UnmatchedResultOptions & {
|
|
20
|
-
readonly ref?: string;
|
|
21
|
-
},
|
|
22
|
-
): UnmatchedResult;
|
|
7
|
+
export declare function unmatched(value: string, reason?: UnmatchedResultReason, options?: UnmatchedResultOptions & {
|
|
8
|
+
readonly ref?: string;
|
|
9
|
+
}): UnmatchedResult;
|
|
@@ -4,8 +4,4 @@
|
|
|
4
4
|
* @param units
|
|
5
5
|
* @param numberType
|
|
6
6
|
*/
|
|
7
|
-
export declare function isQuantity(
|
|
8
|
-
value: string,
|
|
9
|
-
units: readonly string[],
|
|
10
|
-
numberType?: 'int' | 'uint' | 'float',
|
|
11
|
-
): boolean;
|
|
7
|
+
export declare function isQuantity(value: string, units: readonly string[], numberType?: 'int' | 'uint' | 'float'): boolean;
|
|
@@ -3,75 +3,62 @@ import type { UnmatchedResult } from '..';
|
|
|
3
3
|
import type { Expect, Result, List } from '../types';
|
|
4
4
|
import type { ReadonlyDeep } from 'type-fest';
|
|
5
5
|
import { Token } from './token';
|
|
6
|
-
type TokenCollectionOptions = Partial<
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
>;
|
|
6
|
+
type TokenCollectionOptions = Partial<Omit<List, 'token'> & {
|
|
7
|
+
specificSeparator: string | string[];
|
|
8
|
+
}>;
|
|
11
9
|
export type TokenEachCheck = (head: Readonly<Token> | null, tail: ReadonlyDeep<TokenCollection>) => Result | void;
|
|
12
10
|
export declare class TokenCollection extends Array<Token> {
|
|
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
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
): {
|
|
66
|
-
unexpectedLastToken: boolean;
|
|
67
|
-
expectedTokenNumber: number | undefined;
|
|
68
|
-
token: Token;
|
|
69
|
-
} | null;
|
|
70
|
-
toJSON(): {
|
|
71
|
-
type: number;
|
|
72
|
-
value: string;
|
|
73
|
-
offset: number;
|
|
74
|
-
}[];
|
|
75
|
-
private static _new;
|
|
11
|
+
static fromPatterns(value: Readonly<Token> | string, patterns: readonly Readonly<RegExp>[], typeOptions?: ReadonlyDeep<Omit<TokenCollectionOptions, 'specificSeparator'> & {
|
|
12
|
+
repeat?: boolean;
|
|
13
|
+
}>): TokenCollection;
|
|
14
|
+
static get [Symbol.species](): ArrayConstructor;
|
|
15
|
+
readonly allowEmpty: NonNullable<List['allowEmpty']>;
|
|
16
|
+
readonly caseInsensitive: NonNullable<List['caseInsensitive']>;
|
|
17
|
+
readonly disallowToSurroundBySpaces: NonNullable<List['disallowToSurroundBySpaces']>;
|
|
18
|
+
readonly number: List['number'];
|
|
19
|
+
readonly ordered: NonNullable<List['ordered']>;
|
|
20
|
+
readonly separator: NonNullable<List['separator']>;
|
|
21
|
+
readonly unique: NonNullable<List['unique']>;
|
|
22
|
+
constructor(value?: string, typeOptions?: ReadonlyDeep<TokenCollectionOptions>);
|
|
23
|
+
constructor(value?: number);
|
|
24
|
+
get value(): string;
|
|
25
|
+
check(options?: {
|
|
26
|
+
expects?: Expect[];
|
|
27
|
+
ref?: string;
|
|
28
|
+
cache?: boolean;
|
|
29
|
+
}): import("..").MatchedResult | UnmatchedResult;
|
|
30
|
+
chunk(split: number): TokenCollection[];
|
|
31
|
+
compareTokens(callback: (prev: Readonly<Token>, current: Readonly<Token>) => Readonly<Token> | null | void): Readonly<Token> | null | undefined;
|
|
32
|
+
divide(position: number): readonly [TokenCollection, TokenCollection];
|
|
33
|
+
eachCheck(...callbacks: readonly TokenEachCheck[]): Result;
|
|
34
|
+
filter(callback: Parameters<Array<Token>['filter']>[0]): TokenCollection;
|
|
35
|
+
getConsecutiveToken(tokenType: number): Readonly<Token> | null;
|
|
36
|
+
getDuplicated(): Token | null;
|
|
37
|
+
getIdentTokens(): TokenCollection;
|
|
38
|
+
/**
|
|
39
|
+
*
|
|
40
|
+
* @param value The token value or the token type or its list
|
|
41
|
+
*/
|
|
42
|
+
has(value: TokenValue): boolean;
|
|
43
|
+
headAndTail(): {
|
|
44
|
+
head: Token | null;
|
|
45
|
+
tail: TokenCollection;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
*
|
|
49
|
+
* @param value The token value or the token type or its list
|
|
50
|
+
*/
|
|
51
|
+
search(value: TokenValue): Token | null;
|
|
52
|
+
takeTurns(tokenNumbers: ReadonlyArray<number>, lastTokenNumber?: number): {
|
|
53
|
+
unexpectedLastToken: boolean;
|
|
54
|
+
expectedTokenNumber: number | undefined;
|
|
55
|
+
token: Token;
|
|
56
|
+
} | null;
|
|
57
|
+
toJSON(): {
|
|
58
|
+
type: number;
|
|
59
|
+
value: string;
|
|
60
|
+
offset: number;
|
|
61
|
+
}[];
|
|
62
|
+
private static _new;
|
|
76
63
|
}
|
|
77
64
|
export {};
|
package/lib/token/token.d.ts
CHANGED
|
@@ -1,61 +1,56 @@
|
|
|
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
|
-
|
|
56
|
-
options?: UnmatchedResultOptions & {
|
|
57
|
-
readonly ref?: string;
|
|
58
|
-
readonly reason?: UnmatchedResultReason;
|
|
59
|
-
},
|
|
60
|
-
): UnmatchedResult;
|
|
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(token: Readonly<Token>, offset: number): {
|
|
25
|
+
offset: number;
|
|
26
|
+
line: number;
|
|
27
|
+
column: number;
|
|
28
|
+
};
|
|
29
|
+
readonly offset: number;
|
|
30
|
+
readonly originalValue: string;
|
|
31
|
+
readonly type: number;
|
|
32
|
+
readonly value: string;
|
|
33
|
+
constructor(value: string, offset: number, originalValue: string, separators?: readonly string[]);
|
|
34
|
+
get length(): number;
|
|
35
|
+
clone(): Token;
|
|
36
|
+
/**
|
|
37
|
+
*
|
|
38
|
+
* @param value The token value or the token type or its list
|
|
39
|
+
*/
|
|
40
|
+
includes(value: TokenValue, caseInsensitive?: boolean): boolean;
|
|
41
|
+
/**
|
|
42
|
+
*
|
|
43
|
+
* @param value The token value or the token type or its list
|
|
44
|
+
*/
|
|
45
|
+
match(value: TokenValue, caseInsensitive?: boolean): boolean;
|
|
46
|
+
toJSON(): {
|
|
47
|
+
type: number;
|
|
48
|
+
value: string;
|
|
49
|
+
offset: number;
|
|
50
|
+
};
|
|
51
|
+
toNumber(): number;
|
|
52
|
+
unmatched(options?: UnmatchedResultOptions & {
|
|
53
|
+
readonly ref?: string;
|
|
54
|
+
readonly reason?: UnmatchedResultReason;
|
|
55
|
+
}): UnmatchedResult;
|
|
61
56
|
}
|
package/lib/types.d.ts
CHANGED
|
@@ -2,101 +2,77 @@ 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
|
-
|
|
16
|
+
readonly partName?: string;
|
|
17
|
+
readonly expects?: readonly Expect[];
|
|
18
|
+
readonly extra?: Expect;
|
|
19
|
+
readonly candidate?: string;
|
|
20
|
+
};
|
|
21
|
+
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' | {
|
|
22
|
+
readonly type: 'out-of-range';
|
|
23
|
+
readonly gt?: number;
|
|
24
|
+
readonly gte?: number;
|
|
25
|
+
readonly lt?: number;
|
|
26
|
+
readonly lte?: number;
|
|
27
|
+
} | {
|
|
28
|
+
readonly type: 'out-of-range-length-char';
|
|
29
|
+
readonly gte: number;
|
|
30
|
+
readonly lte?: number;
|
|
31
|
+
} | {
|
|
32
|
+
readonly type: 'out-of-range-length-digit';
|
|
33
|
+
readonly gte: number;
|
|
34
|
+
readonly lte?: number;
|
|
20
35
|
};
|
|
21
|
-
export type UnmatchedResultReason =
|
|
22
|
-
| 'syntax-error'
|
|
23
|
-
| 'typo'
|
|
24
|
-
| 'missing-token'
|
|
25
|
-
| 'missing-comma'
|
|
26
|
-
| 'unexpected-token'
|
|
27
|
-
| 'unexpected-space'
|
|
28
|
-
| 'unexpected-newline'
|
|
29
|
-
| 'unexpected-comma'
|
|
30
|
-
| 'empty-token'
|
|
31
|
-
| 'out-of-range'
|
|
32
|
-
| 'doesnt-exist-in-enum'
|
|
33
|
-
| 'duplicated'
|
|
34
|
-
| 'illegal-combination'
|
|
35
|
-
| 'illegal-order'
|
|
36
|
-
| 'extra-token'
|
|
37
|
-
| 'must-be-percent-encoded'
|
|
38
|
-
| 'must-be-serialized'
|
|
39
|
-
| {
|
|
40
|
-
readonly type: 'out-of-range';
|
|
41
|
-
readonly gt?: number;
|
|
42
|
-
readonly gte?: number;
|
|
43
|
-
readonly lt?: number;
|
|
44
|
-
readonly lte?: number;
|
|
45
|
-
}
|
|
46
|
-
| {
|
|
47
|
-
readonly type: 'out-of-range-length-char';
|
|
48
|
-
readonly gte: number;
|
|
49
|
-
readonly lte?: number;
|
|
50
|
-
}
|
|
51
|
-
| {
|
|
52
|
-
readonly type: 'out-of-range-length-digit';
|
|
53
|
-
readonly gte: number;
|
|
54
|
-
readonly lte?: number;
|
|
55
|
-
};
|
|
56
36
|
export type MatchedResult = {
|
|
57
|
-
|
|
37
|
+
readonly matched: true;
|
|
58
38
|
};
|
|
59
39
|
export type Expect = {
|
|
60
|
-
|
|
61
|
-
|
|
40
|
+
readonly type: 'const' | 'format' | 'syntax' | 'regexp' | 'common';
|
|
41
|
+
readonly value: string;
|
|
62
42
|
};
|
|
63
43
|
export type FormattedPrimitiveTypeCheck = (value: string) => boolean;
|
|
64
44
|
export type FormattedPrimitiveTypeCreator<O = never> = (options?: O) => FormattedPrimitiveTypeCheck;
|
|
65
45
|
export type Defs = Record<string, CustomCssSyntax | CustomSyntax>;
|
|
66
46
|
export type CustomSyntax = {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
47
|
+
readonly ref: string;
|
|
48
|
+
readonly expects?: readonly Expect[];
|
|
49
|
+
readonly is: CustomSyntaxCheck;
|
|
70
50
|
};
|
|
71
51
|
export type CustomSyntaxCheck = (value: string) => Result;
|
|
72
52
|
export type CustomSyntaxChecker<O = {}> = (options?: O) => CustomSyntaxCheck;
|
|
73
53
|
export type CustomCssSyntax = {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
54
|
+
readonly ref: string;
|
|
55
|
+
readonly caseSensitive?: boolean;
|
|
56
|
+
readonly expects?: readonly Expect[];
|
|
57
|
+
readonly syntax: {
|
|
58
|
+
readonly apply: `<${string}>`;
|
|
59
|
+
readonly def: Readonly<Record<string, string | CssSyntaxTokenizer>>;
|
|
60
|
+
/**
|
|
61
|
+
* @deprecated
|
|
62
|
+
*/
|
|
63
|
+
readonly ebnf?: Readonly<Record<string, string | readonly string[]>>;
|
|
64
|
+
/**
|
|
65
|
+
* @deprecated
|
|
66
|
+
*/
|
|
67
|
+
readonly properties?: Readonly<Record<string, string>>;
|
|
68
|
+
};
|
|
89
69
|
};
|
|
90
70
|
export type CSSSyntaxToken = {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
71
|
+
readonly type: number;
|
|
72
|
+
readonly value: string;
|
|
73
|
+
readonly index: number;
|
|
74
|
+
readonly balance: number;
|
|
75
|
+
readonly node?: any;
|
|
96
76
|
};
|
|
97
|
-
export type CssSyntaxTokenizer = (
|
|
98
|
-
token: Readonly<CSSSyntaxToken> | null,
|
|
99
|
-
getNextToken: GetNextToken,
|
|
100
|
-
match: typeof cssSyntaxMatch,
|
|
101
|
-
) => number;
|
|
77
|
+
export type CssSyntaxTokenizer = (token: Readonly<CSSSyntaxToken> | null, getNextToken: GetNextToken, match: typeof cssSyntaxMatch) => number;
|
|
102
78
|
export type GetNextToken = (length: number) => CSSSyntaxToken | null;
|