@spyglassmc/core 0.1.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -0
- package/lib/browser.d.ts +2 -0
- package/lib/browser.js +2 -0
- package/lib/common/Dev.d.ts +11 -0
- package/lib/common/Dev.js +90 -0
- package/lib/{service → common}/Logger.d.ts +0 -0
- package/lib/{service → common}/Logger.js +2 -5
- package/lib/common/Operations.d.ts +12 -0
- package/lib/common/Operations.js +33 -0
- package/lib/common/ReadonlyProxy.d.ts +9 -0
- package/lib/common/ReadonlyProxy.js +23 -0
- package/lib/common/StateProxy.d.ts +35 -0
- package/lib/common/StateProxy.js +69 -0
- package/lib/common/TwoWayMap.d.ts +21 -0
- package/lib/common/TwoWayMap.js +69 -0
- package/lib/common/externals/BrowserExternals.d.ts +3 -0
- package/lib/common/externals/BrowserExternals.js +191 -0
- package/lib/common/externals/NodeJsExternals.d.ts +3 -0
- package/lib/common/externals/NodeJsExternals.js +152 -0
- package/lib/common/externals/downloader.d.ts +31 -0
- package/lib/common/externals/downloader.js +32 -0
- package/lib/common/externals/index.d.ts +96 -0
- package/lib/common/externals/index.js +2 -0
- package/lib/common/index.d.ts +8 -1
- package/lib/common/index.js +8 -13
- package/lib/common/util.d.ts +50 -39
- package/lib/common/util.js +73 -122
- package/lib/index.d.ts +7 -7
- package/lib/index.js +7 -19
- package/lib/node/AstNode.d.ts +12 -11
- package/lib/node/AstNode.js +10 -16
- package/lib/node/BooleanNode.d.ts +2 -2
- package/lib/node/BooleanNode.js +4 -7
- package/lib/node/CommentNode.d.ts +6 -5
- package/lib/node/CommentNode.js +4 -9
- package/lib/node/ErrorNode.d.ts +1 -1
- package/lib/node/ErrorNode.js +2 -5
- package/lib/node/FileNode.d.ts +8 -4
- package/lib/node/FileNode.js +3 -6
- package/lib/node/FloatNode.d.ts +3 -3
- package/lib/node/FloatNode.js +4 -7
- package/lib/node/IntegerNode.d.ts +3 -3
- package/lib/node/IntegerNode.js +4 -7
- package/lib/node/ListNode.d.ts +2 -2
- package/lib/node/ListNode.js +2 -5
- package/lib/node/LiteralNode.d.ts +5 -5
- package/lib/node/LiteralNode.js +5 -8
- package/lib/node/LongNode.d.ts +3 -3
- package/lib/node/LongNode.js +4 -7
- package/lib/node/RecordNode.d.ts +2 -2
- package/lib/node/RecordNode.js +2 -5
- package/lib/node/ResourceLocationNode.d.ts +8 -10
- package/lib/node/ResourceLocationNode.js +9 -12
- package/lib/node/Sequence.d.ts +4 -3
- package/lib/node/Sequence.js +4 -6
- package/lib/node/StringNode.d.ts +5 -5
- package/lib/node/StringNode.js +9 -12
- package/lib/node/SymbolNode.d.ts +5 -5
- package/lib/node/SymbolNode.js +5 -8
- package/lib/node/index.d.ts +15 -15
- package/lib/node/index.js +15 -27
- package/lib/nodejs.d.ts +2 -0
- package/lib/nodejs.js +2 -0
- package/lib/parser/Parser.d.ts +3 -3
- package/lib/parser/Parser.js +1 -4
- package/lib/parser/boolean.d.ts +2 -2
- package/lib/parser/boolean.js +3 -6
- package/lib/parser/comment.d.ts +2 -2
- package/lib/parser/comment.js +5 -9
- package/lib/parser/empty.d.ts +1 -1
- package/lib/parser/empty.js +1 -5
- package/lib/parser/error.d.ts +2 -2
- package/lib/parser/error.js +5 -9
- package/lib/parser/file.d.ts +3 -3
- package/lib/parser/file.js +9 -13
- package/lib/parser/float.d.ts +4 -4
- package/lib/parser/float.js +12 -16
- package/lib/parser/index.d.ts +16 -16
- package/lib/parser/index.js +16 -34
- package/lib/parser/integer.d.ts +4 -4
- package/lib/parser/integer.js +10 -14
- package/lib/parser/list.d.ts +2 -2
- package/lib/parser/list.js +15 -19
- package/lib/parser/literal.d.ts +2 -2
- package/lib/parser/literal.js +5 -9
- package/lib/parser/long.d.ts +4 -4
- package/lib/parser/long.js +10 -14
- package/lib/parser/record.d.ts +3 -3
- package/lib/parser/record.js +20 -24
- package/lib/parser/resourceLocation.d.ts +2 -2
- package/lib/parser/resourceLocation.js +12 -24
- package/lib/parser/string.d.ts +7 -7
- package/lib/parser/string.js +40 -44
- package/lib/parser/symbol.d.ts +3 -3
- package/lib/parser/symbol.js +4 -14
- package/lib/parser/util.d.ts +30 -12
- package/lib/parser/util.js +78 -65
- package/lib/processor/ColorInfoProvider.d.ts +1 -1
- package/lib/processor/ColorInfoProvider.js +6 -9
- package/lib/processor/InlayHintProvider.d.ts +4 -3
- package/lib/processor/InlayHintProvider.js +1 -2
- package/lib/processor/SignatureHelpProvider.d.ts +4 -3
- package/lib/processor/SignatureHelpProvider.js +1 -2
- package/lib/processor/binder/Binder.d.ts +26 -0
- package/lib/processor/binder/Binder.js +18 -0
- package/lib/processor/binder/builtin.d.ts +27 -0
- package/lib/processor/binder/builtin.js +116 -0
- package/lib/processor/binder/index.d.ts +3 -0
- package/lib/processor/binder/index.js +3 -0
- package/lib/processor/checker/Checker.d.ts +2 -2
- package/lib/processor/checker/Checker.js +1 -5
- package/lib/processor/checker/builtin.d.ts +4 -4
- package/lib/processor/checker/builtin.js +22 -33
- package/lib/processor/checker/index.d.ts +2 -2
- package/lib/processor/checker/index.js +2 -27
- package/lib/processor/colorizer/Colorizer.d.ts +6 -5
- package/lib/processor/colorizer/Colorizer.js +8 -11
- package/lib/processor/colorizer/builtin.d.ts +3 -3
- package/lib/processor/colorizer/builtin.js +33 -46
- package/lib/processor/colorizer/index.d.ts +2 -2
- package/lib/processor/colorizer/index.js +2 -27
- package/lib/processor/completer/Completer.d.ts +6 -5
- package/lib/processor/completer/Completer.js +14 -33
- package/lib/processor/completer/builtin.d.ts +10 -9
- package/lib/processor/completer/builtin.js +59 -75
- package/lib/processor/completer/index.d.ts +2 -2
- package/lib/processor/completer/index.js +2 -27
- package/lib/processor/formatter/Formatter.d.ts +4 -3
- package/lib/processor/formatter/Formatter.js +2 -7
- package/lib/processor/formatter/builtin.d.ts +3 -3
- package/lib/processor/formatter/builtin.js +22 -36
- package/lib/processor/formatter/index.d.ts +2 -2
- package/lib/processor/formatter/index.js +2 -27
- package/lib/processor/index.d.ts +10 -9
- package/lib/processor/index.js +10 -21
- package/lib/processor/linter/Linter.d.ts +4 -3
- package/lib/processor/linter/Linter.js +1 -2
- package/lib/processor/linter/builtin/undeclaredSymbol.d.ts +2 -2
- package/lib/processor/linter/builtin/undeclaredSymbol.js +23 -27
- package/lib/processor/linter/builtin.d.ts +4 -3
- package/lib/processor/linter/builtin.js +19 -26
- package/lib/processor/linter/index.d.ts +2 -2
- package/lib/processor/linter/index.js +2 -27
- package/lib/processor/util.d.ts +4 -14
- package/lib/processor/util.js +1 -16
- package/lib/service/CacheService.d.ts +8 -6
- package/lib/service/CacheService.js +35 -56
- package/lib/service/Config.d.ts +17 -16
- package/lib/service/Config.js +56 -51
- package/lib/service/Context.d.ts +24 -21
- package/lib/service/Context.js +40 -36
- package/lib/service/Dependency.js +2 -5
- package/lib/service/Downloader.d.ts +9 -39
- package/lib/service/Downloader.js +37 -106
- package/lib/service/ErrorReporter.d.ts +2 -2
- package/lib/service/ErrorReporter.js +11 -15
- package/lib/service/FileService.d.ts +40 -14
- package/lib/service/FileService.js +107 -81
- package/lib/service/Hover.d.ts +2 -2
- package/lib/service/Hover.js +4 -7
- package/lib/service/MetaRegistry.d.ts +17 -12
- package/lib/service/MetaRegistry.js +81 -73
- package/lib/service/Profiler.d.ts +3 -2
- package/lib/service/Profiler.js +81 -45
- package/lib/service/Project.d.ts +101 -73
- package/lib/service/Project.js +438 -367
- package/lib/service/Service.d.ts +19 -29
- package/lib/service/Service.js +57 -53
- package/lib/service/SymbolLocations.d.ts +3 -3
- package/lib/service/SymbolLocations.js +4 -7
- package/lib/service/SymbolRegistrar.d.ts +1 -1
- package/lib/service/SymbolRegistrar.js +1 -2
- package/lib/service/UriProcessor.d.ts +5 -0
- package/lib/service/UriProcessor.js +2 -0
- package/lib/service/fileUtil.d.ts +21 -41
- package/lib/service/fileUtil.js +59 -129
- package/lib/service/index.d.ts +16 -17
- package/lib/service/index.js +16 -31
- package/lib/source/IndexMap.d.ts +1 -1
- package/lib/source/IndexMap.js +7 -10
- package/lib/source/LanguageError.d.ts +2 -2
- package/lib/source/LanguageError.js +3 -6
- package/lib/source/Location.d.ts +3 -3
- package/lib/source/Location.js +6 -9
- package/lib/source/Offset.d.ts +1 -1
- package/lib/source/Offset.js +4 -7
- package/lib/source/Position.js +2 -5
- package/lib/source/PositionRange.d.ts +2 -2
- package/lib/source/PositionRange.js +14 -17
- package/lib/source/Range.d.ts +1 -1
- package/lib/source/Range.js +7 -10
- package/lib/source/Source.d.ts +9 -4
- package/lib/source/Source.js +58 -31
- package/lib/source/index.d.ts +8 -8
- package/lib/source/index.js +8 -20
- package/lib/symbol/Symbol.d.ts +15 -14
- package/lib/symbol/Symbol.js +53 -68
- package/lib/symbol/SymbolUtil.d.ts +30 -39
- package/lib/symbol/SymbolUtil.js +189 -168
- package/lib/symbol/index.d.ts +2 -3
- package/lib/symbol/index.js +2 -15
- package/package.json +7 -4
- package/lib/service/Operations.d.ts +0 -8
- package/lib/service/Operations.js +0 -26
- package/lib/symbol/UriBinder.d.ts +0 -3
- package/lib/symbol/UriBinder.js +0 -3
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
// https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/60592
|
|
2
|
+
import chokidar from 'chokidar';
|
|
3
|
+
import decompress from 'decompress';
|
|
4
|
+
import followRedirects from 'follow-redirects';
|
|
5
|
+
import globby from 'globby';
|
|
6
|
+
import { Buffer } from 'node:buffer';
|
|
7
|
+
import cp from 'node:child_process';
|
|
8
|
+
import crypto from 'node:crypto';
|
|
9
|
+
import { EventEmitter } from 'node:events';
|
|
10
|
+
import { promises as fsp } from 'node:fs';
|
|
11
|
+
import process from 'node:process';
|
|
12
|
+
import url from 'node:url';
|
|
13
|
+
import { promisify } from 'node:util';
|
|
14
|
+
import zlib from 'node:zlib';
|
|
15
|
+
import { promisifyAsyncIterable, Uri } from '../util.js';
|
|
16
|
+
const { http, https } = followRedirects;
|
|
17
|
+
const gunzip = promisify(zlib.gunzip);
|
|
18
|
+
const gzip = promisify(zlib.gzip);
|
|
19
|
+
class NodeJsExternalDownloader {
|
|
20
|
+
get(uri, options = {}) {
|
|
21
|
+
const protocol = new Uri(uri).protocol;
|
|
22
|
+
return new Promise((resolve, reject) => {
|
|
23
|
+
const backend = protocol === 'http:' ? http : https;
|
|
24
|
+
backend.get(uri, options, (res) => {
|
|
25
|
+
if (res.statusCode !== 200) {
|
|
26
|
+
reject(new Error(`Status code ${res.statusCode}: ${res.statusMessage}`));
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
resolve(promisifyAsyncIterable(res, chunks => Buffer.concat(chunks)));
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export const NodeJsExternals = {
|
|
36
|
+
archive: {
|
|
37
|
+
decompressBall(buffer, options) {
|
|
38
|
+
if (buffer instanceof Buffer) {
|
|
39
|
+
return decompress(buffer, { strip: options?.stripLevel });
|
|
40
|
+
}
|
|
41
|
+
throw new TypeError(`The 'buffer' argument for 'decompressBall' on Node.js must be an instance of 'Buffer'. Got '${buffer}' instead.`);
|
|
42
|
+
},
|
|
43
|
+
gunzip(buffer) {
|
|
44
|
+
return gunzip(buffer);
|
|
45
|
+
},
|
|
46
|
+
gzip(buffer) {
|
|
47
|
+
return gzip(buffer);
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
crypto: {
|
|
51
|
+
async getSha1(data) {
|
|
52
|
+
const hash = crypto.createHash('sha1');
|
|
53
|
+
hash.update(data);
|
|
54
|
+
return hash.digest('hex');
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
downloader: new NodeJsExternalDownloader(),
|
|
58
|
+
error: {
|
|
59
|
+
isKind(e, kind) {
|
|
60
|
+
return e instanceof Error && e.code === kind;
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
event: {
|
|
64
|
+
EventEmitter,
|
|
65
|
+
},
|
|
66
|
+
fs: {
|
|
67
|
+
chmod(location, mode) {
|
|
68
|
+
return fsp.chmod(toFsPathLike(location), mode);
|
|
69
|
+
},
|
|
70
|
+
async getAllFiles(location) {
|
|
71
|
+
return (await globby(toPath(location) + '**/*', { absolute: true, dot: true })).map(uriFromPath);
|
|
72
|
+
},
|
|
73
|
+
async mkdir(location, options) {
|
|
74
|
+
return void await fsp.mkdir(toFsPathLike(location), options);
|
|
75
|
+
},
|
|
76
|
+
readFile(location) {
|
|
77
|
+
return fsp.readFile(toFsPathLike(location));
|
|
78
|
+
},
|
|
79
|
+
async showFile(location) {
|
|
80
|
+
const execFile = promisify(cp.execFile);
|
|
81
|
+
let command;
|
|
82
|
+
switch (process.platform) {
|
|
83
|
+
case 'darwin':
|
|
84
|
+
command = 'open';
|
|
85
|
+
break;
|
|
86
|
+
case 'win32':
|
|
87
|
+
command = 'explorer';
|
|
88
|
+
break;
|
|
89
|
+
default:
|
|
90
|
+
command = 'xdg-open';
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
return void await execFile(command, [toPath(location)]);
|
|
94
|
+
},
|
|
95
|
+
stat(location) {
|
|
96
|
+
return fsp.stat(toFsPathLike(location));
|
|
97
|
+
},
|
|
98
|
+
unlink(location) {
|
|
99
|
+
return fsp.unlink(toFsPathLike(location));
|
|
100
|
+
},
|
|
101
|
+
watch(location) {
|
|
102
|
+
return new ChokidarWatcherWrapper(chokidar.watch(toPath(location)));
|
|
103
|
+
},
|
|
104
|
+
writeFile(location, data, options) {
|
|
105
|
+
return fsp.writeFile(toFsPathLike(location), data, options);
|
|
106
|
+
},
|
|
107
|
+
},
|
|
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
|
+
};
|
|
119
|
+
Object.freeze(NodeJsExternals);
|
|
120
|
+
/**
|
|
121
|
+
* @returns A {@link fs.PathLike}.
|
|
122
|
+
*/
|
|
123
|
+
function toFsPathLike(path) {
|
|
124
|
+
if (typeof path === 'string' && path.startsWith('file:')) {
|
|
125
|
+
return new Uri(path);
|
|
126
|
+
}
|
|
127
|
+
return path;
|
|
128
|
+
}
|
|
129
|
+
function toPath(path) {
|
|
130
|
+
if (typeof path === 'string' && !path.startsWith('file:')) {
|
|
131
|
+
return path;
|
|
132
|
+
}
|
|
133
|
+
return uriToPath(path);
|
|
134
|
+
}
|
|
135
|
+
const uriToPath = (uri) => url.fileURLToPath(uri);
|
|
136
|
+
const uriFromPath = (path) => url.pathToFileURL(path).toString();
|
|
137
|
+
class ChokidarWatcherWrapper extends EventEmitter {
|
|
138
|
+
#watcher;
|
|
139
|
+
constructor(watcher) {
|
|
140
|
+
super();
|
|
141
|
+
this.#watcher = watcher
|
|
142
|
+
.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));
|
|
147
|
+
}
|
|
148
|
+
close() {
|
|
149
|
+
return this.#watcher.close();
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
//# sourceMappingURL=NodeJsExternals.js.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
declare type RemoteUriProtocol = 'http:' | 'https:';
|
|
2
|
+
export declare type RemoteUriString = `${RemoteUriProtocol}${string}`;
|
|
3
|
+
export declare const RemoteUriString: Readonly<{
|
|
4
|
+
is(value: string): value is `http:${string}` | `https:${string}`;
|
|
5
|
+
}>;
|
|
6
|
+
export interface ExternalDownloaderOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Use an string array to set multiple values to the header.
|
|
9
|
+
*/
|
|
10
|
+
headers?: Record<string, string | string[]>;
|
|
11
|
+
timeout?: number;
|
|
12
|
+
}
|
|
13
|
+
export interface ExternalDownloader {
|
|
14
|
+
/**
|
|
15
|
+
* @throws
|
|
16
|
+
*/
|
|
17
|
+
get(uri: RemoteUriString, options?: ExternalDownloaderOptions): Promise<Uint8Array>;
|
|
18
|
+
}
|
|
19
|
+
export declare const ExternalDownloader: Readonly<{
|
|
20
|
+
mock(options: ExternalDownloaderMockOptions): ExternalDownloader;
|
|
21
|
+
}>;
|
|
22
|
+
interface ExternalDownloaderMockOptions {
|
|
23
|
+
/**
|
|
24
|
+
* A record from URIs to fixture data. The {@link ExternalDownloader.get} only returns a {@link Uint8Array},
|
|
25
|
+
* therefore `string` fixtures will be turned into a `Uint8Array` and `object` fixtures will be transformed
|
|
26
|
+
* into JSON and then turned into a `Uint8Array`.
|
|
27
|
+
*/
|
|
28
|
+
fixtures: Record<RemoteUriString, string | Uint8Array | object>;
|
|
29
|
+
}
|
|
30
|
+
export {};
|
|
31
|
+
//# sourceMappingURL=downloader.d.ts.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export const RemoteUriString = Object.freeze({
|
|
2
|
+
is(value) {
|
|
3
|
+
return value.startsWith('http:') || value.startsWith('https:');
|
|
4
|
+
},
|
|
5
|
+
});
|
|
6
|
+
export const ExternalDownloader = Object.freeze({
|
|
7
|
+
mock(options) {
|
|
8
|
+
return new ExternalDownloaderMock(options);
|
|
9
|
+
},
|
|
10
|
+
});
|
|
11
|
+
class ExternalDownloaderMock {
|
|
12
|
+
options;
|
|
13
|
+
constructor(options) {
|
|
14
|
+
this.options = options;
|
|
15
|
+
}
|
|
16
|
+
async get(uri) {
|
|
17
|
+
if (!this.options.fixtures[uri]) {
|
|
18
|
+
throw new Error(`404 not found: ${uri}`);
|
|
19
|
+
}
|
|
20
|
+
const fixture = this.options.fixtures[uri];
|
|
21
|
+
if (fixture instanceof Uint8Array) {
|
|
22
|
+
return fixture;
|
|
23
|
+
}
|
|
24
|
+
else if (typeof fixture === 'string') {
|
|
25
|
+
return new TextEncoder().encode(fixture);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
return new TextEncoder().encode(JSON.stringify(fixture));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=downloader.js.map
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type { Uri } from '../util.js';
|
|
2
|
+
import type { ExternalDownloader } from './downloader.js';
|
|
3
|
+
export * from './downloader.js';
|
|
4
|
+
export interface Externals {
|
|
5
|
+
archive: {
|
|
6
|
+
decompressBall: (buffer: Uint8Array, options?: {
|
|
7
|
+
stripLevel?: number;
|
|
8
|
+
}) => Promise<DecompressedFile[]>;
|
|
9
|
+
gzip: (buffer: Uint8Array) => Promise<Uint8Array>;
|
|
10
|
+
gunzip: (buffer: Uint8Array) => Promise<Uint8Array>;
|
|
11
|
+
};
|
|
12
|
+
crypto: {
|
|
13
|
+
/**
|
|
14
|
+
* @returns SHA-1 digest of the given data in hexadecimal format.
|
|
15
|
+
*/
|
|
16
|
+
getSha1: (data: string | Uint8Array) => Promise<string>;
|
|
17
|
+
};
|
|
18
|
+
downloader: ExternalDownloader;
|
|
19
|
+
error: {
|
|
20
|
+
isKind: (e: unknown, kind: ExternalErrorKind) => boolean;
|
|
21
|
+
};
|
|
22
|
+
event: {
|
|
23
|
+
EventEmitter: new () => ExternalEventEmitter;
|
|
24
|
+
};
|
|
25
|
+
fs: ExternalFileSystem;
|
|
26
|
+
uri: {
|
|
27
|
+
normalize: (uri: string) => string;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
export interface DecompressedFile {
|
|
31
|
+
data: Uint8Array;
|
|
32
|
+
mode: number;
|
|
33
|
+
mtime: string;
|
|
34
|
+
path: string;
|
|
35
|
+
type: string;
|
|
36
|
+
}
|
|
37
|
+
export declare type ExternalErrorKind = 'EEXIST' | 'EISDIR' | 'ENOENT';
|
|
38
|
+
export interface ExternalEventEmitter {
|
|
39
|
+
emit(eventName: string, ...args: unknown[]): boolean;
|
|
40
|
+
on(eventName: string, listener: (...args: unknown[]) => unknown): this;
|
|
41
|
+
once(eventName: string, listener: (...args: unknown[]) => unknown): this;
|
|
42
|
+
}
|
|
43
|
+
export interface ExternalFileSystem {
|
|
44
|
+
/**
|
|
45
|
+
* @param mode File mode bit mask (e.g. `0o775`).
|
|
46
|
+
*/
|
|
47
|
+
chmod(location: FsLocation, mode: number): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* @returns an array of file URIs under the given `location`.
|
|
50
|
+
*/
|
|
51
|
+
getAllFiles(location: FsLocation): Promise<string[]>;
|
|
52
|
+
/**
|
|
53
|
+
* @param options `mode` - File mode bit mask (e.g. `0o775`).
|
|
54
|
+
*/
|
|
55
|
+
mkdir(location: FsLocation, options?: {
|
|
56
|
+
mode?: number;
|
|
57
|
+
recursive?: boolean;
|
|
58
|
+
}): Promise<void>;
|
|
59
|
+
readFile(location: FsLocation): Promise<Uint8Array>;
|
|
60
|
+
/**
|
|
61
|
+
* Show the file/directory in the platform-specific explorer program.
|
|
62
|
+
*
|
|
63
|
+
* Should not be called with unsanitized user-input path due to the possibility of arbitrary code execution.
|
|
64
|
+
*/
|
|
65
|
+
showFile(path: FsLocation): Promise<void>;
|
|
66
|
+
stat(location: FsLocation): Promise<{
|
|
67
|
+
isDirectory(): boolean;
|
|
68
|
+
isFile(): boolean;
|
|
69
|
+
}>;
|
|
70
|
+
unlink(location: FsLocation): Promise<void>;
|
|
71
|
+
watch(location: FsLocation): FsWatcher;
|
|
72
|
+
/**
|
|
73
|
+
* @param options `mode` - File mode bit mask (e.g. `0o775`).
|
|
74
|
+
*/
|
|
75
|
+
writeFile(location: FsLocation, data: string | Uint8Array, options?: {
|
|
76
|
+
mode: number;
|
|
77
|
+
}): Promise<void>;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* A file file URI string or a URI object.
|
|
81
|
+
*/
|
|
82
|
+
export declare type FsLocation = string | Uri;
|
|
83
|
+
export interface FsWatcher {
|
|
84
|
+
on(eventName: 'ready', listener: () => unknown): this;
|
|
85
|
+
once(eventName: 'ready', listener: () => unknown): this;
|
|
86
|
+
on(eventName: 'add', listener: (uri: string) => unknown): this;
|
|
87
|
+
once(eventName: 'add', listener: (uri: string) => unknown): this;
|
|
88
|
+
on(eventName: 'change', listener: (uri: string) => unknown): this;
|
|
89
|
+
once(eventName: 'change', listener: (uri: string) => unknown): this;
|
|
90
|
+
on(eventName: 'unlink', listener: (uri: string) => unknown): this;
|
|
91
|
+
once(eventName: 'unlink', listener: (uri: string) => unknown): this;
|
|
92
|
+
on(eventName: 'error', listener: (error: Error) => unknown): this;
|
|
93
|
+
once(eventName: 'error', listener: (error: Error) => unknown): this;
|
|
94
|
+
close(): Promise<void>;
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=index.d.ts.map
|
package/lib/common/index.d.ts
CHANGED
|
@@ -1,2 +1,9 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './Dev.js';
|
|
2
|
+
export * from './externals/index.js';
|
|
3
|
+
export * from './Logger.js';
|
|
4
|
+
export * from './Operations.js';
|
|
5
|
+
export * from './ReadonlyProxy.js';
|
|
6
|
+
export * from './StateProxy.js';
|
|
7
|
+
export * from './TwoWayMap.js';
|
|
8
|
+
export * from './util.js';
|
|
2
9
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/common/index.js
CHANGED
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
-
};
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
__exportStar(require("./util"), exports);
|
|
1
|
+
export * from './Dev.js';
|
|
2
|
+
export * from './externals/index.js';
|
|
3
|
+
export * from './Logger.js';
|
|
4
|
+
export * from './Operations.js';
|
|
5
|
+
export * from './ReadonlyProxy.js';
|
|
6
|
+
export * from './StateProxy.js';
|
|
7
|
+
export * from './TwoWayMap.js';
|
|
8
|
+
export * from './util.js';
|
|
14
9
|
//# sourceMappingURL=index.js.map
|
package/lib/common/util.d.ts
CHANGED
|
@@ -1,21 +1,32 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import externalBinarySearch from 'binary-search';
|
|
3
|
-
import type {
|
|
4
|
-
import type { ProcessorContext
|
|
5
|
-
|
|
2
|
+
import type { AstNode } from '../node/index.js';
|
|
3
|
+
import type { ProcessorContext } from '../service/index.js';
|
|
4
|
+
import type { Externals } from './externals/index.js';
|
|
5
|
+
import type { DeepReadonly } from './ReadonlyProxy.js';
|
|
6
|
+
export declare const Uri: {
|
|
7
|
+
new (url: string | URL, base?: string | URL | undefined): URL;
|
|
8
|
+
prototype: URL;
|
|
9
|
+
createObjectURL(obj: Blob | MediaSource): string;
|
|
10
|
+
revokeObjectURL(url: string): void;
|
|
11
|
+
};
|
|
12
|
+
export declare type Uri = URL;
|
|
6
13
|
/**
|
|
7
|
-
*
|
|
8
|
-
|
|
14
|
+
* `NodeJS.Timeout` on Node.js and `number` on browser.
|
|
15
|
+
*/
|
|
16
|
+
export declare type IntervalId = any;
|
|
17
|
+
/**
|
|
18
|
+
* @param getKey A function that takes the actual arguments being passed into the decorated method, and returns anything.
|
|
19
|
+
* The result of this function will be used as the key to identify the `Promise`. By default the first element in the argument
|
|
9
20
|
* list will be used.
|
|
10
21
|
*
|
|
11
22
|
* This is a decorator for async methods. Decorated methods will return the same `Promise` for
|
|
12
|
-
* the same
|
|
23
|
+
* the same key, provided that the previously returned `Promise` is still pending.
|
|
13
24
|
*/
|
|
14
|
-
export declare function
|
|
25
|
+
export declare function SingletonPromise(getKey?: (args: any[]) => any): MethodDecorator;
|
|
15
26
|
/**
|
|
16
|
-
* This is a decorator for
|
|
27
|
+
* This is a decorator for methods. Decorated methods will return the same non-`undefined` value no matter what.
|
|
17
28
|
*/
|
|
18
|
-
export declare const
|
|
29
|
+
export declare const Singleton: MethodDecorator;
|
|
19
30
|
/**
|
|
20
31
|
* @param getKey A function that takes the actual arguments being passed into the decorated method, and returns anything.
|
|
21
32
|
* The result of this function will be used as the key to cache the `Timeout`. By default the first element in the argument
|
|
@@ -24,22 +35,6 @@ export declare const SingletonPromise: MethodDecorator;
|
|
|
24
35
|
* Decorated methods will be scheduled to run after `ms` milliseconds. The timer will reset when the method is called again.
|
|
25
36
|
*/
|
|
26
37
|
export declare function Delay(ms: number, getKey?: (args: any[]) => any): MethodDecorator;
|
|
27
|
-
export declare namespace SpyglassUri {
|
|
28
|
-
const Protocol = "spyglassmc:";
|
|
29
|
-
namespace Archive {
|
|
30
|
-
const Hostname = "archive";
|
|
31
|
-
function get(archiveUri: string): RootUriString;
|
|
32
|
-
function get(archiveUri: string, pathInArchive: string): string;
|
|
33
|
-
function is(uri: Uri): boolean;
|
|
34
|
-
/**
|
|
35
|
-
* @throws When `uri` has the wrong protocol or hostname.
|
|
36
|
-
*/
|
|
37
|
-
function decode(uri: Uri): {
|
|
38
|
-
archiveUri: string;
|
|
39
|
-
pathInArchive: string;
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
38
|
export declare type FullResourceLocation = `${string}:${string}`;
|
|
44
39
|
export interface ResourceLocation {
|
|
45
40
|
isTag: boolean;
|
|
@@ -67,15 +62,7 @@ export declare namespace ResourceLocation {
|
|
|
67
62
|
* @returns The string value decoded from the buffer according to UTF-8.
|
|
68
63
|
* Byte order mark is correctly removed.
|
|
69
64
|
*/
|
|
70
|
-
export declare function bufferToString(buffer:
|
|
71
|
-
export declare function stringToBase64(str: string): string;
|
|
72
|
-
export declare function base64ToString(base64: string): string;
|
|
73
|
-
/**
|
|
74
|
-
* @throws
|
|
75
|
-
*/
|
|
76
|
-
export declare function getSha1(data: string | Buffer): string;
|
|
77
|
-
export declare function isErrorCode(e: unknown, code: string): boolean;
|
|
78
|
-
export declare function isEnoent(e: unknown): boolean;
|
|
65
|
+
export declare function bufferToString(buffer: Uint8Array): string;
|
|
79
66
|
export declare type Arrayable<T> = T | readonly T[];
|
|
80
67
|
export declare namespace Arrayable {
|
|
81
68
|
function is<T>(value: unknown, isT: (value: unknown) => value is T): value is Arrayable<T>;
|
|
@@ -85,10 +72,11 @@ export declare namespace TypePredicates {
|
|
|
85
72
|
function isString(value: unknown): value is string;
|
|
86
73
|
}
|
|
87
74
|
export declare function promisifyAsyncIterable<T, U>(iterable: AsyncIterable<T>, joiner: (chunks: T[]) => U): Promise<U>;
|
|
88
|
-
export declare
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
75
|
+
export declare function parseGzippedJson(externals: Externals, buffer: Uint8Array): Promise<unknown>;
|
|
76
|
+
/**
|
|
77
|
+
* @returns Is Plain Old JavaScript Object (POJO).
|
|
78
|
+
*/
|
|
79
|
+
export declare function isPojo(value: unknown): value is Record<string, unknown>;
|
|
92
80
|
export declare function merge<T extends Record<string, any>>(a: T, b: Record<string, any>): T;
|
|
93
81
|
export declare type Lazy<T> = T | Lazy.ComplexLazy<T>;
|
|
94
82
|
export declare namespace Lazy {
|
|
@@ -117,4 +105,27 @@ export declare namespace Lazy {
|
|
|
117
105
|
export declare function getStates(category: 'block' | 'fluid', ids: readonly string[], ctx: ProcessorContext): Record<string, string[]>;
|
|
118
106
|
export declare const binarySearch: typeof externalBinarySearch;
|
|
119
107
|
export declare function isIterable(value: unknown): value is Iterable<unknown>;
|
|
108
|
+
export declare function atArray<T>(array: readonly T[] | undefined, index: number): T | undefined;
|
|
109
|
+
export declare function emplaceMap<K, V>(map: Map<K, V>, key: K, handler: {
|
|
110
|
+
insert?: (key: K, map: Map<K, V>) => V;
|
|
111
|
+
update?: (existing: V, key: K, map: Map<K, V>) => V;
|
|
112
|
+
}): V;
|
|
113
|
+
/**
|
|
114
|
+
* @returns If `val` is an non-null object or a callable object (i.e. function).
|
|
115
|
+
*/
|
|
116
|
+
export declare function isObject(val: unknown): val is object;
|
|
117
|
+
/**
|
|
118
|
+
* @example
|
|
119
|
+
* ```ts
|
|
120
|
+
* function isCommentNode<T extends DeepReadonly<AstNode> | undefined>(node: T): node is IsHelper<AstNode, CommentNode, T>
|
|
121
|
+
* ```
|
|
122
|
+
*/
|
|
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
|
+
/**
|
|
125
|
+
* @example
|
|
126
|
+
* ```ts
|
|
127
|
+
* function isCommentNode<T extends DeepReadonly<AstNode> | undefined>(node: T): node is NodeIsHelper<CommentNode, T>
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
export declare type NodeIsHelper<TARGET extends AstNode, INPUT extends DeepReadonly<AstNode> | undefined> = IsHelper<AstNode, TARGET, INPUT>;
|
|
120
131
|
//# sourceMappingURL=util.d.ts.map
|