@spyglassmc/core 0.1.2 → 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.js +4 -10
- 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 -17
- package/lib/common/util.d.ts +15 -15
- package/lib/common/util.js +30 -77
- package/lib/index.d.ts +7 -7
- package/lib/index.js +7 -23
- 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 +3 -3
- package/lib/node/LiteralNode.js +4 -7
- 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 +5 -5
- package/lib/node/ResourceLocationNode.js +9 -12
- package/lib/node/Sequence.d.ts +2 -2
- package/lib/node/Sequence.js +4 -7
- package/lib/node/StringNode.d.ts +4 -4
- package/lib/node/StringNode.js +9 -12
- package/lib/node/SymbolNode.d.ts +3 -3
- package/lib/node/SymbolNode.js +4 -7
- package/lib/node/index.d.ts +15 -15
- package/lib/node/index.js +15 -31
- 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 -38
- 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 +5 -5
- package/lib/parser/string.js +36 -42
- package/lib/parser/symbol.d.ts +3 -3
- package/lib/parser/symbol.js +3 -7
- package/lib/parser/util.d.ts +5 -5
- package/lib/parser/util.js +38 -56
- 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 +4 -4
- package/lib/processor/checker/builtin.js +19 -30
- package/lib/processor/checker/index.d.ts +2 -2
- package/lib/processor/checker/index.js +2 -31
- 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 -31
- 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 +46 -62
- package/lib/processor/completer/index.d.ts +2 -2
- package/lib/processor/completer/index.js +2 -31
- 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 -31
- package/lib/processor/index.d.ts +9 -9
- package/lib/processor/index.js +9 -25
- 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 +20 -24
- package/lib/processor/linter/builtin.d.ts +3 -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 -31
- 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 +32 -56
- package/lib/service/Config.d.ts +11 -12
- package/lib/service/Config.js +50 -45
- package/lib/service/Context.d.ts +13 -13
- package/lib/service/Context.js +29 -32
- package/lib/service/Dependency.js +2 -5
- package/lib/service/Downloader.d.ts +10 -40
- package/lib/service/Downloader.js +37 -110
- package/lib/service/ErrorReporter.d.ts +2 -2
- package/lib/service/ErrorReporter.js +10 -14
- package/lib/service/FileService.d.ts +16 -14
- package/lib/service/FileService.js +55 -92
- 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 +47 -51
- package/lib/service/Project.js +199 -239
- package/lib/service/Service.d.ts +17 -27
- package/lib/service/Service.js +37 -43
- 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 +15 -45
- package/lib/service/fileUtil.js +38 -143
- package/lib/service/index.d.ts +17 -17
- package/lib/service/index.js +17 -35
- 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 +2 -5
- 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 +3 -3
- package/lib/source/Source.js +28 -29
- package/lib/source/index.d.ts +8 -8
- package/lib/source/index.js +8 -24
- package/lib/symbol/Symbol.d.ts +2 -2
- package/lib/symbol/Symbol.js +49 -65
- package/lib/symbol/SymbolUtil.d.ts +22 -25
- package/lib/symbol/SymbolUtil.js +150 -151
- 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 -19
- package/package.json +7 -4
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.Delay = exports.Singleton = 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
31
|
* This is a decorator for methods. Decorated methods will return the same non-`undefined` value no matter what.
|
|
43
32
|
*/
|
|
44
|
-
const Singleton = (_target, _key, descripter) => {
|
|
33
|
+
export const Singleton = (_target, _key, descripter) => {
|
|
45
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 value
|
|
38
|
+
return value ??= decoratedMethod.apply(this, args);
|
|
50
39
|
};
|
|
51
40
|
return descripter;
|
|
52
41
|
};
|
|
53
|
-
exports.Singleton = Singleton;
|
|
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.Singleton = Singleton;
|
|
|
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,8 +64,7 @@ function Delay(ms, getKey = args => args[0]) {
|
|
|
76
64
|
return descripter;
|
|
77
65
|
};
|
|
78
66
|
}
|
|
79
|
-
|
|
80
|
-
var ResourceLocation;
|
|
67
|
+
export var ResourceLocation;
|
|
81
68
|
(function (ResourceLocation) {
|
|
82
69
|
/**
|
|
83
70
|
* The prefix for tags.
|
|
@@ -107,45 +94,19 @@ var ResourceLocation;
|
|
|
107
94
|
return value.replace(/^(?:minecraft)?:/, '');
|
|
108
95
|
}
|
|
109
96
|
ResourceLocation.shorten = shorten;
|
|
110
|
-
})(ResourceLocation
|
|
97
|
+
})(ResourceLocation || (ResourceLocation = {}));
|
|
111
98
|
/**
|
|
112
99
|
* @returns The string value decoded from the buffer according to UTF-8.
|
|
113
100
|
* Byte order mark is correctly removed.
|
|
114
101
|
*/
|
|
115
|
-
function bufferToString(buffer) {
|
|
116
|
-
const ans =
|
|
117
|
-
if (ans.charCodeAt(0) === 0xFEFF) {
|
|
118
|
-
|
|
119
|
-
}
|
|
102
|
+
export function bufferToString(buffer) {
|
|
103
|
+
const ans = new TextDecoder().decode(buffer);
|
|
104
|
+
// if (ans.charCodeAt(0) === 0xFEFF) {
|
|
105
|
+
// return ans.slice(1)
|
|
106
|
+
// }
|
|
120
107
|
return ans;
|
|
121
108
|
}
|
|
122
|
-
|
|
123
|
-
function stringToBase64(str) {
|
|
124
|
-
return Buffer.from(str).toString('base64');
|
|
125
|
-
}
|
|
126
|
-
exports.stringToBase64 = stringToBase64;
|
|
127
|
-
function base64ToString(base64) {
|
|
128
|
-
return Buffer.from(base64, 'base64').toString('utf-8');
|
|
129
|
-
}
|
|
130
|
-
exports.base64ToString = base64ToString;
|
|
131
|
-
/**
|
|
132
|
-
* @throws
|
|
133
|
-
*/
|
|
134
|
-
function getSha1(data) {
|
|
135
|
-
const hash = crypto_1.default.createHash('sha1');
|
|
136
|
-
hash.update(data);
|
|
137
|
-
return hash.digest('hex');
|
|
138
|
-
}
|
|
139
|
-
exports.getSha1 = getSha1;
|
|
140
|
-
function isErrorCode(e, code) {
|
|
141
|
-
return e instanceof Error && e.code === code;
|
|
142
|
-
}
|
|
143
|
-
exports.isErrorCode = isErrorCode;
|
|
144
|
-
function isEnoent(e) {
|
|
145
|
-
return isErrorCode(e, 'ENOENT');
|
|
146
|
-
}
|
|
147
|
-
exports.isEnoent = isEnoent;
|
|
148
|
-
var Arrayable;
|
|
109
|
+
export var Arrayable;
|
|
149
110
|
(function (Arrayable) {
|
|
150
111
|
function is(value, isT) {
|
|
151
112
|
return Array.isArray(value)
|
|
@@ -157,15 +118,15 @@ var Arrayable;
|
|
|
157
118
|
return Array.isArray(value) ? value : [value];
|
|
158
119
|
}
|
|
159
120
|
Arrayable.toArray = toArray;
|
|
160
|
-
})(Arrayable
|
|
161
|
-
var TypePredicates;
|
|
121
|
+
})(Arrayable || (Arrayable = {}));
|
|
122
|
+
export var TypePredicates;
|
|
162
123
|
(function (TypePredicates) {
|
|
163
124
|
function isString(value) {
|
|
164
125
|
return typeof value === 'string';
|
|
165
126
|
}
|
|
166
127
|
TypePredicates.isString = isString;
|
|
167
|
-
})(TypePredicates
|
|
168
|
-
function promisifyAsyncIterable(iterable, joiner) {
|
|
128
|
+
})(TypePredicates || (TypePredicates = {}));
|
|
129
|
+
export function promisifyAsyncIterable(iterable, joiner) {
|
|
169
130
|
return (async () => {
|
|
170
131
|
const chunks = [];
|
|
171
132
|
for await (const chunk of iterable) {
|
|
@@ -174,19 +135,14 @@ function promisifyAsyncIterable(iterable, joiner) {
|
|
|
174
135
|
return joiner(chunks);
|
|
175
136
|
})();
|
|
176
137
|
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
exports.zip = (0, util_1.promisify)(zlib_1.default.gzip);
|
|
180
|
-
async function parseGzippedJson(buffer) {
|
|
181
|
-
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)));
|
|
182
140
|
}
|
|
183
|
-
|
|
184
|
-
function isObject(value) {
|
|
141
|
+
export function isObject(value) {
|
|
185
142
|
return !!value && typeof value === 'object' && !Array.isArray(value);
|
|
186
143
|
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
const ans = (0, rfdc_1.default)()(a);
|
|
144
|
+
export function merge(a, b) {
|
|
145
|
+
const ans = rfdc()(a);
|
|
190
146
|
for (const [key, value] of Object.entries(b)) {
|
|
191
147
|
if (isObject(ans[key]) && isObject(value)) {
|
|
192
148
|
ans[key] = merge(ans[key], value);
|
|
@@ -200,8 +156,7 @@ function merge(a, b) {
|
|
|
200
156
|
}
|
|
201
157
|
return ans;
|
|
202
158
|
}
|
|
203
|
-
|
|
204
|
-
var Lazy;
|
|
159
|
+
export var Lazy;
|
|
205
160
|
(function (Lazy) {
|
|
206
161
|
const LazyDiscriminator = Symbol('LazyDiscriminator');
|
|
207
162
|
function create(getter) {
|
|
@@ -223,13 +178,13 @@ var Lazy;
|
|
|
223
178
|
return isUnresolved(lazy) ? lazy.value = lazy.getter() : lazy;
|
|
224
179
|
}
|
|
225
180
|
Lazy.resolve = resolve;
|
|
226
|
-
})(Lazy
|
|
181
|
+
})(Lazy || (Lazy = {}));
|
|
227
182
|
/**
|
|
228
183
|
* @param ids An array of block/fluid IDs, with or without the namespace.
|
|
229
184
|
* @returns A map from state names to the corresponding sets of values. The first element in the value array is the default
|
|
230
185
|
* value for that state.
|
|
231
186
|
*/
|
|
232
|
-
function getStates(category, ids, ctx) {
|
|
187
|
+
export function getStates(category, ids, ctx) {
|
|
233
188
|
const ans = {};
|
|
234
189
|
ids = ids.map(ResourceLocation.lengthen);
|
|
235
190
|
for (const id of ids) {
|
|
@@ -237,7 +192,7 @@ function getStates(category, ids, ctx) {
|
|
|
237
192
|
.query(ctx.doc, category, id)
|
|
238
193
|
.forEachMember((state, stateQuery) => {
|
|
239
194
|
const values = Object.keys(stateQuery.visibleMembers);
|
|
240
|
-
const set = ans[state]
|
|
195
|
+
const set = ans[state] ??= new Set();
|
|
241
196
|
const defaultValue = stateQuery.symbol?.relations?.default;
|
|
242
197
|
if (defaultValue) {
|
|
243
198
|
set.add(defaultValue.path[defaultValue.path.length - 1]);
|
|
@@ -249,10 +204,8 @@ function getStates(category, ids, ctx) {
|
|
|
249
204
|
}
|
|
250
205
|
return Object.fromEntries(Object.entries(ans).map(([k, v]) => [k, [...v]]));
|
|
251
206
|
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
function isIterable(value) {
|
|
207
|
+
export const binarySearch = externalBinarySearch;
|
|
208
|
+
export function isIterable(value) {
|
|
255
209
|
return !!value[Symbol.iterator];
|
|
256
210
|
}
|
|
257
|
-
exports.isIterable = isIterable;
|
|
258
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,24 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./common"), exports);
|
|
18
|
-
__exportStar(require("./node"), exports);
|
|
19
|
-
__exportStar(require("./parser"), exports);
|
|
20
|
-
__exportStar(require("./processor"), exports);
|
|
21
|
-
__exportStar(require("./service"), exports);
|
|
22
|
-
__exportStar(require("./source"), exports);
|
|
23
|
-
__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';
|
|
24
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
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { ColorTokenType } from '../processor';
|
|
2
|
-
import type { RangeLike } from '../source';
|
|
3
|
-
import type { AstNode } from './AstNode';
|
|
1
|
+
import type { ColorTokenType } from '../processor/index.js';
|
|
2
|
+
import type { RangeLike } from '../source/index.js';
|
|
3
|
+
import type { AstNode } from './AstNode.js';
|
|
4
4
|
export interface LiteralOptions {
|
|
5
5
|
pool: string[];
|
|
6
6
|
colorTokenType?: ColorTokenType;
|
package/lib/node/LiteralNode.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.LiteralNode = void 0;
|
|
4
|
-
const source_1 = require("../source");
|
|
5
|
-
var LiteralNode;
|
|
1
|
+
import { Range } from '../source/index.js';
|
|
2
|
+
export var LiteralNode;
|
|
6
3
|
(function (LiteralNode) {
|
|
7
4
|
/* istanbul ignore next */
|
|
8
5
|
function is(obj) {
|
|
@@ -12,11 +9,11 @@ var LiteralNode;
|
|
|
12
9
|
function mock(range, options) {
|
|
13
10
|
return {
|
|
14
11
|
type: 'literal',
|
|
15
|
-
range:
|
|
12
|
+
range: Range.get(range),
|
|
16
13
|
options,
|
|
17
14
|
value: '',
|
|
18
15
|
};
|
|
19
16
|
}
|
|
20
17
|
LiteralNode.mock = mock;
|
|
21
|
-
})(LiteralNode
|
|
18
|
+
})(LiteralNode || (LiteralNode = {}));
|
|
22
19
|
//# sourceMappingURL=LiteralNode.js.map
|
package/lib/node/LongNode.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 LongBaseNode extends AstNode {
|
|
4
4
|
readonly value: bigint;
|
|
5
5
|
}
|
package/lib/node/LongNode.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.LongNode = void 0;
|
|
4
|
-
const source_1 = require("../source");
|
|
5
|
-
var LongNode;
|
|
1
|
+
import { Range } from '../source/index.js';
|
|
2
|
+
export var LongNode;
|
|
6
3
|
(function (LongNode) {
|
|
7
4
|
function is(obj) {
|
|
8
5
|
return obj.type === 'long';
|
|
@@ -11,10 +8,10 @@ var LongNode;
|
|
|
11
8
|
function mock(range) {
|
|
12
9
|
return {
|
|
13
10
|
type: 'long',
|
|
14
|
-
range:
|
|
11
|
+
range: Range.get(range),
|
|
15
12
|
value: 0n,
|
|
16
13
|
};
|
|
17
14
|
}
|
|
18
15
|
LongNode.mock = mock;
|
|
19
|
-
})(LongNode
|
|
16
|
+
})(LongNode || (LongNode = {}));
|
|
20
17
|
//# sourceMappingURL=LongNode.js.map
|
package/lib/node/RecordNode.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 RecordBaseNode<K extends AstNode, V extends AstNode> extends AstNode {
|
|
4
4
|
readonly children: PairNode<K, V>[];
|
|
5
5
|
}
|
package/lib/node/RecordNode.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PairNode = void 0;
|
|
4
|
-
var PairNode;
|
|
1
|
+
export var PairNode;
|
|
5
2
|
(function (PairNode) {
|
|
6
3
|
function is(node) {
|
|
7
4
|
return node?.type === 'pair';
|
|
8
5
|
}
|
|
9
6
|
PairNode.is = is;
|
|
10
|
-
})(PairNode
|
|
7
|
+
})(PairNode || (PairNode = {}));
|
|
11
8
|
//# sourceMappingURL=RecordNode.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { FullResourceLocation } from '../common';
|
|
2
|
-
import { ResourceLocation } from '../common';
|
|
3
|
-
import type { RangeLike } from '../source';
|
|
4
|
-
import type { ResourceLocationCategory, SymbolAccessType, SymbolUsageType, TaggableResourceLocationCategory } from '../symbol';
|
|
5
|
-
import type { AstNode } from './AstNode';
|
|
1
|
+
import type { FullResourceLocation } from '../common/index.js';
|
|
2
|
+
import { ResourceLocation } from '../common/index.js';
|
|
3
|
+
import type { RangeLike } from '../source/index.js';
|
|
4
|
+
import type { ResourceLocationCategory, SymbolAccessType, SymbolUsageType, TaggableResourceLocationCategory } from '../symbol/index.js';
|
|
5
|
+
import type { AstNode } from './AstNode.js';
|
|
6
6
|
export declare type ResourceLocationOptions = {
|
|
7
7
|
accessType?: SymbolAccessType;
|
|
8
8
|
isPredicate?: boolean;
|