@spyglassmc/core 0.4.0 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/lib/common/Dev.js +5 -2
  2. package/lib/common/Operations.js +7 -3
  3. package/lib/common/ReadonlyProxy.d.ts +2 -2
  4. package/lib/common/ReadonlyProxy.js +3 -1
  5. package/lib/common/StateProxy.d.ts +2 -2
  6. package/lib/common/StateProxy.js +18 -7
  7. package/lib/common/externals/BrowserExternals.js +2 -9
  8. package/lib/common/externals/NodeJsExternals.js +11 -18
  9. package/lib/common/externals/downloader.d.ts +2 -2
  10. package/lib/common/externals/index.d.ts +2 -5
  11. package/lib/common/util.d.ts +8 -7
  12. package/lib/common/util.js +16 -12
  13. package/lib/node/AstNode.d.ts +1 -1
  14. package/lib/node/AstNode.js +9 -5
  15. package/lib/node/CommentNode.d.ts +2 -2
  16. package/lib/node/FileNode.js +6 -1
  17. package/lib/node/ResourceLocationNode.d.ts +3 -3
  18. package/lib/node/ResourceLocationNode.js +9 -5
  19. package/lib/node/StringNode.d.ts +3 -3
  20. package/lib/node/StringNode.js +4 -1
  21. package/lib/parser/Parser.d.ts +5 -5
  22. package/lib/parser/boolean.js +1 -1
  23. package/lib/parser/comment.d.ts +1 -1
  24. package/lib/parser/comment.js +1 -1
  25. package/lib/parser/float.d.ts +1 -1
  26. package/lib/parser/float.js +2 -1
  27. package/lib/parser/integer.d.ts +1 -1
  28. package/lib/parser/integer.js +2 -1
  29. package/lib/parser/list.d.ts +1 -1
  30. package/lib/parser/list.js +3 -3
  31. package/lib/parser/long.d.ts +1 -1
  32. package/lib/parser/long.js +2 -1
  33. package/lib/parser/record.d.ts +1 -1
  34. package/lib/parser/record.js +18 -8
  35. package/lib/parser/resourceLocation.js +61 -8
  36. package/lib/parser/string.js +79 -8
  37. package/lib/parser/util.d.ts +7 -7
  38. package/lib/parser/util.js +14 -5
  39. package/lib/processor/ColorInfoProvider.d.ts +3 -3
  40. package/lib/processor/ColorInfoProvider.js +22 -7
  41. package/lib/processor/InlayHintProvider.d.ts +1 -1
  42. package/lib/processor/SignatureHelpProvider.d.ts +1 -1
  43. package/lib/processor/binder/Binder.d.ts +1 -1
  44. package/lib/processor/binder/builtin.d.ts +2 -2
  45. package/lib/processor/binder/builtin.js +30 -18
  46. package/lib/processor/binder/index.d.ts +1 -1
  47. package/lib/processor/binder/index.js +1 -1
  48. package/lib/processor/checker/Checker.d.ts +3 -3
  49. package/lib/processor/checker/builtin.d.ts +2 -3
  50. package/lib/processor/checker/builtin.js +12 -13
  51. package/lib/processor/colorizer/Colorizer.d.ts +3 -3
  52. package/lib/processor/colorizer/builtin.js +8 -7
  53. package/lib/processor/completer/Completer.d.ts +1 -1
  54. package/lib/processor/completer/Completer.js +4 -2
  55. package/lib/processor/completer/builtin.js +33 -26
  56. package/lib/processor/formatter/Formatter.d.ts +1 -1
  57. package/lib/processor/formatter/Formatter.js +3 -1
  58. package/lib/processor/formatter/builtin.js +14 -12
  59. package/lib/processor/linter/Linter.d.ts +1 -1
  60. package/lib/processor/linter/builtin/undeclaredSymbol.js +47 -24
  61. package/lib/processor/linter/builtin.js +7 -8
  62. package/lib/processor/util.d.ts +1 -1
  63. package/lib/service/CacheService.d.ts +1 -1
  64. package/lib/service/CacheService.js +9 -6
  65. package/lib/service/Config.d.ts +11 -11
  66. package/lib/service/Config.js +28 -21
  67. package/lib/service/Dependency.d.ts +3 -3
  68. package/lib/service/Downloader.js +12 -7
  69. package/lib/service/FileService.d.ts +1 -1
  70. package/lib/service/FileService.js +28 -10
  71. package/lib/service/MetaRegistry.js +7 -6
  72. package/lib/service/Profiler.js +10 -5
  73. package/lib/service/Project.d.ts +5 -5
  74. package/lib/service/Project.js +45 -34
  75. package/lib/service/Service.js +31 -12
  76. package/lib/service/SymbolRegistrar.d.ts +1 -1
  77. package/lib/service/UriProcessor.d.ts +3 -3
  78. package/lib/service/fileUtil.d.ts +2 -2
  79. package/lib/service/fileUtil.js +2 -1
  80. package/lib/source/IndexMap.d.ts +1 -1
  81. package/lib/source/IndexMap.js +1 -1
  82. package/lib/source/LanguageError.js +1 -1
  83. package/lib/source/Location.d.ts +1 -1
  84. package/lib/source/Location.js +4 -1
  85. package/lib/source/Offset.d.ts +1 -1
  86. package/lib/source/Range.d.ts +1 -1
  87. package/lib/source/Range.js +6 -3
  88. package/lib/source/Source.d.ts +4 -4
  89. package/lib/source/Source.js +3 -1
  90. package/lib/symbol/Symbol.d.ts +19 -19
  91. package/lib/symbol/Symbol.js +27 -12
  92. package/lib/symbol/SymbolUtil.d.ts +6 -6
  93. package/lib/symbol/SymbolUtil.js +76 -44
  94. package/package.json +2 -2
