@spyglassmc/core 0.1.0 → 0.2.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 (196) 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/TwoWayMap.d.ts +21 -0
  5. package/lib/common/TwoWayMap.js +69 -0
  6. package/lib/common/externals/BrowserExternals.d.ts +3 -0
  7. package/lib/common/externals/BrowserExternals.js +191 -0
  8. package/lib/common/externals/NodeJsExternals.d.ts +3 -0
  9. package/lib/common/externals/NodeJsExternals.js +151 -0
  10. package/lib/common/externals/downloader.d.ts +31 -0
  11. package/lib/common/externals/downloader.js +32 -0
  12. package/lib/common/externals/index.d.ts +96 -0
  13. package/lib/common/externals/index.js +2 -0
  14. package/lib/common/index.d.ts +2 -1
  15. package/lib/common/index.js +2 -13
  16. package/lib/common/util.d.ts +17 -34
  17. package/lib/common/util.js +32 -113
  18. package/lib/index.d.ts +7 -7
  19. package/lib/index.js +7 -19
  20. package/lib/node/AstNode.d.ts +3 -3
  21. package/lib/node/AstNode.js +10 -16
  22. package/lib/node/BooleanNode.d.ts +2 -2
  23. package/lib/node/BooleanNode.js +4 -7
  24. package/lib/node/CommentNode.d.ts +1 -1
  25. package/lib/node/CommentNode.js +2 -5
  26. package/lib/node/ErrorNode.d.ts +1 -1
  27. package/lib/node/ErrorNode.js +2 -5
  28. package/lib/node/FileNode.d.ts +3 -3
  29. package/lib/node/FileNode.js +2 -5
  30. package/lib/node/FloatNode.d.ts +2 -2
  31. package/lib/node/FloatNode.js +4 -7
  32. package/lib/node/IntegerNode.d.ts +2 -2
  33. package/lib/node/IntegerNode.js +4 -7
  34. package/lib/node/ListNode.d.ts +2 -2
  35. package/lib/node/ListNode.js +2 -5
  36. package/lib/node/LiteralNode.d.ts +4 -4
  37. package/lib/node/LiteralNode.js +5 -8
  38. package/lib/node/LongNode.d.ts +2 -2
  39. package/lib/node/LongNode.js +4 -7
  40. package/lib/node/RecordNode.d.ts +2 -2
  41. package/lib/node/RecordNode.js +2 -5
  42. package/lib/node/ResourceLocationNode.d.ts +6 -8
  43. package/lib/node/ResourceLocationNode.js +9 -12
  44. package/lib/node/Sequence.d.ts +4 -3
  45. package/lib/node/Sequence.js +4 -6
  46. package/lib/node/StringNode.d.ts +5 -5
  47. package/lib/node/StringNode.js +9 -12
  48. package/lib/node/SymbolNode.d.ts +4 -4
  49. package/lib/node/SymbolNode.js +5 -8
  50. package/lib/node/index.d.ts +15 -15
  51. package/lib/node/index.js +15 -27
  52. package/lib/nodejs.d.ts +2 -0
  53. package/lib/nodejs.js +2 -0
  54. package/lib/parser/Parser.d.ts +3 -3
  55. package/lib/parser/Parser.js +1 -4
  56. package/lib/parser/boolean.d.ts +2 -2
  57. package/lib/parser/boolean.js +3 -6
  58. package/lib/parser/comment.d.ts +2 -2
  59. package/lib/parser/comment.js +5 -9
  60. package/lib/parser/empty.d.ts +1 -1
  61. package/lib/parser/empty.js +1 -5
  62. package/lib/parser/error.d.ts +2 -2
  63. package/lib/parser/error.js +5 -9
  64. package/lib/parser/file.d.ts +3 -3
  65. package/lib/parser/file.js +9 -13
  66. package/lib/parser/float.d.ts +4 -4
  67. package/lib/parser/float.js +12 -16
  68. package/lib/parser/index.d.ts +16 -16
  69. package/lib/parser/index.js +16 -34
  70. package/lib/parser/integer.d.ts +4 -4
  71. package/lib/parser/integer.js +10 -14
  72. package/lib/parser/list.d.ts +2 -2
  73. package/lib/parser/list.js +15 -19
  74. package/lib/parser/literal.d.ts +2 -2
  75. package/lib/parser/literal.js +5 -9
  76. package/lib/parser/long.d.ts +4 -4
  77. package/lib/parser/long.js +10 -14
  78. package/lib/parser/record.d.ts +3 -3
  79. package/lib/parser/record.js +20 -24
  80. package/lib/parser/resourceLocation.d.ts +2 -2
  81. package/lib/parser/resourceLocation.js +14 -18
  82. package/lib/parser/string.d.ts +7 -7
  83. package/lib/parser/string.js +40 -44
  84. package/lib/parser/symbol.d.ts +3 -3
  85. package/lib/parser/symbol.js +3 -7
  86. package/lib/parser/util.d.ts +30 -12
  87. package/lib/parser/util.js +78 -63
  88. package/lib/processor/ColorInfoProvider.d.ts +1 -1
  89. package/lib/processor/ColorInfoProvider.js +6 -9
  90. package/lib/processor/InlayHintProvider.d.ts +2 -2
  91. package/lib/processor/InlayHintProvider.js +1 -2
  92. package/lib/processor/SignatureHelpProvider.d.ts +2 -2
  93. package/lib/processor/SignatureHelpProvider.js +1 -2
  94. package/lib/processor/checker/Checker.d.ts +2 -2
  95. package/lib/processor/checker/Checker.js +1 -5
  96. package/lib/processor/checker/builtin.d.ts +5 -4
  97. package/lib/processor/checker/builtin.js +26 -28
  98. package/lib/processor/checker/index.d.ts +2 -2
  99. package/lib/processor/checker/index.js +2 -27
  100. package/lib/processor/colorizer/Colorizer.d.ts +4 -4
  101. package/lib/processor/colorizer/Colorizer.js +8 -11
  102. package/lib/processor/colorizer/builtin.d.ts +3 -3
  103. package/lib/processor/colorizer/builtin.js +33 -46
  104. package/lib/processor/colorizer/index.d.ts +2 -2
  105. package/lib/processor/colorizer/index.js +2 -27
  106. package/lib/processor/completer/Completer.d.ts +4 -4
  107. package/lib/processor/completer/Completer.js +14 -33
  108. package/lib/processor/completer/builtin.d.ts +7 -7
  109. package/lib/processor/completer/builtin.js +58 -74
  110. package/lib/processor/completer/index.d.ts +2 -2
  111. package/lib/processor/completer/index.js +2 -27
  112. package/lib/processor/formatter/Formatter.d.ts +2 -2
  113. package/lib/processor/formatter/Formatter.js +2 -7
  114. package/lib/processor/formatter/builtin.d.ts +3 -3
  115. package/lib/processor/formatter/builtin.js +22 -36
  116. package/lib/processor/formatter/index.d.ts +2 -2
  117. package/lib/processor/formatter/index.js +2 -27
  118. package/lib/processor/index.d.ts +9 -9
  119. package/lib/processor/index.js +9 -21
  120. package/lib/processor/linter/Linter.d.ts +2 -2
  121. package/lib/processor/linter/Linter.js +1 -2
  122. package/lib/processor/linter/builtin/undeclaredSymbol.d.ts +2 -2
  123. package/lib/processor/linter/builtin/undeclaredSymbol.js +23 -27
  124. package/lib/processor/linter/builtin.d.ts +3 -3
  125. package/lib/processor/linter/builtin.js +19 -31
  126. package/lib/processor/linter/index.d.ts +2 -2
  127. package/lib/processor/linter/index.js +2 -27
  128. package/lib/processor/util.d.ts +2 -2
  129. package/lib/processor/util.js +4 -9
  130. package/lib/service/CacheService.d.ts +6 -6
  131. package/lib/service/CacheService.js +38 -48
  132. package/lib/service/Config.d.ts +17 -16
  133. package/lib/service/Config.js +56 -51
  134. package/lib/service/Context.d.ts +14 -14
  135. package/lib/service/Context.js +30 -32
  136. package/lib/service/Dependency.js +2 -5
  137. package/lib/service/Downloader.d.ts +10 -39
  138. package/lib/service/Downloader.js +37 -106
  139. package/lib/service/ErrorReporter.d.ts +2 -2
  140. package/lib/service/ErrorReporter.js +11 -15
  141. package/lib/service/FileService.d.ts +41 -14
  142. package/lib/service/FileService.js +107 -81
  143. package/lib/service/Hover.d.ts +2 -2
  144. package/lib/service/Hover.js +4 -7
  145. package/lib/service/Logger.js +2 -5
  146. package/lib/service/MetaRegistry.d.ts +12 -12
  147. package/lib/service/MetaRegistry.js +62 -73
  148. package/lib/service/Operations.js +3 -9
  149. package/lib/service/Profiler.d.ts +1 -1
  150. package/lib/service/Profiler.js +25 -41
  151. package/lib/service/Project.d.ts +50 -51
  152. package/lib/service/Project.js +240 -238
  153. package/lib/service/Service.d.ts +19 -29
  154. package/lib/service/Service.js +57 -53
  155. package/lib/service/SymbolLocations.d.ts +3 -3
  156. package/lib/service/SymbolLocations.js +4 -7
  157. package/lib/service/SymbolRegistrar.d.ts +1 -1
  158. package/lib/service/SymbolRegistrar.js +1 -2
  159. package/lib/service/fileUtil.d.ts +21 -41
  160. package/lib/service/fileUtil.js +59 -129
  161. package/lib/service/index.d.ts +17 -17
  162. package/lib/service/index.js +17 -31
  163. package/lib/source/IndexMap.d.ts +1 -1
  164. package/lib/source/IndexMap.js +7 -10
  165. package/lib/source/LanguageError.d.ts +2 -2
  166. package/lib/source/LanguageError.js +3 -6
  167. package/lib/source/Location.d.ts +3 -3
  168. package/lib/source/Location.js +6 -9
  169. package/lib/source/Offset.d.ts +1 -1
  170. package/lib/source/Offset.js +4 -7
  171. package/lib/source/Position.js +2 -5
  172. package/lib/source/PositionRange.d.ts +2 -2
  173. package/lib/source/PositionRange.js +14 -17
  174. package/lib/source/Range.d.ts +1 -1
  175. package/lib/source/Range.js +7 -10
  176. package/lib/source/Source.d.ts +12 -4
  177. package/lib/source/Source.js +84 -29
  178. package/lib/source/index.d.ts +8 -8
  179. package/lib/source/index.js +8 -20
  180. package/lib/symbol/Symbol.d.ts +15 -15
  181. package/lib/symbol/Symbol.js +53 -68
  182. package/lib/symbol/SymbolUtil.d.ts +23 -33
  183. package/lib/symbol/SymbolUtil.js +162 -163
  184. package/lib/symbol/UriBinder.d.ts +1 -1
  185. package/lib/symbol/UriBinder.js +1 -2
  186. package/lib/symbol/index.d.ts +3 -3
  187. package/lib/symbol/index.js +3 -15
  188. package/package.json +7 -4
  189. package/lib/common/Heap.d.ts +0 -1
  190. package/lib/common/Heap.js +0 -2
  191. package/lib/node/TableNode.d.ts +0 -17
  192. package/lib/node/TableNode.js +0 -11
  193. package/lib/parser/table.d.ts +0 -22
  194. package/lib/parser/table.js +0 -97
  195. package/lib/service/CommandExecutor.d.ts +0 -3
  196. package/lib/service/CommandExecutor.js +0 -7
