@spyglassmc/core 0.1.1 → 0.3.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.
Files changed (206) hide show
  1. package/README.md +7 -0
  2. package/lib/browser.d.ts +2 -0
  3. package/lib/browser.js +2 -0
  4. package/lib/common/Dev.d.ts +11 -0
  5. package/lib/common/Dev.js +90 -0
  6. package/lib/{service → common}/Logger.d.ts +0 -0
  7. package/lib/{service → common}/Logger.js +2 -5
  8. package/lib/common/Operations.d.ts +12 -0
  9. package/lib/common/Operations.js +33 -0
  10. package/lib/common/ReadonlyProxy.d.ts +9 -0
  11. package/lib/common/ReadonlyProxy.js +23 -0
  12. package/lib/common/StateProxy.d.ts +35 -0
  13. package/lib/common/StateProxy.js +69 -0
  14. package/lib/common/TwoWayMap.d.ts +21 -0
  15. package/lib/common/TwoWayMap.js +69 -0
  16. package/lib/common/externals/BrowserExternals.d.ts +3 -0
  17. package/lib/common/externals/BrowserExternals.js +191 -0
  18. package/lib/common/externals/NodeJsExternals.d.ts +3 -0
  19. package/lib/common/externals/NodeJsExternals.js +152 -0
  20. package/lib/common/externals/downloader.d.ts +31 -0
  21. package/lib/common/externals/downloader.js +32 -0
  22. package/lib/common/externals/index.d.ts +96 -0
  23. package/lib/common/externals/index.js +2 -0
  24. package/lib/common/index.d.ts +8 -1
  25. package/lib/common/index.js +8 -13
  26. package/lib/common/util.d.ts +50 -39
  27. package/lib/common/util.js +73 -122
  28. package/lib/index.d.ts +7 -7
  29. package/lib/index.js +7 -19
  30. package/lib/node/AstNode.d.ts +12 -11
  31. package/lib/node/AstNode.js +10 -16
  32. package/lib/node/BooleanNode.d.ts +2 -2
  33. package/lib/node/BooleanNode.js +4 -7
  34. package/lib/node/CommentNode.d.ts +6 -5
  35. package/lib/node/CommentNode.js +4 -9
  36. package/lib/node/ErrorNode.d.ts +1 -1
  37. package/lib/node/ErrorNode.js +2 -5
  38. package/lib/node/FileNode.d.ts +8 -4
  39. package/lib/node/FileNode.js +3 -6
  40. package/lib/node/FloatNode.d.ts +3 -3
  41. package/lib/node/FloatNode.js +4 -7
  42. package/lib/node/IntegerNode.d.ts +3 -3
  43. package/lib/node/IntegerNode.js +4 -7
  44. package/lib/node/ListNode.d.ts +2 -2
  45. package/lib/node/ListNode.js +2 -5
  46. package/lib/node/LiteralNode.d.ts +5 -5
  47. package/lib/node/LiteralNode.js +5 -8
  48. package/lib/node/LongNode.d.ts +3 -3
  49. package/lib/node/LongNode.js +4 -7
  50. package/lib/node/RecordNode.d.ts +2 -2
  51. package/lib/node/RecordNode.js +2 -5
  52. package/lib/node/ResourceLocationNode.d.ts +8 -10
  53. package/lib/node/ResourceLocationNode.js +9 -12
  54. package/lib/node/Sequence.d.ts +4 -3
  55. package/lib/node/Sequence.js +4 -6
  56. package/lib/node/StringNode.d.ts +5 -5
  57. package/lib/node/StringNode.js +9 -12
  58. package/lib/node/SymbolNode.d.ts +5 -5
  59. package/lib/node/SymbolNode.js +5 -8
  60. package/lib/node/index.d.ts +15 -15
  61. package/lib/node/index.js +15 -27
  62. package/lib/nodejs.d.ts +2 -0
  63. package/lib/nodejs.js +2 -0
  64. package/lib/parser/Parser.d.ts +3 -3
  65. package/lib/parser/Parser.js +1 -4
  66. package/lib/parser/boolean.d.ts +2 -2
  67. package/lib/parser/boolean.js +3 -6
  68. package/lib/parser/comment.d.ts +2 -2
  69. package/lib/parser/comment.js +5 -9
  70. package/lib/parser/empty.d.ts +1 -1
  71. package/lib/parser/empty.js +1 -5
  72. package/lib/parser/error.d.ts +2 -2
  73. package/lib/parser/error.js +5 -9
  74. package/lib/parser/file.d.ts +3 -3
  75. package/lib/parser/file.js +9 -13
  76. package/lib/parser/float.d.ts +4 -4
  77. package/lib/parser/float.js +12 -16
  78. package/lib/parser/index.d.ts +16 -16
  79. package/lib/parser/index.js +16 -34
  80. package/lib/parser/integer.d.ts +4 -4
  81. package/lib/parser/integer.js +10 -14
  82. package/lib/parser/list.d.ts +2 -2
  83. package/lib/parser/list.js +15 -19
  84. package/lib/parser/literal.d.ts +2 -2
  85. package/lib/parser/literal.js +5 -9
  86. package/lib/parser/long.d.ts +4 -4
  87. package/lib/parser/long.js +10 -14
  88. package/lib/parser/record.d.ts +3 -3
  89. package/lib/parser/record.js +20 -24
  90. package/lib/parser/resourceLocation.d.ts +2 -2
  91. package/lib/parser/resourceLocation.js +12 -24
  92. package/lib/parser/string.d.ts +7 -7
  93. package/lib/parser/string.js +40 -44
  94. package/lib/parser/symbol.d.ts +3 -3
  95. package/lib/parser/symbol.js +4 -14
  96. package/lib/parser/util.d.ts +30 -12
  97. package/lib/parser/util.js +78 -65
  98. package/lib/processor/ColorInfoProvider.d.ts +1 -1
  99. package/lib/processor/ColorInfoProvider.js +6 -9
  100. package/lib/processor/InlayHintProvider.d.ts +4 -3
  101. package/lib/processor/InlayHintProvider.js +1 -2
  102. package/lib/processor/SignatureHelpProvider.d.ts +4 -3
  103. package/lib/processor/SignatureHelpProvider.js +1 -2
  104. package/lib/processor/binder/Binder.d.ts +26 -0
  105. package/lib/processor/binder/Binder.js +18 -0
  106. package/lib/processor/binder/builtin.d.ts +27 -0
  107. package/lib/processor/binder/builtin.js +116 -0
  108. package/lib/processor/binder/index.d.ts +3 -0
  109. package/lib/processor/binder/index.js +3 -0
  110. package/lib/processor/checker/Checker.d.ts +2 -2
  111. package/lib/processor/checker/Checker.js +1 -5
  112. package/lib/processor/checker/builtin.d.ts +4 -4
  113. package/lib/processor/checker/builtin.js +22 -33
  114. package/lib/processor/checker/index.d.ts +2 -2
  115. package/lib/processor/checker/index.js +2 -27
  116. package/lib/processor/colorizer/Colorizer.d.ts +6 -5
  117. package/lib/processor/colorizer/Colorizer.js +8 -11
  118. package/lib/processor/colorizer/builtin.d.ts +3 -3
  119. package/lib/processor/colorizer/builtin.js +33 -46
  120. package/lib/processor/colorizer/index.d.ts +2 -2
  121. package/lib/processor/colorizer/index.js +2 -27
  122. package/lib/processor/completer/Completer.d.ts +6 -5
  123. package/lib/processor/completer/Completer.js +14 -33
  124. package/lib/processor/completer/builtin.d.ts +10 -9
  125. package/lib/processor/completer/builtin.js +59 -75
  126. package/lib/processor/completer/index.d.ts +2 -2
  127. package/lib/processor/completer/index.js +2 -27
  128. package/lib/processor/formatter/Formatter.d.ts +4 -3
  129. package/lib/processor/formatter/Formatter.js +2 -7
  130. package/lib/processor/formatter/builtin.d.ts +3 -3
  131. package/lib/processor/formatter/builtin.js +22 -36
  132. package/lib/processor/formatter/index.d.ts +2 -2
  133. package/lib/processor/formatter/index.js +2 -27
  134. package/lib/processor/index.d.ts +10 -9
  135. package/lib/processor/index.js +10 -21
  136. package/lib/processor/linter/Linter.d.ts +4 -3
  137. package/lib/processor/linter/Linter.js +1 -2
  138. package/lib/processor/linter/builtin/undeclaredSymbol.d.ts +2 -2
  139. package/lib/processor/linter/builtin/undeclaredSymbol.js +23 -27
  140. package/lib/processor/linter/builtin.d.ts +4 -3
  141. package/lib/processor/linter/builtin.js +19 -26
  142. package/lib/processor/linter/index.d.ts +2 -2
  143. package/lib/processor/linter/index.js +2 -27
  144. package/lib/processor/util.d.ts +4 -14
  145. package/lib/processor/util.js +1 -16
  146. package/lib/service/CacheService.d.ts +8 -6
  147. package/lib/service/CacheService.js +35 -56
  148. package/lib/service/Config.d.ts +17 -16
  149. package/lib/service/Config.js +56 -51
  150. package/lib/service/Context.d.ts +24 -21
  151. package/lib/service/Context.js +40 -36
  152. package/lib/service/Dependency.js +2 -5
  153. package/lib/service/Downloader.d.ts +9 -39
  154. package/lib/service/Downloader.js +37 -106
  155. package/lib/service/ErrorReporter.d.ts +2 -2
  156. package/lib/service/ErrorReporter.js +11 -15
  157. package/lib/service/FileService.d.ts +40 -14
  158. package/lib/service/FileService.js +107 -81
  159. package/lib/service/Hover.d.ts +2 -2
  160. package/lib/service/Hover.js +4 -7
  161. package/lib/service/MetaRegistry.d.ts +17 -12
  162. package/lib/service/MetaRegistry.js +81 -73
  163. package/lib/service/Profiler.d.ts +3 -2
  164. package/lib/service/Profiler.js +81 -45
  165. package/lib/service/Project.d.ts +101 -73
  166. package/lib/service/Project.js +438 -367
  167. package/lib/service/Service.d.ts +19 -29
  168. package/lib/service/Service.js +57 -53
  169. package/lib/service/SymbolLocations.d.ts +3 -3
  170. package/lib/service/SymbolLocations.js +4 -7
  171. package/lib/service/SymbolRegistrar.d.ts +1 -1
  172. package/lib/service/SymbolRegistrar.js +1 -2
  173. package/lib/service/UriProcessor.d.ts +5 -0
  174. package/lib/service/UriProcessor.js +2 -0
  175. package/lib/service/fileUtil.d.ts +21 -41
  176. package/lib/service/fileUtil.js +59 -129
  177. package/lib/service/index.d.ts +16 -17
  178. package/lib/service/index.js +16 -31
  179. package/lib/source/IndexMap.d.ts +1 -1
  180. package/lib/source/IndexMap.js +7 -10
  181. package/lib/source/LanguageError.d.ts +2 -2
  182. package/lib/source/LanguageError.js +3 -6
  183. package/lib/source/Location.d.ts +3 -3
  184. package/lib/source/Location.js +6 -9
  185. package/lib/source/Offset.d.ts +1 -1
  186. package/lib/source/Offset.js +4 -7
  187. package/lib/source/Position.js +2 -5
  188. package/lib/source/PositionRange.d.ts +2 -2
  189. package/lib/source/PositionRange.js +14 -17
  190. package/lib/source/Range.d.ts +1 -1
  191. package/lib/source/Range.js +7 -10
  192. package/lib/source/Source.d.ts +9 -4
  193. package/lib/source/Source.js +58 -31
  194. package/lib/source/index.d.ts +8 -8
  195. package/lib/source/index.js +8 -20
  196. package/lib/symbol/Symbol.d.ts +15 -14
  197. package/lib/symbol/Symbol.js +53 -68
  198. package/lib/symbol/SymbolUtil.d.ts +30 -39
  199. package/lib/symbol/SymbolUtil.js +189 -168
  200. package/lib/symbol/index.d.ts +2 -3
  201. package/lib/symbol/index.js +2 -15
  202. package/package.json +7 -4
  203. package/lib/service/Operations.d.ts +0 -8
  204. package/lib/service/Operations.js +0 -26
  205. package/lib/symbol/UriBinder.d.ts +0 -3
  206. package/lib/symbol/UriBinder.js +0 -3
