@spyglassmc/core 0.4.0 → 0.4.2

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.
Files changed (94) hide show
  1. package/lib/common/Dev.js +5 -2
  2. package/lib/common/Operations.js +7 -3
  3. package/lib/common/ReadonlyProxy.d.ts +2 -2
  4. package/lib/common/ReadonlyProxy.js +3 -1
  5. package/lib/common/StateProxy.d.ts +2 -2
  6. package/lib/common/StateProxy.js +18 -7
  7. package/lib/common/externals/BrowserExternals.js +2 -9
  8. package/lib/common/externals/NodeJsExternals.js +11 -18
  9. package/lib/common/externals/downloader.d.ts +2 -2
  10. package/lib/common/externals/index.d.ts +2 -5
  11. package/lib/common/util.d.ts +8 -7
  12. package/lib/common/util.js +16 -12
  13. package/lib/node/AstNode.d.ts +1 -1
  14. package/lib/node/AstNode.js +9 -5
  15. package/lib/node/CommentNode.d.ts +2 -2
  16. package/lib/node/FileNode.js +6 -1
  17. package/lib/node/ResourceLocationNode.d.ts +3 -3
  18. package/lib/node/ResourceLocationNode.js +9 -5
  19. package/lib/node/StringNode.d.ts +3 -3
  20. package/lib/node/StringNode.js +4 -1
  21. package/lib/parser/Parser.d.ts +5 -5
  22. package/lib/parser/boolean.js +1 -1
  23. package/lib/parser/comment.d.ts +1 -1
  24. package/lib/parser/comment.js +1 -1
  25. package/lib/parser/float.d.ts +1 -1
  26. package/lib/parser/float.js +2 -1
  27. package/lib/parser/integer.d.ts +1 -1
  28. package/lib/parser/integer.js +2 -1
  29. package/lib/parser/list.d.ts +1 -1
  30. package/lib/parser/list.js +3 -3
  31. package/lib/parser/long.d.ts +1 -1
  32. package/lib/parser/long.js +2 -1
  33. package/lib/parser/record.d.ts +1 -1
  34. package/lib/parser/record.js +18 -8
  35. package/lib/parser/resourceLocation.js +61 -8
  36. package/lib/parser/string.js +79 -8
  37. package/lib/parser/util.d.ts +7 -7
  38. package/lib/parser/util.js +14 -5
  39. package/lib/processor/ColorInfoProvider.d.ts +3 -3
  40. package/lib/processor/ColorInfoProvider.js +22 -7
  41. package/lib/processor/InlayHintProvider.d.ts +1 -1
  42. package/lib/processor/SignatureHelpProvider.d.ts +1 -1
  43. package/lib/processor/binder/Binder.d.ts +1 -1
  44. package/lib/processor/binder/builtin.d.ts +2 -2
  45. package/lib/processor/binder/builtin.js +30 -18
  46. package/lib/processor/binder/index.d.ts +1 -1
  47. package/lib/processor/binder/index.js +1 -1
  48. package/lib/processor/checker/Checker.d.ts +3 -3
  49. package/lib/processor/checker/builtin.d.ts +2 -3
  50. package/lib/processor/checker/builtin.js +12 -13
  51. package/lib/processor/colorizer/Colorizer.d.ts +3 -3
  52. package/lib/processor/colorizer/builtin.js +8 -7
  53. package/lib/processor/completer/Completer.d.ts +1 -1
  54. package/lib/processor/completer/Completer.js +4 -2
  55. package/lib/processor/completer/builtin.js +33 -26
  56. package/lib/processor/formatter/Formatter.d.ts +1 -1
  57. package/lib/processor/formatter/Formatter.js +3 -1
  58. package/lib/processor/formatter/builtin.js +14 -12
  59. package/lib/processor/linter/Linter.d.ts +1 -1
  60. package/lib/processor/linter/builtin/undeclaredSymbol.js +47 -24
  61. package/lib/processor/linter/builtin.js +7 -8
  62. package/lib/processor/util.d.ts +1 -1
  63. package/lib/service/CacheService.d.ts +1 -1
  64. package/lib/service/CacheService.js +9 -6
  65. package/lib/service/Config.d.ts +11 -11
  66. package/lib/service/Config.js +28 -21
  67. package/lib/service/Dependency.d.ts +3 -3
  68. package/lib/service/Downloader.js +12 -7
  69. package/lib/service/FileService.d.ts +1 -1
  70. package/lib/service/FileService.js +28 -10
  71. package/lib/service/MetaRegistry.js +7 -6
  72. package/lib/service/Profiler.js +10 -5
  73. package/lib/service/Project.d.ts +5 -5
  74. package/lib/service/Project.js +45 -34
  75. package/lib/service/Service.js +31 -12
  76. package/lib/service/SymbolRegistrar.d.ts +1 -1
  77. package/lib/service/UriProcessor.d.ts +3 -3
  78. package/lib/service/fileUtil.d.ts +2 -2
  79. package/lib/service/fileUtil.js +2 -1
  80. package/lib/source/IndexMap.d.ts +1 -1
  81. package/lib/source/IndexMap.js +1 -1
  82. package/lib/source/LanguageError.js +1 -1
  83. package/lib/source/Location.d.ts +1 -1
  84. package/lib/source/Location.js +4 -1
  85. package/lib/source/Offset.d.ts +1 -1
  86. package/lib/source/Range.d.ts +1 -1
  87. package/lib/source/Range.js +6 -3
  88. package/lib/source/Source.d.ts +4 -4
  89. package/lib/source/Source.js +3 -1
  90. package/lib/symbol/Symbol.d.ts +19 -19
  91. package/lib/symbol/Symbol.js +27 -12
  92. package/lib/symbol/SymbolUtil.d.ts +6 -6
  93. package/lib/symbol/SymbolUtil.js +76 -44
  94. package/package.json +2 -2