@@ -1,15 +1,7 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.ConfigService = exports.VanillaConfig = exports.SymbolLinterConfig = exports.LinterConfigValue = exports.LinterSeverity = void 0;
7
- const events_1 = __importDefault(require("events"));
8
- const fs_1 = require("fs");
9
- const rfdc_1 = __importDefault(require("rfdc"));
10
- const common_1 = require("../common");
11
- const symbol_1 = require("../symbol");
12
- var LinterSeverity;
1
+ import rfdc from 'rfdc';
2
+ import { Arrayable, bufferToString, TypePredicates } from '../common/index.js';
3
+ import { FileCategories, RegistryCategories } from '../symbol/index.js';
4
+ export var LinterSeverity;
13
5
  (function (LinterSeverity) {
14
6
  function is(value) {
15
7
  return value === 'hint' ||
@@ -21,18 +13,18 @@ var LinterSeverity;
21
13
  function toErrorSeverity(value) {
22
14
  switch (value) {
23
15
  case 'error':
24
- return 3 /* Error */;
16
+ return 3 /* ErrorSeverity.Error */;
25
17
  case 'hint':
26
- return 0 /* Hint */;
18
+ return 0 /* ErrorSeverity.Hint */;
27
19
  case 'information':
28
- return 1 /* Information */;
20
+ return 1 /* ErrorSeverity.Information */;
29
21
  case 'warning':
30
- return 2 /* Warning */;
22
+ return 2 /* ErrorSeverity.Warning */;
31
23
  }
32
24
  }
33
25
  LinterSeverity.toErrorSeverity = toErrorSeverity;
34
- })(LinterSeverity = exports.LinterSeverity || (exports.LinterSeverity = {}));
35
- var LinterConfigValue;
26
+ })(LinterSeverity || (LinterSeverity = {}));
27
+ export var LinterConfigValue;
36
28
  (function (LinterConfigValue) {
37
29
  function destruct(value) {
38
30
  if (value === null || value === undefined) {
@@ -51,16 +43,16 @@ var LinterConfigValue;
51
43
  };
52
44
  }
53
45
  return {
54
- ruleSeverity: 2 /* Warning */,
46
+ ruleSeverity: 2 /* ErrorSeverity.Warning */,
55
47
  ruleValue: value,
56
48
  };
57
49
  }
58
50
  LinterConfigValue.destruct = destruct;
59
- })(LinterConfigValue = exports.LinterConfigValue || (exports.LinterConfigValue = {}));
60
- var SymbolLinterConfig;
51
+ })(LinterConfigValue || (LinterConfigValue = {}));
52
+ export var SymbolLinterConfig;
61
53
  (function (SymbolLinterConfig) {
62
54
  function is(value) {
63
- return common_1.Arrayable.is(value, Complex.is) || Action.is(value);
55
+ return Arrayable.is(value, Complex.is) || Action.is(value);
64
56
  }
65
57
  SymbolLinterConfig.is = is;
66
58
  let Complex;
@@ -70,9 +62,9 @@ var SymbolLinterConfig;
70
62
  return false;
71
63
  }
72
64
  const value = v;
73
- return ((value.if === undefined || common_1.Arrayable.is(value.if, Condition.is)) &&
65
+ return ((value.if === undefined || Arrayable.is(value.if, Condition.is)) &&
74
66
  (value.then === undefined || Action.is(value.then)) &&
75
- (value.override === undefined || common_1.Arrayable.is(value.override, Complex.is)));
67
+ (value.override === undefined || Arrayable.is(value.override, Complex.is)));
76
68
  }
