@markuplint/types 3.3.0 → 3.4.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.
@@ -1,5 +1,2 @@
1
1
  import type { CustomSyntaxCheck, UnmatchedResult } from './types';
2
- export declare function checkMultiTypes(
3
- value: string,
4
- checks: CustomSyntaxCheck[],
5
- ): UnmatchedResult | import('./types').MatchedResult;
2
+ export declare function checkMultiTypes(value: string, checks: readonly CustomSyntaxCheck[]): import("./types").MatchedResult | UnmatchedResult;
package/lib/check.d.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  import type { Type, Result, List, CustomSyntax, CustomCssSyntax, Enum, KeywordDefinedType, Number } from './types';
2
- export declare function check(value: string, type: Type, ref?: string, cache?: boolean): Result;
3
- export declare function isKeyword(type: Type): type is KeywordDefinedType;
4
- export declare function isList(type: Type): type is List;
5
- export declare function isEnum(type: Type): type is Enum;
6
- export declare function isNumber(type: Type): type is Number;
2
+ import type { ReadonlyDeep } from 'type-fest';
3
+ export declare function check(value: string, type: ReadonlyDeep<Type>, ref?: string, cache?: boolean): Result;
4
+ export declare function isKeyword(type: ReadonlyDeep<Type>): type is ReadonlyDeep<KeywordDefinedType>;
5
+ export declare function isList(type: ReadonlyDeep<Type>): type is ReadonlyDeep<List>;
6
+ export declare function isEnum(type: ReadonlyDeep<Type>): type is ReadonlyDeep<Enum>;
7
+ export declare function isNumber(type: ReadonlyDeep<Type>): type is ReadonlyDeep<Number>;
7
8
  export declare function isCSSSyntax(type: CustomSyntax | CustomCssSyntax): type is CustomCssSyntax;
8
9
  export declare function isCustomSyntax(type: CustomSyntax | CustomCssSyntax): type is CustomSyntax;
package/lib/css-syntax.js CHANGED
@@ -126,7 +126,17 @@ function detectName(def) {
126
126
  name,
127
127
  };
128
128
  }
