@spyglassmc/core 0.1.2 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (205) 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.js +4 -10
  15. package/lib/common/externals/BrowserExternals.d.ts +3 -0
  16. package/lib/common/externals/BrowserExternals.js +191 -0
  17. package/lib/common/externals/NodeJsExternals.d.ts +3 -0
  18. package/lib/common/externals/NodeJsExternals.js +152 -0
  19. package/lib/common/externals/downloader.d.ts +31 -0
  20. package/lib/common/externals/downloader.js +32 -0
  21. package/lib/common/externals/index.d.ts +96 -0
  22. package/lib/common/externals/index.js +2 -0
  23. package/lib/common/index.d.ts +8 -1
  24. package/lib/common/index.js +8 -17
  25. package/lib/common/util.d.ts +48 -20
  26. package/lib/common/util.js +71 -86
  27. package/lib/index.d.ts +7 -7
  28. package/lib/index.js +7 -23
  29. package/lib/node/AstNode.d.ts +12 -11
  30. package/lib/node/AstNode.js +10 -16
  31. package/lib/node/BooleanNode.d.ts +2 -2
  32. package/lib/node/BooleanNode.js +4 -7
  33. package/lib/node/CommentNode.d.ts +6 -5
  34. package/lib/node/CommentNode.js +4 -9
  35. package/lib/node/ErrorNode.d.ts +1 -1
  36. package/lib/node/ErrorNode.js +2 -5
  37. package/lib/node/FileNode.d.ts +8 -4
  38. package/lib/node/FileNode.js +3 -6
  39. package/lib/node/FloatNode.d.ts +3 -3
  40. package/lib/node/FloatNode.js +4 -7
  41. package/lib/node/IntegerNode.d.ts +3 -3
  42. package/lib/node/IntegerNode.js +4 -7
  43. package/lib/node/ListNode.d.ts +2 -2
  44. package/lib/node/ListNode.js +2 -5
  45. package/lib/node/LiteralNode.d.ts +4 -4
  46. package/lib/node/LiteralNode.js +4 -7
  47. package/lib/node/LongNode.d.ts +3 -3
  48. package/lib/node/LongNode.js +4 -7
  49. package/lib/node/RecordNode.d.ts +2 -2
  50. package/lib/node/RecordNode.js +2 -5
  51. package/lib/node/ResourceLocationNode.d.ts +7 -7
  52. package/lib/node/ResourceLocationNode.js +9 -12
  53. package/lib/node/Sequence.d.ts +2 -2
  54. package/lib/node/Sequence.js +4 -7
  55. package/lib/node/StringNode.d.ts +5 -5
  56. package/lib/node/StringNode.js +9 -12
  57. package/lib/node/SymbolNode.d.ts +4 -4
  58. package/lib/node/SymbolNode.js +4 -7
  59. package/lib/node/index.d.ts +15 -15
  60. package/lib/node/index.js +15 -31
  61. package/lib/nodejs.d.ts +2 -0
  62. package/lib/nodejs.js +2 -0
  63. package/lib/parser/Parser.d.ts +3 -3
  64. package/lib/parser/Parser.js +1 -4
  65. package/lib/parser/boolean.d.ts +2 -2
  66. package/lib/parser/boolean.js +3 -6
  67. package/lib/parser/comment.d.ts +2 -2
  68. package/lib/parser/comment.js +5 -9
  69. package/lib/parser/empty.d.ts +1 -1
  70. package/lib/parser/empty.js +1 -5
  71. package/lib/parser/error.d.ts +2 -2
  72. package/lib/parser/error.js +5 -9
  73. package/lib/parser/file.d.ts +3 -3
  74. package/lib/parser/file.js +9 -13
  75. package/lib/parser/float.d.ts +4 -4
  76. package/lib/parser/float.js +12 -16
  77. package/lib/parser/index.d.ts +16 -16
  78. package/lib/parser/index.js +16 -38
  79. package/lib/parser/integer.d.ts +4 -4
  80. package/lib/parser/integer.js +10 -14
  81. package/lib/parser/list.d.ts +2 -2
  82. package/lib/parser/list.js +15 -19
  83. package/lib/parser/literal.d.ts +2 -2
  84. package/lib/parser/literal.js +5 -9
  85. package/lib/parser/long.d.ts +4 -4
  86. package/lib/parser/long.js +10 -14
  87. package/lib/parser/record.d.ts +3 -3
  88. package/lib/parser/record.js +20 -24
  89. package/lib/parser/resourceLocation.d.ts +2 -2
  90. package/lib/parser/resourceLocation.js +12 -24
  91. package/lib/parser/string.d.ts +7 -7
  92. package/lib/parser/string.js +36 -42
  93. package/lib/parser/symbol.d.ts +3 -3
  94. package/lib/parser/symbol.js +4 -14
  95. package/lib/parser/util.d.ts +6 -5
  96. package/lib/parser/util.js +40 -60
  97. package/lib/processor/ColorInfoProvider.d.ts +1 -1
  98. package/lib/processor/ColorInfoProvider.js +6 -9
  99. package/lib/processor/InlayHintProvider.d.ts +4 -3
  100. package/lib/processor/InlayHintProvider.js +1 -2
  101. package/lib/processor/SignatureHelpProvider.d.ts +4 -3
  102. package/lib/processor/SignatureHelpProvider.js +1 -2
  103. package/lib/processor/binder/Binder.d.ts +26 -0
  104. package/lib/processor/binder/Binder.js +18 -0
  105. package/lib/processor/binder/builtin.d.ts +27 -0
  106. package/lib/processor/binder/builtin.js +116 -0
  107. package/lib/processor/binder/index.d.ts +3 -0
  108. package/lib/processor/binder/index.js +3 -0
  109. package/lib/processor/checker/Checker.d.ts +2 -2
  110. package/lib/processor/checker/Checker.js +1 -5
  111. package/lib/processor/checker/builtin.d.ts +4 -4
  112. package/lib/processor/checker/builtin.js +22 -33
  113. package/lib/processor/checker/index.d.ts +2 -2
  114. package/lib/processor/checker/index.js +2 -31
  115. package/lib/processor/colorizer/Colorizer.d.ts +6 -5
  116. package/lib/processor/colorizer/Colorizer.js +8 -11
  117. package/lib/processor/colorizer/builtin.d.ts +3 -3
  118. package/lib/processor/colorizer/builtin.js +34 -46
  119. package/lib/processor/colorizer/index.d.ts +2 -2
  120. package/lib/processor/colorizer/index.js +2 -31
  121. package/lib/processor/completer/Completer.d.ts +6 -5
  122. package/lib/processor/completer/Completer.js +14 -33
  123. package/lib/processor/completer/builtin.d.ts +10 -9
  124. package/lib/processor/completer/builtin.js +47 -63
  125. package/lib/processor/completer/index.d.ts +2 -2
  126. package/lib/processor/completer/index.js +2 -31
  127. package/lib/processor/formatter/Formatter.d.ts +4 -3
  128. package/lib/processor/formatter/Formatter.js +2 -7
  129. package/lib/processor/formatter/builtin.d.ts +3 -3
  130. package/lib/processor/formatter/builtin.js +22 -36
  131. package/lib/processor/formatter/index.d.ts +2 -2
  132. package/lib/processor/formatter/index.js +2 -31
  133. package/lib/processor/index.d.ts +10 -9
  134. package/lib/processor/index.js +10 -25
  135. package/lib/processor/linter/Linter.d.ts +4 -3
  136. package/lib/processor/linter/Linter.js +1 -2
  137. package/lib/processor/linter/builtin/undeclaredSymbol.d.ts +2 -2
  138. package/lib/processor/linter/builtin/undeclaredSymbol.js +20 -24
  139. package/lib/processor/linter/builtin.d.ts +4 -3
  140. package/lib/processor/linter/builtin.js +19 -26
  141. package/lib/processor/linter/index.d.ts +2 -2
  142. package/lib/processor/linter/index.js +2 -31
  143. package/lib/processor/util.d.ts +4 -14
  144. package/lib/processor/util.js +1 -16
  145. package/lib/service/CacheService.d.ts +13 -8
  146. package/lib/service/CacheService.js +45 -57
  147. package/lib/service/Config.d.ts +11 -12
  148. package/lib/service/Config.js +50 -45
  149. package/lib/service/Context.d.ts +23 -20
  150. package/lib/service/Context.js +39 -36
  151. package/lib/service/Dependency.js +2 -5
  152. package/lib/service/Downloader.d.ts +9 -40
  153. package/lib/service/Downloader.js +37 -110
  154. package/lib/service/ErrorReporter.d.ts +2 -2
  155. package/lib/service/ErrorReporter.js +10 -14
  156. package/lib/service/FileService.d.ts +15 -14
  157. package/lib/service/FileService.js +55 -92
  158. package/lib/service/Hover.d.ts +2 -2
  159. package/lib/service/Hover.js +4 -7
  160. package/lib/service/MetaRegistry.d.ts +22 -12
  161. package/lib/service/MetaRegistry.js +81 -73
  162. package/lib/service/Profiler.d.ts +3 -2
  163. package/lib/service/Profiler.js +81 -45
  164. package/lib/service/Project.d.ts +105 -76
  165. package/lib/service/Project.js +449 -370
  166. package/lib/service/Service.d.ts +17 -27
  167. package/lib/service/Service.js +37 -43
  168. package/lib/service/SymbolLocations.d.ts +3 -3
  169. package/lib/service/SymbolLocations.js +4 -7
  170. package/lib/service/SymbolRegistrar.d.ts +1 -1
  171. package/lib/service/SymbolRegistrar.js +1 -2
  172. package/lib/service/UriProcessor.d.ts +5 -0
  173. package/lib/service/UriProcessor.js +2 -0
  174. package/lib/service/fileUtil.d.ts +15 -45
  175. package/lib/service/fileUtil.js +38 -143
  176. package/lib/service/index.d.ts +16 -17
  177. package/lib/service/index.js +16 -35
  178. package/lib/source/IndexMap.d.ts +1 -1
  179. package/lib/source/IndexMap.js +7 -10
  180. package/lib/source/LanguageError.d.ts +20 -6
  181. package/lib/source/LanguageError.js +16 -9
  182. package/lib/source/Location.d.ts +3 -3
  183. package/lib/source/Location.js +6 -9
  184. package/lib/source/Offset.d.ts +1 -1
  185. package/lib/source/Offset.js +4 -7
  186. package/lib/source/Position.js +2 -5
  187. package/lib/source/PositionRange.d.ts +3 -3
  188. package/lib/source/PositionRange.js +17 -20
  189. package/lib/source/Range.d.ts +1 -1
  190. package/lib/source/Range.js +7 -10
  191. package/lib/source/Source.d.ts +5 -3
  192. package/lib/source/Source.js +34 -29
  193. package/lib/source/index.d.ts +8 -8
  194. package/lib/source/index.js +8 -24
  195. package/lib/symbol/Symbol.d.ts +5 -4
  196. package/lib/symbol/Symbol.js +49 -65
  197. package/lib/symbol/SymbolUtil.d.ts +29 -31
  198. package/lib/symbol/SymbolUtil.js +178 -157
  199. package/lib/symbol/index.d.ts +2 -3
  200. package/lib/symbol/index.js +2 -19
  201. package/package.json +7 -4
  202. package/lib/service/Operations.d.ts +0 -8
  203. package/lib/service/Operations.js +0 -26
  204. package/lib/symbol/UriBinder.d.ts +0 -3
  205. package/lib/symbol/UriBinder.js +0 -3