77
69
  Complex.is = is;
78
70
  })(Complex = SymbolLinterConfig.Complex || (SymbolLinterConfig.Complex = {}));
@@ -83,11 +75,11 @@ var SymbolLinterConfig;
83
75
  return false;
84
76
  }
85
77
  const value = v;
86
- return ((value.category === undefined || common_1.Arrayable.is(value.category, common_1.TypePredicates.isString)) &&
87
- (value.pattern === undefined || common_1.Arrayable.is(value.pattern, common_1.TypePredicates.isString)) &&
88
- (value.excludePattern === undefined || common_1.Arrayable.is(value.excludePattern, common_1.TypePredicates.isString)) &&
89
- (value.namespace === undefined || common_1.Arrayable.is(value.namespace, common_1.TypePredicates.isString)) &&
90
- (value.excludeNamespace === undefined || common_1.Arrayable.is(value.excludeNamespace, common_1.TypePredicates.isString)));
78
+ return ((value.category === undefined || Arrayable.is(value.category, TypePredicates.isString)) &&
79
+ (value.pattern === undefined || Arrayable.is(value.pattern, TypePredicates.isString)) &&
80
+ (value.excludePattern === undefined || Arrayable.is(value.excludePattern, TypePredicates.isString)) &&
81
+ (value.namespace === undefined || Arrayable.is(value.namespace, TypePredicates.isString)) &&
82
+ (value.excludeNamespace === undefined || Arrayable.is(value.excludeNamespace, TypePredicates.isString)));
91
83
  }
