@spyglassmc/core 0.4.1 → 0.4.3
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/lib/common/Dev.d.ts +7 -7
- package/lib/common/Dev.js +20 -14
- package/lib/common/ReadonlyProxy.d.ts +9 -6
- package/lib/common/ReadonlyProxy.js +6 -4
- package/lib/common/StateProxy.d.ts +11 -11
- package/lib/common/StateProxy.js +21 -14
- package/lib/common/externals/NodeJsExternals.js +11 -3
- package/lib/common/externals/downloader.d.ts +8 -8
- package/lib/common/externals/downloader.js +12 -8
- package/lib/common/externals/index.d.ts +3 -3
- package/lib/common/util.d.ts +23 -21
- package/lib/common/util.js +13 -2
- package/lib/node/AstNode.d.ts +1 -1
- package/lib/node/AstNode.js +3 -1
- package/lib/node/CommentNode.d.ts +4 -4
- package/lib/node/CommentNode.js +6 -4
- package/lib/node/ResourceLocationNode.d.ts +1 -1
- package/lib/node/ResourceLocationNode.js +6 -8
- package/lib/node/StringNode.d.ts +3 -3
- package/lib/node/StringNode.js +4 -1
- package/lib/parser/Parser.d.ts +5 -5
- package/lib/parser/float.d.ts +1 -1
- package/lib/parser/integer.d.ts +1 -1
- package/lib/parser/long.d.ts +1 -1
- package/lib/parser/resourceLocation.js +1 -1
- package/lib/parser/string.js +4 -1
- package/lib/parser/util.d.ts +11 -7
- package/lib/parser/util.js +17 -2
- package/lib/processor/ColorInfoProvider.d.ts +3 -3
- package/lib/processor/ColorInfoProvider.js +4 -2
- package/lib/processor/InlayHintProvider.d.ts +4 -2
- package/lib/processor/SignatureHelpProvider.d.ts +1 -1
- package/lib/processor/binder/Binder.d.ts +9 -9
- package/lib/processor/binder/Binder.js +18 -12
- package/lib/processor/binder/builtin.d.ts +2 -2
- package/lib/processor/binder/builtin.js +3 -1
- package/lib/processor/binder/index.d.ts +1 -1
- package/lib/processor/binder/index.js +1 -1
- package/lib/processor/checker/Checker.d.ts +3 -3
- package/lib/processor/checker/builtin.d.ts +1 -1
- package/lib/processor/checker/builtin.js +2 -1
- package/lib/processor/colorizer/Colorizer.d.ts +3 -3
- package/lib/processor/completer/Completer.d.ts +1 -1
- package/lib/processor/completer/builtin.js +8 -4
- package/lib/processor/formatter/Formatter.d.ts +1 -1
- package/lib/processor/formatter/Formatter.js +3 -1
- package/lib/processor/linter/Linter.d.ts +1 -1
- package/lib/processor/util.d.ts +1 -1
- package/lib/service/CacheService.d.ts +1 -1
- package/lib/service/CacheService.js +2 -2
- package/lib/service/Config.d.ts +9 -9
- package/lib/service/Config.js +17 -3
- package/lib/service/Dependency.d.ts +3 -3
- package/lib/service/FileService.d.ts +3 -3
- package/lib/service/FileService.js +40 -32
- package/lib/service/Project.d.ts +5 -5
- package/lib/service/Project.js +9 -5
- package/lib/service/Service.js +12 -3
- package/lib/service/SymbolRegistrar.d.ts +1 -1
- package/lib/service/UriProcessor.d.ts +3 -3
- package/lib/service/fileUtil.d.ts +3 -2
- package/lib/service/fileUtil.js +4 -0
- package/lib/source/IndexMap.d.ts +1 -1
- package/lib/source/IndexMap.js +7 -7
- package/lib/source/LanguageError.d.ts +4 -4
- package/lib/source/LanguageError.js +9 -6
- package/lib/source/Location.d.ts +1 -1
- package/lib/source/Offset.d.ts +1 -1
- package/lib/source/Range.d.ts +1 -1
- package/lib/source/Source.d.ts +12 -10
- package/lib/source/Source.js +16 -9
- package/lib/symbol/Symbol.d.ts +16 -16
- package/lib/symbol/Symbol.js +15 -9
- package/lib/symbol/SymbolUtil.d.ts +4 -4
- package/lib/symbol/SymbolUtil.js +4 -3
- package/package.json +5 -3
package/lib/common/Dev.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export declare
|
|
2
|
-
assertDefined<T>(value: T): asserts value is Exclude<T, undefined>;
|
|
3
|
-
assertNever(value: never): never;
|
|
4
|
-
assertTrue(value: boolean, message: string): void;
|
|
1
|
+
export declare namespace Dev {
|
|
2
|
+
function assertDefined<T>(value: T): asserts value is Exclude<T, undefined>;
|
|
3
|
+
function assertNever(value: never): never;
|
|
4
|
+
function assertTrue(value: boolean, message: string): void;
|
|
5
5
|
/**
|
|
6
6
|
* @returns An estimate of the memory taken by the given value, assuming objects are stored as array-like structures instead of dictionaries in the V8 engine.
|
|
7
7
|
*/
|
|
8
|
-
estimateMemoryUsage(value: unknown): number;
|
|
9
|
-
stringify(value: unknown): string;
|
|
10
|
-
}
|
|
8
|
+
function estimateMemoryUsage(value: unknown): number;
|
|
9
|
+
function stringify(value: unknown): string;
|
|
10
|
+
}
|
|
11
11
|
//# sourceMappingURL=Dev.d.ts.map
|
package/lib/common/Dev.js
CHANGED
|
@@ -1,21 +1,25 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
1
|
+
export var Dev;
|
|
2
|
+
(function (Dev) {
|
|
3
|
+
function assertDefined(value) {
|
|
3
4
|
if (value === undefined) {
|
|
4
5
|
throw new Error(`'${Dev.stringify(value)}' is 'undefined'`);
|
|
5
6
|
}
|
|
6
|
-
}
|
|
7
|
-
|
|
7
|
+
}
|
|
8
|
+
Dev.assertDefined = assertDefined;
|
|
9
|
+
function assertNever(value) {
|
|
8
10
|
throw new Error(`'${Dev.stringify(value)}' is not of type 'never'`);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
+
}
|
|
12
|
+
Dev.assertNever = assertNever;
|
|
13
|
+
function assertTrue(value, message) {
|
|
11
14
|
if (!value) {
|
|
12
15
|
throw new Error(`Assertion failed: ${message}. '${Dev.stringify(value)}' should be true.`);
|
|
13
16
|
}
|
|
14
|
-
}
|
|
17
|
+
}
|
|
18
|
+
Dev.assertTrue = assertTrue;
|
|
15
19
|
/**
|
|
16
20
|
* @returns An estimate of the memory taken by the given value, assuming objects are stored as array-like structures instead of dictionaries in the V8 engine.
|
|
17
21
|
*/
|
|
18
|
-
estimateMemoryUsage(value) {
|
|
22
|
+
function estimateMemoryUsage(value) {
|
|
19
23
|
const ByteToBits = 8;
|
|
20
24
|
const PointerSize = 8;
|
|
21
25
|
let ans = 0;
|
|
@@ -26,8 +30,8 @@ export const Dev = Object.freeze({
|
|
|
26
30
|
switch (typeof current) {
|
|
27
31
|
case 'bigint': {
|
|
28
32
|
const bits = Math.ceil(Math.log2(Number(current)));
|
|
29
|
-
ans +=
|
|
30
|
-
|
|
33
|
+
ans += (2 + Math.ceil(bits / (ByteToBits * PointerSize))) *
|
|
34
|
+
PointerSize; // https://stackoverflow.com/a/54298760
|
|
31
35
|
break;
|
|
32
36
|
}
|
|
33
37
|
case 'boolean':
|
|
@@ -59,8 +63,9 @@ export const Dev = Object.freeze({
|
|
|
59
63
|
}
|
|
60
64
|
}
|
|
61
65
|
return ans;
|
|
62
|
-
}
|
|
63
|
-
|
|
66
|
+
}
|
|
67
|
+
Dev.estimateMemoryUsage = estimateMemoryUsage;
|
|
68
|
+
function stringify(value) {
|
|
64
69
|
if (value && typeof value === 'object') {
|
|
65
70
|
try {
|
|
66
71
|
const seen = new Set();
|
|
@@ -88,6 +93,7 @@ export const Dev = Object.freeze({
|
|
|
88
93
|
else {
|
|
89
94
|
return `${value}`;
|
|
90
95
|
}
|
|
91
|
-
}
|
|
92
|
-
|
|
96
|
+
}
|
|
97
|
+
Dev.stringify = stringify;
|
|
98
|
+
})(Dev || (Dev = {}));
|
|
93
99
|
//# sourceMappingURL=Dev.js.map
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
readonly [K in keyof T]:
|
|
1
|
+
type DeepReadonlyValue<T> = T extends object ? DeepReadonly<T> : T;
|
|
2
|
+
export type DeepReadonly<T extends object> = {
|
|
3
|
+
readonly [K in keyof T]: DeepReadonlyValue<T[K]>;
|
|
4
4
|
};
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
}
|
|
5
|
+
export type ReadWrite<T extends object> = {
|
|
6
|
+
-readonly [K in keyof T]: T[K];
|
|
7
|
+
};
|
|
8
|
+
export declare namespace ReadonlyProxy {
|
|
9
|
+
function create<T extends object>(obj: T): DeepReadonly<T>;
|
|
10
|
+
}
|
|
8
11
|
export {};
|
|
9
12
|
//# sourceMappingURL=ReadonlyProxy.d.ts.map
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { emplaceMap, isObject } from './util.js';
|
|
2
|
-
export
|
|
3
|
-
|
|
2
|
+
export var ReadonlyProxy;
|
|
3
|
+
(function (ReadonlyProxy) {
|
|
4
|
+
function create(obj) {
|
|
4
5
|
return new Proxy(obj, new ReadonlyProxyHandler());
|
|
5
|
-
}
|
|
6
|
-
|
|
6
|
+
}
|
|
7
|
+
ReadonlyProxy.create = create;
|
|
8
|
+
})(ReadonlyProxy || (ReadonlyProxy = {}));
|
|
7
9
|
class ReadonlyProxyHandler {
|
|
8
10
|
map = new Map();
|
|
9
11
|
get(target, p, receiver) {
|
|
@@ -3,7 +3,7 @@ declare const Is: unique symbol;
|
|
|
3
3
|
declare const Origin: unique symbol;
|
|
4
4
|
declare const Redo: unique symbol;
|
|
5
5
|
declare const Undo: unique symbol;
|
|
6
|
-
|
|
6
|
+
type Wrap<T> = T extends object ? StateProxy<T> : T;
|
|
7
7
|
/**
|
|
8
8
|
* A proxy wrapped around an arbitrary object value.
|
|
9
9
|
* You can access and mutate the value as normal, but you also have the ability to revert all changes ever since the
|
|
@@ -12,7 +12,7 @@ declare type Wrap<T> = T extends object ? StateProxy<T> : T;
|
|
|
12
12
|
* A new proxy can be branched off of an existing proxy using {@link StateProxy.branchOff} to have finer control
|
|
13
13
|
* over what changes to be reverted.
|
|
14
14
|
*/
|
|
15
|
-
export
|
|
15
|
+
export type StateProxy<T extends object> = {
|
|
16
16
|
[K in keyof T]: Wrap<T[K]>;
|
|
17
17
|
} & {
|
|
18
18
|
[BranchOff]: () => StateProxy<T>;
|
|
@@ -21,15 +21,15 @@ export declare type StateProxy<T extends object> = {
|
|
|
21
21
|
[Redo]: () => void;
|
|
22
22
|
[Undo]: () => void;
|
|
23
23
|
};
|
|
24
|
-
export declare
|
|
25
|
-
branchOff<T extends object>(proxy: StateProxy<T>): StateProxy<T>;
|
|
26
|
-
create<
|
|
24
|
+
export declare namespace StateProxy {
|
|
25
|
+
function branchOff<T extends object>(proxy: StateProxy<T>): StateProxy<T>;
|
|
26
|
+
function create<T extends object>(obj: T): T extends StateProxy<any> ? void & {
|
|
27
27
|
_cannotCreateProxyFromProxy: never;
|
|
28
|
-
} : StateProxy<
|
|
29
|
-
dereference<
|
|
30
|
-
is(obj: any): obj is StateProxy<object>;
|
|
31
|
-
redoChanges(proxy: StateProxy<object>): void;
|
|
32
|
-
undoChanges(proxy: StateProxy<object>): void;
|
|
33
|
-
}
|
|
28
|
+
} : StateProxy<T>;
|
|
29
|
+
function dereference<T extends object>(value: StateProxy<T> | T): T;
|
|
30
|
+
function is(obj: any): obj is StateProxy<object>;
|
|
31
|
+
function redoChanges(proxy: StateProxy<object>): void;
|
|
32
|
+
function undoChanges(proxy: StateProxy<object>): void;
|
|
33
|
+
}
|
|
34
34
|
export {};
|
|
35
35
|
//# sourceMappingURL=StateProxy.d.ts.map
|
package/lib/common/StateProxy.js
CHANGED
|
@@ -5,29 +5,36 @@ const Is = Symbol('IsStateProxy');
|
|
|
5
5
|
const Origin = Symbol('OriginState');
|
|
6
6
|
const Redo = Symbol('RedoStateChanges');
|
|
7
7
|
const Undo = Symbol('UndoStateChanges');
|
|
8
|
-
export
|
|
9
|
-
|
|
8
|
+
export var StateProxy;
|
|
9
|
+
(function (StateProxy) {
|
|
10
|
+
function branchOff(proxy) {
|
|
10
11
|
return proxy[BranchOff]();
|
|
11
|
-
}
|
|
12
|
-
|
|
12
|
+
}
|
|
13
|
+
StateProxy.branchOff = branchOff;
|
|
14
|
+
function create(obj) {
|
|
13
15
|
if (StateProxy.is(obj)) {
|
|
14
16
|
throw new TypeError('Cannot create a proxy over a proxy. You might want to use branchOff instead.');
|
|
15
17
|
}
|
|
16
18
|
return _createStateProxy(obj, new Operations());
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
+
}
|
|
20
|
+
StateProxy.create = create;
|
|
21
|
+
function dereference(value) {
|
|
19
22
|
return StateProxy.is(value) ? value[Origin] : value;
|
|
20
|
-
}
|
|
21
|
-
|
|
23
|
+
}
|
|
24
|
+
StateProxy.dereference = dereference;
|
|
25
|
+
function is(obj) {
|
|
22
26
|
return obj?.[Is];
|
|
23
|
-
}
|
|
24
|
-
|
|
27
|
+
}
|
|
28
|
+
StateProxy.is = is;
|
|
29
|
+
function redoChanges(proxy) {
|
|
25
30
|
proxy[Redo]();
|
|
26
|
-
}
|
|
27
|
-
|
|
31
|
+
}
|
|
32
|
+
StateProxy.redoChanges = redoChanges;
|
|
33
|
+
function undoChanges(proxy) {
|
|
28
34
|
proxy[Undo]();
|
|
29
|
-
}
|
|
30
|
-
|
|
35
|
+
}
|
|
36
|
+
StateProxy.undoChanges = undoChanges;
|
|
37
|
+
})(StateProxy || (StateProxy = {}));
|
|
31
38
|
class StateProxyHandler {
|
|
32
39
|
rootOps;
|
|
33
40
|
map = new Map();
|
|
@@ -68,7 +68,10 @@ export const NodeJsExternals = {
|
|
|
68
68
|
return fsp.chmod(toFsPathLike(location), mode);
|
|
69
69
|
},
|
|
70
70
|
async getAllFiles(location) {
|
|
71
|
-
return (await globby(toPath(location) + '**/*', {
|
|
71
|
+
return (await globby(toPath(location) + '**/*', {
|
|
72
|
+
absolute: true,
|
|
73
|
+
dot: true,
|
|
74
|
+
})).map(uriFromPath);
|
|
72
75
|
},
|
|
73
76
|
async mkdir(location, options) {
|
|
74
77
|
return void (await fsp.mkdir(toFsPathLike(location), options));
|
|
@@ -111,8 +114,13 @@ Object.freeze(NodeJsExternals);
|
|
|
111
114
|
* @returns A {@link fs.PathLike}.
|
|
112
115
|
*/
|
|
113
116
|
function toFsPathLike(path) {
|
|
117
|
+
if (path instanceof Uri) {
|
|
118
|
+
// Convert WHATWG URL to string so that it will be converted
|
|
119
|
+
// to Node.js URL by the next if-block.
|
|
120
|
+
path = path.toString();
|
|
121
|
+
}
|
|
114
122
|
if (typeof path === 'string' && path.startsWith('file:')) {
|
|
115
|
-
return new
|
|
123
|
+
return new url.URL(path);
|
|
116
124
|
}
|
|
117
125
|
return path;
|
|
118
126
|
}
|
|
@@ -122,7 +130,7 @@ function toPath(path) {
|
|
|
122
130
|
}
|
|
123
131
|
return uriToPath(path);
|
|
124
132
|
}
|
|
125
|
-
const uriToPath = (uri) => url.fileURLToPath(uri);
|
|
133
|
+
const uriToPath = (uri) => url.fileURLToPath(uri instanceof Uri ? new url.URL(uri.toString()) : uri);
|
|
126
134
|
const uriFromPath = (path) => url.pathToFileURL(path).toString();
|
|
127
135
|
class ChokidarWatcherWrapper extends EventEmitter {
|
|
128
136
|
#watcher;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
export declare
|
|
4
|
-
is(value: string): value is
|
|
5
|
-
}
|
|
1
|
+
type RemoteUriProtocol = 'http:' | 'https:';
|
|
2
|
+
export type RemoteUriString = `${RemoteUriProtocol}${string}`;
|
|
3
|
+
export declare namespace RemoteUriString {
|
|
4
|
+
function is(value: string): value is RemoteUriString;
|
|
5
|
+
}
|
|
6
6
|
export interface ExternalDownloaderOptions {
|
|
7
7
|
/**
|
|
8
8
|
* Use an string array to set multiple values to the header.
|
|
@@ -16,9 +16,9 @@ export interface ExternalDownloader {
|
|
|
16
16
|
*/
|
|
17
17
|
get(uri: RemoteUriString, options?: ExternalDownloaderOptions): Promise<Uint8Array>;
|
|
18
18
|
}
|
|
19
|
-
export declare
|
|
20
|
-
mock(options: ExternalDownloaderMockOptions): ExternalDownloader;
|
|
21
|
-
}
|
|
19
|
+
export declare namespace ExternalDownloader {
|
|
20
|
+
function mock(options: ExternalDownloaderMockOptions): ExternalDownloader;
|
|
21
|
+
}
|
|
22
22
|
interface ExternalDownloaderMockOptions {
|
|
23
23
|
/**
|
|
24
24
|
* A record from URIs to fixture data. The {@link ExternalDownloader.get} only returns a {@link Uint8Array},
|
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
1
|
+
export var RemoteUriString;
|
|
2
|
+
(function (RemoteUriString) {
|
|
3
|
+
function is(value) {
|
|
3
4
|
return value.startsWith('http:') || value.startsWith('https:');
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
}
|
|
6
|
+
RemoteUriString.is = is;
|
|
7
|
+
})(RemoteUriString || (RemoteUriString = {}));
|
|
8
|
+
export var ExternalDownloader;
|
|
9
|
+
(function (ExternalDownloader) {
|
|
10
|
+
function mock(options) {
|
|
8
11
|
return new ExternalDownloaderMock(options);
|
|
9
|
-
}
|
|
10
|
-
|
|
12
|
+
}
|
|
13
|
+
ExternalDownloader.mock = mock;
|
|
14
|
+
})(ExternalDownloader || (ExternalDownloader = {}));
|
|
11
15
|
class ExternalDownloaderMock {
|
|
12
16
|
options;
|
|
13
17
|
constructor(options) {
|
|
@@ -31,7 +31,7 @@ export interface DecompressedFile {
|
|
|
31
31
|
path: string;
|
|
32
32
|
type: string;
|
|
33
33
|
}
|
|
34
|
-
export
|
|
34
|
+
export type ExternalErrorKind = 'EEXIST' | 'EISDIR' | 'ENOENT';
|
|
35
35
|
export interface ExternalEventEmitter {
|
|
36
36
|
emit(eventName: string, ...args: unknown[]): boolean;
|
|
37
37
|
on(eventName: string, listener: (...args: unknown[]) => unknown): this;
|
|
@@ -74,9 +74,9 @@ export interface ExternalFileSystem {
|
|
|
74
74
|
}): Promise<void>;
|
|
75
75
|
}
|
|
76
76
|
/**
|
|
77
|
-
* A file
|
|
77
|
+
* A file URI string or a URI object.
|
|
78
78
|
*/
|
|
79
|
-
export
|
|
79
|
+
export type FsLocation = string | Uri;
|
|
80
80
|
export interface FsWatcher {
|
|
81
81
|
on(eventName: 'ready', listener: () => unknown): this;
|
|
82
82
|
once(eventName: 'ready', listener: () => unknown): this;
|
package/lib/common/util.d.ts
CHANGED
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
import externalBinarySearch from 'binary-search';
|
|
2
|
+
import { URL } from 'whatwg-url';
|
|
2
3
|
import type { AstNode } from '../node/index.js';
|
|
3
4
|
import type { ProcessorContext } from '../service/index.js';
|
|
4
5
|
import type { Externals } from './externals/index.js';
|
|
5
|
-
import type { DeepReadonly } from './ReadonlyProxy.js';
|
|
6
|
-
export declare const Uri:
|
|
7
|
-
|
|
8
|
-
prototype: URL;
|
|
9
|
-
createObjectURL(obj: Blob | MediaSource): string;
|
|
10
|
-
revokeObjectURL(url: string): void;
|
|
11
|
-
};
|
|
12
|
-
export declare type Uri = URL;
|
|
6
|
+
import type { DeepReadonly, ReadWrite } from './ReadonlyProxy.js';
|
|
7
|
+
export declare const Uri: typeof URL;
|
|
8
|
+
export type Uri = URL;
|
|
13
9
|
/**
|
|
14
10
|
* `NodeJS.Timeout` on Node.js and `number` on browser.
|
|
15
11
|
*/
|
|
16
|
-
export
|
|
12
|
+
export type IntervalId = any;
|
|
17
13
|
/**
|
|
18
14
|
* @param getKey A function that takes the actual arguments being passed into the decorated method, and returns anything.
|
|
19
15
|
* The result of this function will be used as the key to identify the `Promise`. By default the first element in the argument
|
|
@@ -35,7 +31,7 @@ export declare const Singleton: MethodDecorator;
|
|
|
35
31
|
* Decorated methods will be scheduled to run after `ms` milliseconds. The timer will reset when the method is called again.
|
|
36
32
|
*/
|
|
37
33
|
export declare function Delay(ms: number, getKey?: (args: any[]) => any): MethodDecorator;
|
|
38
|
-
export
|
|
34
|
+
export type FullResourceLocation = `${string}:${string}`;
|
|
39
35
|
export interface ResourceLocation {
|
|
40
36
|
isTag: boolean;
|
|
41
37
|
namespace: string | undefined;
|
|
@@ -63,7 +59,7 @@ export declare namespace ResourceLocation {
|
|
|
63
59
|
* Byte order mark is correctly removed.
|
|
64
60
|
*/
|
|
65
61
|
export declare function bufferToString(buffer: Uint8Array): string;
|
|
66
|
-
export
|
|
62
|
+
export type Arrayable<T> = T | readonly T[];
|
|
67
63
|
export declare namespace Arrayable {
|
|
68
64
|
function is<T>(value: unknown, isT: (value: unknown) => value is T): value is Arrayable<T>;
|
|
69
65
|
function toArray<T>(value: Arrayable<T>): T[];
|
|
@@ -78,7 +74,7 @@ export declare function parseGzippedJson(externals: Externals, buffer: Uint8Arra
|
|
|
78
74
|
*/
|
|
79
75
|
export declare function isPojo(value: unknown): value is Record<string, unknown>;
|
|
80
76
|
export declare function merge<T extends Record<string, any>>(a: T, b: Record<string, any>): T;
|
|
81
|
-
export
|
|
77
|
+
export type Lazy<T> = T | Lazy.ComplexLazy<T>;
|
|
82
78
|
export declare namespace Lazy {
|
|
83
79
|
const LazyDiscriminator: unique symbol;
|
|
84
80
|
export type UnresolvedLazy<T> = {
|
|
@@ -116,17 +112,23 @@ export declare function emplaceMap<K, V>(map: Map<K, V>, key: K, handler: {
|
|
|
116
112
|
export declare function isObject(val: unknown): val is object;
|
|
117
113
|
export declare function normalizeUri(uri: string): string;
|
|
118
114
|
/**
|
|
115
|
+
* Return a read-write TARGET type if the INPUT type is read-write, and a
|
|
116
|
+
* readonly TARGET type if the INPUT type is readonly, and `never` if the INPUT
|
|
117
|
+
* type is `undefined`.
|
|
118
|
+
*
|
|
119
|
+
* It is used in the return type of an AST node
|
|
120
|
+
* [user-defined type guard](https://www.typescriptlang.org/docs/handbook/2/narrowing.html#using-type-predicates).
|
|
121
|
+
*
|
|
119
122
|
* @example
|
|
120
123
|
* ```ts
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
* function isCommentNode<T extends DeepReadonly<AstNode> | undefined>(node: T): node is NodeIsHelper<CommentNode, T>
|
|
124
|
+
* export namespace CommentNode {
|
|
125
|
+
* export function is<T extends DeepReadonly<AstNode> | undefined>(
|
|
126
|
+
* obj: T,
|
|
127
|
+
* ): obj is InheritReadonly<CommentNode, T> {
|
|
128
|
+
* return (obj as CommentNode | undefined)?.type === 'comment'
|
|
129
|
+
* }
|
|
130
|
+
* }
|
|
129
131
|
* ```
|
|
130
132
|
*/
|
|
131
|
-
export
|
|
133
|
+
export type InheritReadonly<TARGET extends AstNode, INPUT extends DeepReadonly<AstNode> | undefined> = INPUT & (INPUT extends ReadWrite<AstNode> ? TARGET : DeepReadonly<TARGET>);
|
|
132
134
|
//# sourceMappingURL=util.d.ts.map
|
package/lib/common/util.js
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
import externalBinarySearch from 'binary-search';
|
|
2
2
|
import rfdc from 'rfdc';
|
|
3
|
+
import { URL } from 'whatwg-url';
|
|
4
|
+
// Spyglass uses the URL class provided by the
|
|
5
|
+
// [spec](https://url.spec.whatwg.org/)-compliant `whatwg-url` package instead
|
|
6
|
+
// of the broken one shipped with browsers that do not parse non-special scheme
|
|
7
|
+
// URLs with hosts properly.
|
|
8
|
+
//
|
|
9
|
+
// * [Chromium bug](https://issues.chromium.org/issues/40587286)
|
|
10
|
+
// * [FireFox bug](https://bugzilla.mozilla.org/show_bug.cgi?id=1374505)
|
|
11
|
+
//
|
|
12
|
+
// We use the name "URI" instead of "URL" when possible, since it is what
|
|
13
|
+
// LSP has chosen to use for the string that uniquely identifies a file.
|
|
3
14
|
export const Uri = URL;
|
|
4
15
|
/**
|
|
5
16
|
* @param getKey A function that takes the actual arguments being passed into the decorated method, and returns anything.
|
|
@@ -210,7 +221,7 @@ export const binarySearch = externalBinarySearch;
|
|
|
210
221
|
export function isIterable(value) {
|
|
211
222
|
return !!value[Symbol.iterator];
|
|
212
223
|
}
|
|
213
|
-
|
|
224
|
+
// #region ESNext functions polyfill
|
|
214
225
|
export function atArray(array, index) {
|
|
215
226
|
return index >= 0 ? array?.[index] : array?.[array.length + index];
|
|
216
227
|
}
|
|
@@ -232,7 +243,7 @@ export function emplaceMap(map, key, handler) {
|
|
|
232
243
|
throw new Error(`No key ${key} in map and no insert handler provided`);
|
|
233
244
|
}
|
|
234
245
|
}
|
|
235
|
-
|
|
246
|
+
// #endregion
|
|
236
247
|
/**
|
|
237
248
|
* @returns If `val` is an non-null object or a callable object (i.e. function).
|
|
238
249
|
*/
|
package/lib/node/AstNode.d.ts
CHANGED
|
@@ -59,7 +59,7 @@ export declare namespace AstNode {
|
|
|
59
59
|
export function getLocalsToLeaves(node: AstNode): Generator<SymbolTable>;
|
|
60
60
|
export {};
|
|
61
61
|
}
|
|
62
|
-
export
|
|
62
|
+
export type Mutable<N> = N extends AstNode ? {
|
|
63
63
|
-readonly [K in keyof N]: Mutable<N[K]>;
|
|
64
64
|
} : N;
|
|
65
65
|
//# sourceMappingURL=AstNode.d.ts.map
|
package/lib/node/AstNode.js
CHANGED
|
@@ -24,7 +24,9 @@ export var AstNode;
|
|
|
24
24
|
if (!node.children) {
|
|
25
25
|
return -1;
|
|
26
26
|
}
|
|
27
|
-
const comparator = typeof needle === 'number'
|
|
27
|
+
const comparator = typeof needle === 'number'
|
|
28
|
+
? Range.compareOffset
|
|
29
|
+
: Range.compare;
|
|
28
30
|
return binarySearch(node.children, needle, (a, b) => comparator(a.range, b, endInclusive));
|
|
29
31
|
}
|
|
30
32
|
AstNode.findChildIndex = findChildIndex;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DeepReadonly } from '../common/index.js';
|
|
1
|
+
import type { DeepReadonly, InheritReadonly } from '../common/index.js';
|
|
2
2
|
import type { AstNode } from './AstNode.js';
|
|
3
3
|
export interface CommentNode extends AstNode {
|
|
4
4
|
readonly type: 'comment';
|
|
@@ -7,7 +7,7 @@ export interface CommentNode extends AstNode {
|
|
|
7
7
|
*/
|
|
8
8
|
comment: string;
|
|
9
9
|
}
|
|
10
|
-
export declare
|
|
11
|
-
is<T extends DeepReadonly<AstNode> | undefined>(obj: T): obj is
|
|
12
|
-
}
|
|
10
|
+
export declare namespace CommentNode {
|
|
11
|
+
function is<T extends DeepReadonly<AstNode> | undefined>(obj: T): obj is InheritReadonly<CommentNode, T>;
|
|
12
|
+
}
|
|
13
13
|
//# sourceMappingURL=CommentNode.d.ts.map
|
package/lib/node/CommentNode.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
1
|
+
export var CommentNode;
|
|
2
|
+
(function (CommentNode) {
|
|
3
|
+
function is(obj) {
|
|
3
4
|
return obj?.type === 'comment';
|
|
4
|
-
}
|
|
5
|
-
|
|
5
|
+
}
|
|
6
|
+
CommentNode.is = is;
|
|
7
|
+
})(CommentNode || (CommentNode = {}));
|
|
6
8
|
//# sourceMappingURL=CommentNode.js.map
|
|
@@ -3,7 +3,7 @@ import { ResourceLocation } from '../common/index.js';
|
|
|
3
3
|
import type { RangeLike } from '../source/index.js';
|
|
4
4
|
import type { ResourceLocationCategory, SymbolAccessType, SymbolUsageType, TaggableResourceLocationCategory } from '../symbol/index.js';
|
|
5
5
|
import type { AstNode } from './AstNode.js';
|
|
6
|
-
export
|
|
6
|
+
export type ResourceLocationOptions = {
|
|
7
7
|
accessType?: SymbolAccessType;
|
|
8
8
|
isPredicate?: boolean;
|
|
9
9
|
usageType?: SymbolUsageType;
|
|
@@ -43,10 +43,9 @@ export var ResourceLocationNode;
|
|
|
43
43
|
switch (type) {
|
|
44
44
|
case 'origin':
|
|
45
45
|
// Use `node.namespace !== undefined`, so that empty namespaces can be correctly restored to string.
|
|
46
|
-
id =
|
|
47
|
-
node.namespace
|
|
48
|
-
|
|
49
|
-
: path;
|
|
46
|
+
id = node.namespace !== undefined
|
|
47
|
+
? `${node.namespace}${NamespacePathSep}${path}`
|
|
48
|
+
: path;
|
|
50
49
|
break;
|
|
51
50
|
case 'full':
|
|
52
51
|
// Use `node.namespace` before `||`, so that both undefined and empty value can result in the default namespace.
|
|
@@ -55,10 +54,9 @@ export var ResourceLocationNode;
|
|
|
55
54
|
break;
|
|
56
55
|
case 'short':
|
|
57
56
|
// Use `node.namespace` before `&&` for the same reason stated above.
|
|
58
|
-
id =
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
: path;
|
|
57
|
+
id = node.namespace && node.namespace !== DefaultNamespace
|
|
58
|
+
? `${node.namespace}${NamespacePathSep}${path}`
|
|
59
|
+
: path;
|
|
62
60
|
break;
|
|
63
61
|
}
|
|
64
62
|
return includesTagPrefix && node.isTag ? `${TagPrefix}${id}` : id;
|
package/lib/node/StringNode.d.ts
CHANGED
|
@@ -3,12 +3,12 @@ import type { ColorTokenType } from '../processor/index.js';
|
|
|
3
3
|
import type { IndexMap, RangeLike } from '../source/index.js';
|
|
4
4
|
import type { AstNode } from './AstNode.js';
|
|
5
5
|
export declare const EscapeChars: readonly ["\"", "'", "\\", "b", "f", "n", "r", "t"];
|
|
6
|
-
export
|
|
6
|
+
export type EscapeChar = (typeof EscapeChars)[number];
|
|
7
7
|
export declare namespace EscapeChar {
|
|
8
8
|
function is(expected: EscapeChar[] | undefined, c: string): c is EscapeChar;
|
|
9
9
|
}
|
|
10
10
|
export declare const EscapeTable: Map<"\"" | "'" | "b" | "f" | "n" | "r" | "t" | "\\", string>;
|
|
11
|
-
export
|
|
11
|
+
export type Quote = "'" | '"';
|
|
12
12
|
export interface StringOptions {
|
|
13
13
|
colorTokenType?: ColorTokenType;
|
|
14
14
|
escapable?: {
|
|
@@ -47,7 +47,7 @@ export interface StringOptions {
|
|
|
47
47
|
type: AstNode['type'];
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
|
-
export
|
|
50
|
+
export type QuoteTypeConfig = 'always double' | 'always single' | 'prefer double' | 'prefer single';
|
|
51
51
|
export interface StringBaseNode extends AstNode {
|
|
52
52
|
readonly options: StringOptions;
|
|
53
53
|
value: string;
|
package/lib/node/StringNode.js
CHANGED
|
@@ -32,7 +32,10 @@ export var StringNode;
|
|
|
32
32
|
range,
|
|
33
33
|
options,
|
|
34
34
|
value: '',
|
|
35
|
-
valueMap: [{
|
|
35
|
+
valueMap: [{
|
|
36
|
+
inner: Range.create(0),
|
|
37
|
+
outer: Range.create(range.start),
|
|
38
|
+
}],
|
|
36
39
|
};
|
|
37
40
|
}
|
|
38
41
|
StringNode.mock = mock;
|
package/lib/parser/Parser.d.ts
CHANGED
|
@@ -4,13 +4,13 @@ import type { Source } from '../source/index.js';
|
|
|
4
4
|
/**
|
|
5
5
|
* A parser.
|
|
6
6
|
*/
|
|
7
|
-
export
|
|
7
|
+
export type Parser<N extends Returnable = AstNode> = (this: void, src: Source, ctx: ParserContext) => Result<N>;
|
|
8
8
|
/**
|
|
9
9
|
* A parser that always succeeds.
|
|
10
10
|
*/
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
export
|
|
11
|
+
export type InfallibleParser<N extends Returnable = AstNode> = (this: void, src: Source, ctx: ParserContext) => Success<N>;
|
|
12
|
+
export type Result<T extends Returnable> = Success<T> | typeof Failure;
|
|
13
|
+
export type Success<T extends Returnable> = T;
|
|
14
14
|
export declare const Failure: unique symbol;
|
|
15
|
-
export
|
|
15
|
+
export type Returnable = object | string | number | bigint | boolean | undefined;
|
|
16
16
|
//# sourceMappingURL=Parser.d.ts.map
|
package/lib/parser/float.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ interface InfallibleOptions extends OptionsBase {
|
|
|
26
26
|
failsOnEmpty?: false;
|
|
27
27
|
}
|
|
28
28
|
/** @internal For test only */
|
|
29
|
-
export
|
|
29
|
+
export type Options = FallibleOptions | InfallibleOptions;
|
|
30
30
|
export declare function float(options: InfallibleOptions): InfallibleParser<FloatNode>;
|
|
31
31
|
export declare function float(options: FallibleOptions): Parser<FloatNode>;
|
|
32
32
|
export {};
|
package/lib/parser/integer.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ interface InfallibleOptions extends OptionsBase {
|
|
|
26
26
|
failsOnEmpty?: false;
|
|
27
27
|
}
|
|
28
28
|
/** @internal For test only */
|
|
29
|
-
export
|
|
29
|
+
export type Options = FallibleOptions | InfallibleOptions;
|
|
30
30
|
export declare function integer(options: InfallibleOptions): InfallibleParser<IntegerNode>;
|
|
31
31
|
export declare function integer(options: FallibleOptions): Parser<IntegerNode>;
|
|
32
32
|
export {};
|
package/lib/parser/long.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ interface InfallibleOptions extends OptionsBase {
|
|
|
26
26
|
failsOnEmpty?: false;
|
|
27
27
|
}
|
|
28
28
|
/** @internal For test only */
|
|
29
|
-
export
|
|
29
|
+
export type Options = FallibleOptions | InfallibleOptions;
|
|
30
30
|
export declare function long(options: InfallibleOptions): InfallibleParser<LongNode>;
|
|
31
31
|
export declare function long(options: FallibleOptions): Parser<LongNode>;
|
|
32
32
|
export {};
|
|
@@ -96,7 +96,7 @@ export function resourceLocation(options) {
|
|
|
96
96
|
ctx.err.report(localize('parser.resource-location.illegal', arrayToMessage(illegalChars, true, 'and')), ans);
|
|
97
97
|
}
|
|
98
98
|
if (ans.isTag && !options.allowTag) {
|
|
99
|
-
ctx.err.report(localize('parser.resource-location.tag-
|
|
99
|
+
ctx.err.report(localize('parser.resource-location.tag-disallowed'), ans);
|
|
100
100
|
}
|
|
101
101
|
if (!ans.namespace && options.isPredicate) {
|
|
102
102
|
ctx.err.report(localize('parser.resource-location.namespace-expected'), ans);
|