129
- function eachMimicCases(key, obj) {
129
+ /**
130
+ *
131
+ * @param key
132
+ * @param obj
133
+ * @modifies obj
134
+ * @returns
135
+ */
136
+ function eachMimicCases(key,
137
+ // Mutable
138
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
139
+ obj) {
130
140
  const value = obj[key];
131
141
  if (!value) {
132
142
  return;
package/lib/enum.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  import type { Result } from './types';
2
2
  import type { Enum } from './types.schema';
3
- export declare function checkEnum(value: string, type: Enum, ref?: string): Result;
3
+ import type { ReadonlyDeep } from 'type-fest';
4
+ export declare function checkEnum(value: string, type: ReadonlyDeep<Enum>, ref?: string): Result;
package/lib/enum.js CHANGED
@@ -9,7 +9,7 @@ function checkEnum(value, type, ref) {
9
9
  if (!disallowToSurroundBySpaces) {
10
10
  value = value.trim();
11
11
  }
12
- let values = type.enum;
12
+ let values = type.enum.slice();
13
13
  if (caseInsensitive) {
14
14
  value = value.toLowerCase();
15
15
  values = type.enum.map(v => v.toLowerCase());
@@ -1,6 +1,3 @@
1
1
  type NullableString = string | null | undefined;
2
- export declare function getCandidate(
3
- value: NullableString,
4
- ...candidates: (NullableString | NullableString[])[]
5
- ): string | undefined;
2
+ export declare function getCandidate(value: NullableString, ...candidates: readonly (NullableString | readonly NullableString[])[]): string | undefined;
6
3
  export {};
package/lib/list.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  import type { Result } from './types';
2
2
  import type { List } from './types.schema';
3
- export declare function checkList(value: string, type: List, ref?: string, cache?: boolean): Result;
3
+ import type { ReadonlyDeep } from 'type-fest';
4
+ export declare function checkList(value: string, type: ReadonlyDeep<List>, ref?: string, cache?: boolean): Result;
@@ -1,22 +1,9 @@
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) => UnmatchedResult | MatchedResult;
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
- value: string,
18
- reason?: UnmatchedResultReason,
19
- options?: UnmatchedResultOptions & {
20
- ref?: string;
21
- },
22
- ): UnmatchedResult;
7
+ export declare function unmatched(value: string, reason?: UnmatchedResultReason, options?: UnmatchedResultOptions & {
8
+ readonly ref?: string;
9
+ }): UnmatchedResult;
package/lib/number.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  import type { Result } from './types';
2
2
  import type { Number } from './types.schema';
3
- export declare function checkNumber(value: string, type: Number, ref?: string): Result;
3
+ export declare function checkNumber(value: string, type: Readonly<Number>, ref?: string): Result;
@@ -4,4 +4,4 @@
4
4
  * @param units
5
5
  * @param numberType
6
6
  */
7
- export declare function isQuantity(value: string, units: string[], numberType?: 'int' | 'uint' | 'float'): boolean;
7
+ export declare function isQuantity(value: string, units: readonly string[], numberType?: 'int' | 'uint' | 'float'): boolean;
@@ -3,9 +3,6 @@
3
3
  *
4
4
  * @param value
5
5
  */
6
- export declare function isUint(
7
- value: string,
8
- options?: {
9
- gt?: number;
10
- },
11
- ): boolean;
6
+ export declare function isUint(value: string, options?: {
7
+ readonly gt?: number;
8
+ }): boolean;
@@ -4,6 +4,6 @@
4
4
  * @returns
5
5
  */
6
6
  export declare function splitUnit(value: string): {
7
- num: string;
8
- unit: string;
7
+ num: string;
8
+ unit: string;
9
9
  };
@@ -1,71 +1,64 @@
1
+ import type { TokenValue } from './types';
1
2
  import type { UnmatchedResult } from '..';
2
3
  import type { Expect, Result, List } from '../types';
4
+ import type { ReadonlyDeep } from 'type-fest';
3
5
  import { Token } from './token';
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;
6
+ type TokenCollectionOptions = Partial<Omit<List, 'token'> & {
7
+ specificSeparator: string | string[];
8
+ }>;
9
+ export type TokenEachCheck = (head: Readonly<Token> | null, tail: ReadonlyDeep<TokenCollection>) => Result | void;
10
10
  export declare class TokenCollection extends Array<Token> {
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
- }): UnmatchedResult | import('..').MatchedResult;
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 | undefined;
62
- token: Token;
63
- } | null;
64
- toJSON(): {
65
- type: number;
66
- value: string;
67
- offset: number;
68
- }[];
69
- 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;
70
63
  }
71
64
  export {};
@@ -5,12 +5,12 @@ const match_result_1 = require("../match-result");
5
5
  const token_1 = require("./token");