92
84
  Condition.is = is;
93
85
  })(Condition = SymbolLinterConfig.Condition || (SymbolLinterConfig.Condition = {}));
@@ -110,15 +102,15 @@ var SymbolLinterConfig;
110
102
  }
111
103
  Action.is = is;
112
104
  })(Action = SymbolLinterConfig.Action || (SymbolLinterConfig.Action = {}));
113
- })(SymbolLinterConfig = exports.SymbolLinterConfig || (exports.SymbolLinterConfig = {}));
105
+ })(SymbolLinterConfig || (SymbolLinterConfig = {}));
114
106
  /**
115
107
  * Config which simulates the default vanilla command system.
116
108
  */
117
- exports.VanillaConfig = {
109
+ export const VanillaConfig = {
118
110
  env: {
119
111
  dataSource: 'GitHub',
120
112
  dependencies: [
121
- '@mc-nbtdoc',
113
+ '@vanilla-mcdoc',
122
114
  ],
123
115
  feature: {
124
116
  codeActions: true,
@@ -195,8 +187,8 @@ exports.VanillaConfig = {
195
187
  undeclaredSymbol: [
196
188
  {
197
189
  if: [
198
- { category: symbol_1.RegistryCategories, namespace: 'minecraft' },
199
- { category: [...symbol_1.FileCategories, 'bossbar', 'objective', 'team'] },
190
+ { category: RegistryCategories, namespace: 'minecraft' },
191
+ { category: [...FileCategories, 'bossbar', 'objective', 'team'] },
200
192
  ],
201
193
  then: { report: 'warning' },
202
194
  },
@@ -210,10 +202,18 @@ exports.VanillaConfig = {
210
202
  summonAec: 'summon minecraft:area_effect_cloud ~ ~ ~ {Age: -2147483648, Duration: -1, WaitTime: -2147483648, Tags: ["${1:tag}"]}',
211
203
  },
212
204
  };
213
- class ConfigService extends events_1.default {
214
- constructor(project) {
215
- super();
205
+ export class ConfigService {
206
+ project;
207
+ defaultConfig;
208
+ static ConfigFileNames = Object.freeze([
209
+ 'spyglass.json',
210
+ '.spyglassrc.json',
211
+ ]);
212
+ #eventEmitter;
213
+ constructor(project, defaultConfig = VanillaConfig) {
216
214
  this.project = project;
215
+ this.defaultConfig = defaultConfig;
216
+ this.#eventEmitter = new project.externals.event.EventEmitter();
217
217
  const handler = async ({ uri }) => {
218
218
  if (ConfigService.isConfigFile(uri)) {
219
219
  this.emit('changed', { config: await this.load() });
@@ -223,31 +223,41 @@ class ConfigService extends events_1.default {
223
223
  project.on('fileModified', handler);
224
224
  project.on('fileDeleted', handler);
225
225
  }
226
+ on(event, callbackFn) {
227
+ this.#eventEmitter.on(event, callbackFn);
228
+ return this;
229
+ }
230
+ once(event, callbackFn) {
231
+ this.#eventEmitter.once(event, callbackFn);
232
+ return this;
233
+ }
234
+ emit(event, ...args) {
235
+ return this.#eventEmitter.emit(event, ...args);
236
+ }
226
237
  async load() {
227
- let ans = exports.VanillaConfig;
238
+ let ans = this.defaultConfig;
228
239
  for (const name of ConfigService.ConfigFileNames) {
229
- const uriString = this.project.projectRoot + name;
230
- const uri = new common_1.Uri(uriString);
240
+ const uri = this.project.projectRoot + name;
231
241
  try {
232
- ans = JSON.parse((0, common_1.bufferToString)(await fs_1.promises.readFile(uri)));
242
+ ans = JSON.parse(bufferToString(await this.project.externals.fs.readFile(uri)));
233
243
  }
234
244
  catch (e) {
235
- if ((0, common_1.isEnoent)(e)) {
245
+ if (this.project.externals.error.isKind(e, 'ENOENT')) {
236
246
  // File doesn't exist.
237
247
  continue;
238
248
  }
239
- this.emit('error', { error: e, uri: uriString });
249
+ this.emit('error', { error: e, uri });
240
250
  }
241
251
  break;
242
252
  }
243
- return this.merge(exports.VanillaConfig, ans);
253
+ return ConfigService.merge(this.defaultConfig, ans);
244
254
  }
245
255
  static isConfigFile(uri) {
246
256
  return ConfigService.ConfigFileNames.some(n => uri.endsWith(`/${n}`));
247
257
  }
248
- merge(base, ...overrides) {
258
+ static merge(base, ...overrides) {
249
259
  // FIXME
250
- const ans = (0, rfdc_1.default)()(base);
260
+ const ans = rfdc()(base);
251
261
  for (const override of overrides) {
252
262
  for (const key of ['env', 'format', 'lint', 'snippet']) {
253
263
  ans[key] = { ...ans[key], ...override[key] };
@@ -256,9 +266,4 @@ class ConfigService extends events_1.default {
256
266
  return ans;
257
267
  }
258
268
  }
259
- exports.ConfigService = ConfigService;
260
- ConfigService.ConfigFileNames = Object.freeze([
261
- 'spyglass.json',
262
- '.spyglassrc.json',
263
- ]);
264
269
  //# sourceMappingURL=Config.js.map
@@ -1,22 +1,24 @@
1
1
  import type { TextDocument } from 'vscode-languageserver-textdocument';
2
- import type { LinterErrorReporter } from '.';
3
- import type { Range } from '../source';
4
- import { ReadonlySource } from '../source';
5
- import type { SymbolTable, SymbolUtil } from '../symbol';
6
- import type { Config } from './Config';
7
- import { ErrorReporter } from './ErrorReporter';
8
- import type { FileService } from './FileService';
9
- import type { RootUriString } from './fileUtil';
10
- import type { Logger } from './Logger';
11
- import type { MetaRegistry } from './MetaRegistry';
12
- import { Operations } from './Operations';
13
- import type { DocAndNode, ProjectData } from './Project';
2
+ import type { LinterErrorReporter } from './index.js';
3
+ import type { Range } from '../source/index.js';
4
+ import { ReadonlySource } from '../source/index.js';
5
+ import type { SymbolTable, SymbolUtil } from '../symbol/index.js';
6
+ import type { Config } from './Config.js';
7
+ import { ErrorReporter } from './ErrorReporter.js';
8
+ import type { FileService } from './FileService.js';
9
+ import type { RootUriString } from './fileUtil.js';
10
+ import type { Logger } from './Logger.js';
11
+ import type { MetaRegistry } from './MetaRegistry.js';
12
+ import { Operations } from './Operations.js';
13
+ import type { ProfilerFactory } from './Profiler.js';
14
+ import type { DocAndNode, ProjectData } from './Project.js';
14
15
  export interface ContextBase {
15
16
  fs: FileService;
16
17
  getDocAndNode: (uri: string) => DocAndNode | undefined;
17
18
  global: SymbolTable;
18
19
  logger: Logger;
19
20
  meta: MetaRegistry;
21
+ profilers: ProfilerFactory;
20
22
  project: Record<string, string>;
21
23
  roots: readonly RootUriString[];
22
24
  }
@@ -27,7 +29,6 @@ export interface ParserContext extends ContextBase {
27
29
  config: Config;
28
30
  doc: TextDocument;
29
31
  err: ErrorReporter;
30
- /** @deprecated */
31
32
  symbols: SymbolUtil;
32
33
  }
33
34
  interface ParserContextOptions {
@@ -41,7 +42,6 @@ export interface ProcessorContext extends ContextBase {
41
42
  config: Config;
42
43
  doc: TextDocument;
43
44
  src: ReadonlySource;
44
- /** @deprecated */
45
45
  symbols: SymbolUtil;
46
46
  }
47
47
  interface ProcessorContextOptions {
@@ -1,12 +1,9 @@
1
- "use strict";
2
1
  /* istanbul ignore file */
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.UriBinderContext = exports.SignatureHelpProviderContext = exports.CompleterContext = exports.ColorizerContext = exports.FormatterContext = exports.LinterContext = exports.CheckerContext = exports.ProcessorContext = exports.ParserContext = exports.ContextBase = void 0;
5
- const processor_1 = require("../processor");
6
- const source_1 = require("../source");
7
- const ErrorReporter_1 = require("./ErrorReporter");
8
- const Operations_1 = require("./Operations");
9
- var ContextBase;
2
+ import { formatterContextIndentation } from '../processor/index.js';
3
+ import { ReadonlySource } from '../source/index.js';
4
+ import { ErrorReporter } from './ErrorReporter.js';
5
+ import { Operations } from './Operations.js';
6
+ export var ContextBase;
10
7
  (function (ContextBase) {
11
8
  function create(project) {
12
9
  return {
@@ -15,38 +12,39 @@ var ContextBase;
15
12
  global: project.symbols.global,
16
13
  logger: project.logger,
17
14
  meta: project.meta,
15
+ profilers: project.profilers,
18
16
  roots: project.roots,
19
17
  project: project.ctx,
20
18
  };
21
19
  }
22
20
  ContextBase.create = create;
23
- })(ContextBase = exports.ContextBase || (exports.ContextBase = {}));
24
- var ParserContext;
21
+ })(ContextBase || (ContextBase = {}));
22
+ export var ParserContext;
25
23
  (function (ParserContext) {
26
24
  function create(project, opts) {
27
25
  return {
28
26
  ...ContextBase.create(project),
29
27
  config: project.config,
30
28
  doc: opts.doc,
31
- err: opts.err ?? new ErrorReporter_1.ErrorReporter(),
29
+ err: opts.err ?? new ErrorReporter(),
32
30
  symbols: project.symbols,
33
31
  };
34
32
  }
35
33
  ParserContext.create = create;
36
- })(ParserContext = exports.ParserContext || (exports.ParserContext = {}));
37
- var ProcessorContext;
34
+ })(ParserContext || (ParserContext = {}));
35
+ export var ProcessorContext;
38
36
  (function (ProcessorContext) {
39
37
  function create(project, opts) {
40
38
  return {
41
39
  ...ContextBase.create(project),
42
40
  config: project.config,
43
41
  doc: opts.doc,
44
- src: opts.src ?? new source_1.ReadonlySource(opts.doc.getText()),
42
+ src: opts.src ?? new ReadonlySource(opts.doc.getText()),
45
43
  symbols: project.symbols,
46
44
  };
47
45
  }
48
46
  ProcessorContext.create = create;
49
- })(ProcessorContext = exports.ProcessorContext || (exports.ProcessorContext = {}));
47
+ })(ProcessorContext || (ProcessorContext = {}));
50
48
  var ProcessorWithRangeContext;
51
49
  (function (ProcessorWithRangeContext) {
52
50
  function create(project, opts) {
@@ -67,19 +65,19 @@ var ProcessorWithOffsetContext;
67
65
  }
68
66
  ProcessorWithOffsetContext.create = create;
69
67
  })(ProcessorWithOffsetContext || (ProcessorWithOffsetContext = {}));
70
- var CheckerContext;
68
+ export var CheckerContext;
71
69
  (function (CheckerContext) {
72
70
  function create(project, opts) {
73
71
  return {
74
72
  ...ProcessorContext.create(project, opts),
75
- err: opts.err ?? new ErrorReporter_1.ErrorReporter(),
76
- ops: opts.ops ?? new Operations_1.Operations(),
73
+ err: opts.err ?? new ErrorReporter(),
74
+ ops: opts.ops ?? new Operations(),
77
75
  ensureChecked: project.ensureParsedAndChecked?.bind(project),
78
76
  };
79
77
  }
80
78
  CheckerContext.create = create;
81
- })(CheckerContext = exports.CheckerContext || (exports.CheckerContext = {}));
82
- var LinterContext;
79
+ })(CheckerContext || (CheckerContext = {}));
80
+ export var LinterContext;
83
81
  (function (LinterContext) {
84
82
  function create(project, opts) {
85
83
  return {
@@ -90,8 +88,8 @@ var LinterContext;
90
88
  };
91
89
  }
92
90
  LinterContext.create = create;
93
- })(LinterContext = exports.LinterContext || (exports.LinterContext = {}));
94
- var FormatterContext;
91
+ })(LinterContext || (LinterContext = {}));
92
+ export var FormatterContext;
95
93
  (function (FormatterContext) {
96
94
  function create(project, opts) {
97
95
  return {
@@ -99,20 +97,20 @@ var FormatterContext;
99
97
  ...opts,
100
98
  indentLevel: 0,
101
99
  indent(additionalLevels) {
102
- return (0, processor_1.formatterContextIndentation)(this, additionalLevels);
100
+ return formatterContextIndentation(this, additionalLevels);
103
101
  },
104
102
  };
105
103
  }
106
104
  FormatterContext.create = create;
107
- })(FormatterContext = exports.FormatterContext || (exports.FormatterContext = {}));
108
- var ColorizerContext;
105
+ })(FormatterContext || (FormatterContext = {}));
106
+ export var ColorizerContext;
109
107
  (function (ColorizerContext) {
110
108
  function create(project, opts) {
111
109
  return ProcessorWithRangeContext.create(project, opts);
112
110
  }
113
111
  ColorizerContext.create = create;
114
- })(ColorizerContext = exports.ColorizerContext || (exports.ColorizerContext = {}));
115
- var CompleterContext;
112
+ })(ColorizerContext || (ColorizerContext = {}));
113
+ export var CompleterContext;
116
114
  (function (CompleterContext) {
117
115
  function create(project, opts) {
118
116
  return {
@@ -122,15 +120,15 @@ var CompleterContext;
122
120
  };
123
121
  }
124
122
  CompleterContext.create = create;
125
- })(CompleterContext = exports.CompleterContext || (exports.CompleterContext = {}));
126
- var SignatureHelpProviderContext;
123
+ })(CompleterContext || (CompleterContext = {}));
124
+ export var SignatureHelpProviderContext;
127
125
  (function (SignatureHelpProviderContext) {
128
126
  function create(project, opts) {
129
127
  return ProcessorWithOffsetContext.create(project, opts);
130
128
  }
131
129
  SignatureHelpProviderContext.create = create;
132
- })(SignatureHelpProviderContext = exports.SignatureHelpProviderContext || (exports.SignatureHelpProviderContext = {}));
133
- var UriBinderContext;
130
+ })(SignatureHelpProviderContext || (SignatureHelpProviderContext = {}));
131
+ export var UriBinderContext;
134
132
  (function (UriBinderContext) {
135
133
  function create(project) {
136
134
  return {
@@ -139,5 +137,5 @@ var UriBinderContext;
139
137
  };
140
138
  }
141
139
  UriBinderContext.create = create;
142
- })(UriBinderContext = exports.UriBinderContext || (exports.UriBinderContext = {}));
140
+ })(UriBinderContext || (UriBinderContext = {}));
143
141
  //# sourceMappingURL=Context.js.map