@@ -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' ||
@@ -31,8 +23,8 @@ var LinterSeverity;
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) {
@@ -56,11 +48,11 @@ var LinterConfigValue;
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,11 +102,11 @@ 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: [
@@ -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,21 +1,18 @@
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 { ProfilerFactory } from './Profiler';
14
- import type { DocAndNode, ProjectData } from './Project';
2
+ import type { Logger } from '../common/index.js';
3
+ import type { Range } from '../source/index.js';
4
+ import { ReadonlySource } from '../source/index.js';
5
+ import type { 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 { LinterErrorReporter } from './index.js';
11
+ import type { MetaRegistry } from './MetaRegistry.js';
12
+ import type { ProfilerFactory } from './Profiler.js';
13
+ import type { ProjectData } from './Project.js';
15
14
  export interface ContextBase {
16
15
  fs: FileService;
17
- getDocAndNode: (uri: string) => DocAndNode | undefined;
18
- global: SymbolTable;
19
16
  logger: Logger;
20
17
  meta: MetaRegistry;
21
18
  profilers: ProfilerFactory;
@@ -29,7 +26,6 @@ export interface ParserContext extends ContextBase {
29
26
  config: Config;
30
27
  doc: TextDocument;
31
28
  err: ErrorReporter;
32
- symbols: SymbolUtil;
33
29
  }
34
30
  interface ParserContextOptions {
35
31
  doc: TextDocument;
@@ -69,14 +65,22 @@ interface ProcessorWithOffsetContextOptions extends ProcessorContextOptions {
69
65
  declare namespace ProcessorWithOffsetContext {
70
66
  function create(project: ProjectData, opts: ProcessorWithOffsetContextOptions): ProcessorWithOffsetContext;
71
67
  }
68
+ export interface BinderContext extends ProcessorContext {
69
+ err: ErrorReporter;
70
+ ensureBindingStarted: (this: void, uri: string) => Promise<unknown>;
71
+ }
72
+ interface BinderContextOptions extends ProcessorContextOptions {
73
+ err?: ErrorReporter;
74
+ }
75
+ export declare namespace BinderContext {
76
+ function create(project: ProjectData, opts: BinderContextOptions): BinderContext;
77
+ }
72
78
  export interface CheckerContext extends ProcessorContext {
73
79
  err: ErrorReporter;
74
- ops: Operations;
75
- ensureChecked: (this: void, uri: string) => Promise<unknown>;
80
+ ensureBindingStarted: (this: void, uri: string) => Promise<unknown>;
76
81
  }
77
82
  interface CheckerContextOptions extends ProcessorContextOptions {
78
83
  err?: ErrorReporter;
79
- ops?: Operations;
80
84
  }
81
85
  export declare namespace CheckerContext {
82
86
  function create(project: ProjectData, opts: CheckerContextOptions): CheckerContext;
@@ -133,7 +137,6 @@ export declare namespace SignatureHelpProviderContext {
133
137
  function create(project: ProjectData, opts: SignatureHelpProviderContextOptions): SignatureHelpProviderContext;
134
138
  }
135
139
  export interface UriBinderContext extends ContextBase {
136
- /** @deprecated */
137
140
  symbols: SymbolUtil;
138
141
  }
139
142
  export declare namespace UriBinderContext {
@@ -1,18 +1,12 @@
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
+ export var ContextBase;
10
6
  (function (ContextBase) {
11
7
  function create(project) {
12
8
  return {
13
9
  fs: project.fs,
14
- getDocAndNode: project.get.bind(project),
15
- global: project.symbols.global,
16
10
  logger: project.logger,
17
11
  meta: project.meta,
18
12
  profilers: project.profilers,
@@ -21,33 +15,32 @@ var ContextBase;
21
15
  };
22
16
  }
23
17
  ContextBase.create = create;
24
- })(ContextBase = exports.ContextBase || (exports.ContextBase = {}));
25
- var ParserContext;
18
+ })(ContextBase || (ContextBase = {}));
19
+ export var ParserContext;
26
20
  (function (ParserContext) {
27
21
  function create(project, opts) {
28
22
  return {
29
23
  ...ContextBase.create(project),
30
24
  config: project.config,
31
25
  doc: opts.doc,
32
- err: opts.err ?? new ErrorReporter_1.ErrorReporter(),
33
- symbols: project.symbols,
26
+ err: opts.err ?? new ErrorReporter(),
34
27
  };
35
28
  }
36
29
  ParserContext.create = create;
37
- })(ParserContext = exports.ParserContext || (exports.ParserContext = {}));
38
- var ProcessorContext;
30
+ })(ParserContext || (ParserContext = {}));
31
+ export var ProcessorContext;
39
32
  (function (ProcessorContext) {
40
33
  function create(project, opts) {
41
34
  return {
42
35
  ...ContextBase.create(project),
43
36
  config: project.config,
44
37
  doc: opts.doc,
45
- src: opts.src ?? new source_1.ReadonlySource(opts.doc.getText()),
38
+ src: opts.src ?? new ReadonlySource(opts.doc.getText()),
46
39
  symbols: project.symbols,
47
40
  };
48
41
  }
49
42
  ProcessorContext.create = create;
50
- })(ProcessorContext = exports.ProcessorContext || (exports.ProcessorContext = {}));
43
+ })(ProcessorContext || (ProcessorContext = {}));
51
44
  var ProcessorWithRangeContext;
52
45
  (function (ProcessorWithRangeContext) {
53
46
  function create(project, opts) {
@@ -68,19 +61,29 @@ var ProcessorWithOffsetContext;
68
61
  }
69
62
  ProcessorWithOffsetContext.create = create;
70
63
  })(ProcessorWithOffsetContext || (ProcessorWithOffsetContext = {}));
71
- var CheckerContext;
64
+ export var BinderContext;
65
+ (function (BinderContext) {
66
+ function create(project, opts) {
67
+ return {
68
+ ...ProcessorContext.create(project, opts),
69
+ err: opts.err ?? new ErrorReporter(),
70
+ ensureBindingStarted: project.ensureBindingStarted?.bind(project),
71
+ };
72
+ }
73
+ BinderContext.create = create;
74
+ })(BinderContext || (BinderContext = {}));
75
+ export var CheckerContext;
72
76
  (function (CheckerContext) {
73
77
  function create(project, opts) {
74
78
  return {
75
79
  ...ProcessorContext.create(project, opts),
76
- err: opts.err ?? new ErrorReporter_1.ErrorReporter(),
77
- ops: opts.ops ?? new Operations_1.Operations(),
78
- ensureChecked: project.ensureParsedAndChecked?.bind(project),
80
+ err: opts.err ?? new ErrorReporter(),
81
+ ensureBindingStarted: project.ensureBindingStarted?.bind(project),
79
82
  };
80
83
  }
81
84
  CheckerContext.create = create;
82
- })(CheckerContext = exports.CheckerContext || (exports.CheckerContext = {}));
83
- var LinterContext;
85
+ })(CheckerContext || (CheckerContext = {}));
86
+ export var LinterContext;
84
87
  (function (LinterContext) {
85
88
  function create(project, opts) {
86
89
  return {
@@ -91,8 +94,8 @@ var LinterContext;
91
94
  };
92
95
  }
93
96
  LinterContext.create = create;
94
- })(LinterContext = exports.LinterContext || (exports.LinterContext = {}));
95
- var FormatterContext;
97
+ })(LinterContext || (LinterContext = {}));
98
+ export var FormatterContext;
96
99
  (function (FormatterContext) {
97
100
  function create(project, opts) {
98
101
  return {
@@ -100,20 +103,20 @@ var FormatterContext;
100
103
  ...opts,
101
104
  indentLevel: 0,
102
105
  indent(additionalLevels) {
103
- return (0, processor_1.formatterContextIndentation)(this, additionalLevels);
106
+ return formatterContextIndentation(this, additionalLevels);
104
107
  },
105
108
  };
106
109
  }
107
110
  FormatterContext.create = create;
108
- })(FormatterContext = exports.FormatterContext || (exports.FormatterContext = {}));
109
- var ColorizerContext;
111
+ })(FormatterContext || (FormatterContext = {}));
112
+ export var ColorizerContext;
110
113
  (function (ColorizerContext) {
111
114
  function create(project, opts) {
112
115
  return ProcessorWithRangeContext.create(project, opts);
113
116
  }
114
117
  ColorizerContext.create = create;
115
- })(ColorizerContext = exports.ColorizerContext || (exports.ColorizerContext = {}));
116
- var CompleterContext;
118
+ })(ColorizerContext || (ColorizerContext = {}));
119
+ export var CompleterContext;
117
120
  (function (CompleterContext) {
118
121
  function create(project, opts) {
119
122
  return {
@@ -123,15 +126,15 @@ var CompleterContext;
123
126
  };
124
127
  }
125
128
  CompleterContext.create = create;
126
- })(CompleterContext = exports.CompleterContext || (exports.CompleterContext = {}));
127
- var SignatureHelpProviderContext;
129
+ })(CompleterContext || (CompleterContext = {}));
130
+ export var SignatureHelpProviderContext;
128
131
  (function (SignatureHelpProviderContext) {
129
132
  function create(project, opts) {
130
133
  return ProcessorWithOffsetContext.create(project, opts);
131
134
  }
132
135
  SignatureHelpProviderContext.create = create;
133
- })(SignatureHelpProviderContext = exports.SignatureHelpProviderContext || (exports.SignatureHelpProviderContext = {}));
134
- var UriBinderContext;
136
+ })(SignatureHelpProviderContext || (SignatureHelpProviderContext = {}));
137
+ export var UriBinderContext;
135
138
  (function (UriBinderContext) {
136
139
  function create(project) {
137
140
  return {
@@ -140,5 +143,5 @@ var UriBinderContext;
140
143
  };
141
144
  }
142
145
  UriBinderContext.create = create;
143
- })(UriBinderContext = exports.UriBinderContext || (exports.UriBinderContext = {}));
146
+ })(UriBinderContext || (UriBinderContext = {}));
144
147
  //# 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,21 +1,15 @@
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 is(value: string): value is RemoteUriString;
7
- function getProtocol(uri: RemoteUriString): RemoteProtocol;
8
- }
1
+ import type { ExternalDownloaderOptions, Externals, Logger, RemoteUriString } from '../common/index.js';
2
+ import type { RootUriString } from './fileUtil.js';
9
3
  export interface DownloaderDownloadOut {
10
- cachePath?: string;
4
+ cacheUri?: string;
11
5
  checksum?: string;
12
6
  }
