@spyglassmc/core 0.4.39 → 0.4.41
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.
- package/README.md +1 -3
- package/lib/common/TwoWayMap.d.ts +4 -4
- package/lib/common/externals/BrowserExternals.js +2 -2
- package/lib/common/externals/NodeJsExternals.d.ts +25 -30
- package/lib/common/externals/index.d.ts +7 -7
- package/lib/common/util.d.ts +1 -1
- package/lib/parser/float.js +2 -2
- package/lib/parser/integer.js +2 -2
- package/lib/parser/list.js +2 -2
- package/lib/parser/long.js +2 -2
- package/lib/parser/record.js +2 -2
- package/lib/parser/resourceLocation.js +2 -2
- package/lib/processor/binder/builtin.js +2 -1
- package/lib/service/CacheService.js +1 -1
- package/lib/service/Config.d.ts +2 -2
- package/lib/service/Config.js +7 -6
- package/lib/service/Dependency.d.ts +1 -1
- package/lib/service/ErrorReporter.js +2 -2
- package/lib/service/FileService.d.ts +8 -9
- package/lib/service/FileService.js +0 -1
- package/lib/service/Project.d.ts +3 -0
- package/lib/service/Project.js +3 -1
- package/lib/service/Service.d.ts +1 -1
- package/lib/service/fileUtil.d.ts +4 -4
- package/lib/source/LanguageError.d.ts +1 -1
- package/lib/source/LanguageError.js +8 -1
- package/lib/symbol/SymbolUtil.d.ts +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -12,6 +12,4 @@ This package is the core of the Spyglass Project. It defines the structure of a
|
|
|
12
12
|
## Exports
|
|
13
13
|
|
|
14
14
|
* `@spyglassmc/core`: Contains all core functionalities.
|
|
15
|
-
* `@spyglassmc/core/
|
|
16
|
-
* `@spyglassmc/core/lib/nodejs.js`: Contains Node.js-specific features.
|
|
17
|
-
* `@spyglassmc/core/test-out/utils.js`: For internal development use only. Does not exist in the package published to npm.
|
|
15
|
+
* `@spyglassmc/core/test/utils.ts`: For internal development use only. Does not exist in the package published to npm.
|
|
@@ -12,10 +12,10 @@ export declare class TwoWayMap<K, V> implements Map<K, V> {
|
|
|
12
12
|
hasValue(value: V): boolean;
|
|
13
13
|
set(key: K, value: V): this;
|
|
14
14
|
forEach(callbackfn: (value: V, key: K, map: TwoWayMap<K, V>) => void, thisArg?: any): void;
|
|
15
|
-
entries():
|
|
16
|
-
keys():
|
|
17
|
-
values():
|
|
18
|
-
[Symbol.iterator]():
|
|
15
|
+
entries(): MapIterator<[K, V]>;
|
|
16
|
+
keys(): MapIterator<K>;
|
|
17
|
+
values(): MapIterator<V>;
|
|
18
|
+
[Symbol.iterator](): MapIterator<[K, V]>;
|
|
19
19
|
[Symbol.toStringTag]: string;
|
|
20
20
|
}
|
|
21
21
|
//# sourceMappingURL=TwoWayMap.d.ts.map
|
|
@@ -113,7 +113,7 @@ class BrowserFileSystem {
|
|
|
113
113
|
if (typeof data === 'string') {
|
|
114
114
|
data = new TextEncoder().encode(data);
|
|
115
115
|
}
|
|
116
|
-
data = arrayBufferToBase64(data);
|
|
116
|
+
data = arrayBufferToBase64(data.buffer);
|
|
117
117
|
this.states[location] = { type: 'file', content: data };
|
|
118
118
|
this.saveStates();
|
|
119
119
|
}
|
|
@@ -135,7 +135,7 @@ export const BrowserExternals = {
|
|
|
135
135
|
if (typeof data === 'string') {
|
|
136
136
|
data = new TextEncoder().encode(data);
|
|
137
137
|
}
|
|
138
|
-
const hash = await crypto.subtle.digest('SHA-1', data);
|
|
138
|
+
const hash = await crypto.subtle.digest('SHA-1', data.buffer);
|
|
139
139
|
return uint8ArrayToHex(new Uint8Array(hash));
|
|
140
140
|
},
|
|
141
141
|
},
|
|
@@ -1,25 +1,20 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
/// <reference types="node" />
|
|
4
1
|
import chokidar from 'chokidar';
|
|
5
|
-
import decompress from 'decompress';
|
|
6
|
-
import { Buffer } from 'node:buffer';
|
|
7
2
|
import { EventEmitter } from 'node:events';
|
|
8
3
|
import fs from 'node:fs';
|
|
9
|
-
import type { RootUriString } from '../../index.js';
|
|
4
|
+
import type { DecompressedFile, RootUriString } from '../../index.js';
|
|
10
5
|
import type { FsLocation, FsWatcher } from './index.js';
|
|
11
6
|
export declare function getNodeJsExternals({ cacheRoot }?: {
|
|
12
7
|
cacheRoot?: RootUriString;
|
|
13
8
|
}): Readonly<{
|
|
14
9
|
archive: {
|
|
15
|
-
decompressBall(buffer: Uint8Array
|
|
16
|
-
stripLevel?: number
|
|
17
|
-
} | undefined): Promise<
|
|
18
|
-
gunzip(buffer: Uint8Array): Promise<
|
|
19
|
-
gzip(buffer: Uint8Array): Promise<
|
|
10
|
+
decompressBall(buffer: Uint8Array<ArrayBuffer>, options: {
|
|
11
|
+
stripLevel?: number;
|
|
12
|
+
} | undefined): Promise<DecompressedFile[]>;
|
|
13
|
+
gunzip(buffer: Uint8Array<ArrayBuffer>): Promise<NonSharedBuffer>;
|
|
14
|
+
gzip(buffer: Uint8Array<ArrayBuffer>): Promise<NonSharedBuffer>;
|
|
20
15
|
};
|
|
21
16
|
crypto: {
|
|
22
|
-
getSha1(data: string | Uint8Array): Promise<string>;
|
|
17
|
+
getSha1(data: string | Uint8Array<ArrayBuffer>): Promise<string>;
|
|
23
18
|
};
|
|
24
19
|
error: {
|
|
25
20
|
createKind(kind: import("./index.js").ExternalErrorKind, message: string): Error;
|
|
@@ -31,18 +26,18 @@ export declare function getNodeJsExternals({ cacheRoot }?: {
|
|
|
31
26
|
fs: {
|
|
32
27
|
chmod(location: FsLocation, mode: number): Promise<void>;
|
|
33
28
|
mkdir(location: FsLocation, options: {
|
|
34
|
-
mode?: number
|
|
35
|
-
recursive?: boolean
|
|
29
|
+
mode?: number;
|
|
30
|
+
recursive?: boolean;
|
|
36
31
|
} | undefined): Promise<undefined>;
|
|
37
|
-
readdir(location: FsLocation): Promise<fs.Dirent[]>;
|
|
38
|
-
readFile(location: FsLocation): Promise<
|
|
32
|
+
readdir(location: FsLocation): Promise<fs.Dirent<string>[]>;
|
|
33
|
+
readFile(location: FsLocation): Promise<NonSharedBuffer>;
|
|
39
34
|
showFile(location: FsLocation): Promise<void>;
|
|
40
35
|
stat(location: FsLocation): Promise<fs.Stats>;
|
|
41
36
|
unlink(location: FsLocation): Promise<void>;
|
|
42
37
|
watch(locations: FsLocation[], { usePolling }?: {
|
|
43
|
-
usePolling?: boolean
|
|
38
|
+
usePolling?: boolean;
|
|
44
39
|
}): ChokidarWatcherWrapper;
|
|
45
|
-
writeFile(location: FsLocation, data: string | Uint8Array
|
|
40
|
+
writeFile(location: FsLocation, data: string | Uint8Array<ArrayBuffer>, options: {
|
|
46
41
|
mode: number;
|
|
47
42
|
} | undefined): Promise<void>;
|
|
48
43
|
};
|
|
@@ -53,14 +48,14 @@ export declare function getNodeJsExternals({ cacheRoot }?: {
|
|
|
53
48
|
}>;
|
|
54
49
|
export declare const NodeJsExternals: Readonly<{
|
|
55
50
|
archive: {
|
|
56
|
-
decompressBall(buffer: Uint8Array
|
|
57
|
-
stripLevel?: number
|
|
58
|
-
} | undefined): Promise<
|
|
59
|
-
gunzip(buffer: Uint8Array): Promise<
|
|
60
|
-
gzip(buffer: Uint8Array): Promise<
|
|
51
|
+
decompressBall(buffer: Uint8Array<ArrayBuffer>, options: {
|
|
52
|
+
stripLevel?: number;
|
|
53
|
+
} | undefined): Promise<DecompressedFile[]>;
|
|
54
|
+
gunzip(buffer: Uint8Array<ArrayBuffer>): Promise<NonSharedBuffer>;
|
|
55
|
+
gzip(buffer: Uint8Array<ArrayBuffer>): Promise<NonSharedBuffer>;
|
|
61
56
|
};
|
|
62
57
|
crypto: {
|
|
63
|
-
getSha1(data: string | Uint8Array): Promise<string>;
|
|
58
|
+
getSha1(data: string | Uint8Array<ArrayBuffer>): Promise<string>;
|
|
64
59
|
};
|
|
65
60
|
error: {
|
|
66
61
|
createKind(kind: import("./index.js").ExternalErrorKind, message: string): Error;
|
|
@@ -72,18 +67,18 @@ export declare const NodeJsExternals: Readonly<{
|
|
|
72
67
|
fs: {
|
|
73
68
|
chmod(location: FsLocation, mode: number): Promise<void>;
|
|
74
69
|
mkdir(location: FsLocation, options: {
|
|
75
|
-
mode?: number
|
|
76
|
-
recursive?: boolean
|
|
70
|
+
mode?: number;
|
|
71
|
+
recursive?: boolean;
|
|
77
72
|
} | undefined): Promise<undefined>;
|
|
78
|
-
readdir(location: FsLocation): Promise<fs.Dirent[]>;
|
|
79
|
-
readFile(location: FsLocation): Promise<
|
|
73
|
+
readdir(location: FsLocation): Promise<fs.Dirent<string>[]>;
|
|
74
|
+
readFile(location: FsLocation): Promise<NonSharedBuffer>;
|
|
80
75
|
showFile(location: FsLocation): Promise<void>;
|
|
81
76
|
stat(location: FsLocation): Promise<fs.Stats>;
|
|
82
77
|
unlink(location: FsLocation): Promise<void>;
|
|
83
78
|
watch(locations: FsLocation[], { usePolling }?: {
|
|
84
|
-
usePolling?: boolean
|
|
79
|
+
usePolling?: boolean;
|
|
85
80
|
}): ChokidarWatcherWrapper;
|
|
86
|
-
writeFile(location: FsLocation, data: string | Uint8Array
|
|
81
|
+
writeFile(location: FsLocation, data: string | Uint8Array<ArrayBuffer>, options: {
|
|
87
82
|
mode: number;
|
|
88
83
|
} | undefined): Promise<void>;
|
|
89
84
|
};
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import type { Uri } from '../util.js';
|
|
2
2
|
export interface Externals {
|
|
3
3
|
archive: {
|
|
4
|
-
decompressBall: (buffer: Uint8Array
|
|
4
|
+
decompressBall: (buffer: Uint8Array<ArrayBuffer>, options?: {
|
|
5
5
|
stripLevel?: number;
|
|
6
6
|
}) => Promise<DecompressedFile[]>;
|
|
7
|
-
gzip: (buffer: Uint8Array) => Promise<Uint8Array
|
|
8
|
-
gunzip: (buffer: Uint8Array) => Promise<Uint8Array
|
|
7
|
+
gzip: (buffer: Uint8Array<ArrayBuffer>) => Promise<Uint8Array<ArrayBuffer>>;
|
|
8
|
+
gunzip: (buffer: Uint8Array<ArrayBuffer>) => Promise<Uint8Array<ArrayBuffer>>;
|
|
9
9
|
};
|
|
10
10
|
crypto: {
|
|
11
11
|
/**
|
|
12
12
|
* @returns SHA-1 digest of the given data in hexadecimal format.
|
|
13
13
|
*/
|
|
14
|
-
getSha1: (data: string | Uint8Array) => Promise<string>;
|
|
14
|
+
getSha1: (data: string | Uint8Array<ArrayBuffer>) => Promise<string>;
|
|
15
15
|
};
|
|
16
16
|
error: {
|
|
17
17
|
/**
|
|
@@ -33,7 +33,7 @@ export interface Externals {
|
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
35
|
export interface DecompressedFile {
|
|
36
|
-
data: Uint8Array
|
|
36
|
+
data: Uint8Array<ArrayBuffer>;
|
|
37
37
|
mode: number;
|
|
38
38
|
mtime: string;
|
|
39
39
|
path: string;
|
|
@@ -63,7 +63,7 @@ export interface ExternalFileSystem {
|
|
|
63
63
|
isFile(): boolean;
|
|
64
64
|
isSymbolicLink(): boolean;
|
|
65
65
|
}[]>;
|
|
66
|
-
readFile(location: FsLocation): Promise<Uint8Array
|
|
66
|
+
readFile(location: FsLocation): Promise<Uint8Array<ArrayBuffer>>;
|
|
67
67
|
/**
|
|
68
68
|
* Show the file/directory in the platform-specific explorer program.
|
|
69
69
|
*
|
|
@@ -81,7 +81,7 @@ export interface ExternalFileSystem {
|
|
|
81
81
|
/**
|
|
82
82
|
* @param options `mode` - File mode bit mask (e.g. `0o775`).
|
|
83
83
|
*/
|
|
84
|
-
writeFile(location: FsLocation, data: string | Uint8Array
|
|
84
|
+
writeFile(location: FsLocation, data: string | Uint8Array<ArrayBuffer>, options?: {
|
|
85
85
|
mode: number;
|
|
86
86
|
}): Promise<void>;
|
|
87
87
|
}
|
package/lib/common/util.d.ts
CHANGED
|
@@ -68,7 +68,7 @@ export declare namespace TypePredicates {
|
|
|
68
68
|
function isString(value: unknown): value is string;
|
|
69
69
|
}
|
|
70
70
|
export declare function promisifyAsyncIterable<T, U>(iterable: AsyncIterable<T>, joiner: (chunks: T[]) => U): Promise<U>;
|
|
71
|
-
export declare function parseGzippedJson(externals: Externals, buffer: Uint8Array): Promise<unknown>;
|
|
71
|
+
export declare function parseGzippedJson(externals: Externals, buffer: Uint8Array<ArrayBuffer>): Promise<unknown>;
|
|
72
72
|
/**
|
|
73
73
|
* @returns Is Plain Old JavaScript Object (POJO).
|
|
74
74
|
*/
|
package/lib/parser/float.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { localize } from '@spyglassmc/locales';
|
|
2
|
-
import { Range, Source } from '../source/index.js';
|
|
2
|
+
import { ErrorSeverity, Range, Source } from '../source/index.js';
|
|
3
3
|
import { Failure } from './Parser.js';
|
|
4
4
|
const fallbackOnOutOfRange = (ans, _src, ctx, options) => {
|
|
5
|
-
ctx.err.report(localize('expected', localize('float.between', options.min ?? '-∞', options.max ?? '+∞')), ans,
|
|
5
|
+
ctx.err.report(localize('expected', localize('float.between', options.min ?? '-∞', options.max ?? '+∞')), ans, ErrorSeverity.Error);
|
|
6
6
|
};
|
|
7
7
|
export function float(options) {
|
|
8
8
|
return (src, ctx) => {
|
package/lib/parser/integer.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { localize } from '@spyglassmc/locales';
|
|
2
|
-
import { Range, Source } from '../source/index.js';
|
|
2
|
+
import { ErrorSeverity, Range, Source } from '../source/index.js';
|
|
3
3
|
import { Failure } from './Parser.js';
|
|
4
4
|
const fallbackOnOutOfRange = (ans, _src, ctx, options) => {
|
|
5
|
-
ctx.err.report(localize('expected', localize('integer.between', options.min ?? '-∞', options.max ?? '+∞')), ans,
|
|
5
|
+
ctx.err.report(localize('expected', localize('integer.between', options.min ?? '-∞', options.max ?? '+∞')), ans, ErrorSeverity.Error);
|
|
6
6
|
};
|
|
7
7
|
export function integer(options) {
|
|
8
8
|
return (src, ctx) => {
|
package/lib/parser/list.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { localeQuote, localize } from '@spyglassmc/locales';
|
|
2
|
-
import { Range } from '../source/index.js';
|
|
2
|
+
import { ErrorSeverity, Range } from '../source/index.js';
|
|
3
3
|
import { Failure } from './Parser.js';
|
|
4
4
|
import { attempt } from './util.js';
|
|
5
5
|
export function list({ start, value, sep, trailingSep, end }) {
|
|
@@ -46,7 +46,7 @@ export function list({ start, value, sep, trailingSep, end }) {
|
|
|
46
46
|
// Trailing item sep.
|
|
47
47
|
if (hasValueSep && !trailingSep) {
|
|
48
48
|
const trailingRange = ans.children[ans.children.length - 1].sep;
|
|
49
|
-
ctx.err.report(localize('parser.list.trailing-sep'), trailingRange,
|
|
49
|
+
ctx.err.report(localize('parser.list.trailing-sep'), trailingRange, ErrorSeverity.Error, {
|
|
50
50
|
codeAction: {
|
|
51
51
|
title: localize('code-action.remove-trailing-separation'),
|
|
52
52
|
isPreferred: true,
|
package/lib/parser/long.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { localize } from '@spyglassmc/locales';
|
|
2
|
-
import { Range, Source } from '../source/index.js';
|
|
2
|
+
import { ErrorSeverity, Range, Source } from '../source/index.js';
|
|
3
3
|
import { Failure } from './Parser.js';
|
|
4
4
|
const fallbackOnOutOfRange = (ans, _src, ctx, options) => {
|
|
5
|
-
ctx.err.report(localize('expected', localize('long.between', options.min ?? '-∞', options.max ?? '+∞')), ans,
|
|
5
|
+
ctx.err.report(localize('expected', localize('long.between', options.min ?? '-∞', options.max ?? '+∞')), ans, ErrorSeverity.Error);
|
|
6
6
|
};
|
|
7
7
|
export function long(options) {
|
|
8
8
|
return (src, ctx) => {
|
package/lib/parser/record.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { localeQuote, localize } from '@spyglassmc/locales';
|
|
2
|
-
import { Range } from '../source/index.js';
|
|
2
|
+
import { ErrorSeverity, Range } from '../source/index.js';
|
|
3
3
|
import { Failure } from './Parser.js';
|
|
4
4
|
import { attempt } from './util.js';
|
|
5
5
|
/**
|
|
@@ -82,7 +82,7 @@ export function record({ start, pair, end }) {
|
|
|
82
82
|
// Trailing pair end.
|
|
83
83
|
if (hasPairEnd && !pair.trailingEnd) {
|
|
84
84
|
const trailingRange = ans.children[ans.children.length - 1].end;
|
|
85
|
-
ctx.err.report(localize('parser.record.trailing-end'), trailingRange,
|
|
85
|
+
ctx.err.report(localize('parser.record.trailing-end'), trailingRange, ErrorSeverity.Error, {
|
|
86
86
|
codeAction: {
|
|
87
87
|
title: localize('code-action.remove-trailing-separation'),
|
|
88
88
|
isPreferred: true,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { arrayToMessage, localize } from '@spyglassmc/locales';
|
|
2
2
|
import { ResourceLocation } from '../common/index.js';
|
|
3
|
-
import { Range } from '../source/index.js';
|
|
3
|
+
import { ErrorSeverity, Range } from '../source/index.js';
|
|
4
4
|
const Terminators = new Set([
|
|
5
5
|
' ',
|
|
6
6
|
'\r',
|
|
@@ -104,7 +104,7 @@ export function resourceLocation(options) {
|
|
|
104
104
|
ctx.err.report(localize('parser.resource-location.tag-required'), ans);
|
|
105
105
|
}
|
|
106
106
|
if (!ans.namespace && options.requireCanonical) {
|
|
107
|
-
ctx.err.report(localize('parser.resource-location.namespace-expected'), ans,
|
|
107
|
+
ctx.err.report(localize('parser.resource-location.namespace-expected'), ans, ErrorSeverity.Error, {
|
|
108
108
|
codeAction: {
|
|
109
109
|
title: localize('code-action.add-default-namespace'),
|
|
110
110
|
isPreferred: true,
|
|
@@ -2,6 +2,7 @@ import { localize } from '@spyglassmc/locales';
|
|
|
2
2
|
import { ResourceLocation, StateProxy } from '../../common/index.js';
|
|
3
3
|
import { ResourceLocationNode } from '../../node/index.js';
|
|
4
4
|
import { ErrorReporter } from '../../service/index.js';
|
|
5
|
+
import { ErrorSeverity } from '../../source/index.js';
|
|
5
6
|
import { traversePreOrder } from '../util.js';
|
|
6
7
|
import { AsyncBinder, SyncBinder } from './Binder.js';
|
|
7
8
|
export function attempt(binder, node, ctx) {
|
|
@@ -107,7 +108,7 @@ export const resourceLocation = SyncBinder.create((node, ctx) => {
|
|
|
107
108
|
}
|
|
108
109
|
if (node.options.pool && !node.options.allowUnknown) {
|
|
109
110
|
if (!node.options.pool.includes(sanitizedRaw)) {
|
|
110
|
-
ctx.err.report(localize('expected', node.options.pool), node,
|
|
111
|
+
ctx.err.report(localize('expected', node.options.pool), node, ErrorSeverity.Error);
|
|
111
112
|
}
|
|
112
113
|
return;
|
|
113
114
|
}
|
package/lib/service/Config.d.ts
CHANGED
|
@@ -255,7 +255,7 @@ export declare class ConfigService implements ExternalEventEmitter {
|
|
|
255
255
|
#private;
|
|
256
256
|
private readonly project;
|
|
257
257
|
private readonly defaultConfig;
|
|
258
|
-
static readonly ConfigFileNames: readonly ["spyglass.json", ".spyglassrc.json"];
|
|
258
|
+
static readonly ConfigFileNames: readonly ["spyglass.json", ".spyglassrc", ".spyglassrc.json"];
|
|
259
259
|
constructor(project: Project, defaultConfig?: Config);
|
|
260
260
|
on(event: 'changed', callbackFn: (data: ConfigEvent) => void): this;
|
|
261
261
|
on(event: 'error', callbackFn: (data: ErrorEvent) => void): this;
|
|
@@ -264,7 +264,7 @@ export declare class ConfigService implements ExternalEventEmitter {
|
|
|
264
264
|
emit(event: 'changed', data: ConfigEvent): boolean;
|
|
265
265
|
emit(event: 'error', data: ErrorEvent): boolean;
|
|
266
266
|
load(): Promise<Config>;
|
|
267
|
-
|
|
267
|
+
static isConfigFile(this: void, uri: string): boolean;
|
|
268
268
|
static merge(base: Config, ...overrides: any[]): Config;
|
|
269
269
|
}
|
|
270
270
|
export {};
|
package/lib/service/Config.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import rfdc from 'rfdc';
|
|
2
2
|
import { Arrayable, bufferToString, merge, TypePredicates } from '../common/index.js';
|
|
3
|
+
import { ErrorSeverity } from '../source/index.js';
|
|
3
4
|
import { DataFileCategories, RegistryCategories } from '../symbol/index.js';
|
|
4
5
|
export var LinterSeverity;
|
|
5
6
|
(function (LinterSeverity) {
|
|
@@ -13,13 +14,13 @@ export var LinterSeverity;
|
|
|
13
14
|
function toErrorSeverity(value) {
|
|
14
15
|
switch (value) {
|
|
15
16
|
case 'error':
|
|
16
|
-
return
|
|
17
|
+
return ErrorSeverity.Error;
|
|
17
18
|
case 'hint':
|
|
18
|
-
return
|
|
19
|
+
return ErrorSeverity.Hint;
|
|
19
20
|
case 'information':
|
|
20
|
-
return
|
|
21
|
+
return ErrorSeverity.Information;
|
|
21
22
|
case 'warning':
|
|
22
|
-
return
|
|
23
|
+
return ErrorSeverity.Warning;
|
|
23
24
|
}
|
|
24
25
|
}
|
|
25
26
|
LinterSeverity.toErrorSeverity = toErrorSeverity;
|
|
@@ -36,7 +37,7 @@ export var LinterConfigValue;
|
|
|
36
37
|
if (Array.isArray(value) && LinterSeverity.is(value[0])) {
|
|
37
38
|
return { ruleSeverity: LinterSeverity.toErrorSeverity(value[0]), ruleValue: value[1] };
|
|
38
39
|
}
|
|
39
|
-
return { ruleSeverity:
|
|
40
|
+
return { ruleSeverity: ErrorSeverity.Warning, ruleValue: value };
|
|
40
41
|
}
|
|
41
42
|
LinterConfigValue.destruct = destruct;
|
|
42
43
|
})(LinterConfigValue || (LinterConfigValue = {}));
|
|
@@ -219,7 +220,7 @@ export const VanillaConfig = {
|
|
|
219
220
|
export class ConfigService {
|
|
220
221
|
project;
|
|
221
222
|
defaultConfig;
|
|
222
|
-
static ConfigFileNames = Object.freeze(['spyglass.json', '.spyglassrc.json']);
|
|
223
|
+
static ConfigFileNames = Object.freeze(['spyglass.json', '.spyglassrc', '.spyglassrc.json']);
|
|
223
224
|
#eventEmitter;
|
|
224
225
|
constructor(project, defaultConfig = VanillaConfig) {
|
|
225
226
|
this.project = project;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { localize } from '@spyglassmc/locales';
|
|
2
|
-
import { LanguageError, Range } from '../source/index.js';
|
|
2
|
+
import { ErrorSeverity, LanguageError, Range } from '../source/index.js';
|
|
3
3
|
export class ErrorReporter {
|
|
4
4
|
source;
|
|
5
5
|
errors = [];
|
|
@@ -9,7 +9,7 @@ export class ErrorReporter {
|
|
|
9
9
|
/**
|
|
10
10
|
* Reports a new error.
|
|
11
11
|
*/
|
|
12
|
-
report(message, range, severity =
|
|
12
|
+
report(message, range, severity = ErrorSeverity.Error, info) {
|
|
13
13
|
if (message.trim() === '') {
|
|
14
14
|
throw new Error('Tried to report an error with no message');
|
|
15
15
|
}
|
|
@@ -15,7 +15,7 @@ export interface UriProtocolSupporter {
|
|
|
15
15
|
* @returns The content of the file at `uri`.
|
|
16
16
|
* @throws If the URI doesn't exist in the file system.
|
|
17
17
|
*/
|
|
18
|
-
readFile(uri: string): Promise<Uint8Array
|
|
18
|
+
readFile(uri: string): Promise<Uint8Array<ArrayBuffer>>;
|
|
19
19
|
listFiles(): Iterable<string>;
|
|
20
20
|
/**
|
|
21
21
|
* Each URI in this array must end with a slash (`/`).
|
|
@@ -58,7 +58,7 @@ export declare class FileServiceImpl implements FileService {
|
|
|
58
58
|
* A two-way map from mapped physical URIs to virtual URIs.
|
|
59
59
|
*/
|
|
60
60
|
private readonly map;
|
|
61
|
-
constructor(externals: Externals, virtualUrisRoot?:
|
|
61
|
+
constructor(externals: Externals, virtualUrisRoot?: RootUriString | undefined);
|
|
62
62
|
register(protocol: Protocol, supporter: UriProtocolSupporter, force?: boolean): void;
|
|
63
63
|
unregister(protocol: Protocol): void;
|
|
64
64
|
/**
|
|
@@ -74,9 +74,9 @@ export declare class FileServiceImpl implements FileService {
|
|
|
74
74
|
/**
|
|
75
75
|
* @throws
|
|
76
76
|
*/
|
|
77
|
-
readFile(uri: string): Promise<Uint8Array
|
|
78
|
-
listFiles(): Generator<string, void,
|
|
79
|
-
listRoots(): Generator<`${string}/`, void,
|
|
77
|
+
readFile(uri: string): Promise<Uint8Array<ArrayBuffer>>;
|
|
78
|
+
listFiles(): Generator<string, void, any>;
|
|
79
|
+
listRoots(): Generator<`${string}/`, void, any>;
|
|
80
80
|
mapToDisk(virtualUri: string): Promise<string | undefined>;
|
|
81
81
|
mapFromDisk(mappedUri: string): string;
|
|
82
82
|
}
|
|
@@ -87,8 +87,8 @@ export declare class FileUriSupporter implements UriProtocolSupporter {
|
|
|
87
87
|
readonly protocol = "file:";
|
|
88
88
|
private constructor();
|
|
89
89
|
hash(uri: string): Promise<string>;
|
|
90
|
-
readFile(uri: string): Promise<Uint8Array
|
|
91
|
-
listFiles(): Generator<string, void,
|
|
90
|
+
readFile(uri: string): Promise<Uint8Array<ArrayBuffer>>;
|
|
91
|
+
listFiles(): Generator<string, void, unknown>;
|
|
92
92
|
listRoots(): `${string}/`[];
|
|
93
93
|
mapToDisk(uri: string): Promise<string | undefined>;
|
|
94
94
|
static create(dependencies: readonly Dependency[], externals: Externals, logger: Logger): Promise<FileUriSupporter>;
|
|
@@ -98,14 +98,13 @@ export declare class ArchiveUriSupporter implements UriProtocolSupporter {
|
|
|
98
98
|
private readonly logger;
|
|
99
99
|
private readonly entries;
|
|
100
100
|
static readonly Protocol = "archive:";
|
|
101
|
-
private static readonly SupportedArchiveExtnames;
|
|
102
101
|
readonly protocol = "archive:";
|
|
103
102
|
/**
|
|
104
103
|
* @param entries A map from archive names to unzipped entries.
|
|
105
104
|
*/
|
|
106
105
|
private constructor();
|
|
107
106
|
hash(uri: string): Promise<string>;
|
|
108
|
-
readFile(uri: string): Promise<Uint8Array
|
|
107
|
+
readFile(uri: string): Promise<Uint8Array<ArrayBuffer>>;
|
|
109
108
|
/**
|
|
110
109
|
* @throws
|
|
111
110
|
*/
|
|
@@ -161,7 +161,6 @@ export class ArchiveUriSupporter {
|
|
|
161
161
|
logger;
|
|
162
162
|
entries;
|
|
163
163
|
static Protocol = 'archive:';
|
|
164
|
-
static SupportedArchiveExtnames = ['.tar', '.tar.bz2', '.tar.gz', '.zip'];
|
|
165
164
|
protocol = ArchiveUriSupporter.Protocol;
|
|
166
165
|
/**
|
|
167
166
|
* @param entries A map from archive names to unzipped entries.
|
package/lib/service/Project.d.ts
CHANGED
|
@@ -132,6 +132,7 @@ export declare class Project implements ExternalEventEmitter {
|
|
|
132
132
|
on(event: 'ready', callbackFn: (data: EmptyEvent) => void): this;
|
|
133
133
|
on(event: 'rootsUpdated', callbackFn: (data: RootsEvent) => void): this;
|
|
134
134
|
on(event: 'symbolRegistrarExecuted', callbackFn: (data: SymbolRegistrarEvent) => void): this;
|
|
135
|
+
on(event: 'configChanged', callbackFn: (data: Config) => void): this;
|
|
135
136
|
once(event: 'documentErrored', callbackFn: (data: DocumentErrorEvent) => void): this;
|
|
136
137
|
once(event: 'documentUpdated', callbackFn: (data: DocumentEvent) => void): this;
|
|
137
138
|
once(event: 'documentRemoved', callbackFn: (data: FileEvent) => void): this;
|
|
@@ -139,6 +140,7 @@ export declare class Project implements ExternalEventEmitter {
|
|
|
139
140
|
once(event: 'ready', callbackFn: (data: EmptyEvent) => void): this;
|
|
140
141
|
once(event: 'rootsUpdated', callbackFn: (data: RootsEvent) => void): this;
|
|
141
142
|
once(event: 'symbolRegistrarExecuted', callbackFn: (data: SymbolRegistrarEvent) => void): this;
|
|
143
|
+
once(event: 'configChanged', callbackFn: (data: Config) => void): this;
|
|
142
144
|
emit(event: 'documentErrored', data: DocumentErrorEvent): boolean;
|
|
143
145
|
emit(event: 'documentUpdated', data: DocumentEvent): boolean;
|
|
144
146
|
emit(event: 'documentRemoved', data: FileEvent): boolean;
|
|
@@ -146,6 +148,7 @@ export declare class Project implements ExternalEventEmitter {
|
|
|
146
148
|
emit(event: 'ready', data: EmptyEvent): boolean;
|
|
147
149
|
emit(event: 'rootsUpdated', data: RootsEvent): boolean;
|
|
148
150
|
emit(event: 'symbolRegistrarExecuted', data: SymbolRegistrarEvent): boolean;
|
|
151
|
+
emit(event: 'configChanged', data: Config): boolean;
|
|
149
152
|
/**
|
|
150
153
|
* Get all files that are tracked and supported.
|
|
151
154
|
*
|
package/lib/service/Project.js
CHANGED
|
@@ -173,6 +173,7 @@ export class Project {
|
|
|
173
173
|
this.#configService.on('changed', ({ config }) => {
|
|
174
174
|
this.config = config;
|
|
175
175
|
this.logger.info('[Project] [Config] Changed');
|
|
176
|
+
this.emit('configChanged', config);
|
|
176
177
|
}).on('error', ({ error, uri }) => this.logger.error(`[Project] [Config] Failed loading ${uri}`, error));
|
|
177
178
|
this.setInitPromise();
|
|
178
179
|
this.setReadyPromise();
|
|
@@ -729,7 +730,8 @@ export class Project {
|
|
|
729
730
|
* its file extension.
|
|
730
731
|
*/
|
|
731
732
|
shouldExclude(uri, language) {
|
|
732
|
-
return !this.isSupportedLanguage(uri, language)
|
|
733
|
+
return (!this.isSupportedLanguage(uri, language) && !ConfigService.isConfigFile(uri))
|
|
734
|
+
|| this.isUserExcluded(uri);
|
|
733
735
|
}
|
|
734
736
|
isSupportedLanguage(uri, language) {
|
|
735
737
|
language ??= this.guessLanguageID(uri);
|
package/lib/service/Service.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ export declare class Service {
|
|
|
28
28
|
getCodeActions(node: FileNode<AstNode>, doc: TextDocument, range: Range): readonly CodeAction[];
|
|
29
29
|
getColorInfo(node: FileNode<AstNode>, doc: TextDocument): ColorInfo[];
|
|
30
30
|
getColorPresentation(file: FileNode<AstNode>, doc: TextDocument, range: Range, color: Color): ColorPresentation[];
|
|
31
|
-
complete(node: FileNode<AstNode>, doc: TextDocument, offset: number, triggerCharacter?: string): import("../
|
|
31
|
+
complete(node: FileNode<AstNode>, doc: TextDocument, offset: number, triggerCharacter?: string): import("../index.js").CompletionItem[];
|
|
32
32
|
dataHackPubify(initialism: string): string;
|
|
33
33
|
format(node: FileNode<AstNode>, doc: TextDocument, tabSize: number, insertSpaces: boolean): string;
|
|
34
34
|
getHover(file: FileNode<AstNode>, doc: TextDocument, offset: number): Hover | undefined;
|
|
@@ -72,7 +72,7 @@ export declare namespace fileUtil {
|
|
|
72
72
|
function getAllFiles(externals: Externals, root: FsLocation, depth?: number): Promise<string[]>;
|
|
73
73
|
function markReadOnly(externals: Externals, path: FsLocation): Promise<void>;
|
|
74
74
|
function unlink(externals: Externals, path: FsLocation): Promise<void>;
|
|
75
|
-
function readFile(externals: Externals, path: FsLocation): Promise<Uint8Array
|
|
75
|
+
function readFile(externals: Externals, path: FsLocation): Promise<Uint8Array<ArrayBuffer>>;
|
|
76
76
|
/**
|
|
77
77
|
* @throws
|
|
78
78
|
*
|
|
@@ -85,7 +85,7 @@ export declare namespace fileUtil {
|
|
|
85
85
|
* * Mode: `0o666` (`rw-rw-rw-`)
|
|
86
86
|
* * Flag: `w`
|
|
87
87
|
*/
|
|
88
|
-
function writeFile(externals: Externals, path: FsLocation, data: Uint8Array | string, mode?: number): Promise<void>;
|
|
88
|
+
function writeFile(externals: Externals, path: FsLocation, data: Uint8Array<ArrayBuffer> | string, mode?: number): Promise<void>;
|
|
89
89
|
/**
|
|
90
90
|
* @throws
|
|
91
91
|
*/
|
|
@@ -99,11 +99,11 @@ export declare namespace fileUtil {
|
|
|
99
99
|
/**
|
|
100
100
|
* @throws
|
|
101
101
|
*/
|
|
102
|
-
function readGzippedFile(externals: Externals, path: FsLocation): Promise<Uint8Array
|
|
102
|
+
function readGzippedFile(externals: Externals, path: FsLocation): Promise<Uint8Array<ArrayBuffer>>;
|
|
103
103
|
/**
|
|
104
104
|
* @throws
|
|
105
105
|
*/
|
|
106
|
-
function writeGzippedFile(externals: Externals, path: FsLocation, buffer: Uint8Array | string): Promise<void>;
|
|
106
|
+
function writeGzippedFile(externals: Externals, path: FsLocation, buffer: Uint8Array<ArrayBuffer> | string): Promise<void>;
|
|
107
107
|
/**
|
|
108
108
|
* @throws
|
|
109
109
|
*/
|
|
@@ -24,7 +24,7 @@ export declare namespace LanguageError {
|
|
|
24
24
|
*/
|
|
25
25
|
function withPosRange(error: LanguageError, doc: TextDocument): PosRangeLanguageError;
|
|
26
26
|
}
|
|
27
|
-
export declare
|
|
27
|
+
export declare enum ErrorSeverity {
|
|
28
28
|
Hint = 0,
|
|
29
29
|
Information = 1,
|
|
30
30
|
Warning = 2,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PositionRange } from './PositionRange.js';
|
|
2
2
|
export var LanguageError;
|
|
3
3
|
(function (LanguageError) {
|
|
4
|
-
function create(message, range, severity =
|
|
4
|
+
function create(message, range, severity = ErrorSeverity.Error, info, source) {
|
|
5
5
|
const ans = { range, message, severity };
|
|
6
6
|
if (info) {
|
|
7
7
|
ans.info = info;
|
|
@@ -26,4 +26,11 @@ export var LanguageError;
|
|
|
26
26
|
}
|
|
27
27
|
LanguageError.withPosRange = withPosRange;
|
|
28
28
|
})(LanguageError || (LanguageError = {}));
|
|
29
|
+
export var ErrorSeverity;
|
|
30
|
+
(function (ErrorSeverity) {
|
|
31
|
+
ErrorSeverity[ErrorSeverity["Hint"] = 0] = "Hint";
|
|
32
|
+
ErrorSeverity[ErrorSeverity["Information"] = 1] = "Information";
|
|
33
|
+
ErrorSeverity[ErrorSeverity["Warning"] = 2] = "Warning";
|
|
34
|
+
ErrorSeverity[ErrorSeverity["Error"] = 3] = "Error";
|
|
35
|
+
})(ErrorSeverity || (ErrorSeverity = {}));
|
|
29
36
|
//# sourceMappingURL=LanguageError.js.map
|
|
@@ -206,7 +206,7 @@ export declare class SymbolUtil implements ExternalEventEmitter {
|
|
|
206
206
|
type: SymbolUsageType;
|
|
207
207
|
location: SymbolLocation;
|
|
208
208
|
}) => unknown): void;
|
|
209
|
-
static isVisibilityInGlobal(v: SymbolVisibility | undefined):
|
|
209
|
+
static isVisibilityInGlobal(v: SymbolVisibility | undefined): v is SymbolVisibility.Public | SymbolVisibility.Restricted | undefined;
|
|
210
210
|
static areVisibilitiesCompatible(v1: SymbolVisibility | undefined, v2: SymbolVisibility | undefined): boolean;
|
|
211
211
|
}
|
|
212
212
|
interface SymbolAddition {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spyglassmc/core",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.41",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
},
|
|
12
12
|
"scripts": {
|
|
13
13
|
"release": "npm publish",
|
|
14
|
-
"release:dry": "npm publish --dry-run"
|
|
14
|
+
"release:dry": "npm publish --tag latest --dry-run"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"base64-arraybuffer": "^1.0.2",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"rfdc": "^1.3.0",
|
|
25
25
|
"vscode-languageserver-textdocument": "^1.0.4",
|
|
26
26
|
"whatwg-url": "^14.0.0",
|
|
27
|
-
"@spyglassmc/locales": "0.3.
|
|
27
|
+
"@spyglassmc/locales": "0.3.21"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@types/decompress": "^4.2.3",
|