@@ -1,11 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DependencyKey = void 0;
4
- var DependencyKey;
1
+ export var DependencyKey;
5
2
  (function (DependencyKey) {
6
3
  function is(value) {
7
4
  return value.startsWith('@');
8
5
  }
9
6
  DependencyKey.is = is;
10
- })(DependencyKey = exports.DependencyKey || (exports.DependencyKey = {}));
7
+ })(DependencyKey || (DependencyKey = {}));
11
8
  //# sourceMappingURL=Dependency.js.map
@@ -1,20 +1,16 @@
1
- /// <reference types="node" />
2
- import type { Logger } from './Logger';
3
- declare type RemoteProtocol = 'http:' | 'https:';
4
- export declare type RemoteUriString = `${RemoteProtocol}${string}`;
5
- export declare namespace RemoteUriString {
6
- function getProtocol(uri: RemoteUriString): RemoteProtocol;
7
- }
1
+ import type { ExternalDownloaderOptions, Externals, RemoteUriString } from '../common/index.js';
2
+ import type { RootUriString } from './fileUtil.js';
3
+ import type { Logger } from './Logger.js';
8
4
  export interface DownloaderDownloadOut {
9
- cachePath?: string;
5
+ cacheUri?: string;
10
6
  checksum?: string;
11
7
  }