@@ -1,6 +1,6 @@
1
- import type { FileNode } from '../node';
2
- import { AstNode } from '../node';
3
- import type { InfallibleParser } from './Parser';
1
+ import type { FileNode } from '../node/index.js';
2
+ import { AstNode } from '../node/index.js';
3
+ import type { InfallibleParser } from './Parser.js';
4
4
  /**
5
5
  * Dispatches to the corresponding parser for the language.
6
6
  * @throws If there's no parser registered for this language ID.
@@ -1,17 +1,14 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.file = void 0;
4
- const node_1 = require("../node");
5
- const source_1 = require("../source");
6
- const error_1 = require("./error");
7
- const Parser_1 = require("./Parser");
1
+ import { AstNode } from '../node/index.js';
2
+ import { Range } from '../source/index.js';
3
+ import { error } from './error.js';
4
+ import { Failure } from './Parser.js';
8
5
  /**
9
6
  * Dispatches to the corresponding parser for the language.
10
7
  * @throws If there's no parser registered for this language ID.
11
8
  */
12
- function file() {
9
+ export function file() {
13
10
  return (src, ctx) => {
14
- const fullRange = source_1.Range.create(src, src.string.length);
11
+ const fullRange = Range.create(src, src.string.length);
15
12
  const ans = {
16
13
  type: 'file',
17
14
  range: fullRange,
@@ -22,16 +19,15 @@ function file() {
22
19
  src.skipWhitespace();
23
20
  const parser = ctx.meta.getParserForLanguageId(ctx.doc.languageId);
24
21
  const result = parser(src, ctx);
25
- if (result && result !== Parser_1.Failure) {
22
+ if (result && result !== Failure) {
26
23
  ans.children.push(result);
27
24
  }
28
25
  if (src.skipWhitespace().canRead()) {
29
- ans.children.push((0, error_1.error)(src, ctx));
26
+ ans.children.push(error(src, ctx));
30
27
  }
31
- node_1.AstNode.setParents(ans);
28
+ AstNode.setParents(ans);
32
29
  ans.parserErrors = ctx.err.dump();
33
30
  return ans;
34
31
  };
35
32
  }
36
- exports.file = file;
37
33
  //# sourceMappingURL=file.js.map
@@ -1,7 +1,7 @@
1
- import type { FloatNode } from '../node';
2
- import type { ParserContext } from '../service';
3
- import { Source } from '../source';
4
- import type { InfallibleParser, Parser } from './Parser';
1
+ import type { FloatNode } from '../node/index.js';
2
+ import type { ParserContext } from '../service/index.js';
3
+ import { Source } from '../source/index.js';
4
+ import type { InfallibleParser, Parser } from './Parser.js';
5
5
  interface OptionsBase {
6
6
  pattern: RegExp;
7
7
  /**
@@ -1,27 +1,24 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.float = void 0;
4
- const locales_1 = require("@spyglassmc/locales");
5
- const source_1 = require("../source");
6
- const Parser_1 = require("./Parser");
1
+ import { localize } from '@spyglassmc/locales';
2
+ import { Range, Source } from '../source/index.js';
3
+ import { Failure } from './Parser.js';
7
4
  const fallbackOnOutOfRange = (ans, _src, ctx, options) => {
8
- ctx.err.report((0, locales_1.localize)('expected', (0, locales_1.localize)('float.between', options.min ?? '-∞', options.max ?? '+∞')), ans, 3 /* Error */);
5
+ ctx.err.report(localize('expected', localize('float.between', options.min ?? '-∞', options.max ?? '+∞')), ans, 3 /* ErrorSeverity.Error */);
9
6
  };
10
- function float(options) {
7
+ export function float(options) {
11
8
  return (src, ctx) => {
12
9
  const ans = {
13
10
  type: 'float',
14
- range: source_1.Range.create(src),
11
+ range: Range.create(src),
15
12
  value: 0,
16
13
  };
17
14
  if (src.peek() === '-' || src.peek() === '+') {
18
15
  src.skip();
19
16
  }
20
- while (src.canRead() && source_1.Source.isDigit(src.peek())) {
17
+ while (src.canRead() && Source.isDigit(src.peek())) {
21
18
  src.skip();
22
19
  }
23
20
  if (src.trySkip('.')) {
24
- while (src.canRead() && source_1.Source.isDigit(src.peek())) {
21
+ while (src.canRead() && Source.isDigit(src.peek())) {
25
22
  src.skip();
26
23
  }
27
24
  }
@@ -30,7 +27,7 @@ function float(options) {
30
27
  if (src.peek() === '-' || src.peek() === '+') {
31
28
  src.skip();
32
29
  }
33
- while (src.canRead() && source_1.Source.isDigit(src.peek())) {
30
+ while (src.canRead() && Source.isDigit(src.peek())) {
34
31
  src.skip();
35
32
  }
36
33
  }
@@ -39,12 +36,12 @@ function float(options) {
39
36
  ans.value = parseFloat(raw) || 0;
40
37
  if (!raw) {
41
38
  if (options.failsOnEmpty) {
42
- return Parser_1.Failure;
39
+ return Failure;
43
40
  }
44
- ctx.err.report((0, locales_1.localize)('expected', (0, locales_1.localize)('float')), ans);
41
+ ctx.err.report(localize('expected', localize('float')), ans);
45
42
  }
46
43
  else if (!options.pattern.test(raw)) {
47
- ctx.err.report((0, locales_1.localize)('parser.float.illegal', options.pattern), ans);
44
+ ctx.err.report(localize('parser.float.illegal', options.pattern), ans);
48
45
  }
49
46
  else if ((options.min && ans.value < options.min) || (options.max && ans.value > options.max)) {
50
47
  const onOutOfRange = options.onOutOfRange ?? fallbackOnOutOfRange;
@@ -53,5 +50,4 @@ function float(options) {
53
50
  return ans;
54
51
  };
55
52
  }
56
- exports.float = float;
57
53
  //# sourceMappingURL=float.js.map
@@ -1,17 +1,17 @@
1
- export * from './boolean';
2
- export * from './comment';
3
- export * from './empty';
4
- export * from './error';
5
- export * from './file';
6
- export { float } from './float';
7
- export { integer } from './integer';
8
- export { list } from './list';
9
- export * from './literal';
10
- export { long } from './long';
11
- export * from './Parser';
12
- export { record } from './record';
13
- export * from './resourceLocation';
14
- export * from './string';
15
- export * from './symbol';
16
- export * from './util';
1
+ export * from './boolean.js';
2
+ export * from './comment.js';
3
+ export * from './empty.js';
4
+ export * from './error.js';
5
+ export * from './file.js';
6
+ export { float } from './float.js';
7
+ export { integer } from './integer.js';
8
+ export { list } from './list.js';
9
+ export * from './literal.js';
10
+ export { long } from './long.js';
11
+ export * from './Parser.js';
12
+ export { record } from './record.js';
13
+ export * from './resourceLocation.js';
14
+ export * from './string.js';
15
+ export * from './symbol.js';
16
+ export * from './util.js';
17
17
  //# sourceMappingURL=index.d.ts.map
@@ -1,36 +1,18 @@
1
- "use strict";
2
1
  /* istanbul ignore file */
3
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
- if (k2 === undefined) k2 = k;
5
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
6
- }) : (function(o, m, k, k2) {
7
- if (k2 === undefined) k2 = k;
8
- o[k2] = m[k];
9
- }));
10
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
11
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
12
- };
13
- Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.record = exports.long = exports.list = exports.integer = exports.float = void 0;
15
- __exportStar(require("./boolean"), exports);
16
- __exportStar(require("./comment"), exports);
17
- __exportStar(require("./empty"), exports);
18
- __exportStar(require("./error"), exports);
19
- __exportStar(require("./file"), exports);
20
- var float_1 = require("./float");
21
- Object.defineProperty(exports, "float", { enumerable: true, get: function () { return float_1.float; } });
22
- var integer_1 = require("./integer");
23
- Object.defineProperty(exports, "integer", { enumerable: true, get: function () { return integer_1.integer; } });
24
- var list_1 = require("./list");
25
- Object.defineProperty(exports, "list", { enumerable: true, get: function () { return list_1.list; } });
26
- __exportStar(require("./literal"), exports);
27
- var long_1 = require("./long");
28
- Object.defineProperty(exports, "long", { enumerable: true, get: function () { return long_1.long; } });
29
- __exportStar(require("./Parser"), exports);
30
- var record_1 = require("./record");
31
- Object.defineProperty(exports, "record", { enumerable: true, get: function () { return record_1.record; } });
32
- __exportStar(require("./resourceLocation"), exports);
33
- __exportStar(require("./string"), exports);
34
- __exportStar(require("./symbol"), exports);
35
- __exportStar(require("./util"), exports);
2
+ export * from './boolean.js';
3
+ export * from './comment.js';
4
+ export * from './empty.js';
5
+ export * from './error.js';
6
+ export * from './file.js';
7
+ export { float } from './float.js';
8
+ export { integer } from './integer.js';
9
+ export { list } from './list.js';
10
+ export * from './literal.js';
11
+ export { long } from './long.js';
12
+ export * from './Parser.js';
13
+ export { record } from './record.js';
14
+ export * from './resourceLocation.js';
15
+ export * from './string.js';
16
+ export * from './symbol.js';
17
+ export * from './util.js';
36
18
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
- import type { IntegerNode } from '../node';
2
- import type { ParserContext } from '../service';
3
- import { Source } from '../source';
4
- import type { InfallibleParser, Parser } from './Parser';
1
+ import type { IntegerNode } from '../node/index.js';
2
+ import type { ParserContext } from '../service/index.js';
3
+ import { Source } from '../source/index.js';
4
+ import type { InfallibleParser, Parser } from './Parser.js';
5
5
  interface OptionsBase {
6
6
  pattern: RegExp;
7
7
  /**
@@ -1,23 +1,20 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.integer = void 0;
4
- const locales_1 = require("@spyglassmc/locales");
5
- const source_1 = require("../source");
6
- const Parser_1 = require("./Parser");
1
+ import { localize } from '@spyglassmc/locales';
2
+ import { Range, Source } from '../source/index.js';
3
+ import { Failure } from './Parser.js';
7
4
  const fallbackOnOutOfRange = (ans, _src, ctx, options) => {
8
- ctx.err.report((0, locales_1.localize)('expected', (0, locales_1.localize)('integer.between', options.min ?? '-∞', options.max ?? '+∞')), ans, 3 /* Error */);
5
+ ctx.err.report(localize('expected', localize('integer.between', options.min ?? '-∞', options.max ?? '+∞')), ans, 3 /* ErrorSeverity.Error */);
9
6
  };
10
- function integer(options) {
7
+ export function integer(options) {
11
8
  return (src, ctx) => {
12
9
  const ans = {
13
10
  type: 'integer',
14
- range: source_1.Range.create(src),
11
+ range: Range.create(src),
15
12
  value: 0,
16
13
  };
17
14
  if (src.peek() === '-' || src.peek() === '+') {
18
15
  src.skip();
19
16
  }
20
- while (src.canRead() && source_1.Source.isDigit(src.peek())) {
17
+ while (src.canRead() && Source.isDigit(src.peek())) {
21
18
  src.skip();
22
19
  }
23
20
  ans.range.end = src.cursor;
@@ -28,12 +25,12 @@ function integer(options) {
28
25
  }
29
26
  if (!raw) {
30
27
  if (options.failsOnEmpty) {
31
- return Parser_1.Failure;
28
+ return Failure;
32
29
  }
33
- ctx.err.report((0, locales_1.localize)('expected', (0, locales_1.localize)('integer')), ans);
30
+ ctx.err.report(localize('expected', localize('integer')), ans);
34
31
  }
35
32
  else if (!options.pattern.test(raw) || isOnlySign) {
36
- ctx.err.report((0, locales_1.localize)('parser.integer.illegal', options.pattern), ans);
33
+ ctx.err.report(localize('parser.integer.illegal', options.pattern), ans);
37
34
  }
38
35
  else if ((options.min !== undefined && ans.value < options.min) || (options.max !== undefined && ans.value > options.max)) {
39
36
  const onOutOfRange = options.onOutOfRange ?? fallbackOnOutOfRange;
@@ -42,5 +39,4 @@ function integer(options) {
42
39
  return ans;
43
40
  };
44
41
  }
45
- exports.integer = integer;
46
42
  //# sourceMappingURL=integer.js.map
@@ -1,5 +1,5 @@
1
- import type { AstNode, ListNode } from '../node';
2
- import type { InfallibleParser, Parser } from './Parser';
1
+ import type { AstNode, ListNode } from '../node/index.js';
2
+ import type { InfallibleParser, Parser } from './Parser.js';
3
3
  /** @internal For test only */
4
4
  export interface Options<V extends AstNode> {
5
5
  start: string;
@@ -1,15 +1,12 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.list = void 0;
4
- const locales_1 = require("@spyglassmc/locales");
5
- const source_1 = require("../source");
6
- const Parser_1 = require("./Parser");
7
- const util_1 = require("./util");
8
- function list({ start, value, sep, trailingSep, end }) {
1
+ import { localeQuote, localize } from '@spyglassmc/locales';
2
+ import { Range } from '../source/index.js';
3
+ import { Failure } from './Parser.js';
4
+ import { attempt } from './util.js';
5
+ export function list({ start, value, sep, trailingSep, end }) {
9
6
  return (src, ctx) => {
10
7
  const ans = {
11
8
  type: 'list',
12
- range: source_1.Range.create(src),
9
+ range: Range.create(src),
13
10
  children: [],
14
11
  };
15
12
  if (src.trySkip(start)) {
@@ -21,13 +18,13 @@ function list({ start, value, sep, trailingSep, end }) {
21
18
  let valueNode;
22
19
  // Item sep of the last item.
23
20
  if (requiresValueSep && !hasValueSep) {
24
- ctx.err.report((0, locales_1.localize)('expected', (0, locales_1.localeQuote)(sep)), src);
21
+ ctx.err.report(localize('expected', localeQuote(sep)), src);
25
22
  }
26
23
  // Value.
27
24
  src.skipWhitespace();
28
- const { result, endCursor, updateSrcAndCtx } = (0, util_1.attempt)(value, src, ctx);
29
- if (result === Parser_1.Failure || endCursor === src.cursor) {
30
- ctx.err.report((0, locales_1.localize)('expected', (0, locales_1.localize)('parser.list.value')), source_1.Range.create(src, () => src.skipUntilOrEnd(sep, end, '\r', '\n')));
25
+ const { result, endCursor, updateSrcAndCtx } = attempt(value, src, ctx);
26
+ if (result === Failure || endCursor === src.cursor) {
27
+ ctx.err.report(localize('expected', localize('parser.list.value')), Range.create(src, () => src.skipUntilOrEnd(sep, end, '\r', '\n')));
31
28
  }
32
29
  else {
33
30
  updateSrcAndCtx();
@@ -38,12 +35,12 @@ function list({ start, value, sep, trailingSep, end }) {
38
35
  src.skipWhitespace();
39
36
  requiresValueSep = true;
40
37
  if (hasValueSep = src.peek(sep.length) === sep) {
41
- sepRange = source_1.Range.create(src, () => src.skip(sep.length));
38
+ sepRange = Range.create(src, () => src.skip(sep.length));
42
39
  }
43
40
  // Create item.
44
41
  ans.children.push({
45
42
  type: 'item',
46
- range: source_1.Range.create(itemStart, src),
43
+ range: Range.create(itemStart, src),
47
44
  ...valueNode ? { children: [valueNode] } : {},
48
45
  value: valueNode,
49
46
  sep: sepRange,
@@ -52,19 +49,18 @@ function list({ start, value, sep, trailingSep, end }) {
52
49
  }
53
50
  // Trailing item sep.
54
51
  if (hasValueSep && !trailingSep) {
55
- ctx.err.report((0, locales_1.localize)('parser.list.trailing-sep'), ans.children[ans.children.length - 1].sep);
52
+ ctx.err.report(localize('parser.list.trailing-sep'), ans.children[ans.children.length - 1].sep);
56
53
  }
57
54
  // End.
58
55
  if (!src.trySkip(end)) {
59
- ctx.err.report((0, locales_1.localize)('expected', (0, locales_1.localeQuote)(end)), src);
56
+ ctx.err.report(localize('expected', localeQuote(end)), src);
60
57
  }
61
58
  }
62
59
  else {
63
- ctx.err.report((0, locales_1.localize)('expected', (0, locales_1.localeQuote)(start)), src);
60
+ ctx.err.report(localize('expected', localeQuote(start)), src);
64
61
  }
65
62
  ans.range.end = src.cursor;
66
63
  return ans;
67
64
  };
68
65
  }
69
- exports.list = list;
70
66
  //# sourceMappingURL=list.js.map
@@ -1,5 +1,5 @@
1
- import type { LiteralNode, LiteralOptions } from '../node/LiteralNode';
2
- import type { InfallibleParser } from './Parser';
1
+ import type { LiteralNode, LiteralOptions } from '../node/LiteralNode.js';
2
+ import type { InfallibleParser } from './Parser.js';
3
3
  export declare function literal(...pool: string[]): InfallibleParser<LiteralNode>;
4
4
  export declare function literal(options: LiteralOptions): InfallibleParser<LiteralNode>;
5
5
  //# sourceMappingURL=literal.d.ts.map
@@ -1,14 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.literal = void 0;
4
- const locales_1 = require("@spyglassmc/locales");
5
- const source_1 = require("../source");
6
- function literal(...param) {
1
+ import { localize } from '@spyglassmc/locales';
2
+ import { Range } from '../source/index.js';
3
+ export function literal(...param) {
7
4
  const options = getOptions(param);
8
5
  return (src, ctx) => {
9
6
  const ans = {
10
7
  type: 'literal',
11
- range: source_1.Range.create(src),
8
+ range: Range.create(src),
12
9
  options,
13
10
  value: '',
14
11
  };
@@ -19,11 +16,10 @@ function literal(...param) {
19
16
  return ans;
20
17
  }
21
18
  }
22
- ctx.err.report((0, locales_1.localize)('expected', options.pool), ans);
19
+ ctx.err.report(localize('expected', options.pool), ans);
23
20
  return ans;
24
21
  };
25
22
  }
26
- exports.literal = literal;
27
23
  function getOptions(param) {
28
24
  let ans;
29
25
  if (typeof param[0] === 'object') {
@@ -1,7 +1,7 @@
1
- import type { LongNode } from '../node';
2
- import type { ParserContext } from '../service';
3
- import { Source } from '../source';
4
- import type { InfallibleParser, Parser } from './Parser';
1
+ import type { LongNode } from '../node/index.js';
2
+ import type { ParserContext } from '../service/index.js';
3
+ import { Source } from '../source/index.js';
4
+ import type { InfallibleParser, Parser } from './Parser.js';
5
5
  interface OptionsBase {
6
6
  pattern: RegExp;
7
7
  /**
@@ -1,23 +1,20 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.long = void 0;
4
- const locales_1 = require("@spyglassmc/locales");
5
- const source_1 = require("../source");
6
- const Parser_1 = require("./Parser");
1
+ import { localize } from '@spyglassmc/locales';
2
+ import { Range, Source } from '../source/index.js';
3
+ import { Failure } from './Parser.js';
7
4
  const fallbackOnOutOfRange = (ans, _src, ctx, options) => {
8
- ctx.err.report((0, locales_1.localize)('expected', (0, locales_1.localize)('long.between', options.min ?? '-∞', options.max ?? '+∞')), ans, 3 /* Error */);
5
+ ctx.err.report(localize('expected', localize('long.between', options.min ?? '-∞', options.max ?? '+∞')), ans, 3 /* ErrorSeverity.Error */);
9
6
  };
10
- function long(options) {
7
+ export function long(options) {
11
8
  return (src, ctx) => {
12
9
  const ans = {
13
10
  type: 'long',
14
- range: source_1.Range.create(src),
11
+ range: Range.create(src),
15
12
  value: 0n,
16
13
  };
17
14
  if (src.peek() === '-' || src.peek() === '+') {
18
15
  src.skip();
19
16
  }
20
- while (src.canRead() && source_1.Source.isDigit(src.peek())) {
17
+ while (src.canRead() && Source.isDigit(src.peek())) {
21
18
  src.skip();
22
19
  }
23
20
  ans.range.end = src.cursor;
@@ -32,12 +29,12 @@ function long(options) {
32
29
  }
33
30
  if (!raw) {
34
31
  if (options.failsOnEmpty) {
35
- return Parser_1.Failure;
32
+ return Failure;
36
33
  }
37
- ctx.err.report((0, locales_1.localize)('expected', (0, locales_1.localize)('long')), ans);
34
+ ctx.err.report(localize('expected', localize('long')), ans);
38
35
  }
39
36
  else if (!options.pattern.test(raw) || isOnlySign) {
40
- ctx.err.report((0, locales_1.localize)('parser.long.illegal', options.pattern), ans);
37
+ ctx.err.report(localize('parser.long.illegal', options.pattern), ans);
41
38
  }
42
39
  else if ((options.min && ans.value < options.min) || (options.max && ans.value > options.max)) {
43
40
  const onOutOfRange = options.onOutOfRange ?? fallbackOnOutOfRange;
@@ -46,5 +43,4 @@ function long(options) {
46
43
  return ans;
47
44
  };
48
45
  }
49
- exports.long = long;
50
46
  //# sourceMappingURL=long.js.map
@@ -1,6 +1,6 @@
1
- import type { AstNode } from '../node';
2
- import type { RecordNode } from '../node/RecordNode';
3
- import type { InfallibleParser, Parser } from './Parser';
1
+ import type { AstNode } from '../node/index.js';
2
+ import type { RecordNode } from '../node/RecordNode.js';
3
+ import type { InfallibleParser, Parser } from './Parser.js';
4
4
  /** @internal For test only */
5
5
  export interface Options<K extends AstNode, V extends AstNode> {
6
6
  start: string;
@@ -1,18 +1,15 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.record = void 0;
4
- const locales_1 = require("@spyglassmc/locales");
5
- const source_1 = require("../source");
6
- const Parser_1 = require("./Parser");
7
- const util_1 = require("./util");
1
+ import { localeQuote, localize } from '@spyglassmc/locales';
2
+ import { Range } from '../source/index.js';
3
+ import { Failure } from './Parser.js';
4
+ import { attempt } from './util.js';
8
5
  /**
9
6
  * @returns A parser that parses something coming in a key-value pair form. e.g. SNBT objects, entity selector arguments.
10
7
  */
11
- function record({ start, pair, end }) {
8
+ export function record({ start, pair, end }) {
12
9
  return (src, ctx) => {
13
10
  const ans = {
14
11
  type: 'record',
15
- range: source_1.Range.create(src),
12
+ range: Range.create(src),
16
13
  children: [],
17
14
  };
18
15
  if (src.trySkip(start)) {
@@ -25,13 +22,13 @@ function record({ start, pair, end }) {
25
22
  let value;
26
23
  // Pair end of the last pair.
27
24
  if (requiresPairEnd && !hasPairEnd) {
28
- ctx.err.report((0, locales_1.localize)('expected', (0, locales_1.localeQuote)(pair.end)), src);
25
+ ctx.err.report(localize('expected', localeQuote(pair.end)), src);
29
26
  }
30
27
  // Key.
31
28
  const keyStart = src.cursor;
32
- const { result: keyResult, updateSrcAndCtx: updateForKey, endCursor: keyEnd } = (0, util_1.attempt)(pair.key, src, ctx);
33
- if (keyResult === Parser_1.Failure || (keyEnd - keyStart === 0 && ![pair.sep, pair.end, end, '\r', '\n', '\t', ' '].includes(src.peek()))) {
34
- ctx.err.report((0, locales_1.localize)('expected', (0, locales_1.localize)('parser.record.key')), source_1.Range.create(src, () => src.skipUntilOrEnd(pair.sep, pair.end, end, '\r', '\n')));
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()))) {
31
+ ctx.err.report(localize('expected', localize('parser.record.key')), Range.create(src, () => src.skipUntilOrEnd(pair.sep, pair.end, end, '\r', '\n')));
35
32
  }
36
33
  else {
37
34
  updateForKey();
@@ -41,18 +38,18 @@ function record({ start, pair, end }) {
41
38
  let sepCharRange = undefined;
42
39
  src.skipWhitespace();
43
40
  if (src.peek(pair.sep.length) === pair.sep) {
44
- sepCharRange = source_1.Range.create(src, () => src.skip(pair.sep.length));
41
+ sepCharRange = Range.create(src, () => src.skip(pair.sep.length));
45
42
  }
46
43
  else {
47
- ctx.err.report((0, locales_1.localize)('expected', (0, locales_1.localeQuote)(pair.sep)), src);
44
+ ctx.err.report(localize('expected', localeQuote(pair.sep)), src);
48
45
  }
49
46
  // Value.
50
47
  src.skipWhitespace();
51
48
  const valueParser = typeof pair.value === 'function' ? pair.value : pair.value.get(ans, key);
52
49
  const valueStart = src.cursor;
53
- const { result: valueResult, updateSrcAndCtx: updateForValue, endCursor: valueEnd } = (0, util_1.attempt)(valueParser, src, ctx);
54
- if (valueResult === Parser_1.Failure || (valueEnd - valueStart === 0 && ![pair.sep, pair.end, end, '\r', '\n', '\t', ' '].includes(src.peek()))) {
55
- ctx.err.report((0, locales_1.localize)('expected', (0, locales_1.localize)('parser.record.value')), source_1.Range.create(src, () => src.skipUntilOrEnd(pair.sep, pair.end, end, '\r', '\n')));
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()))) {
52
+ ctx.err.report(localize('expected', localize('parser.record.value')), Range.create(src, () => src.skipUntilOrEnd(pair.sep, pair.end, end, '\r', '\n')));
56
53
  }
57
54
  else {
58
55
  updateForValue();
@@ -63,12 +60,12 @@ function record({ start, pair, end }) {
63
60
  src.skipWhitespace();
64
61
  requiresPairEnd = true;
65
62
  if (hasPairEnd = src.peek(pair.end.length) === pair.end) {
66
- endCharRange = source_1.Range.create(src, () => src.skip(pair.end.length));
63
+ endCharRange = Range.create(src, () => src.skip(pair.end.length));
67
64
  }
68
65
  // Create pair.
69
66
  ans.children.push({
70
67
  type: 'pair',
71
- range: source_1.Range.create(pairStart, src),
68
+ range: Range.create(pairStart, src),
72
69
  ...(key || value) ? { children: [key, value].filter(v => !!v) } : {},
73
70
  key,
74
71
  sep: sepCharRange,
@@ -79,19 +76,18 @@ function record({ start, pair, end }) {
79
76
  }
80
77
  // Trailing pair end.
81
78
  if (hasPairEnd && !pair.trailingEnd) {
82
- ctx.err.report((0, locales_1.localize)('parser.record.trailing-end'), ans.children[ans.children.length - 1].end);
79
+ ctx.err.report(localize('parser.record.trailing-end'), ans.children[ans.children.length - 1].end);
83
80
  }
84
81
  // End.
85
82
  if (!src.trySkip(end)) {
86
- ctx.err.report((0, locales_1.localize)('expected', (0, locales_1.localeQuote)(end)), src);
83
+ ctx.err.report(localize('expected', localeQuote(end)), src);
87
84
  }
88
85
  }
89
86
  else {
90
- ctx.err.report((0, locales_1.localize)('expected', (0, locales_1.localeQuote)(start)), src);
87
+ ctx.err.report(localize('expected', localeQuote(start)), src);
91
88
  }
92
89
  ans.range.end = src.cursor;
93
90
  return ans;
94
91
  };
95
92
  }
96
- exports.record = record;
97
93
  //# sourceMappingURL=record.js.map
@@ -1,4 +1,4 @@
1
- import type { ResourceLocationNode, ResourceLocationOptions } from '../node';
2
- import type { InfallibleParser } from './Parser';
1
+ import type { ResourceLocationNode, ResourceLocationOptions } from '../node/index.js';
2
+ import type { InfallibleParser } from './Parser.js';
3
3
  export declare function resourceLocation(options: ResourceLocationOptions): InfallibleParser<ResourceLocationNode>;
4
4
  //# sourceMappingURL=resourceLocation.d.ts.map