package/lib/common/Dev.js CHANGED
@@ -26,7 +26,8 @@ export const Dev = Object.freeze({
26
26
  switch (typeof current) {
27
27
  case 'bigint': {
28
28
  const bits = Math.ceil(Math.log2(Number(current)));
29
- ans += (2 + Math.ceil(bits / (ByteToBits * PointerSize))) * PointerSize; // https://stackoverflow.com/a/54298760
29
+ ans += (2 + Math.ceil(bits / (ByteToBits * PointerSize))) *
30
+ PointerSize; // https://stackoverflow.com/a/54298760
30
31
  break;
31
32
  }
32
33
  case 'boolean':
@@ -75,7 +76,9 @@ export const Dev = Object.freeze({
75
76
  catch (ignored) {
76
77
  // Most likely "Maximum callstack size exceeded".
77
78
  // Fall back to a shallow string representation.
78
- return `{ ${Object.entries(value).map(([k, v]) => `'${k}': '${String(v)}'`).join(', ')} }`;
79
+ return `{ ${Object.entries(value)
80
+ .map(([k, v]) => `'${k}': '${String(v)}'`)
81
+ .join(', ')} }`;
79
82
  }
80
83
  }
81
84
  else if (typeof value === 'symbol') {
@@ -15,8 +15,12 @@ export class Operations {
15
15
  }
16
16
  set(obj, key, value, receiver = obj) {
17
17
  const oldValue = Reflect.get(obj, key, receiver);
18
- const op = () => { Reflect.set(obj, key, value, receiver); };
19
- const undoOp = () => { Reflect.set(obj, key, oldValue, receiver); };
18
+ const op = () => {
19
+ Reflect.set(obj, key, value, receiver);
20
+ };
21
+ const undoOp = () => {
22
+ Reflect.set(obj, key, oldValue, receiver);
23
+ };
20
24
  this.addRedoOp(op);
21
25
  this.addUndoOp(undoOp);
22
26
  op();
@@ -27,7 +31,7 @@ export class Operations {
27
31
  }
28
32
  }
29
33
  redo() {
30
- this.redoOps.forEach(op => op());
34
+ this.redoOps.forEach((op) => op());
31
35
  }
32
36
  }
33
37
  //# sourceMappingURL=Operations.js.map
@@ -1,5 +1,5 @@
1
- declare type Wrap<T> = T extends object ? DeepReadonly<T> : T;
2
- export declare type DeepReadonly<T extends object> = {
1
+ type Wrap<T> = T extends object ? DeepReadonly<T> : T;
2
+ export type DeepReadonly<T extends object> = {
3
3
  readonly [K in keyof T]: Wrap<T[K]>;
4
4
  };
5
5
  export declare const ReadonlyProxy: Readonly<{
@@ -9,7 +9,9 @@ class ReadonlyProxyHandler {
9
9
  get(target, p, receiver) {
10
10
  const value = Reflect.get(target, p, receiver);
11
11
  if (p !== 'prototype' && isObject(value)) {
12
- return emplaceMap(this.map, p, { insert: () => ReadonlyProxy.create(value) });
12
+ return emplaceMap(this.map, p, {
13
+ insert: () => ReadonlyProxy.create(value),
14
+ });
13
15
  }
14
16
  return value;
15
17
  }
@@ -3,7 +3,7 @@ declare const Is: unique symbol;
3
3
  declare const Origin: unique symbol;
4
4
  declare const Redo: unique symbol;
5
5
  declare const Undo: unique symbol;
6
- declare type Wrap<T> = T extends object ? StateProxy<T> : T;
6
+ type Wrap<T> = T extends object ? StateProxy<T> : T;
7
7
  /**
8
8
  * A proxy wrapped around an arbitrary object value.
9
9
  * You can access and mutate the value as normal, but you also have the ability to revert all changes ever since the
@@ -12,7 +12,7 @@ declare type Wrap<T> = T extends object ? StateProxy<T> : T;
12
12
  * A new proxy can be branched off of an existing proxy using {@link StateProxy.branchOff} to have finer control
13
13
  * over what changes to be reverted.
14
14
  */
15
- export declare type StateProxy<T extends object> = {
15
+ export type StateProxy<T extends object> = {
16
16
  [K in keyof T]: Wrap<T[K]>;
17
17
  } & {
18
18
  [BranchOff]: () => StateProxy<T>;
@@ -43,20 +43,31 @@ class StateProxyHandler {
43
43
  }
44
44
  get(target, p, receiver) {
45
45
  switch (p) {
46
- case BranchOff: return () => this.#branchOff(target);
47
- case Is: return true;
48
- case Origin: return target;
49
- case Redo: return () => this.rootOps.redo();
50
- case Undo: return () => this.rootOps.undo();
46
+ case BranchOff:
47
+ return () => this.#branchOff(target);
48
+ case Is:
49
+ return true;
50
+ case Origin:
51
+ return target;
52
+ case Redo:
53
+ return () => this.rootOps.redo();
54
+ case Undo:
55
+ return () => this.rootOps.undo();
51
56
  }
52
57
  const value = Reflect.get(target, p, receiver);
53
58
  if (p !== 'prototype' && isObject(value)) {
54
- return emplaceMap(this.map, p, { insert: () => _createStateProxy(value, this.rootOps) });
59
+ return emplaceMap(this.map, p, {
60
+ insert: () => _createStateProxy(value, this.rootOps),
61
+ });
55
62
  }
56
63
  return value;
57
64
  }
58
65
  set(target, p, value, receiver) {
59
- if (p === BranchOff || p === Is || p === Origin || p === Redo || p === Undo) {
66
+ if (p === BranchOff ||
67
+ p === Is ||
68
+ p === Origin ||
69
+ p === Redo ||
70
+ p === Undo) {
60
71
  throw new TypeError(`Cannot set ${String(p)}`);
61
72
  }
62
73
  this.rootOps.set(target, p, StateProxy.dereference(value), receiver);
@@ -1,7 +1,6 @@
1
- import { decode as arrayBufferFromBase64, encode as arrayBufferToBase64 } from 'base64-arraybuffer';
1
+ import { decode as arrayBufferFromBase64, encode as arrayBufferToBase64, } from 'base64-arraybuffer';
2
2
  import pako from 'pako';
3
3
  import { fileUtil } from '../../service/fileUtil.js';
4
- import { Uri } from '../index.js';
5
4
  class BrowserEventEmitter {
6
5
  #listeners = new Map();
7
6
  emit(eventName, ...args) {
@@ -70,8 +69,7 @@ class BrowserFsWatcher {
70
69
  }
71
70
  return this;
72
71
  }
73
- async close() {
74
- }
72
+ async close() { }
75
73
  }
76
74
  class BrowserFileSystem {
77
75
  static LocalStorageKey = 'spyglassmc-browser-fs';
@@ -174,11 +172,6 @@ export const BrowserExternals = {
174
172
  EventEmitter: BrowserEventEmitter,
175
173
  },
176
174
  fs: new BrowserFileSystem(),
177
- uri: {
178
- normalize(uri) {
179
- return new Uri(uri).toString();
180
- },
181
- },
182
175
  };
183
176
  function uint8ArrayToHex(array) {
184
177
  let ans = '';
@@ -26,7 +26,7 @@ class NodeJsExternalDownloader {
26
26
  reject(new Error(`Status code ${res.statusCode}: ${res.statusMessage}`));
27
27
  }
28
28
  else {
29
- resolve(promisifyAsyncIterable(res, chunks => Buffer.concat(chunks)));
29
+ resolve(promisifyAsyncIterable(res, (chunks) => Buffer.concat(chunks)));
30
30
  }
31
31
  });
32
32
  });
@@ -68,10 +68,13 @@ export const NodeJsExternals = {
68
68
  return fsp.chmod(toFsPathLike(location), mode);
69
69
  },
70
70
  async getAllFiles(location) {
71
- return (await globby(toPath(location) + '**/*', { absolute: true, dot: true })).map(uriFromPath);
71
+ return (await globby(toPath(location) + '**/*', {
72
+ absolute: true,
73
+ dot: true,
74
+ })).map(uriFromPath);
72
75
  },
73
76
  async mkdir(location, options) {
74
- return void await fsp.mkdir(toFsPathLike(location), options);
77
+ return void (await fsp.mkdir(toFsPathLike(location), options));
75
78
  },
76
79
  readFile(location) {
77
80
  return fsp.readFile(toFsPathLike(location));
@@ -90,7 +93,7 @@ export const NodeJsExternals = {
90
93
  command = 'xdg-open';
91
94
  break;
92
95
  }
93
- return void await execFile(command, [toPath(location)]);
96
+ return void (await execFile(command, [toPath(location)]));
94
97
  },
95
98
  stat(location) {
96
99
  return fsp.stat(toFsPathLike(location));
@@ -105,16 +108,6 @@ export const NodeJsExternals = {
105
108
  return fsp.writeFile(toFsPathLike(location), data, options);
106
109
  },
107
110
  },
108
- uri: {
109
- normalize(uri) {
110
- if (uri.startsWith('file:')) {
111
- return url.pathToFileURL(url.fileURLToPath(uri)).toString();
112
- }
113
- else {
114
- return new Uri(uri).toString();
115
- }
116
- },
117
- },
118
111
  };
119
112
  Object.freeze(NodeJsExternals);
120
113
  /**
@@ -140,10 +133,10 @@ class ChokidarWatcherWrapper extends EventEmitter {
140
133
  super();
141
134
  this.#watcher = watcher
142
135
  .on('ready', () => this.emit('ready'))
143
- .on('add', path => this.emit('add', uriFromPath(path)))
144
- .on('change', path => this.emit('change', uriFromPath(path)))
145
- .on('unlink', path => this.emit('unlink', uriFromPath(path)))
146
- .on('error', e => this.emit('error', e));
136
+ .on('add', (path) => this.emit('add', uriFromPath(path)))
137
+ .on('change', (path) => this.emit('change', uriFromPath(path)))
138
+ .on('unlink', (path) => this.emit('unlink', uriFromPath(path)))
139
+ .on('error', (e) => this.emit('error', e));
147
140
  }
148
141
  close() {
149
142
  return this.#watcher.close();
@@ -1,5 +1,5 @@
1
- declare type RemoteUriProtocol = 'http:' | 'https:';
2
- export declare type RemoteUriString = `${RemoteUriProtocol}${string}`;
1
+ type RemoteUriProtocol = 'http:' | 'https:';
2
+ export type RemoteUriString = `${RemoteUriProtocol}${string}`;
3
3
  export declare const RemoteUriString: Readonly<{
4
4
  is(value: string): value is `http:${string}` | `https:${string}`;
5
5
  }>;
@@ -23,9 +23,6 @@ export interface Externals {
23
23
  EventEmitter: new () => ExternalEventEmitter;
24
24
  };
25
25
  fs: ExternalFileSystem;
26
- uri: {
27
- normalize: (uri: string) => string;
28
- };
29
26
  }
30
27
  export interface DecompressedFile {
31
28
  data: Uint8Array;
@@ -34,7 +31,7 @@ export interface DecompressedFile {
34
31
  path: string;
35
32
  type: string;
36
33
  }
37
- export declare type ExternalErrorKind = 'EEXIST' | 'EISDIR' | 'ENOENT';
34
+ export type ExternalErrorKind = 'EEXIST' | 'EISDIR' | 'ENOENT';
38
35
  export interface ExternalEventEmitter {
39
36
  emit(eventName: string, ...args: unknown[]): boolean;
40
37
  on(eventName: string, listener: (...args: unknown[]) => unknown): this;
@@ -79,7 +76,7 @@ export interface ExternalFileSystem {
79
76
  /**
80
77
  * A file file URI string or a URI object.
81
78
  */
82
- export declare type FsLocation = string | Uri;
79
+ export type FsLocation = string | Uri;
83
80
  export interface FsWatcher {
84
81
  on(eventName: 'ready', listener: () => unknown): this;
85
82
  once(eventName: 'ready', listener: () => unknown): this;
@@ -9,11 +9,11 @@ export declare const Uri: {
9
9
  createObjectURL(obj: Blob | MediaSource): string;
10
10
  revokeObjectURL(url: string): void;
11
11
  };
12
- export declare type Uri = URL;
12
+ export type Uri = URL;
13
13
  /**
14
14
  * `NodeJS.Timeout` on Node.js and `number` on browser.
15
15
  */
16
- export declare type IntervalId = any;
16
+ export type IntervalId = any;
17
17
  /**
18
18
  * @param getKey A function that takes the actual arguments being passed into the decorated method, and returns anything.
19
19
  * The result of this function will be used as the key to identify the `Promise`. By default the first element in the argument
@@ -35,7 +35,7 @@ export declare const Singleton: MethodDecorator;
35
35
  * Decorated methods will be scheduled to run after `ms` milliseconds. The timer will reset when the method is called again.
36
36
  */
37
37
  export declare function Delay(ms: number, getKey?: (args: any[]) => any): MethodDecorator;
38
- export declare type FullResourceLocation = `${string}:${string}`;
38
+ export type FullResourceLocation = `${string}:${string}`;
39
39
  export interface ResourceLocation {
40
40
  isTag: boolean;
41
41
  namespace: string | undefined;
@@ -63,7 +63,7 @@ export declare namespace ResourceLocation {
63
63
  * Byte order mark is correctly removed.
64
64
  */
65
65
  export declare function bufferToString(buffer: Uint8Array): string;
66
- export declare type Arrayable<T> = T | readonly T[];
66
+ export type Arrayable<T> = T | readonly T[];
67
67
  export declare namespace Arrayable {
68
68
  function is<T>(value: unknown, isT: (value: unknown) => value is T): value is Arrayable<T>;
69
69
  function toArray<T>(value: Arrayable<T>): T[];
@@ -78,7 +78,7 @@ export declare function parseGzippedJson(externals: Externals, buffer: Uint8Arra
78
78
  */
79
79
  export declare function isPojo(value: unknown): value is Record<string, unknown>;
80
80
  export declare function merge<T extends Record<string, any>>(a: T, b: Record<string, any>): T;
81
- export declare type Lazy<T> = T | Lazy.ComplexLazy<T>;
81
+ export type Lazy<T> = T | Lazy.ComplexLazy<T>;
82
82
  export declare namespace Lazy {
83
83
  const LazyDiscriminator: unique symbol;
84
84
  export type UnresolvedLazy<T> = {
@@ -114,18 +114,19 @@ export declare function emplaceMap<K, V>(map: Map<K, V>, key: K, handler: {
114
114
  * @returns If `val` is an non-null object or a callable object (i.e. function).
115
115
  */
116
116
  export declare function isObject(val: unknown): val is object;
117
+ export declare function normalizeUri(uri: string): string;
117
118
  /**
118
119
  * @example
119
120
  * ```ts
120
121
  * function isCommentNode<T extends DeepReadonly<AstNode> | undefined>(node: T): node is IsHelper<AstNode, CommentNode, T>
121
122
  * ```
122
123
  */
123
- export declare type IsHelper<ROOT extends object, TARGET extends ROOT, INPUT extends DeepReadonly<ROOT> | undefined> = INPUT extends DeepReadonly<ROOT> ? INPUT & DeepReadonly<TARGET> : INPUT & TARGET;
124
+ export type IsHelper<ROOT extends object, TARGET extends ROOT, INPUT extends DeepReadonly<ROOT> | undefined> = INPUT extends DeepReadonly<ROOT> ? INPUT & DeepReadonly<TARGET> : INPUT & TARGET;
124
125
  /**
125
126
  * @example
126
127
  * ```ts
127
128
  * function isCommentNode<T extends DeepReadonly<AstNode> | undefined>(node: T): node is NodeIsHelper<CommentNode, T>
128
129
  * ```
129
130
  */
130
- export declare type NodeIsHelper<TARGET extends AstNode, INPUT extends DeepReadonly<AstNode> | undefined> = IsHelper<AstNode, TARGET, INPUT>;
131
+ export type NodeIsHelper<TARGET extends AstNode, INPUT extends DeepReadonly<AstNode> | undefined> = IsHelper<AstNode, TARGET, INPUT>;
131
132
  //# sourceMappingURL=util.d.ts.map
@@ -9,7 +9,7 @@ export const Uri = URL;
9
9
  * This is a decorator for async methods. Decorated methods will return the same `Promise` for
10
10
  * the same key, provided that the previously returned `Promise` is still pending.
11
11
  */
12
- export function SingletonPromise(getKey = args => args[0]) {
12
+ export function SingletonPromise(getKey = (args) => args[0]) {
13
13
  return (_target, _key, descripter) => {
14
14
  const promises = new Map();
15
15
  const decoratedMethod = descripter.value;
@@ -19,8 +19,7 @@ export function SingletonPromise(getKey = args => args[0]) {
19
19
  if (promises.has(key)) {
20
20
  return promises.get(key);
21
21
  }
22
- const ans = decoratedMethod.apply(this, args)
23
- .then(ans => (promises.delete(key), ans), e => (promises.delete(key), Promise.reject(e)));
22
+ const ans = decoratedMethod.apply(this, args).then((ans) => (promises.delete(key), ans), (e) => (promises.delete(key), Promise.reject(e)));
24
23
  promises.set(key, ans);
25
24
  return ans;
26
25
  };
@@ -35,7 +34,7 @@ export const Singleton = (_target, _key, descripter) => {
35
34
  const decoratedMethod = descripter.value;
36
35
  // The `function` syntax is used to preserve `this` context from the decorated method.
37
36
  descripter.value = function (...args) {
38
- return value ??= decoratedMethod.apply(this, args);
37
+ return (value ??= decoratedMethod.apply(this, args));
39
38
  };
40
39
  return descripter;
41
40
  };
@@ -46,7 +45,7 @@ export const Singleton = (_target, _key, descripter) => {
46
45
  *
47
46
  * Decorated methods will be scheduled to run after `ms` milliseconds. The timer will reset when the method is called again.
48
47
  */
49
- export function Delay(ms, getKey = args => args[0]) {
48
+ export function Delay(ms, getKey = (args) => args[0]) {
50
49
  return (_target, _key, descripter) => {
51
50
  const timeouts = new Map();
52
51
  const decoratedMethod = descripter.value;
@@ -109,9 +108,7 @@ export function bufferToString(buffer) {
109
108
  export var Arrayable;
110
109
  (function (Arrayable) {
111
110
  function is(value, isT) {
112
- return Array.isArray(value)
113
- ? value.every(e => isT(e))
114
- : isT(value);
111
+ return Array.isArray(value) ? value.every((e) => isT(e)) : isT(value);
115
112
  }
116
113
  Arrayable.is = is;
117
114
  function toArray(value) {
@@ -178,7 +175,9 @@ export var Lazy;
178
175
  }
179
176
  Lazy.isUnresolved = isUnresolved;
180
177
  function resolve(lazy) {
181
- return isUnresolved(lazy) ? lazy.value = lazy.getter() : lazy;
178
+ return isUnresolved(lazy)
179
+ ? (lazy.value = lazy.getter())
180
+ : lazy;
182
181
  }
183
182
  Lazy.resolve = resolve;
184
183
  })(Lazy || (Lazy = {}));
@@ -195,7 +194,7 @@ export function getStates(category, ids, ctx) {
195
194
  .query(ctx.doc, category, id)
196
195
  .forEachMember((state, stateQuery) => {
197
196
  const values = Object.keys(stateQuery.visibleMembers);
198
- const set = ans[state] ??= new Set();
197
+ const set = (ans[state] ??= new Set());
199
198
  const defaultValue = stateQuery.symbol?.relations?.default;
200
199
  if (defaultValue) {
201
200
  set.add(defaultValue.path[defaultValue.path.length - 1]);
@@ -211,7 +210,7 @@ export const binarySearch = externalBinarySearch;
211
210
  export function isIterable(value) {
212
211
  return !!value[Symbol.iterator];
213
212
  }
214
- //#region ESNext functions polyfill
213
+ // #region ESNext functions polyfill
215
214
  export function atArray(array, index) {
216
215
  return index >= 0 ? array?.[index] : array?.[array.length + index];
217
216
  }
@@ -233,11 +232,16 @@ export function emplaceMap(map, key, handler) {
233
232
  throw new Error(`No key ${key} in map and no insert handler provided`);
234
233
  }
235
234
  }
236
- //#endregion
235
+ // #endregion
237
236
  /**
238
237
  * @returns If `val` is an non-null object or a callable object (i.e. function).
239
238
  */
240
239
  export function isObject(val) {
241
240
  return typeof val === 'function' || (!!val && typeof val === 'object');
242
241
  }
242
+ export function normalizeUri(uri) {
243
+ const obj = new Uri(uri);
244
+ obj.pathname = obj.pathname.replace(/%3A/gi, ':');
245
+ return obj.toString();
246
+ }
243
247
  //# sourceMappingURL=util.js.map
@@ -59,7 +59,7 @@ export declare namespace AstNode {
59
59
  export function getLocalsToLeaves(node: AstNode): Generator<SymbolTable>;
60
60
  export {};
61
61
  }
62
- export declare type Mutable<N> = N extends AstNode ? {
62
+ export type Mutable<N> = N extends AstNode ? {
63
63
  -readonly [K in keyof N]: Mutable<N[K]>;
64
64
  } : N;
65
65
  //# sourceMappingURL=AstNode.d.ts.map
@@ -4,8 +4,10 @@ export var AstNode;
4
4
  (function (AstNode) {
5
5
  /* istanbul ignore next */
6
6
  function is(obj) {
7
- return !!obj && typeof obj === 'object' && typeof obj.type === 'string' &&
8
- Range.is(obj.range);
7
+ return (!!obj &&
8
+ typeof obj === 'object' &&
9
+ typeof obj.type === 'string' &&
10
+ Range.is(obj.range));
9
11
  }
10
12
  AstNode.is = is;
11
13
  function setParents(node) {
@@ -22,7 +24,9 @@ export var AstNode;
22
24
  if (!node.children) {
23
25
  return -1;
24
26
  }
25
- const comparator = typeof needle === 'number' ? Range.compareOffset : Range.compare;
27
+ const comparator = typeof needle === 'number'
28
+ ? Range.compareOffset
29
+ : Range.compare;
26
30
  return binarySearch(node.children, needle, (a, b) => comparator(a.range, b, endInclusive));
27
31
  }
28
32
  AstNode.findChildIndex = findChildIndex;
@@ -61,7 +65,7 @@ export var AstNode;
61
65
  return node.children?.[findLastChildIndex(node, needle, endInclusive)];
62
66
  }
63
67
  AstNode.findLastChild = findLastChild;
64
- function findDeepestChild({ node, needle, endInclusive = false, predicate = () => true }) {
68
+ function findDeepestChild({ node, needle, endInclusive = false, predicate = () => true, }) {
65
69
  let last;
66
70
  let head = Range.contains(node, needle, endInclusive) ? node : undefined;
67
71
  while (head && predicate(head)) {
@@ -71,7 +75,7 @@ export var AstNode;
71
75
  return last;
72
76
  }
73
77
  AstNode.findDeepestChild = findDeepestChild;
74
- function findShallowestChild({ node, needle, endInclusive = false, predicate = () => true }) {
78
+ function findShallowestChild({ node, needle, endInclusive = false, predicate = () => true, }) {
75
79
  let head = Range.contains(node, needle, endInclusive) ? node : undefined;
76
80
  while (head && !predicate(head)) {
77
81
  head = findChild(head, needle, endInclusive);
@@ -1,4 +1,4 @@
1
- import type { DeepReadonly } from '../common/index.js';
1
+ import type { DeepReadonly, NodeIsHelper } from '../common/index.js';
2
2
  import type { AstNode } from './AstNode.js';
3
3
  export interface CommentNode extends AstNode {
4
4
  readonly type: 'comment';
@@ -8,6 +8,6 @@ export interface CommentNode extends AstNode {
8
8
  comment: string;
9
9
  }
10
10
  export declare const CommentNode: Readonly<{
11
- is<T extends DeepReadonly<AstNode> | undefined>(obj: T): obj is import("../common/util.js").IsHelper<AstNode, CommentNode, T>;
11
+ is<T extends DeepReadonly<AstNode> | undefined>(obj: T): obj is NodeIsHelper<CommentNode, T>;
12
12
  }>;
13
13
  //# sourceMappingURL=CommentNode.d.ts.map
@@ -1,7 +1,12 @@
1
1
  export var FileNode;
2
2
  (function (FileNode) {
3
3
  function getErrors(node) {
4
- return [...node.parserErrors, ...node.binderErrors ?? [], ...node.checkerErrors ?? [], ...node.linterErrors ?? []];
4
+ return [
5
+ ...node.parserErrors,
6
+ ...(node.binderErrors ?? []),
7
+ ...(node.checkerErrors ?? []),
8
+ ...(node.linterErrors ?? []),
9
+ ];
5
10
  }
6
11
  FileNode.getErrors = getErrors;
7
12
  })(FileNode || (FileNode = {}));
@@ -3,7 +3,7 @@ import { ResourceLocation } from '../common/index.js';
3
3
  import type { RangeLike } from '../source/index.js';
4
4
  import type { ResourceLocationCategory, SymbolAccessType, SymbolUsageType, TaggableResourceLocationCategory } from '../symbol/index.js';
5
5
  import type { AstNode } from './AstNode.js';
6
- export declare type ResourceLocationOptions = {
6
+ export type ResourceLocationOptions = {
7
7
  accessType?: SymbolAccessType;
8
8
  isPredicate?: boolean;
9
9
  usageType?: SymbolUsageType;
@@ -33,7 +33,7 @@ export interface ResourceLocationNode extends ResourceLocationBaseNode {
33
33
  export declare namespace ResourceLocationNode {
34
34
  function is(obj: AstNode | undefined): obj is ResourceLocationNode;
35
35
  function mock(range: RangeLike, options: ResourceLocationOptions): ResourceLocationNode;
36
- function toString(node: DeepReadonly<ResourceLocationBaseNode>, type?: 'full'): FullResourceLocation;
37
- function toString(node: DeepReadonly<ResourceLocationBaseNode>, type?: 'origin' | 'full' | 'short'): string;
36
+ function toString(node: DeepReadonly<ResourceLocationBaseNode>, type?: 'full', includesTagPrefix?: false): FullResourceLocation;
37
+ function toString(node: DeepReadonly<ResourceLocationBaseNode>, type?: 'origin' | 'full' | 'short', includesTagPrefix?: boolean): string;
38
38
  }
39
39
  //# sourceMappingURL=ResourceLocationNode.d.ts.map
@@ -17,7 +17,7 @@ export var ResourceLocationNode;
17
17
  const DefaultNamespace = ResourceLocation.DefaultNamespace;
18
18
  /* istanbul ignore next */
19
19
  function is(obj) {
20
- return obj?.type === 'resource_location';
20
+ return (obj?.type === 'resource_location');
21
21
  }
22
22
  ResourceLocationNode.is = is;
23
23
  function mock(range, options) {
@@ -28,7 +28,7 @@ export var ResourceLocationNode;
28
28
  };
29
29
  }
30
30
  ResourceLocationNode.mock = mock;
31
- function toString(node, type = 'origin') {
31
+ function toString(node, type = 'origin', includesTagPrefix = false) {
32
32
  const path = node.path ? node.path.join(PathSep) : '';
33
33
  let id;
34
34
  /*
@@ -43,7 +43,9 @@ export var ResourceLocationNode;
43
43
  switch (type) {
44
44
  case 'origin':
45
45
  // Use `node.namespace !== undefined`, so that empty namespaces can be correctly restored to string.
46
- id = node.namespace !== undefined ? `${node.namespace}${NamespacePathSep}${path}` : path;
46
+ id = node.namespace !== undefined
47
+ ? `${node.namespace}${NamespacePathSep}${path}`
48
+ : path;
47
49
  break;
48
50
  case 'full':
49
51
  // Use `node.namespace` before `||`, so that both undefined and empty value can result in the default namespace.
@@ -52,10 +54,12 @@ export var ResourceLocationNode;
52
54
  break;
53
55
  case 'short':
54
56
  // Use `node.namespace` before `&&` for the same reason stated above.
55
- id = node.namespace && node.namespace !== DefaultNamespace ? `${node.namespace}${NamespacePathSep}${path}` : path;
57
+ id = node.namespace && node.namespace !== DefaultNamespace
58
+ ? `${node.namespace}${NamespacePathSep}${path}`
59
+ : path;
56
60
  break;
57
61
  }
58
- return node.isTag ? `${TagPrefix}${id}` : id;
62
+ return includesTagPrefix && node.isTag ? `${TagPrefix}${id}` : id;
59
63
  }
60
64
  ResourceLocationNode.toString = toString;
61
65
  })(ResourceLocationNode || (ResourceLocationNode = {}));
@@ -3,12 +3,12 @@ import type { ColorTokenType } from '../processor/index.js';
3
3
  import type { IndexMap, RangeLike } from '../source/index.js';
4
4
  import type { AstNode } from './AstNode.js';
5
5
  export declare const EscapeChars: readonly ["\"", "'", "\\", "b", "f", "n", "r", "t"];
6
- export declare type EscapeChar = typeof EscapeChars[number];
6
+ export type EscapeChar = (typeof EscapeChars)[number];
7
7
  export declare namespace EscapeChar {
8
8
  function is(expected: EscapeChar[] | undefined, c: string): c is EscapeChar;
9
9
  }
10
10
  export declare const EscapeTable: Map<"\"" | "'" | "b" | "f" | "n" | "r" | "t" | "\\", string>;
11
- export declare type Quote = "'" | '"';
11
+ export type Quote = "'" | '"';
12
12
  export interface StringOptions {
13
13
  colorTokenType?: ColorTokenType;
14
14
  escapable?: {
@@ -47,7 +47,7 @@ export interface StringOptions {
47
47
  type: AstNode['type'];
48
48
  };
49
49
  }
50
- export declare type QuoteTypeConfig = 'always double' | 'always single' | 'prefer double' | 'prefer single';
50
+ export type QuoteTypeConfig = 'always double' | 'always single' | 'prefer double' | 'prefer single';
51
51
  export interface StringBaseNode extends AstNode {
52
52
  readonly options: StringOptions;
53
53
  value: string;
@@ -32,7 +32,10 @@ export var StringNode;
32
32
  range,
33
33
  options,
34
34
  value: '',
35
- valueMap: [{ inner: Range.create(0), outer: Range.create(range.start) }],
35
+ valueMap: [{
36
+ inner: Range.create(0),
37
+ outer: Range.create(range.start),
38
+ }],
36
39
  };
37
40
  }
38
41
  StringNode.mock = mock;
@@ -4,13 +4,13 @@ import type { Source } from '../source/index.js';
4
4
  /**
5
5
  * A parser.
6
6
  */
7
- export declare type Parser<N extends Returnable = AstNode> = (this: void, src: Source, ctx: ParserContext) => Result<N>;
7
+ export type Parser<N extends Returnable = AstNode> = (this: void, src: Source, ctx: ParserContext) => Result<N>;
8
8
  /**
9
9
  * A parser that always succeeds.
10
10
  */
11
- export declare type InfallibleParser<N extends Returnable = AstNode> = (this: void, src: Source, ctx: ParserContext) => Success<N>;
12
- export declare type Result<T extends Returnable> = Success<T> | typeof Failure;
13
- export declare type Success<T extends Returnable> = T;
11
+ export type InfallibleParser<N extends Returnable = AstNode> = (this: void, src: Source, ctx: ParserContext) => Success<N>;
12
+ export type Result<T extends Returnable> = Success<T> | typeof Failure;
13
+ export type Success<T extends Returnable> = T;
14
14
  export declare const Failure: unique symbol;
15
- export declare type Returnable = object | string | number | bigint | boolean | undefined;
15
+ export type Returnable = object | string | number | bigint | boolean | undefined;
16
16
  //# sourceMappingURL=Parser.d.ts.map
@@ -1,6 +1,6 @@
1
1
  import { literal } from './literal.js';
2
2
  import { map } from './util.js';
3
- export const boolean = map(literal('false', 'true'), res => ({
3
+ export const boolean = map(literal('false', 'true'), (res) => ({
4
4
  type: 'boolean',
5
5
  range: res.range,
6
6
  value: res.value === '' ? undefined : res.value === 'true',
@@ -7,6 +7,6 @@ interface Options {
7
7
  /**
8
8
  * `Failure` when three isn't a comment.
9
9
  */
10
- export declare function comment({ singleLinePrefixes, includesEol }: Options): Parser<CommentNode>;
10
+ export declare function comment({ singleLinePrefixes, includesEol, }: Options): Parser<CommentNode>;
11
11
  export {};
12
12
  //# sourceMappingURL=comment.d.ts.map
@@ -3,7 +3,7 @@ import { Failure } from './Parser.js';
3
3
  /**
4
4
  * `Failure` when three isn't a comment.
5
5
  */
6
- export function comment({ singleLinePrefixes, includesEol }) {
6
+ export function comment({ singleLinePrefixes, includesEol, }) {
7
7
  return (src, _ctx) => {
8
8
  const start = src.cursor;
9
9
  const ans = {