12
8
  export declare class Downloader {
13
9
  #private;
14
10
  private readonly cacheRoot;
11
+ private readonly externals;
15
12
  private readonly logger;
16
- private readonly lld;
17
- constructor(cacheRoot: string, logger: Logger, lld?: LowLevelDownloader);
13
+ constructor(cacheRoot: RootUriString, externals: Externals, logger: Logger);
18
14
  download<R>(job: Job<R>, out?: DownloaderDownloadOut): Promise<R | undefined>;
19
15
  }
20
16
  interface Job<R> {
@@ -31,37 +27,12 @@ interface Job<R> {
31
27
  */
32
28
  checksumJob: Omit<Job<string>, 'cache' | 'id'>;
33
29
  checksumExtension: `.${string}`;
34
- serializer?: (data: Buffer) => Buffer;
35
- deserializer?: (cache: Buffer) => Buffer;
30
+ serializer?: (data: Uint8Array) => Uint8Array;
31
+ deserializer?: (cache: Uint8Array) => Uint8Array;
36
32
  };
37
- transformer: (data: Buffer) => PromiseLike<R> | R;
38
- options?: LowLevelDownloadOptions;
33
+ transformer: (data: Uint8Array) => PromiseLike<R> | R;
34
+ options?: ExternalDownloaderOptions;
39
35
  ttl?: number;
40
36
  }
41
- interface LowLevelDownloadOptions {
42
- /**
43
- * Use an string array to set multiple values to the header.
44
- */
45
- headers?: Record<string, string | string[]>;
46
- timeout?: number;
47
- }
48
- export interface LowLevelDownloader {
49
- /**
50
- * @throws
51
- */
52
- get(uri: RemoteUriString, options?: LowLevelDownloadOptions): Promise<Buffer>;
53
- }
54
- export declare namespace LowLevelDownloader {
55
- function create(): LowLevelDownloader;
56
- function mock(options: LowLevelDownloaderMockOptions): LowLevelDownloader;
57
- }
58
- interface LowLevelDownloaderMockOptions {
59
- /**
60
- * A record from URIs to fixture data. The {@link LowLevelDownloader.get} only returns a {@link Buffer},
61
- * therefore `string` fixtures will be turned into a `Buffer` and `object` fixtures will be transformed
62
- * into JSON and then turned into a `Buffer`.
63
- */
64
- fixtures: Record<RemoteUriString, string | Buffer | object>;
65
- }
66
37
  export {};
67
38
  //# sourceMappingURL=Downloader.d.ts.map