13
7
  export declare class Downloader {
14
8
  #private;
15
9
  private readonly cacheRoot;
10
+ private readonly externals;
16
11
  private readonly logger;
17
- private readonly lld;
18
- constructor(cacheRoot: string, logger: Logger, lld?: LowLevelDownloader);
12
+ constructor(cacheRoot: RootUriString, externals: Externals, logger: Logger);
19
13
  download<R>(job: Job<R>, out?: DownloaderDownloadOut): Promise<R | undefined>;
20
14
  }
21
15
  interface Job<R> {
@@ -32,37 +26,12 @@ interface Job<R> {
32
26
  */
33
27
  checksumJob: Omit<Job<string>, 'cache' | 'id'>;
34
28
  checksumExtension: `.${string}`;
35
- serializer?: (data: Buffer) => Buffer;
36
- deserializer?: (cache: Buffer) => Buffer;
29
+ serializer?: (data: Uint8Array) => Uint8Array;
30
+ deserializer?: (cache: Uint8Array) => Uint8Array;
37
31
  };
38
- transformer: (data: Buffer) => PromiseLike<R> | R;
39
- options?: LowLevelDownloadOptions;
32
+ transformer: (data: Uint8Array) => PromiseLike<R> | R;
33
+ options?: ExternalDownloaderOptions;
40
34
  ttl?: number;
41
35
  }
42
- interface LowLevelDownloadOptions {
43
- /**
44
- * Use an string array to set multiple values to the header.
45
- */
46
- headers?: Record<string, string | string[]>;
47
- timeout?: number;
48
- }
49
- export interface LowLevelDownloader {
50
- /**
51
- * @throws
52
- */
53
- get(uri: RemoteUriString, options?: LowLevelDownloadOptions): Promise<Buffer>;
54
- }
55
- export declare namespace LowLevelDownloader {
56
- function create(): LowLevelDownloader;
57
- function mock(options: LowLevelDownloaderMockOptions): LowLevelDownloader;
58
- }
59
- interface LowLevelDownloaderMockOptions {
60
- /**
61
- * A record from URIs to fixture data. The {@link LowLevelDownloader.get} only returns a {@link Buffer},
62
- * therefore `string` fixtures will be turned into a `Buffer` and `object` fixtures will be transformed
63
- * into JSON and then turned into a `Buffer`.
64
- */
65
- fixtures: Record<RemoteUriString, string | Buffer | object>;
66
- }
67
36
  export {};
68
37
  //# sourceMappingURL=Downloader.d.ts.map