@markuplint/types 3.0.0-alpha.4 → 3.0.0-alpha.6
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 -0
- package/lib/get-candidate.d.ts +5 -2
- package/lib/match-result.d.ts +21 -8
- 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 +65 -56
- package/lib/token/token-collection.js +47 -47
- package/lib/token/token.d.ts +57 -52
- package/lib/token/token.js +7 -7
- package/lib/types.d.ts +93 -69
- package/lib/types.schema.d.ts +1036 -34
- 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 +2 -2
- package/src/defs.ts +1 -0
- package/src/token/token-collection.ts +1 -1
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -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: CustomSyntaxCheck[],
|
|
5
|
+
): import('./types').MatchedResult | UnmatchedResult;
|
package/lib/defs.js
CHANGED
package/lib/get-candidate.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function getCandidate(
|
|
1
|
+
type NullableString = string | null | undefined;
|
|
2
|
+
export declare function getCandidate(
|
|
3
|
+
value: NullableString,
|
|
4
|
+
...candidates: (NullableString | 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
|
+
ref?: string;
|
|
12
|
+
reason?: UnmatchedResultReason;
|
|
13
|
+
},
|
|
14
|
+
): (value: string) => MatchedResult | UnmatchedResult;
|
|
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
|
+
ref?: string;
|
|
21
|
+
},
|
|
22
|
+
): UnmatchedResult;
|
|
@@ -1,62 +1,71 @@
|
|
|
1
1
|
import type { UnmatchedResult } from '..';
|
|
2
2
|
import type { Expect, Result, List } from '../types';
|
|
3
3
|
import { Token } from './token';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
type TokenCollectionOptions = Partial<
|
|
5
|
+
Omit<List, 'token'> & {
|
|
6
|
+
specificSeparator: string | string[];
|
|
7
|
+
}
|
|
8
|
+
>;
|
|
9
|
+
export type TokenEachCheck = (head: Token | null, tail: TokenCollection) => Result | void;
|
|
8
10
|
export declare class TokenCollection extends Array<Token> {
|
|
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
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
11
|
+
static fromPatterns(
|
|
12
|
+
value: Token | string,
|
|
13
|
+
patterns: RegExp[],
|
|
14
|
+
typeOptions?: Omit<TokenCollectionOptions, 'specificSeparator'> & {
|
|
15
|
+
repeat?: boolean;
|
|
16
|
+
},
|
|
17
|
+
): TokenCollection;
|
|
18
|
+
static get [Symbol.species](): ArrayConstructor;
|
|
19
|
+
readonly allowEmpty: NonNullable<List['allowEmpty']>;
|
|
20
|
+
readonly caseInsensitive: NonNullable<List['caseInsensitive']>;
|
|
21
|
+
readonly disallowToSurroundBySpaces: NonNullable<List['disallowToSurroundBySpaces']>;
|
|
22
|
+
readonly number: List['number'];
|
|
23
|
+
readonly ordered: NonNullable<List['ordered']>;
|
|
24
|
+
readonly separator: NonNullable<List['separator']>;
|
|
25
|
+
readonly unique: NonNullable<List['unique']>;
|
|
26
|
+
constructor(value?: string, typeOptions?: TokenCollectionOptions);
|
|
27
|
+
constructor(value?: number);
|
|
28
|
+
get value(): string;
|
|
29
|
+
check(options?: {
|
|
30
|
+
expects?: Expect[];
|
|
31
|
+
ref?: string;
|
|
32
|
+
cache?: boolean;
|
|
33
|
+
}): import('..').MatchedResult | UnmatchedResult;
|
|
34
|
+
chunk(split: number): TokenCollection[];
|
|
35
|
+
compareTokens(callback: (prev: Token, current: Token) => Token | null | void): Token | null | undefined;
|
|
36
|
+
divide(position: number): readonly [TokenCollection, TokenCollection];
|
|
37
|
+
eachCheck(...callbacks: TokenEachCheck[]): Result;
|
|
38
|
+
filter(callback: (value: Token, index: number, array: Token[]) => boolean): TokenCollection;
|
|
39
|
+
getConsecutiveToken(tokenType: number): Token | null;
|
|
40
|
+
getDuplicated(): Token | null;
|
|
41
|
+
getIdentTokens(): TokenCollection;
|
|
42
|
+
/**
|
|
43
|
+
*
|
|
44
|
+
* @param value The token value or the token type or its list
|
|
45
|
+
*/
|
|
46
|
+
has(value: string | RegExp | number | (string | RegExp | number)[]): boolean;
|
|
47
|
+
headAndTail(): {
|
|
48
|
+
head: Token | null;
|
|
49
|
+
tail: TokenCollection;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
*
|
|
53
|
+
* @param value The token value or the token type or its list
|
|
54
|
+
*/
|
|
55
|
+
search(value: string | RegExp | number | (string | RegExp | number)[]): Token | null;
|
|
56
|
+
takeTurns(
|
|
57
|
+
tokenNumbers: ReadonlyArray<number>,
|
|
58
|
+
lastTokenNumber?: number,
|
|
59
|
+
): {
|
|
60
|
+
unexpectedLastToken: boolean;
|
|
61
|
+
expectedTokenNumber: number;
|
|
62
|
+
token: Token;
|
|
63
|
+
} | null;
|
|
64
|
+
toJSON(): {
|
|
65
|
+
type: number;
|
|
66
|
+
value: string;
|
|
67
|
+
offset: number;
|
|
68
|
+
}[];
|
|
69
|
+
private static _new;
|
|
61
70
|
}
|
|
62
71
|
export {};
|
|
@@ -4,6 +4,52 @@ exports.TokenCollection = void 0;
|
|
|
4
4
|
const match_result_1 = require("../match-result");
|
|
5
5
|
const token_1 = require("./token");
|
|
6
6
|
class TokenCollection extends Array {
|
|
7
|
+
static fromPatterns(value, patterns, typeOptions) {
|
|
8
|
+
const origin = typeof value === 'string' ? value : value.origin;
|
|
9
|
+
let strings = typeof value === 'string' ? value : value.value;
|
|
10
|
+
let cumulativeOffset = typeof value === 'string' ? 0 : value.offset;
|
|
11
|
+
const tokens = [];
|
|
12
|
+
function addToken(tokenValue) {
|
|
13
|
+
const token = new token_1.Token(tokenValue, cumulativeOffset, origin);
|
|
14
|
+
tokens.push(token);
|
|
15
|
+
strings = strings.slice(tokenValue.length);
|
|
16
|
+
cumulativeOffset += tokenValue.length;
|
|
17
|
+
return token;
|
|
18
|
+
}
|
|
19
|
+
let isBroken = false;
|
|
20
|
+
do {
|
|
21
|
+
isBroken = false;
|
|
22
|
+
for (const pattern of patterns) {
|
|
23
|
+
const res = pattern.exec(strings);
|
|
24
|
+
let value;
|
|
25
|
+
if (!res) {
|
|
26
|
+
isBroken = true;
|
|
27
|
+
value = '';
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
if (res.index !== 0) {
|
|
31
|
+
value = strings.slice(res.index + res[0].length);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
value = res[0] || '';
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const token = addToken(value);
|
|
38
|
+
// @ts-ignore
|
|
39
|
+
token._ = pattern;
|
|
40
|
+
}
|
|
41
|
+
if (isBroken) {
|
|
42
|
+
addToken(strings);
|
|
43
|
+
}
|
|
44
|
+
} while ((typeOptions === null || typeOptions === void 0 ? void 0 : typeOptions.repeat) && strings);
|
|
45
|
+
if (strings) {
|
|
46
|
+
addToken(strings);
|
|
47
|
+
}
|
|
48
|
+
return TokenCollection._new(tokens, new TokenCollection('', typeOptions));
|
|
49
|
+
}
|
|
50
|
+
static get [Symbol.species]() {
|
|
51
|
+
return Array;
|
|
52
|
+
}
|
|
7
53
|
constructor(value, typeOptions) {
|
|
8
54
|
super();
|
|
9
55
|
this.disallowToSurroundBySpaces = (typeOptions === null || typeOptions === void 0 ? void 0 : typeOptions.disallowToSurroundBySpaces) || false;
|
|
@@ -60,52 +106,6 @@ class TokenCollection extends Array {
|
|
|
60
106
|
offset += v.length;
|
|
61
107
|
});
|
|
62
108
|
}
|
|
63
|
-
static fromPatterns(value, patterns, typeOptions) {
|
|
64
|
-
const origin = typeof value === 'string' ? value : value.origin;
|
|
65
|
-
let strings = typeof value === 'string' ? value : value.value;
|
|
66
|
-
let cumulativeOffset = typeof value === 'string' ? 0 : value.offset;
|
|
67
|
-
const tokens = [];
|
|
68
|
-
function addToken(tokenValue) {
|
|
69
|
-
const token = new token_1.Token(tokenValue, cumulativeOffset, origin);
|
|
70
|
-
tokens.push(token);
|
|
71
|
-
strings = strings.slice(tokenValue.length);
|
|
72
|
-
cumulativeOffset += tokenValue.length;
|
|
73
|
-
return token;
|
|
74
|
-
}
|
|
75
|
-
let isBroken = false;
|
|
76
|
-
do {
|
|
77
|
-
isBroken = false;
|
|
78
|
-
for (const pattern of patterns) {
|
|
79
|
-
const res = pattern.exec(strings);
|
|
80
|
-
let value;
|
|
81
|
-
if (!res) {
|
|
82
|
-
isBroken = true;
|
|
83
|
-
value = '';
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
if (res.index !== 0) {
|
|
87
|
-
value = strings.slice(res.index + res[0].length);
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
value = res[0] || '';
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
const token = addToken(value);
|
|
94
|
-
// @ts-ignore
|
|
95
|
-
token._ = pattern;
|
|
96
|
-
}
|
|
97
|
-
if (isBroken) {
|
|
98
|
-
addToken(strings);
|
|
99
|
-
}
|
|
100
|
-
} while ((typeOptions === null || typeOptions === void 0 ? void 0 : typeOptions.repeat) && strings);
|
|
101
|
-
if (strings) {
|
|
102
|
-
addToken(strings);
|
|
103
|
-
}
|
|
104
|
-
return TokenCollection._new(tokens, new TokenCollection('', typeOptions));
|
|
105
|
-
}
|
|
106
|
-
static get [Symbol.species]() {
|
|
107
|
-
return Array;
|
|
108
|
-
}
|
|
109
109
|
get value() {
|
|
110
110
|
const value = this.map(t => t.value).join('');
|
|
111
111
|
return value;
|
|
@@ -151,7 +151,7 @@ class TokenCollection extends Array {
|
|
|
151
151
|
});
|
|
152
152
|
}
|
|
153
153
|
else if (takeTurnsError.token.type === takeTurnsError.expectedTokenNumber) {
|
|
154
|
-
// Consecutive
|
|
154
|
+
// Consecutive commas
|
|
155
155
|
return takeTurnsError.token.unmatched({
|
|
156
156
|
reason: 'unexpected-comma',
|
|
157
157
|
ref,
|
package/lib/token/token.d.ts
CHANGED
|
@@ -1,55 +1,60 @@
|
|
|
1
1
|
import type { UnmatchedResult, UnmatchedResultOptions, UnmatchedResultReason } from '../types';
|
|
2
2
|
export declare class Token {
|
|
3
|
-
|
|
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
|
-
|
|
3
|
+
#private;
|
|
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?: string[]): 1 | 13 | 18;
|
|
24
|
+
static shiftLocation(
|
|
25
|
+
token: Token,
|
|
26
|
+
offset: number,
|
|
27
|
+
): {
|
|
28
|
+
offset: number;
|
|
29
|
+
line: number;
|
|
30
|
+
column: number;
|
|
31
|
+
};
|
|
32
|
+
readonly offset: number;
|
|
33
|
+
readonly type: number;
|
|
34
|
+
readonly value: string;
|
|
35
|
+
constructor(value: string, offset: number, originalValue: string, separators?: string[]);
|
|
36
|
+
get length(): number;
|
|
37
|
+
get origin(): string;
|
|
38
|
+
/**
|
|
39
|
+
*
|
|
40
|
+
* @param value The token value or the token type or its list
|
|
41
|
+
*/
|
|
42
|
+
includes(value: string | RegExp | number | (string | RegExp | number)[], caseInsensitive?: boolean): boolean;
|
|
43
|
+
/**
|
|
44
|
+
*
|
|
45
|
+
* @param value The token value or the token type or its list
|
|
46
|
+
*/
|
|
47
|
+
match(value: string | RegExp | number | (string | RegExp | number)[], caseInsensitive?: boolean): boolean;
|
|
48
|
+
toJSON(): {
|
|
49
|
+
type: number;
|
|
50
|
+
value: string;
|
|
51
|
+
offset: number;
|
|
52
|
+
};
|
|
53
|
+
toNumber(): number;
|
|
54
|
+
unmatched(
|
|
55
|
+
options?: UnmatchedResultOptions & {
|
|
56
|
+
ref?: string;
|
|
57
|
+
reason?: UnmatchedResultReason;
|
|
58
|
+
},
|
|
59
|
+
): UnmatchedResult;
|
|
55
60
|
}
|
package/lib/token/token.js
CHANGED
|
@@ -4,13 +4,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
exports.Token = void 0;
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
6
|
class Token {
|
|
7
|
-
constructor(value, offset, originalValue, separators) {
|
|
8
|
-
_Token_originalValue.set(this, void 0);
|
|
9
|
-
this.type = Token.getType(value, separators);
|
|
10
|
-
this.value = value;
|
|
11
|
-
this.offset = offset;
|
|
12
|
-
tslib_1.__classPrivateFieldSet(this, _Token_originalValue, originalValue, "f");
|
|
13
|
-
}
|
|
14
7
|
static getCol(value, offset) {
|
|
15
8
|
const lines = value.slice(0, offset).split(/\n/g);
|
|
16
9
|
return lines[lines.length - 1].length + 1;
|
|
@@ -38,6 +31,13 @@ class Token {
|
|
|
38
31
|
column: Token.getCol(tslib_1.__classPrivateFieldGet(token, _Token_originalValue, "f"), shifted),
|
|
39
32
|
};
|
|
40
33
|
}
|
|
34
|
+
constructor(value, offset, originalValue, separators) {
|
|
35
|
+
_Token_originalValue.set(this, void 0);
|
|
36
|
+
this.type = Token.getType(value, separators);
|
|
37
|
+
this.value = value;
|
|
38
|
+
this.offset = offset;
|
|
39
|
+
tslib_1.__classPrivateFieldSet(this, _Token_originalValue, originalValue, "f");
|
|
40
|
+
}
|
|
41
41
|
get length() {
|
|
42
42
|
return this.value.length;
|
|
43
43
|
}
|
package/lib/types.d.ts
CHANGED
|
@@ -1,78 +1,102 @@
|
|
|
1
1
|
import type { cssSyntaxMatch } from './css-syntax';
|
|
2
2
|
export type { Type, List, Enum, CssSyntax, KeywordDefinedType, Number } from './types.schema';
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
3
|
+
export type Result = UnmatchedResult | MatchedResult;
|
|
4
|
+
export type UnmatchedResult = {
|
|
5
|
+
matched: false;
|
|
6
|
+
ref: string | null;
|
|
7
|
+
raw: string;
|
|
8
|
+
length: number;
|
|
9
|
+
offset: number;
|
|
10
|
+
line: number;
|
|
11
|
+
column: number;
|
|
12
|
+
reason: UnmatchedResultReason;
|
|
13
|
+
passCount?: number;
|
|
14
14
|
} & UnmatchedResultOptions;
|
|
15
|
-
export
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
export type UnmatchedResultOptions = {
|
|
16
|
+
partName?: string;
|
|
17
|
+
expects?: Expect[];
|
|
18
|
+
extra?: Expect;
|
|
19
|
+
candidate?: string;
|
|
20
20
|
};
|
|
21
|
-
export
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
+
type: 'out-of-range';
|
|
41
|
+
gt?: number;
|
|
42
|
+
gte?: number;
|
|
43
|
+
lt?: number;
|
|
44
|
+
lte?: number;
|
|
45
|
+
}
|
|
46
|
+
| {
|
|
47
|
+
type: 'out-of-range-length-char';
|
|
48
|
+
gte: number;
|
|
49
|
+
lte?: number;
|
|
50
|
+
}
|
|
51
|
+
| {
|
|
52
|
+
type: 'out-of-range-length-digit';
|
|
53
|
+
gte: number;
|
|
54
|
+
lte?: number;
|
|
55
|
+
};
|
|
56
|
+
export type MatchedResult = {
|
|
57
|
+
matched: true;
|
|
35
58
|
};
|
|
36
|
-
export
|
|
37
|
-
|
|
59
|
+
export type Expect = {
|
|
60
|
+
type: 'const' | 'format' | 'syntax' | 'regexp' | 'common';
|
|
61
|
+
value: string;
|
|
38
62
|
};
|
|
39
|
-
export
|
|
40
|
-
|
|
41
|
-
|
|
63
|
+
export type FormattedPrimitiveTypeCheck = (value: string) => boolean;
|
|
64
|
+
export type FormattedPrimitiveTypeCreator<O = never> = (options?: O) => FormattedPrimitiveTypeCheck;
|
|
65
|
+
export type Defs = Record<string, CustomCssSyntax | CustomSyntax>;
|
|
66
|
+
export type CustomSyntax = {
|
|
67
|
+
ref: string;
|
|
68
|
+
expects?: Expect[];
|
|
69
|
+
is: CustomSyntaxCheck;
|
|
42
70
|
};
|
|
43
|
-
export
|
|
44
|
-
export
|
|
45
|
-
export
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
71
|
+
export type CustomSyntaxCheck = (value: string) => Result;
|
|
72
|
+
export type CustomSyntaxChecker<O = {}> = (options?: O) => CustomSyntaxCheck;
|
|
73
|
+
export type CustomCssSyntax = {
|
|
74
|
+
ref: string;
|
|
75
|
+
caseSensitive?: boolean;
|
|
76
|
+
expects?: Expect[];
|
|
77
|
+
syntax: {
|
|
78
|
+
apply: `<${string}>`;
|
|
79
|
+
def: Record<string, string | CssSyntaxTokenizer>;
|
|
80
|
+
/**
|
|
81
|
+
* @deprecated
|
|
82
|
+
*/
|
|
83
|
+
ebnf?: Record<string, string | string[]>;
|
|
84
|
+
/**
|
|
85
|
+
* @deprecated
|
|
86
|
+
*/
|
|
87
|
+
properties?: Record<string, string>;
|
|
88
|
+
};
|
|
50
89
|
};
|
|
51
|
-
export
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
syntax: {
|
|
58
|
-
apply: `<${string}>`;
|
|
59
|
-
def: Record<string, string | CssSyntaxTokenizer>;
|
|
60
|
-
/**
|
|
61
|
-
* @deprecated
|
|
62
|
-
*/
|
|
63
|
-
ebnf?: Record<string, string | string[]>;
|
|
64
|
-
/**
|
|
65
|
-
* @deprecated
|
|
66
|
-
*/
|
|
67
|
-
properties?: Record<string, string>;
|
|
68
|
-
};
|
|
90
|
+
export type CSSSyntaxToken = {
|
|
91
|
+
type: number;
|
|
92
|
+
value: string;
|
|
93
|
+
index: number;
|
|
94
|
+
balance: number;
|
|
95
|
+
node?: any;
|
|
69
96
|
};
|
|
70
|
-
export
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
};
|
|
77
|
-
export declare type CssSyntaxTokenizer = (token: CSSSyntaxToken | null, getNextToken: GetNextToken, match: typeof cssSyntaxMatch) => number;
|
|
78
|
-
export declare type GetNextToken = (length: number) => CSSSyntaxToken | null;
|
|
97
|
+
export type CssSyntaxTokenizer = (
|
|
98
|
+
token: CSSSyntaxToken | null,
|
|
99
|
+
getNextToken: GetNextToken,
|
|
100
|
+
match: typeof cssSyntaxMatch,
|
|
101
|
+
) => number;
|
|
102
|
+
export type GetNextToken = (length: number) => CSSSyntaxToken | null;
|