@spyglassmc/core 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -0
- package/lib/browser.d.ts +2 -0
- package/lib/browser.js +2 -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 +151 -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 +2 -1
- package/lib/common/index.js +2 -13
- package/lib/common/util.d.ts +17 -34
- package/lib/common/util.js +32 -113
- package/lib/index.d.ts +7 -7
- package/lib/index.js +7 -19
- package/lib/node/AstNode.d.ts +3 -3
- 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 +1 -1
- package/lib/node/CommentNode.js +2 -5
- package/lib/node/ErrorNode.d.ts +1 -1
- package/lib/node/ErrorNode.js +2 -5
- package/lib/node/FileNode.d.ts +3 -3
- package/lib/node/FileNode.js +2 -5
- package/lib/node/FloatNode.d.ts +2 -2
- package/lib/node/FloatNode.js +4 -7
- package/lib/node/IntegerNode.d.ts +2 -2
- 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 +4 -4
- package/lib/node/LiteralNode.js +5 -8
- package/lib/node/LongNode.d.ts +2 -2
- 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 +6 -8
- 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 +4 -4
- 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 +14 -18
- 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 +3 -7
- package/lib/parser/util.d.ts +30 -12
- package/lib/parser/util.js +78 -63
- package/lib/processor/ColorInfoProvider.d.ts +1 -1
- package/lib/processor/ColorInfoProvider.js +6 -9
- package/lib/processor/InlayHintProvider.d.ts +2 -2
- package/lib/processor/InlayHintProvider.js +1 -2
- package/lib/processor/SignatureHelpProvider.d.ts +2 -2
- package/lib/processor/SignatureHelpProvider.js +1 -2
- package/lib/processor/checker/Checker.d.ts +2 -2
- package/lib/processor/checker/Checker.js +1 -5
- package/lib/processor/checker/builtin.d.ts +5 -4
- package/lib/processor/checker/builtin.js +26 -28
- package/lib/processor/checker/index.d.ts +2 -2
- package/lib/processor/checker/index.js +2 -27
- package/lib/processor/colorizer/Colorizer.d.ts +4 -4
- 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 +4 -4
- package/lib/processor/completer/Completer.js +14 -33
- package/lib/processor/completer/builtin.d.ts +7 -7
- package/lib/processor/completer/builtin.js +58 -74
- package/lib/processor/completer/index.d.ts +2 -2
- package/lib/processor/completer/index.js +2 -27
- package/lib/processor/formatter/Formatter.d.ts +2 -2
- 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 +9 -9
- package/lib/processor/index.js +9 -21
- package/lib/processor/linter/Linter.d.ts +2 -2
- 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 +3 -3
- package/lib/processor/linter/builtin.js +19 -31
- package/lib/processor/linter/index.d.ts +2 -2
- package/lib/processor/linter/index.js +2 -27
- package/lib/processor/util.d.ts +2 -2
- package/lib/processor/util.js +4 -9
- package/lib/service/CacheService.d.ts +6 -6
- package/lib/service/CacheService.js +38 -48
- package/lib/service/Config.d.ts +17 -16
- package/lib/service/Config.js +56 -51
- package/lib/service/Context.d.ts +14 -14
- package/lib/service/Context.js +30 -32
- package/lib/service/Dependency.js +2 -5
- package/lib/service/Downloader.d.ts +10 -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 +41 -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/Logger.js +2 -5
- package/lib/service/MetaRegistry.d.ts +12 -12
- package/lib/service/MetaRegistry.js +62 -73
- package/lib/service/Operations.js +3 -9
- package/lib/service/Profiler.d.ts +1 -1
- package/lib/service/Profiler.js +25 -41
- package/lib/service/Project.d.ts +50 -51
- package/lib/service/Project.js +240 -238
- 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/fileUtil.d.ts +21 -41
- package/lib/service/fileUtil.js +59 -129
- package/lib/service/index.d.ts +17 -17
- package/lib/service/index.js +17 -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 +12 -4
- package/lib/source/Source.js +84 -29
- package/lib/source/index.d.ts +8 -8
- package/lib/source/index.js +8 -20
- package/lib/symbol/Symbol.d.ts +15 -15
- package/lib/symbol/Symbol.js +53 -68
- package/lib/symbol/SymbolUtil.d.ts +23 -33
- package/lib/symbol/SymbolUtil.js +162 -163
- package/lib/symbol/UriBinder.d.ts +1 -1
- package/lib/symbol/UriBinder.js +1 -2
- package/lib/symbol/index.d.ts +3 -3
- package/lib/symbol/index.js +3 -15
- package/package.json +7 -4
- package/lib/common/Heap.d.ts +0 -1
- package/lib/common/Heap.js +0 -2
- package/lib/node/TableNode.d.ts +0 -17
- package/lib/node/TableNode.js +0 -11
- package/lib/parser/table.d.ts +0 -22
- package/lib/parser/table.js +0 -97
- package/lib/service/CommandExecutor.d.ts +0 -3
- package/lib/service/CommandExecutor.js +0 -7
package/lib/common/util.d.ts
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import externalBinarySearch from 'binary-search';
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
export
|
|
2
|
+
import type { ProcessorContext } from '../service/index.js';
|
|
3
|
+
import type { Externals } from './externals/index.js';
|
|
4
|
+
export declare const Uri: {
|
|
5
|
+
new (url: string | URL, base?: string | URL | undefined): URL;
|
|
6
|
+
prototype: URL;
|
|
7
|
+
createObjectURL(obj: Blob | MediaSource): string;
|
|
8
|
+
revokeObjectURL(url: string): void;
|
|
9
|
+
};
|
|
10
|
+
export declare type Uri = URL;
|
|
11
|
+
/**
|
|
12
|
+
* `NodeJS.Timeout` on Node.js and `number` on browser.
|
|
13
|
+
*/
|
|
14
|
+
export declare type IntervalId = any;
|
|
6
15
|
/**
|
|
7
16
|
* @param getCacheKey A function that takes the actual arguments being passed into the decorated method, and returns anything.
|
|
8
17
|
* The result of this function will be used as the key to cache the `Promise`. By default the first element in the argument
|
|
@@ -13,9 +22,9 @@ export { URL as Uri } from 'url';
|
|
|
13
22
|
*/
|
|
14
23
|
export declare function CachePromise(getCacheKey?: (args: any[]) => any): MethodDecorator;
|
|
15
24
|
/**
|
|
16
|
-
* This is a decorator for
|
|
25
|
+
* This is a decorator for methods. Decorated methods will return the same non-`undefined` value no matter what.
|
|
17
26
|
*/
|
|
18
|
-
export declare const
|
|
27
|
+
export declare const Singleton: MethodDecorator;
|
|
19
28
|
/**
|
|
20
29
|
* @param getKey A function that takes the actual arguments being passed into the decorated method, and returns anything.
|
|
21
30
|
* 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 +33,6 @@ export declare const SingletonPromise: MethodDecorator;
|
|
|
24
33
|
* Decorated methods will be scheduled to run after `ms` milliseconds. The timer will reset when the method is called again.
|
|
25
34
|
*/
|
|
26
35
|
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
36
|
export declare type FullResourceLocation = `${string}:${string}`;
|
|
44
37
|
export interface ResourceLocation {
|
|
45
38
|
isTag: boolean;
|
|
@@ -67,15 +60,7 @@ export declare namespace ResourceLocation {
|
|
|
67
60
|
* @returns The string value decoded from the buffer according to UTF-8.
|
|
68
61
|
* Byte order mark is correctly removed.
|
|
69
62
|
*/
|
|
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;
|
|
63
|
+
export declare function bufferToString(buffer: Uint8Array): string;
|
|
79
64
|
export declare type Arrayable<T> = T | readonly T[];
|
|
80
65
|
export declare namespace Arrayable {
|
|
81
66
|
function is<T>(value: unknown, isT: (value: unknown) => value is T): value is Arrayable<T>;
|
|
@@ -85,9 +70,7 @@ export declare namespace TypePredicates {
|
|
|
85
70
|
function isString(value: unknown): value is string;
|
|
86
71
|
}
|
|
87
72
|
export declare function promisifyAsyncIterable<T, U>(iterable: AsyncIterable<T>, joiner: (chunks: T[]) => U): Promise<U>;
|
|
88
|
-
export declare
|
|
89
|
-
export declare const zip: (buffer: Buffer) => Promise<Buffer>;
|
|
90
|
-
export declare function parseGzippedJson<T>(buffer: Buffer): Promise<T>;
|
|
73
|
+
export declare function parseGzippedJson(externals: Externals, buffer: Uint8Array): Promise<unknown>;
|
|
91
74
|
export declare function isObject(value: unknown): value is Exclude<object, Array<any>>;
|
|
92
75
|
export declare function merge<T extends Record<string, any>>(a: T, b: Record<string, any>): T;
|
|
93
76
|
export declare type Lazy<T> = T | Lazy.ComplexLazy<T>;
|
package/lib/common/util.js
CHANGED
|
@@ -1,16 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.isIterable = exports.binarySearch = exports.getStates = exports.Lazy = exports.merge = exports.isObject = exports.parseGzippedJson = exports.zip = exports.unzip = exports.promisifyAsyncIterable = exports.TypePredicates = exports.Arrayable = exports.isEnoent = exports.isErrorCode = exports.getSha1 = exports.base64ToString = exports.stringToBase64 = exports.bufferToString = exports.ResourceLocation = exports.SpyglassUri = exports.Delay = exports.SingletonPromise = exports.CachePromise = exports.Uri = void 0;
|
|
7
|
-
const binary_search_1 = __importDefault(require("binary-search"));
|
|
8
|
-
const crypto_1 = __importDefault(require("crypto"));
|
|
9
|
-
const rfdc_1 = __importDefault(require("rfdc"));
|
|
10
|
-
const util_1 = require("util");
|
|
11
|
-
const zlib_1 = __importDefault(require("zlib"));
|
|
12
|
-
var url_1 = require("url");
|
|
13
|
-
Object.defineProperty(exports, "Uri", { enumerable: true, get: function () { return url_1.URL; } });
|
|
1
|
+
import externalBinarySearch from 'binary-search';
|
|
2
|
+
import rfdc from 'rfdc';
|
|
3
|
+
export const Uri = URL;
|
|
14
4
|
/**
|
|
15
5
|
* @param getCacheKey A function that takes the actual arguments being passed into the decorated method, and returns anything.
|
|
16
6
|
* The result of this function will be used as the key to cache the `Promise`. By default the first element in the argument
|
|
@@ -19,7 +9,7 @@ Object.defineProperty(exports, "Uri", { enumerable: true, get: function () { ret
|
|
|
19
9
|
* This is a decorator for async methods. Decorated methods will return the same `Promise` for
|
|
20
10
|
* the same arguments, provided that the cached `Promise` is still pending.
|
|
21
11
|
*/
|
|
22
|
-
function CachePromise(getCacheKey = args => args[0]) {
|
|
12
|
+
export function CachePromise(getCacheKey = args => args[0]) {
|
|
23
13
|
return (_target, _key, descripter) => {
|
|
24
14
|
const promises = new Map();
|
|
25
15
|
const decoratedMethod = descripter.value;
|
|
@@ -37,20 +27,18 @@ function CachePromise(getCacheKey = args => args[0]) {
|
|
|
37
27
|
return descripter;
|
|
38
28
|
};
|
|
39
29
|
}
|
|
40
|
-
exports.CachePromise = CachePromise;
|
|
41
30
|
/**
|
|
42
|
-
* This is a decorator for
|
|
31
|
+
* This is a decorator for methods. Decorated methods will return the same non-`undefined` value no matter what.
|
|
43
32
|
*/
|
|
44
|
-
const
|
|
45
|
-
let
|
|
33
|
+
export const Singleton = (_target, _key, descripter) => {
|
|
34
|
+
let value;
|
|
46
35
|
const decoratedMethod = descripter.value;
|
|
47
36
|
// The `function` syntax is used to preserve `this` context from the decorated method.
|
|
48
37
|
descripter.value = function (...args) {
|
|
49
|
-
return
|
|
38
|
+
return value ??= decoratedMethod.apply(this, args);
|
|
50
39
|
};
|
|
51
40
|
return descripter;
|
|
52
41
|
};
|
|
53
|
-
exports.SingletonPromise = SingletonPromise;
|
|
54
42
|
/**
|
|
55
43
|
* @param getKey A function that takes the actual arguments being passed into the decorated method, and returns anything.
|
|
56
44
|
* The result of this function will be used as the key to cache the `Timeout`. By default the first element in the argument
|
|
@@ -58,7 +46,7 @@ exports.SingletonPromise = SingletonPromise;
|
|
|
58
46
|
*
|
|
59
47
|
* Decorated methods will be scheduled to run after `ms` milliseconds. The timer will reset when the method is called again.
|
|
60
48
|
*/
|
|
61
|
-
function Delay(ms, getKey = args => args[0]) {
|
|
49
|
+
export function Delay(ms, getKey = args => args[0]) {
|
|
62
50
|
return (_target, _key, descripter) => {
|
|
63
51
|
const timeouts = new Map();
|
|
64
52
|
const decoratedMethod = descripter.value;
|
|
@@ -76,42 +64,7 @@ function Delay(ms, getKey = args => args[0]) {
|
|
|
76
64
|
return descripter;
|
|
77
65
|
};
|
|
78
66
|
}
|
|
79
|
-
|
|
80
|
-
var SpyglassUri;
|
|
81
|
-
(function (SpyglassUri) {
|
|
82
|
-
SpyglassUri.Protocol = 'spyglassmc:';
|
|
83
|
-
let Archive;
|
|
84
|
-
(function (Archive) {
|
|
85
|
-
Archive.Hostname = 'archive';
|
|
86
|
-
function get(archiveUri, pathInArchive = '') {
|
|
87
|
-
return `${SpyglassUri.Protocol}//${Archive.Hostname}/${encodeURIComponent(archiveUri)}/${pathInArchive.replace(/\\/g, '/')}`;
|
|
88
|
-
}
|
|
89
|
-
Archive.get = get;
|
|
90
|
-
function is(uri) {
|
|
91
|
-
return uri.protocol === SpyglassUri.Protocol && uri.hostname === Archive.Hostname;
|
|
92
|
-
}
|
|
93
|
-
Archive.is = is;
|
|
94
|
-
/**
|
|
95
|
-
* @throws When `uri` has the wrong protocol or hostname.
|
|
96
|
-
*/
|
|
97
|
-
function decode(uri) {
|
|
98
|
-
if (uri.protocol !== SpyglassUri.Protocol) {
|
|
99
|
-
throw new Error(`Expected protocol “${SpyglassUri.Protocol}” in “${uri.toString()}”`);
|
|
100
|
-
}
|
|
101
|
-
if (uri.hostname !== Archive.Hostname) {
|
|
102
|
-
throw new Error(`Expected hostname “${Archive.Hostname}” in “${uri.toString()}”`);
|
|
103
|
-
}
|
|
104
|
-
// Ex. `pathname`: `/QzpcYS50YXIuZ3o=/foo/bar.json`
|
|
105
|
-
const paths = uri.pathname.split('/');
|
|
106
|
-
return {
|
|
107
|
-
archiveUri: decodeURIComponent(paths[1]),
|
|
108
|
-
pathInArchive: paths.slice(2).join('/'),
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
Archive.decode = decode;
|
|
112
|
-
})(Archive = SpyglassUri.Archive || (SpyglassUri.Archive = {}));
|
|
113
|
-
})(SpyglassUri = exports.SpyglassUri || (exports.SpyglassUri = {}));
|
|
114
|
-
var ResourceLocation;
|
|
67
|
+
export var ResourceLocation;
|
|
115
68
|
(function (ResourceLocation) {
|
|
116
69
|
/**
|
|
117
70
|
* The prefix for tags.
|
|
@@ -141,45 +94,19 @@ var ResourceLocation;
|
|
|
141
94
|
return value.replace(/^(?:minecraft)?:/, '');
|
|
142
95
|
}
|
|
143
96
|
ResourceLocation.shorten = shorten;
|
|
144
|
-
})(ResourceLocation
|
|
97
|
+
})(ResourceLocation || (ResourceLocation = {}));
|
|
145
98
|
/**
|
|
146
99
|
* @returns The string value decoded from the buffer according to UTF-8.
|
|
147
100
|
* Byte order mark is correctly removed.
|
|
148
101
|
*/
|
|
149
|
-
function bufferToString(buffer) {
|
|
150
|
-
const ans =
|
|
151
|
-
if (ans.charCodeAt(0) === 0xFEFF) {
|
|
152
|
-
|
|
153
|
-
}
|
|
102
|
+
export function bufferToString(buffer) {
|
|
103
|
+
const ans = new TextDecoder().decode(buffer);
|
|
104
|
+
// if (ans.charCodeAt(0) === 0xFEFF) {
|
|
105
|
+
// return ans.slice(1)
|
|
106
|
+
// }
|
|
154
107
|
return ans;
|
|
155
108
|
}
|
|
156
|
-
|
|
157
|
-
function stringToBase64(str) {
|
|
158
|
-
return Buffer.from(str).toString('base64');
|
|
159
|
-
}
|
|
160
|
-
exports.stringToBase64 = stringToBase64;
|
|
161
|
-
function base64ToString(base64) {
|
|
162
|
-
return Buffer.from(base64, 'base64').toString('utf-8');
|
|
163
|
-
}
|
|
164
|
-
exports.base64ToString = base64ToString;
|
|
165
|
-
/**
|
|
166
|
-
* @throws
|
|
167
|
-
*/
|
|
168
|
-
function getSha1(data) {
|
|
169
|
-
const hash = crypto_1.default.createHash('sha1');
|
|
170
|
-
hash.update(data);
|
|
171
|
-
return hash.digest('hex');
|
|
172
|
-
}
|
|
173
|
-
exports.getSha1 = getSha1;
|
|
174
|
-
function isErrorCode(e, code) {
|
|
175
|
-
return e instanceof Error && e.code === code;
|
|
176
|
-
}
|
|
177
|
-
exports.isErrorCode = isErrorCode;
|
|
178
|
-
function isEnoent(e) {
|
|
179
|
-
return isErrorCode(e, 'ENOENT');
|
|
180
|
-
}
|
|
181
|
-
exports.isEnoent = isEnoent;
|
|
182
|
-
var Arrayable;
|
|
109
|
+
export var Arrayable;
|
|
183
110
|
(function (Arrayable) {
|
|
184
111
|
function is(value, isT) {
|
|
185
112
|
return Array.isArray(value)
|
|
@@ -191,15 +118,15 @@ var Arrayable;
|
|
|
191
118
|
return Array.isArray(value) ? value : [value];
|
|
192
119
|
}
|
|
193
120
|
Arrayable.toArray = toArray;
|
|
194
|
-
})(Arrayable
|
|
195
|
-
var TypePredicates;
|
|
121
|
+
})(Arrayable || (Arrayable = {}));
|
|
122
|
+
export var TypePredicates;
|
|
196
123
|
(function (TypePredicates) {
|
|
197
124
|
function isString(value) {
|
|
198
125
|
return typeof value === 'string';
|
|
199
126
|
}
|
|
200
127
|
TypePredicates.isString = isString;
|
|
201
|
-
})(TypePredicates
|
|
202
|
-
function promisifyAsyncIterable(iterable, joiner) {
|
|
128
|
+
})(TypePredicates || (TypePredicates = {}));
|
|
129
|
+
export function promisifyAsyncIterable(iterable, joiner) {
|
|
203
130
|
return (async () => {
|
|
204
131
|
const chunks = [];
|
|
205
132
|
for await (const chunk of iterable) {
|
|
@@ -208,19 +135,14 @@ function promisifyAsyncIterable(iterable, joiner) {
|
|
|
208
135
|
return joiner(chunks);
|
|
209
136
|
})();
|
|
210
137
|
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
exports.zip = (0, util_1.promisify)(zlib_1.default.gzip);
|
|
214
|
-
async function parseGzippedJson(buffer) {
|
|
215
|
-
return JSON.parse(bufferToString(await (0, exports.unzip)(buffer)));
|
|
138
|
+
export async function parseGzippedJson(externals, buffer) {
|
|
139
|
+
return JSON.parse(bufferToString(await externals.archive.gunzip(buffer)));
|
|
216
140
|
}
|
|
217
|
-
|
|
218
|
-
function isObject(value) {
|
|
141
|
+
export function isObject(value) {
|
|
219
142
|
return !!value && typeof value === 'object' && !Array.isArray(value);
|
|
220
143
|
}
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
const ans = (0, rfdc_1.default)()(a);
|
|
144
|
+
export function merge(a, b) {
|
|
145
|
+
const ans = rfdc()(a);
|
|
224
146
|
for (const [key, value] of Object.entries(b)) {
|
|
225
147
|
if (isObject(ans[key]) && isObject(value)) {
|
|
226
148
|
ans[key] = merge(ans[key], value);
|
|
@@ -234,8 +156,7 @@ function merge(a, b) {
|
|
|
234
156
|
}
|
|
235
157
|
return ans;
|
|
236
158
|
}
|
|
237
|
-
|
|
238
|
-
var Lazy;
|
|
159
|
+
export var Lazy;
|
|
239
160
|
(function (Lazy) {
|
|
240
161
|
const LazyDiscriminator = Symbol('LazyDiscriminator');
|
|
241
162
|
function create(getter) {
|
|
@@ -257,13 +178,13 @@ var Lazy;
|
|
|
257
178
|
return isUnresolved(lazy) ? lazy.value = lazy.getter() : lazy;
|
|
258
179
|
}
|
|
259
180
|
Lazy.resolve = resolve;
|
|
260
|
-
})(Lazy
|
|
181
|
+
})(Lazy || (Lazy = {}));
|
|
261
182
|
/**
|
|
262
183
|
* @param ids An array of block/fluid IDs, with or without the namespace.
|
|
263
184
|
* @returns A map from state names to the corresponding sets of values. The first element in the value array is the default
|
|
264
185
|
* value for that state.
|
|
265
186
|
*/
|
|
266
|
-
function getStates(category, ids, ctx) {
|
|
187
|
+
export function getStates(category, ids, ctx) {
|
|
267
188
|
const ans = {};
|
|
268
189
|
ids = ids.map(ResourceLocation.lengthen);
|
|
269
190
|
for (const id of ids) {
|
|
@@ -271,7 +192,7 @@ function getStates(category, ids, ctx) {
|
|
|
271
192
|
.query(ctx.doc, category, id)
|
|
272
193
|
.forEachMember((state, stateQuery) => {
|
|
273
194
|
const values = Object.keys(stateQuery.visibleMembers);
|
|
274
|
-
const set = ans[state]
|
|
195
|
+
const set = ans[state] ??= new Set();
|
|
275
196
|
const defaultValue = stateQuery.symbol?.relations?.default;
|
|
276
197
|
if (defaultValue) {
|
|
277
198
|
set.add(defaultValue.path[defaultValue.path.length - 1]);
|
|
@@ -283,10 +204,8 @@ function getStates(category, ids, ctx) {
|
|
|
283
204
|
}
|
|
284
205
|
return Object.fromEntries(Object.entries(ans).map(([k, v]) => [k, [...v]]));
|
|
285
206
|
}
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
function isIterable(value) {
|
|
207
|
+
export const binarySearch = externalBinarySearch;
|
|
208
|
+
export function isIterable(value) {
|
|
289
209
|
return !!value[Symbol.iterator];
|
|
290
210
|
}
|
|
291
|
-
exports.isIterable = isIterable;
|
|
292
211
|
//# sourceMappingURL=util.js.map
|
package/lib/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export * from './common';
|
|
2
|
-
export * from './node';
|
|
3
|
-
export * from './parser';
|
|
4
|
-
export * from './processor';
|
|
5
|
-
export * from './service';
|
|
6
|
-
export * from './source';
|
|
7
|
-
export * from './symbol';
|
|
1
|
+
export * from './common/index.js';
|
|
2
|
+
export * from './node/index.js';
|
|
3
|
+
export * from './parser/index.js';
|
|
4
|
+
export * from './processor/index.js';
|
|
5
|
+
export * from './service/index.js';
|
|
6
|
+
export * from './source/index.js';
|
|
7
|
+
export * from './symbol/index.js';
|
|
8
8
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.js
CHANGED
|
@@ -1,20 +1,8 @@
|
|
|
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("./common"), exports);
|
|
14
|
-
__exportStar(require("./node"), exports);
|
|
15
|
-
__exportStar(require("./parser"), exports);
|
|
16
|
-
__exportStar(require("./processor"), exports);
|
|
17
|
-
__exportStar(require("./service"), exports);
|
|
18
|
-
__exportStar(require("./source"), exports);
|
|
19
|
-
__exportStar(require("./symbol"), exports);
|
|
1
|
+
export * from './common/index.js';
|
|
2
|
+
export * from './node/index.js';
|
|
3
|
+
export * from './parser/index.js';
|
|
4
|
+
export * from './processor/index.js';
|
|
5
|
+
export * from './service/index.js';
|
|
6
|
+
export * from './source/index.js';
|
|
7
|
+
export * from './symbol/index.js';
|
|
20
8
|
//# sourceMappingURL=index.js.map
|
package/lib/node/AstNode.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Color, FormattableColor } from '../processor';
|
|
2
|
-
import { Range } from '../source';
|
|
3
|
-
import type { Symbol, SymbolTable } from '../symbol';
|
|
1
|
+
import type { Color, FormattableColor } from '../processor/index.js';
|
|
2
|
+
import { Range } from '../source/index.js';
|
|
3
|
+
import type { Symbol, SymbolTable } from '../symbol/index.js';
|
|
4
4
|
export interface AstNode {
|
|
5
5
|
readonly type: string;
|
|
6
6
|
readonly range: Range;
|
package/lib/node/AstNode.js
CHANGED
|
@@ -1,17 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.AstNode = void 0;
|
|
7
|
-
const binary_search_1 = __importDefault(require("binary-search"));
|
|
8
|
-
const source_1 = require("../source");
|
|
9
|
-
var AstNode;
|
|
1
|
+
import binarySearch from 'binary-search';
|
|
2
|
+
import { Range } from '../source/index.js';
|
|
3
|
+
export var AstNode;
|
|
10
4
|
(function (AstNode) {
|
|
11
5
|
/* istanbul ignore next */
|
|
12
6
|
function is(obj) {
|
|
13
7
|
return !!obj && typeof obj === 'object' && typeof obj.type === 'string' &&
|
|
14
|
-
|
|
8
|
+
Range.is(obj.range);
|
|
15
9
|
}
|
|
16
10
|
AstNode.is = is;
|
|
17
11
|
function setParents(node) {
|
|
@@ -28,8 +22,8 @@ var AstNode;
|
|
|
28
22
|
if (!node.children) {
|
|
29
23
|
return -1;
|
|
30
24
|
}
|
|
31
|
-
const comparator = typeof needle === 'number' ?
|
|
32
|
-
return (
|
|
25
|
+
const comparator = typeof needle === 'number' ? Range.compareOffset : Range.compare;
|
|
26
|
+
return binarySearch(node.children, needle, (a, b) => comparator(a.range, b, endInclusive));
|
|
33
27
|
}
|
|
34
28
|
AstNode.findChildIndex = findChildIndex;
|
|
35
29
|
/**
|
|
@@ -50,7 +44,7 @@ var AstNode;
|
|
|
50
44
|
}
|
|
51
45
|
let ans = -1;
|
|
52
46
|
for (const [i, childNode] of node.children.entries()) {
|
|
53
|
-
if (
|
|
47
|
+
if (Range.endsBefore(childNode.range, needle, endInclusive)) {
|
|
54
48
|
ans = i;
|
|
55
49
|
}
|
|
56
50
|
else {
|
|
@@ -69,7 +63,7 @@ var AstNode;
|
|
|
69
63
|
AstNode.findLastChild = findLastChild;
|
|
70
64
|
function findDeepestChild({ node, needle, endInclusive = false, predicate = () => true }) {
|
|
71
65
|
let last;
|
|
72
|
-
let head =
|
|
66
|
+
let head = Range.contains(node, needle, endInclusive) ? node : undefined;
|
|
73
67
|
while (head && predicate(head)) {
|
|
74
68
|
last = head;
|
|
75
69
|
head = findChild(head, needle, endInclusive);
|
|
@@ -78,7 +72,7 @@ var AstNode;
|
|
|
78
72
|
}
|
|
79
73
|
AstNode.findDeepestChild = findDeepestChild;
|
|
80
74
|
function findShallowestChild({ node, needle, endInclusive = false, predicate = () => true }) {
|
|
81
|
-
let head =
|
|
75
|
+
let head = Range.contains(node, needle, endInclusive) ? node : undefined;
|
|
82
76
|
while (head && !predicate(head)) {
|
|
83
77
|
head = findChild(head, needle, endInclusive);
|
|
84
78
|
}
|
|
@@ -104,5 +98,5 @@ var AstNode;
|
|
|
104
98
|
}
|
|
105
99
|
}
|
|
106
100
|
AstNode.getLocalsToLeaves = getLocalsToLeaves;
|
|
107
|
-
})(AstNode
|
|
101
|
+
})(AstNode || (AstNode = {}));
|
|
108
102
|
//# sourceMappingURL=AstNode.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { RangeLike } from '../source';
|
|
2
|
-
import type { AstNode } from './AstNode';
|
|
1
|
+
import type { RangeLike } from '../source/index.js';
|
|
2
|
+
import type { AstNode } from './AstNode.js';
|
|
3
3
|
export interface BooleanBaseNode extends AstNode {
|
|
4
4
|
readonly value?: boolean;
|
|
5
5
|
}
|
package/lib/node/BooleanNode.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.BooleanNode = void 0;
|
|
4
|
-
const source_1 = require("../source");
|
|
5
|
-
var BooleanNode;
|
|
1
|
+
import { Range } from '../source/index.js';
|
|
2
|
+
export var BooleanNode;
|
|
6
3
|
(function (BooleanNode) {
|
|
7
4
|
/* istanbul ignore next */
|
|
8
5
|
function is(obj) {
|
|
@@ -12,9 +9,9 @@ var BooleanNode;
|
|
|
12
9
|
function mock(range) {
|
|
13
10
|
return {
|
|
14
11
|
type: 'boolean',
|
|
15
|
-
range:
|
|
12
|
+
range: Range.get(range),
|
|
16
13
|
};
|
|
17
14
|
}
|
|
18
15
|
BooleanNode.mock = mock;
|
|
19
|
-
})(BooleanNode
|
|
16
|
+
})(BooleanNode || (BooleanNode = {}));
|
|
20
17
|
//# sourceMappingURL=BooleanNode.js.map
|
package/lib/node/CommentNode.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CommentNode = void 0;
|
|
4
|
-
var CommentNode;
|
|
1
|
+
export var CommentNode;
|
|
5
2
|
(function (CommentNode) {
|
|
6
3
|
function is(obj) {
|
|
7
4
|
return obj?.type === 'comment';
|
|
8
5
|
}
|
|
9
6
|
CommentNode.is = is;
|
|
10
|
-
})(CommentNode
|
|
7
|
+
})(CommentNode || (CommentNode = {}));
|
|
11
8
|
//# sourceMappingURL=CommentNode.js.map
|
package/lib/node/ErrorNode.d.ts
CHANGED
package/lib/node/ErrorNode.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ErrorNode = void 0;
|
|
4
|
-
var ErrorNode;
|
|
1
|
+
export var ErrorNode;
|
|
5
2
|
(function (ErrorNode) {
|
|
6
3
|
/* istanbul ignore next */
|
|
7
4
|
function is(obj) {
|
|
8
5
|
return obj.type === 'error';
|
|
9
6
|
}
|
|
10
7
|
ErrorNode.is = is;
|
|
11
|
-
})(ErrorNode
|
|
8
|
+
})(ErrorNode || (ErrorNode = {}));
|
|
12
9
|
//# sourceMappingURL=ErrorNode.js.map
|
package/lib/node/FileNode.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { AstNode } from '../node';
|
|
2
|
-
import type { LanguageError } from '../source';
|
|
3
|
-
import type { SymbolTable } from '../symbol';
|
|
1
|
+
import type { AstNode } from '../node/index.js';
|
|
2
|
+
import type { LanguageError } from '../source/index.js';
|
|
3
|
+
import type { SymbolTable } from '../symbol/index.js';
|
|
4
4
|
export interface FileNode<CN extends AstNode> extends AstNode {
|
|
5
5
|
readonly type: 'file';
|
|
6
6
|
readonly children: CN[];
|
package/lib/node/FileNode.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FileNode = void 0;
|
|
4
|
-
var FileNode;
|
|
1
|
+
export var FileNode;
|
|
5
2
|
(function (FileNode) {
|
|
6
3
|
function getErrors(node) {
|
|
7
4
|
return [...node.parserErrors, ...node.checkerErrors ?? [], ...node.linterErrors ?? []];
|
|
8
5
|
}
|
|
9
6
|
FileNode.getErrors = getErrors;
|
|
10
|
-
})(FileNode
|
|
7
|
+
})(FileNode || (FileNode = {}));
|
|
11
8
|
//# sourceMappingURL=FileNode.js.map
|
package/lib/node/FloatNode.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { RangeLike } from '../source';
|
|
2
|
-
import type { AstNode } from './AstNode';
|
|
1
|
+
import type { RangeLike } from '../source/index.js';
|
|
2
|
+
import type { AstNode } from './AstNode.js';
|
|
3
3
|
export interface FloatBaseNode extends AstNode {
|
|
4
4
|
readonly value: number;
|
|
5
5
|
}
|
package/lib/node/FloatNode.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.FloatNode = void 0;
|
|
4
|
-
const source_1 = require("../source");
|
|
5
|
-
var FloatNode;
|
|
1
|
+
import { Range } from '../source/index.js';
|
|
2
|
+
export var FloatNode;
|
|
6
3
|
(function (FloatNode) {
|
|
7
4
|
/* istanbul ignore next */
|
|
8
5
|
function is(obj) {
|
|
@@ -12,10 +9,10 @@ var FloatNode;
|
|
|
12
9
|
function mock(range) {
|
|
13
10
|
return {
|
|
14
11
|
type: 'float',
|
|
15
|
-
range:
|
|
12
|
+
range: Range.get(range),
|
|
16
13
|
value: 0,
|
|
17
14
|
};
|
|
18
15
|
}
|
|
19
16
|
FloatNode.mock = mock;
|
|
20
|
-
})(FloatNode
|
|
17
|
+
})(FloatNode || (FloatNode = {}));
|
|
21
18
|
//# sourceMappingURL=FloatNode.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { RangeLike } from '../source';
|
|
2
|
-
import type { AstNode } from './AstNode';
|
|
1
|
+
import type { RangeLike } from '../source/index.js';
|
|
2
|
+
import type { AstNode } from './AstNode.js';
|
|
3
3
|
export interface IntegerBaseNode extends AstNode {
|
|
4
4
|
readonly value: number;
|
|
5
5
|
}
|
package/lib/node/IntegerNode.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.IntegerNode = void 0;
|
|
4
|
-
const source_1 = require("../source");
|
|
5
|
-
var IntegerNode;
|
|
1
|
+
import { Range } from '../source/index.js';
|
|
2
|
+
export var IntegerNode;
|
|
6
3
|
(function (IntegerNode) {
|
|
7
4
|
function is(obj) {
|
|
8
5
|
return obj.type === 'integer';
|
|
@@ -11,10 +8,10 @@ var IntegerNode;
|
|
|
11
8
|
function mock(range) {
|
|
12
9
|
return {
|
|
13
10
|
type: 'integer',
|
|
14
|
-
range:
|
|
11
|
+
range: Range.get(range),
|
|
15
12
|
value: 0,
|
|
16
13
|
};
|
|
17
14
|
}
|
|
18
15
|
IntegerNode.mock = mock;
|
|
19
|
-
})(IntegerNode
|
|
16
|
+
})(IntegerNode || (IntegerNode = {}));
|
|
20
17
|
//# sourceMappingURL=IntegerNode.js.map
|
package/lib/node/ListNode.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Range } from '../source';
|
|
2
|
-
import type { AstNode } from './AstNode';
|
|
1
|
+
import type { Range } from '../source/index.js';
|
|
2
|
+
import type { AstNode } from './AstNode.js';
|
|
3
3
|
export interface ListNode<V extends AstNode> extends AstNode {
|
|
4
4
|
readonly children: ItemNode<V>[];
|
|
5
5
|
}
|
package/lib/node/ListNode.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ItemNode = void 0;
|
|
4
|
-
var ItemNode;
|
|
1
|
+
export var ItemNode;
|
|
5
2
|
(function (ItemNode) {
|
|
6
3
|
function is(node) {
|
|
7
4
|
return node?.type === 'item';
|
|
8
5
|
}
|
|
9
6
|
ItemNode.is = is;
|
|
10
|
-
})(ItemNode
|
|
7
|
+
})(ItemNode || (ItemNode = {}));
|
|
11
8
|
//# sourceMappingURL=ListNode.js.map
|