6
6
  class TokenCollection extends Array {
7
7
  static fromPatterns(value, patterns, typeOptions) {
8
- const origin = typeof value === 'string' ? value : value.origin;
8
+ const originalValue = typeof value === 'string' ? value : value.originalValue;
9
9
  let strings = typeof value === 'string' ? value : value.value;
10
10
  let cumulativeOffset = typeof value === 'string' ? 0 : value.offset;
11
11
  const tokens = [];
12
12
  function addToken(tokenValue) {
13
- const token = new token_1.Token(tokenValue, cumulativeOffset, origin);
13
+ const token = new token_1.Token(tokenValue, cumulativeOffset, originalValue);
14
14
  tokens.push(token);
15
15
  strings = strings.slice(tokenValue.length);
16
16
  cumulativeOffset += tokenValue.length;
@@ -71,11 +71,11 @@ class TokenCollection extends Array {
71
71
  separators.push(',');
72
72
  }
73
73
  if (typeOptions === null || typeOptions === void 0 ? void 0 : typeOptions.specificSeparator) {
74
- if (Array.isArray(typeOptions.specificSeparator)) {
75
- separators.push(...typeOptions.specificSeparator);
74
+ if (typeof typeOptions.specificSeparator === 'string') {
75
+ separators.push(typeOptions.specificSeparator);
76
76
  }
77
77
  else {
78
- separators.push(typeOptions.specificSeparator);
78
+ separators.push(...typeOptions.specificSeparator);
79
79
  }
80
80
  }
81
81
  const chars = value.split('');
@@ -1,60 +1,56 @@
1
+ import type { TokenValue } from './types';
1
2
  import type { UnmatchedResult, UnmatchedResultOptions, UnmatchedResultReason } from '../types';
2
3
  export declare class Token {
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;
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;
60
56
  }
@@ -1,8 +1,6 @@
1
1
  "use strict";
2
- var _Token_originalValue;
3
2
  Object.defineProperty(exports, "__esModule", { value: true });
4
3
  exports.Token = void 0;
5
- const tslib_1 = require("tslib");
6
4
  class Token {
7
5
  static getCol(value, offset) {
8
6
  var _a;
@@ -29,22 +27,21 @@ class Token {
29
27
  const shifted = token.offset + offset;
30
28
  return {
31
29
  offset: shifted,
32
- line: Token.getLine(tslib_1.__classPrivateFieldGet(token, _Token_originalValue, "f"), shifted),
33
- column: Token.getCol(tslib_1.__classPrivateFieldGet(token, _Token_originalValue, "f"), shifted),
30
+ line: Token.getLine(token.originalValue, shifted),
31
+ column: Token.getCol(token.originalValue, shifted),
34
32
  };
35
33
  }
36
34
  constructor(value, offset, originalValue, separators) {
37
- _Token_originalValue.set(this, void 0);
38
35
  this.type = Token.getType(value, separators);
39
36
  this.value = value;
40
37
  this.offset = offset;
41
- tslib_1.__classPrivateFieldSet(this, _Token_originalValue, originalValue, "f");
38
+ this.originalValue = originalValue;
42
39
  }
43
40
  get length() {
44
41
  return this.value.length;
45
42
  }
46
- get origin() {
47
- return tslib_1.__classPrivateFieldGet(this, _Token_originalValue, "f");
43
+ clone() {
44
+ return new Token(this.value, this.offset, this.originalValue);
48
45
  }
49
46
  /**
50
47
  *
@@ -103,14 +100,12 @@ class Token {
103
100
  raw: this.value,
104
101
  offset: this.offset,
105
102
  length: this.value.length,
106
- line: Token.getLine(tslib_1.__classPrivateFieldGet(this, _Token_originalValue, "f"), this.offset),
107
- column: Token.getCol(tslib_1.__classPrivateFieldGet(this, _Token_originalValue, "f"), this.offset),
103
+ line: Token.getLine(this.originalValue, this.offset),
104
+ column: Token.getCol(this.originalValue, this.offset),
108
105
  reason: (_a = options === null || options === void 0 ? void 0 : options.reason) !== null && _a !== void 0 ? _a : 'syntax-error',
109
106
  };
110
107
  }
111
108
  }
112
- exports.Token = Token;
113
- _Token_originalValue = new WeakMap();
114
109
  /**
115
110
  * @see https://github.com/csstree/csstree/blob/master/lib/tokenizer/types.js
116
111
  */
@@ -128,3 +123,4 @@ Token.WhiteSpace = 13;
128
123
  * @see https://infra.spec.whatwg.org/#ascii-whitespace
129
124
  */
130
125
  Token.whitespace = ['\u0009', '\u000A', '\u000C', '\u000D', '\u0020'];
126
+ exports.Token = Token;
@@ -0,0 +1,3 @@
1
+ export type TokenValueScalar = string | Readonly<RegExp> | number;
2
+ export type TokenValueArray = readonly TokenValue[];
3
+ export type TokenValue = TokenValueScalar | TokenValueArray;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
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
- 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;
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
- partName?: string;
17
- expects?: Expect[];
18
- extra?: Expect;
19
- candidate?: string;
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
- 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
36
  export type MatchedResult = {
57
- matched: true;
37
+ readonly matched: true;
58
38
  };
59
39
  export type Expect = {
60
- type: 'const' | 'format' | 'syntax' | 'regexp' | 'common';
61
- value: string;
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
- ref: string;
68
- expects?: Expect[];
69
- is: CustomSyntaxCheck;
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
- 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
- };
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
- type: number;
92
- value: string;
93
- index: number;
94
- balance: number;
95
- node?: any;
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: 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;