@@ -26,7 +26,7 @@ interface InfallibleOptions extends OptionsBase {
26
26
  failsOnEmpty?: false;
27
27
  }
28
28
  /** @internal For test only */
29
- export declare type Options = FallibleOptions | InfallibleOptions;
29
+ export type Options = FallibleOptions | InfallibleOptions;
30
30
  export declare function float(options: InfallibleOptions): InfallibleParser<FloatNode>;
31
31
  export declare function float(options: FallibleOptions): Parser<FloatNode>;
32
32
  export {};
@@ -43,7 +43,8 @@ export function float(options) {
43
43
  else if (!options.pattern.test(raw)) {
44
44
  ctx.err.report(localize('parser.float.illegal', options.pattern), ans);
45
45
  }
46
- else if ((options.min && ans.value < options.min) || (options.max && ans.value > options.max)) {
46
+ else if ((options.min && ans.value < options.min) ||
47
+ (options.max && ans.value > options.max)) {
47
48
  const onOutOfRange = options.onOutOfRange ?? fallbackOnOutOfRange;
48
49
  onOutOfRange(ans, src, ctx, options);
49
50
  }
@@ -26,7 +26,7 @@ interface InfallibleOptions extends OptionsBase {
26
26
  failsOnEmpty?: false;
27
27
  }
28
28
  /** @internal For test only */
29
- export declare type Options = FallibleOptions | InfallibleOptions;
29
+ export type Options = FallibleOptions | InfallibleOptions;
30
30
  export declare function integer(options: InfallibleOptions): InfallibleParser<IntegerNode>;
31
31
  export declare function integer(options: FallibleOptions): Parser<IntegerNode>;
32
32
  export {};
@@ -32,7 +32,8 @@ export function integer(options) {
32
32
  else if (!options.pattern.test(raw) || isOnlySign) {
33
33
  ctx.err.report(localize('parser.integer.illegal', options.pattern), ans);
34
34
  }
35
- else if ((options.min !== undefined && ans.value < options.min) || (options.max !== undefined && ans.value > options.max)) {
35
+ else if ((options.min !== undefined && ans.value < options.min) ||
36
+ (options.max !== undefined && ans.value > options.max)) {
36
37
  const onOutOfRange = options.onOutOfRange ?? fallbackOnOutOfRange;
37
38
  onOutOfRange(ans, src, ctx, options);
38
39
  }
@@ -8,5 +8,5 @@ export interface Options<V extends AstNode> {
8
8
  trailingSep: boolean;
9
9
  end: string;
10
10
  }
11
- export declare function list<V extends AstNode>({ start, value, sep, trailingSep, end }: Options<V>): InfallibleParser<ListNode<V>>;
11
+ export declare function list<V extends AstNode>({ start, value, sep, trailingSep, end, }: Options<V>): InfallibleParser<ListNode<V>>;
12
12
  //# sourceMappingURL=list.d.ts.map
@@ -2,7 +2,7 @@ import { localeQuote, localize } from '@spyglassmc/locales';
2
2
  import { Range } from '../source/index.js';
3
3
  import { Failure } from './Parser.js';
4
4
  import { attempt } from './util.js';
5
- export function list({ start, value, sep, trailingSep, end }) {
5
+ export function list({ start, value, sep, trailingSep, end, }) {
6
6
  return (src, ctx) => {
7
7
  const ans = {
8
8
  type: 'list',
@@ -34,14 +34,14 @@ export function list({ start, value, sep, trailingSep, end }) {
34
34
  let sepRange = undefined;
35
35
  src.skipWhitespace();
36
36
  requiresValueSep = true;
37
- if (hasValueSep = src.peek(sep.length) === sep) {
37
+ if ((hasValueSep = src.peek(sep.length) === sep)) {
38
38
  sepRange = Range.create(src, () => src.skip(sep.length));
39
39
  }
40
40
  // Create item.
41
41
  ans.children.push({
42
42
  type: 'item',
43
43
  range: Range.create(itemStart, src),
44
- ...valueNode ? { children: [valueNode] } : {},
44
+ ...(valueNode ? { children: [valueNode] } : {}),
45
45
  value: valueNode,
46
46
  sep: sepRange,
47
47
  });
@@ -26,7 +26,7 @@ interface InfallibleOptions extends OptionsBase {
26
26
  failsOnEmpty?: false;
27
27
  }
28
28
  /** @internal For test only */
29
- export declare type Options = FallibleOptions | InfallibleOptions;
29
+ export type Options = FallibleOptions | InfallibleOptions;
30
30
  export declare function long(options: InfallibleOptions): InfallibleParser<LongNode>;
31
31
  export declare function long(options: FallibleOptions): Parser<LongNode>;
32
32
  export {};
@@ -36,7 +36,8 @@ export function long(options) {
36
36
  else if (!options.pattern.test(raw) || isOnlySign) {
37
37
  ctx.err.report(localize('parser.long.illegal', options.pattern), ans);
38
38
  }
39
- else if ((options.min && ans.value < options.min) || (options.max && ans.value > options.max)) {
39
+ else if ((options.min && ans.value < options.min) ||
40
+ (options.max && ans.value > options.max)) {
40
41
  const onOutOfRange = options.onOutOfRange ?? fallbackOnOutOfRange;
41
42
  onOutOfRange(ans, src, ctx, options);
42
43
  }
@@ -18,5 +18,5 @@ export interface Options<K extends AstNode, V extends AstNode> {
18
18
  /**
19
19
  * @returns A parser that parses something coming in a key-value pair form. e.g. SNBT objects, entity selector arguments.
20
20
  */
21
- export declare function record<K extends AstNode, V extends AstNode>({ start, pair, end }: Options<K, V>): InfallibleParser<RecordNode<K, V>>;
21
+ export declare function record<K extends AstNode, V extends AstNode>({ start, pair, end, }: Options<K, V>): InfallibleParser<RecordNode<K, V>>;
22
22
  //# sourceMappingURL=record.d.ts.map
@@ -5,7 +5,7 @@ import { attempt } from './util.js';
5
5
  /**
6
6
  * @returns A parser that parses something coming in a key-value pair form. e.g. SNBT objects, entity selector arguments.
7
7
  */
8
- export function record({ start, pair, end }) {
8
+ export function record({ start, pair, end, }) {
9
9
  return (src, ctx) => {
10
10
  const ans = {
11
11
  type: 'record',
@@ -26,8 +26,10 @@ export function record({ start, pair, end }) {
26
26
  }
27
27
  // Key.
28
28
  const keyStart = src.cursor;
29
- const { result: keyResult, updateSrcAndCtx: updateForKey, endCursor: keyEnd } = attempt(pair.key, src, ctx);
30
- if (keyResult === Failure || (keyEnd - keyStart === 0 && ![pair.sep, pair.end, end, '\r', '\n', '\t', ' '].includes(src.peek()))) {
29
+ const { result: keyResult, updateSrcAndCtx: updateForKey, endCursor: keyEnd, } = attempt(pair.key, src, ctx);
30
+ if (keyResult === Failure ||
31
+ (keyEnd - keyStart === 0 &&
32
+ ![pair.sep, pair.end, end, '\r', '\n', '\t', ' '].includes(src.peek()))) {
31
33
  ctx.err.report(localize('expected', localize('parser.record.key')), Range.create(src, () => src.skipUntilOrEnd(pair.sep, pair.end, end, '\r', '\n')));
32
34
  }
33
35
  else {
@@ -45,10 +47,14 @@ export function record({ start, pair, end }) {
45
47
  }
46
48
  // Value.
47
49
  src.skipWhitespace();
48
- const valueParser = typeof pair.value === 'function' ? pair.value : pair.value.get(ans, key);
50
+ const valueParser = typeof pair.value === 'function'
51
+ ? pair.value
52
+ : pair.value.get(ans, key);
49
53
  const valueStart = src.cursor;
50
- const { result: valueResult, updateSrcAndCtx: updateForValue, endCursor: valueEnd } = attempt(valueParser, src, ctx);
51
- if (valueResult === Failure || (valueEnd - valueStart === 0 && ![pair.sep, pair.end, end, '\r', '\n', '\t', ' '].includes(src.peek()))) {
54
+ const { result: valueResult, updateSrcAndCtx: updateForValue, endCursor: valueEnd, } = attempt(valueParser, src, ctx);
55
+ if (valueResult === Failure ||
56
+ (valueEnd - valueStart === 0 &&
57
+ ![pair.sep, pair.end, end, '\r', '\n', '\t', ' '].includes(src.peek()))) {
52
58
  ctx.err.report(localize('expected', localize('parser.record.value')), Range.create(src, () => src.skipUntilOrEnd(pair.sep, pair.end, end, '\r', '\n')));
53
59
  }
54
60
  else {
@@ -59,14 +65,18 @@ export function record({ start, pair, end }) {
59
65
  let endCharRange = undefined;
60
66
  src.skipWhitespace();
61
67
  requiresPairEnd = true;
62
- if (hasPairEnd = src.peek(pair.end.length) === pair.end) {
68
+ if ((hasPairEnd = src.peek(pair.end.length) === pair.end)) {
63
69
  endCharRange = Range.create(src, () => src.skip(pair.end.length));
64
70
  }
65
71
  // Create pair.
66
72
  ans.children.push({
67
73
  type: 'pair',
68
74
  range: Range.create(pairStart, src),
69
- ...(key || value) ? { children: [key, value].filter(v => !!v) } : {},
75
+ ...(key || value
76
+ ? {
77
+ children: [key, value].filter((v) => !!v),
78
+ }
79
+ : {}),
70
80
  key,
71
81
  sep: sepCharRange,
72
82
  value,
@@ -1,11 +1,62 @@
1
1
  import { arrayToMessage, localize } from '@spyglassmc/locales';
2
2
  import { ResourceLocation } from '../common/index.js';
3
3
  import { Range } from '../source/index.js';
4
- const Terminators = new Set([' ', '\r', '\n', '=', ',', '"', "'", '{', '}', '[', ']', '(', ')', ';']);
4
+ const Terminators = new Set([
5
+ ' ',
6
+ '\r',
7
+ '\n',
8
+ '=',
9
+ ',',
10
+ '"',
11
+ "'",
12
+ '{',
13
+ '}',
14
+ '[',
15
+ ']',
16
+ '(',
17
+ ')',
18
+ ';',
19
+ ]);
5
20
  const LegalCharacters = new Set([
6
- 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
7
- 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
8
- '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '_', '-', '.',
21
+ 'a',
22
+ 'b',
23
+ 'c',
24
+ 'd',
25
+ 'e',
26
+ 'f',
27
+ 'g',
28
+ 'h',
29
+ 'i',
30
+ 'j',
31
+ 'k',
32
+ 'l',
33
+ 'm',
34
+ 'n',
35
+ 'o',
36
+ 'p',
37
+ 'q',
38
+ 'r',
39
+ 's',
40
+ 't',
41
+ 'u',
42
+ 'v',
43
+ 'w',
44
+ 'x',
45
+ 'y',
46
+ 'z',
47
+ '0',
48
+ '1',
49
+ '2',
50
+ '3',
51
+ '4',
52
+ '5',
53
+ '6',
54
+ '7',
55
+ '8',
56
+ '9',
57
+ '_',
58
+ '-',
59
+ '.',
9
60
  ]);
10
61
  export function resourceLocation(options) {
11
62
  return (src, ctx) => {
@@ -35,10 +86,12 @@ export function resourceLocation(options) {
35
86
  ans.path = rawPath.split(ResourceLocation.PathSep);
36
87
  // Check characters.
37
88
  /* istanbul ignore next */
38
- const illegalChars = [...new Set([
39
- ...[...ans.namespace ?? []].filter(c => !LegalCharacters.has(c)),
40
- ...[...rawPath].filter(c => c !== '/' && !LegalCharacters.has(c)),
41
- ])];
89
+ const illegalChars = [
90
+ ...new Set([
91
+ ...[...(ans.namespace ?? [])].filter((c) => !LegalCharacters.has(c)),
92
+ ...[...rawPath].filter((c) => c !== '/' && !LegalCharacters.has(c)),
93
+ ]),
94
+ ];
42
95
  if (illegalChars.length) {
43
96
  ctx.err.report(localize('parser.resource-location.illegal', arrayToMessage(illegalChars, true, 'and')), ans);
44
97
  }
@@ -22,7 +22,9 @@ export function string(options) {
22
22
  const cStart = src.cursor;
23
23
  src.skip();
24
24
  const c2 = src.read();
25
- if (c2 === '\\' || c2 === currentQuote || EscapeChar.is(options.escapable.characters, c2)) {
25
+ if (c2 === '\\' ||
26
+ c2 === currentQuote ||
27
+ EscapeChar.is(options.escapable.characters, c2)) {
26
28
  ans.valueMap.push({
27
29
  inner: Range.create(ans.value.length, ans.value.length + 1),
28
30
  outer: Range.create(cStart, src),
@@ -73,7 +75,8 @@ export function string(options) {
73
75
  start = contentStart;
74
76
  }
75
77
  else if (options.unquotable) {
76
- while (src.canRead() && isAllowedCharacter(src.peek(), options.unquotable)) {
78
+ while (src.canRead() &&
79
+ isAllowedCharacter(src.peek(), options.unquotable)) {
77
80
  ans.value += src.read();
78
81
  }
79
82
  if (!ans.value && !options.unquotable.allowEmpty) {
@@ -83,7 +86,10 @@ export function string(options) {
83
86
  else {
84
87
  ctx.err.report(localize('expected', options.quotes), src);
85
88
  }
86
- ans.valueMap.unshift({ inner: Range.create(0), outer: Range.create(start) });
89
+ ans.valueMap.unshift({
90
+ inner: Range.create(0),
91
+ outer: Range.create(start),
92
+ });
87
93
  if (options.value?.parser) {
88
94
  const valueResult = parseStringValue(options.value.parser, ans.value, ans.valueMap, ctx);
89
95
  /* istanbul ignore else */
@@ -105,14 +111,79 @@ export function parseStringValue(parser, value, map, ctx) {
105
111
  return parser(valueSrc, valueCtx);
106
112
  }
107
113
  export const BrigadierUnquotableCharacters = Object.freeze([
108
- '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
109
- 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
110
- 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
111
- '_', '.', '+', '-',
114
+ '0',
115
+ '1',
116
+ '2',
117
+ '3',
118
+ '4',
119
+ '5',
120
+ '6',
121
+ '7',
122
+ '8',
123
+ '9',
124
+ 'A',
125
+ 'B',
126
+ 'C',
127
+ 'D',
128
+ 'E',
129
+ 'F',
130
+ 'G',
131
+ 'H',
132
+ 'I',
133
+ 'J',
134
+ 'K',
135
+ 'L',
136
+ 'M',
137
+ 'N',
138
+ 'O',
139
+ 'P',
140
+ 'Q',
141
+ 'R',
142
+ 'S',
143
+ 'T',
144
+ 'U',
145
+ 'V',
146
+ 'W',
147
+ 'X',
148
+ 'Y',
149
+ 'Z',
150
+ 'a',
151
+ 'b',
152
+ 'c',
153
+ 'd',
154
+ 'e',
155
+ 'f',
156
+ 'g',
157
+ 'h',
158
+ 'i',
159
+ 'j',
160
+ 'k',
161
+ 'l',
162
+ 'm',
163
+ 'n',
164
+ 'o',
165
+ 'p',
166
+ 'q',
167
+ 'r',
168
+ 's',
169
+ 't',
170
+ 'u',
171
+ 'v',
172
+ 'w',
173
+ 'x',
174
+ 'y',
175
+ 'z',
176
+ '_',
177
+ '.',
178
+ '+',
179
+ '-',
112
180
  ]);
113
181
  export const BrigadierUnquotableCharacterSet = new Set(BrigadierUnquotableCharacters);
114
182
  export const BrigadierUnquotablePattern = /^[0-9A-Za-z_\.\+\-]*$/;
115
- export const BrigadierUnquotableOption = { allowEmpty: true, allowList: BrigadierUnquotableCharacterSet };
183
+ export const BrigadierUnquotableOption = {
184
+ allowEmpty: true,
185
+ allowList: BrigadierUnquotableCharacterSet,
186
+ };
116
187
  export const BrigadierStringOptions = {
117
188
  escapable: {},
118
189
  quotes: ['"', "'"],
@@ -3,11 +3,11 @@ import { SequenceUtil } from '../node/index.js';
3
3
  import type { ParserContext } from '../service/index.js';
4
4
  import type { ErrorSeverity, ReadonlySource, Source } from '../source/index.js';
5
5
  import type { InfallibleParser, Parser, Result, Returnable } from './Parser.js';
6
- declare type ExtractNodeType<P extends Parser<Returnable>> = P extends Parser<infer V> ? V : never;
6
+ type ExtractNodeType<P extends Parser<Returnable>> = P extends Parser<infer V> ? V : never;
7
7
  /**
8
8
  * @template PA Parser array.
9
9
  */
10
- declare type ExtractNodeTypes<PA extends Parser<Returnable>[]> = ExtractNodeType<PA[number]>;
10
+ type ExtractNodeTypes<PA extends Parser<Returnable>[]> = ExtractNodeType<PA[number]>;
11
11
  export interface AttemptResult<N extends Returnable = AstNode> {
12
12
  result: Result<N>;
13
13
  updateSrcAndCtx: () => void;
@@ -27,10 +27,10 @@ interface InfallibleAttemptResult<N extends Returnable = AstNode> extends Attemp
27
27
  */
28
28
  export declare function attempt<N extends Returnable = AstNode>(parser: InfallibleParser<N>, src: Source, ctx: ParserContext): InfallibleAttemptResult<N>;
29
29
  export declare function attempt<N extends Returnable = AstNode>(parser: Parser<N>, src: Source, ctx: ParserContext): AttemptResult<N>;
30
- declare type SP<CN extends AstNode> = SIP<CN> | Parser<CN | SequenceUtil<CN> | undefined> | {
30
+ type SP<CN extends AstNode> = SIP<CN> | Parser<CN | SequenceUtil<CN> | undefined> | {
31
31
  get: (result: SequenceUtil<CN>) => Parser<CN | SequenceUtil<CN> | undefined> | undefined;
32
32
  };
33
- declare type SIP<CN extends AstNode> = InfallibleParser<CN | SequenceUtil<CN> | undefined> | {
33
+ type SIP<CN extends AstNode> = InfallibleParser<CN | SequenceUtil<CN> | undefined> | {
34
34
  get: (result: SequenceUtil<CN>) => InfallibleParser<CN | SequenceUtil<CN> | undefined> | undefined;
35
35
  };
36
36
  /**
@@ -102,13 +102,13 @@ export declare function recover<N extends Returnable>(parser: InfallibleParser<N
102
102
  _inputParserIsInfallible: never;
103
103
  } & void;
104
104
  export declare function recover<N extends Returnable>(parser: Parser<N>, defaultValue: (src: Source, ctx: ParserContext) => N): InfallibleParser<N>;
105
- declare type GettableParser = Parser<Returnable> | {
105
+ type GettableParser = Parser<Returnable> | {
106
106
  get: () => Parser<Returnable>;
107
107
  };
108
- declare type ExtractFromGettableParser<T extends GettableParser> = T extends {
108
+ type ExtractFromGettableParser<T extends GettableParser> = T extends {
109
109
  get: () => infer V;
110
110
  } ? V : T extends Parser<Returnable> ? T : never;
111
- declare type Case = {
111
+ type Case = {
112
112
  predicate?: (this: void, src: ReadonlySource) => boolean;
113
113
  prefix?: string;
114
114
  regex?: RegExp;
@@ -82,9 +82,13 @@ export function repeat(parser, parseGap) {
82
82
  export function any(parsers, out) {
83
83
  return (src, ctx) => {
84
84
  const results = parsers
85
- .map((parser, i) => ({ attempt: attempt(parser, src, ctx), index: i }))
85
+ .map((parser, i) => ({
86
+ attempt: attempt(parser, src, ctx),
87
+ index: i,
88
+ }))
86
89
  .filter(({ attempt }) => attempt.result !== Failure)
87
- .sort((a, b) => (b.attempt.endCursor - a.attempt.endCursor) || (a.attempt.errorAmount - b.attempt.errorAmount));
90
+ .sort((a, b) => b.attempt.endCursor - a.attempt.endCursor ||
91
+ a.attempt.errorAmount - b.attempt.errorAmount);
88
92
  if (results.length === 0) {
89
93
  if (out) {
90
94
  out.index = -1;
@@ -151,8 +155,13 @@ export function recover(parser, defaultValue) {
151
155
  export function select(cases) {
152
156
  return (src, ctx) => {
153
157
  for (const { predicate, prefix, parser, regex } of cases) {
154
- if (predicate?.(src) ?? (prefix !== undefined ? src.tryPeek(prefix) : undefined) ?? (regex && src.matchPattern(regex)) ?? true) {
155
- const callableParser = typeof parser === 'object' ? parser.get() : parser;
158
+ if (predicate?.(src) ??
159
+ (prefix !== undefined ? src.tryPeek(prefix) : undefined) ??
160
+ (regex && src.matchPattern(regex)) ??
161
+ true) {
162
+ const callableParser = typeof parser === 'object'
163
+ ? parser.get()
164
+ : parser;
156
165
  return callableParser(src, ctx);
157
166
  }
158
167
  }
@@ -170,7 +179,7 @@ export function map(parser, fn) {
170
179
  };
171
180
  }
172
181
  export function setType(type, parser) {
173
- return map(parser, res => {
182
+ return map(parser, (res) => {
174
183
  const { type: _type, ...restResult } = res;
175
184
  const ans = {
176
185
  type,
@@ -6,7 +6,7 @@ export interface ColorInfo {
6
6
  /**
7
7
  * An array of four decimal numbers within the interval [0, 1] that represent R, G, B, and A respectively.
8
8
  */
9
- export declare type Color = [number, number, number, number];
9
+ export type Color = [number, number, number, number];
10
10
  export declare namespace Color {
11
11
  const NamedColors: Map<string, number>;
12
12
  const ColorNames: string[];
@@ -71,12 +71,12 @@ export declare enum ColorFormat {
71
71
  */
72
72
  CompositeInt = 6
73
73
  }
74
- export declare type FormattableColor = {
74
+ export type FormattableColor = {
75
75
  value: Color;
76
76
  format: ColorFormat[];
77
77
  range?: Range;
78
78
  };
79
- export declare type ColorPresentation = {
79
+ export type ColorPresentation = {
80
80
  label: string;
81
81
  text: string;
82
82
  range: Range;
@@ -119,19 +119,34 @@ export var ColorPresentation;
119
119
  const round = (num) => parseFloat(num.toFixed(3));
120
120
  switch (format) {
121
121
  case ColorFormat.DecRGBA:
122
- return color.map(c => round(c)).join(' ');
122
+ return color.map((c) => round(c)).join(' ');
123
123
  case ColorFormat.DecRGB:
124
- return color.slice(0, 3).map(c => round(c)).join(' ');
124
+ return color
125
+ .slice(0, 3)
126
+ .map((c) => round(c))
127
+ .join(' ');
125
128
  case ColorFormat.IntRGBA:
126
- return color.map(c => Math.round(c * 255)).join(' ');
129
+ return color.map((c) => Math.round(c * 255)).join(' ');
127
130
  case ColorFormat.IntRGB:
128
- return color.slice(0, 3).map(c => Math.round(c * 255)).join(' ');
131
+ return color
132
+ .slice(0, 3)
133
+ .map((c) => Math.round(c * 255))
134
+ .join(' ');
129
135
  case ColorFormat.HexRGBA:
130
- return `#${Math.round((color[0] * 255 << 24) + (color[1] * 255 << 16) + (color[2] * 255) << 8 + color[3] * 255).toString(16).padStart(8, '0')}`;
136
+ return `#${Math.round((((color[0] * 255) << 24) +
137
+ ((color[1] * 255) << 16) +
138
+ color[2] * 255) <<
139
+ (8 + color[3] * 255))
140
+ .toString(16)
141
+ .padStart(8, '0')}`;
131
142
  case ColorFormat.HexRGB:
132
- return `#${Math.round((color[0] * 255 << 16) + (color[1] * 255 << 8) + color[2] * 255).toString(16).padStart(6, '0')}`;
143
+ return `#${Math.round(((color[0] * 255) << 16) + ((color[1] * 255) << 8) +
144
+ color[2] * 255)
145
+ .toString(16)
146
+ .padStart(6, '0')}`;
133
147
  case ColorFormat.CompositeInt:
134
- return `${Math.round((color[0] * 255 << 16) + (color[1] * 255 << 8) + color[2] * 255)}`;
148
+ return `${Math.round(((color[0] * 255) << 16) + ((color[1] * 255) << 8) +
149
+ color[2] * 255)}`;
135
150
  }
136
151
  }
137
152
  })(ColorPresentation || (ColorPresentation = {}));
@@ -5,5 +5,5 @@ export interface InlayHint {
5
5
  offset: number;
6
6
  text: string;
7
7
  }
8
- export declare type InlayHintProvider<N extends AstNode = AstNode> = (node: DeepReadonly<N>, ctx: ProcessorContext) => readonly InlayHint[];
8
+ export type InlayHintProvider<N extends AstNode = AstNode> = (node: DeepReadonly<N>, ctx: ProcessorContext) => readonly InlayHint[];
9
9
  //# sourceMappingURL=InlayHintProvider.d.ts.map
@@ -15,5 +15,5 @@ export interface ParameterInfo {
15
15
  label: [number, number];
16
16
  documentation?: string;
17
17
  }
18
- export declare type SignatureHelpProvider<N extends AstNode = AstNode> = (node: DeepReadonly<N>, ctx: SignatureHelpProviderContext) => SignatureHelp | undefined;
18
+ export type SignatureHelpProvider<N extends AstNode = AstNode> = (node: DeepReadonly<N>, ctx: SignatureHelpProviderContext) => SignatureHelp | undefined;
19
19
  //# sourceMappingURL=SignatureHelpProvider.d.ts.map
@@ -1,7 +1,7 @@
1
1
  import type { AstNode } from '../../node/index.js';
2
2
  import type { BinderContext } from '../../service/index.js';
3
3
  declare const IsAsync: unique symbol;
4
- export declare type Binder<N extends AstNode> = SyncBinder<N> | AsyncBinder<N>;
4
+ export type Binder<N extends AstNode> = SyncBinder<N> | AsyncBinder<N>;
5
5
  export interface SyncBinderInitializer<N extends AstNode> {
6
6
  (node: N, ctx: BinderContext): void;
7
7
  }
@@ -3,13 +3,13 @@ import { ResourceLocationNode } from '../../node/index.js';
3
3
  import type { BinderContext, MetaRegistry } from '../../service/index.js';
4
4
  import type { Binder } from './Binder.js';
5
5
  import { AsyncBinder, SyncBinder } from './Binder.js';
6
- export declare type AttemptResult = {
6
+ export type AttemptResult = {
7
7
  errorAmount: number;
8
8
  totalErrorSpan: number;
9
9
  updateNodeAndCtx: () => void;
10
10
  };
11
11
  export declare function attempt<B extends Binder<never>>(binder: B, node: B extends Binder<infer N extends AstNode> ? N : never, ctx: BinderContext): B extends SyncBinder<any> ? AttemptResult : Promise<AttemptResult>;
12
- declare type ExtractBinder<B extends Binder<never>> = B extends Binder<infer N extends AstNode> ? N : never;
12
+ type ExtractBinder<B extends Binder<never>> = B extends Binder<infer N extends AstNode> ? N : never;
13
13
  export declare function any<Binders extends Binder<never>[]>(binders: Binders): Binders extends SyncBinder<never>[] ? SyncBinder<ExtractBinder<Binders[number]>> : AsyncBinder<ExtractBinder<Binders[number]>>;
14
14
  /**
15
15
  * No operation.