@markuplint/types 3.4.0 → 3.5.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/types.d.ts CHANGED
@@ -2,77 +2,101 @@ 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
- 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;
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
- 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;
16
+ readonly partName?: string;
17
+ readonly expects?: readonly Expect[];
18
+ readonly extra?: Expect;
19
+ readonly candidate?: string;
35
20
  };
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
+ };
36
56
  export type MatchedResult = {
37
- readonly matched: true;
57
+ readonly matched: true;
38
58
  };
39
59
  export type Expect = {
40
- readonly type: 'const' | 'format' | 'syntax' | 'regexp' | 'common';
41
- readonly value: string;
60
+ readonly type: 'const' | 'format' | 'syntax' | 'regexp' | 'common';
61
+ readonly value: string;
42
62
  };
43
63
  export type FormattedPrimitiveTypeCheck = (value: string) => boolean;
44
64
  export type FormattedPrimitiveTypeCreator<O = never> = (options?: O) => FormattedPrimitiveTypeCheck;
45
65
  export type Defs = Record<string, CustomCssSyntax | CustomSyntax>;
46
66
  export type CustomSyntax = {
47
- readonly ref: string;
48
- readonly expects?: readonly Expect[];
49
- readonly is: CustomSyntaxCheck;
67
+ readonly ref: string;
68
+ readonly expects?: readonly Expect[];
69
+ readonly is: CustomSyntaxCheck;
50
70
  };
51
71
  export type CustomSyntaxCheck = (value: string) => Result;
52
72
  export type CustomSyntaxChecker<O = {}> = (options?: O) => CustomSyntaxCheck;
53
73
  export type CustomCssSyntax = {
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
- };
74
+ readonly ref: string;
75
+ readonly caseSensitive?: boolean;
76
+ readonly expects?: readonly Expect[];
77
+ readonly syntax: {
78
+ readonly apply: `<${string}>`;
79
+ readonly def: Readonly<Record<string, string | CssSyntaxTokenizer>>;
80
+ /**
81
+ * @deprecated
82
+ */
83
+ readonly ebnf?: Readonly<Record<string, string | readonly string[]>>;
84
+ /**
85
+ * @deprecated
86
+ */
87
+ readonly properties?: Readonly<Record<string, string>>;
88
+ };
69
89
  };
70
90
  export type CSSSyntaxToken = {
71
- readonly type: number;
72
- readonly value: string;
73
- readonly index: number;
74
- readonly balance: number;
75
- readonly node?: any;
91
+ readonly type: number;
92
+ readonly value: string;
93
+ readonly index: number;
94
+ readonly balance: number;
95
+ readonly node?: any;
76
96
  };
77
- export type CssSyntaxTokenizer = (token: Readonly<CSSSyntaxToken> | null, getNextToken: GetNextToken, match: typeof cssSyntaxMatch) => number;
97
+ export type CssSyntaxTokenizer = (
98
+ token: Readonly<CSSSyntaxToken> | null,
99
+ getNextToken: GetNextToken,
100
+ match: typeof cssSyntaxMatch,
101
+ ) => number;
78
102
  export type GetNextToken = (length: number) => CSSSyntaxToken | null;