@spyglassmc/core 0.4.39 → 0.4.40

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.
@@ -12,10 +12,10 @@ export declare class TwoWayMap<K, V> implements Map<K, V> {
12
12
  hasValue(value: V): boolean;
13
13
  set(key: K, value: V): this;
14
14
  forEach(callbackfn: (value: V, key: K, map: TwoWayMap<K, V>) => void, thisArg?: any): void;
15
- entries(): IterableIterator<[K, V]>;
16
- keys(): IterableIterator<K>;
17
- values(): IterableIterator<V>;
18
- [Symbol.iterator](): IterableIterator<[K, V]>;
15
+ entries(): MapIterator<[K, V]>;
16
+ keys(): MapIterator<K>;
17
+ values(): MapIterator<V>;
18
+ [Symbol.iterator](): MapIterator<[K, V]>;
19
19
  [Symbol.toStringTag]: string;
20
20
  }
21
21
  //# sourceMappingURL=TwoWayMap.d.ts.map
@@ -113,7 +113,7 @@ class BrowserFileSystem {
113
113
  if (typeof data === 'string') {
114
114
  data = new TextEncoder().encode(data);
115
115
  }
116
- data = arrayBufferToBase64(data);
116
+ data = arrayBufferToBase64(data.buffer);
117
117
  this.states[location] = { type: 'file', content: data };
118
118
  this.saveStates();
119
119
  }
@@ -135,7 +135,7 @@ export const BrowserExternals = {
135
135
  if (typeof data === 'string') {
136
136
  data = new TextEncoder().encode(data);
137
137
  }
138
- const hash = await crypto.subtle.digest('SHA-1', data);
138
+ const hash = await crypto.subtle.digest('SHA-1', data.buffer);
139
139
  return uint8ArrayToHex(new Uint8Array(hash));
140
140
  },
141
141
  },
@@ -1,25 +1,20 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- /// <reference types="node" />
4
1
  import chokidar from 'chokidar';
5
- import decompress from 'decompress';
6
- import { Buffer } from 'node:buffer';
7
2
  import { EventEmitter } from 'node:events';
8
3
  import fs from 'node:fs';
9
- import type { RootUriString } from '../../index.js';
4
+ import type { DecompressedFile, RootUriString } from '../../index.js';
10
5
  import type { FsLocation, FsWatcher } from './index.js';
11
6
  export declare function getNodeJsExternals({ cacheRoot }?: {
12
7
  cacheRoot?: RootUriString;
13
8
  }): Readonly<{
14
9
  archive: {
15
- decompressBall(buffer: Uint8Array, options: {
16
- stripLevel?: number | undefined;
17
- } | undefined): Promise<decompress.File[]>;
18
- gunzip(buffer: Uint8Array): Promise<Buffer>;
19
- gzip(buffer: Uint8Array): Promise<Buffer>;
10
+ decompressBall(buffer: Uint8Array<ArrayBuffer>, options: {
11
+ stripLevel?: number;
12
+ } | undefined): Promise<DecompressedFile[]>;
13
+ gunzip(buffer: Uint8Array<ArrayBuffer>): Promise<NonSharedBuffer>;
14
+ gzip(buffer: Uint8Array<ArrayBuffer>): Promise<NonSharedBuffer>;
20
15
  };
21
16
  crypto: {
22
- getSha1(data: string | Uint8Array): Promise<string>;
17
+ getSha1(data: string | Uint8Array<ArrayBuffer>): Promise<string>;
23
18
  };
24
19
  error: {
25
20
  createKind(kind: import("./index.js").ExternalErrorKind, message: string): Error;
@@ -31,18 +26,18 @@ export declare function getNodeJsExternals({ cacheRoot }?: {
31
26
  fs: {
32
27
  chmod(location: FsLocation, mode: number): Promise<void>;
33
28
  mkdir(location: FsLocation, options: {
34
- mode?: number | undefined;
35
- recursive?: boolean | undefined;
29
+ mode?: number;
30
+ recursive?: boolean;
36
31
  } | undefined): Promise<undefined>;
37
- readdir(location: FsLocation): Promise<fs.Dirent[]>;
38
- readFile(location: FsLocation): Promise<Buffer>;
32
+ readdir(location: FsLocation): Promise<fs.Dirent<string>[]>;
33
+ readFile(location: FsLocation): Promise<NonSharedBuffer>;
39
34
  showFile(location: FsLocation): Promise<void>;
40
35
  stat(location: FsLocation): Promise<fs.Stats>;
41
36
  unlink(location: FsLocation): Promise<void>;
42
37
  watch(locations: FsLocation[], { usePolling }?: {
43
- usePolling?: boolean | undefined;
38
+ usePolling?: boolean;
44
39
  }): ChokidarWatcherWrapper;
45
- writeFile(location: FsLocation, data: string | Uint8Array, options: {
40
+ writeFile(location: FsLocation, data: string | Uint8Array<ArrayBuffer>, options: {
46
41
  mode: number;
47
42
  } | undefined): Promise<void>;
48
43
  };
@@ -53,14 +48,14 @@ export declare function getNodeJsExternals({ cacheRoot }?: {
53
48
  }>;
54
49
  export declare const NodeJsExternals: Readonly<{
55
50
  archive: {
56
- decompressBall(buffer: Uint8Array, options: {
57
- stripLevel?: number | undefined;
58
- } | undefined): Promise<decompress.File[]>;
59
- gunzip(buffer: Uint8Array): Promise<Buffer>;
60
- gzip(buffer: Uint8Array): Promise<Buffer>;
51
+ decompressBall(buffer: Uint8Array<ArrayBuffer>, options: {
52
+ stripLevel?: number;
53
+ } | undefined): Promise<DecompressedFile[]>;
54
+ gunzip(buffer: Uint8Array<ArrayBuffer>): Promise<NonSharedBuffer>;
55
+ gzip(buffer: Uint8Array<ArrayBuffer>): Promise<NonSharedBuffer>;
61
56
  };
62
57
  crypto: {
63
- getSha1(data: string | Uint8Array): Promise<string>;
58
+ getSha1(data: string | Uint8Array<ArrayBuffer>): Promise<string>;
64
59
  };
65
60
  error: {
66
61
  createKind(kind: import("./index.js").ExternalErrorKind, message: string): Error;
@@ -72,18 +67,18 @@ export declare const NodeJsExternals: Readonly<{
72
67
  fs: {
73
68
  chmod(location: FsLocation, mode: number): Promise<void>;
74
69
  mkdir(location: FsLocation, options: {
75
- mode?: number | undefined;
76
- recursive?: boolean | undefined;
70
+ mode?: number;
71
+ recursive?: boolean;
77
72
  } | undefined): Promise<undefined>;
78
- readdir(location: FsLocation): Promise<fs.Dirent[]>;
79
- readFile(location: FsLocation): Promise<Buffer>;
73
+ readdir(location: FsLocation): Promise<fs.Dirent<string>[]>;
74
+ readFile(location: FsLocation): Promise<NonSharedBuffer>;
80
75
  showFile(location: FsLocation): Promise<void>;
81
76
  stat(location: FsLocation): Promise<fs.Stats>;
82
77
  unlink(location: FsLocation): Promise<void>;
83
78
  watch(locations: FsLocation[], { usePolling }?: {
84
- usePolling?: boolean | undefined;
79
+ usePolling?: boolean;
85
80
  }): ChokidarWatcherWrapper;
86
- writeFile(location: FsLocation, data: string | Uint8Array, options: {
81
+ writeFile(location: FsLocation, data: string | Uint8Array<ArrayBuffer>, options: {
87
82
  mode: number;
88
83
  } | undefined): Promise<void>;
89
84
  };
@@ -1,17 +1,17 @@
1
1
  import type { Uri } from '../util.js';
2
2
  export interface Externals {
3
3
  archive: {
4
- decompressBall: (buffer: Uint8Array, options?: {
4
+ decompressBall: (buffer: Uint8Array<ArrayBuffer>, options?: {
5
5
  stripLevel?: number;
6
6
  }) => Promise<DecompressedFile[]>;
7
- gzip: (buffer: Uint8Array) => Promise<Uint8Array>;
8
- gunzip: (buffer: Uint8Array) => Promise<Uint8Array>;
7
+ gzip: (buffer: Uint8Array<ArrayBuffer>) => Promise<Uint8Array<ArrayBuffer>>;
8
+ gunzip: (buffer: Uint8Array<ArrayBuffer>) => Promise<Uint8Array<ArrayBuffer>>;
9
9
  };
10
10
  crypto: {
11
11
  /**
12
12
  * @returns SHA-1 digest of the given data in hexadecimal format.
13
13
  */
14
- getSha1: (data: string | Uint8Array) => Promise<string>;
14
+ getSha1: (data: string | Uint8Array<ArrayBuffer>) => Promise<string>;
15
15
  };
16
16
  error: {
17
17
  /**
@@ -33,7 +33,7 @@ export interface Externals {
33
33
  };
34
34
  }
35
35
  export interface DecompressedFile {
36
- data: Uint8Array;
36
+ data: Uint8Array<ArrayBuffer>;
37
37
  mode: number;
38
38
  mtime: string;
39
39
  path: string;
@@ -63,7 +63,7 @@ export interface ExternalFileSystem {
63
63
  isFile(): boolean;
64
64
  isSymbolicLink(): boolean;
65
65
  }[]>;
66
- readFile(location: FsLocation): Promise<Uint8Array>;
66
+ readFile(location: FsLocation): Promise<Uint8Array<ArrayBuffer>>;
67
67
  /**
68
68
  * Show the file/directory in the platform-specific explorer program.
69
69
  *
@@ -81,7 +81,7 @@ export interface ExternalFileSystem {
81
81
  /**
82
82
  * @param options `mode` - File mode bit mask (e.g. `0o775`).
83
83
  */
84
- writeFile(location: FsLocation, data: string | Uint8Array, options?: {
84
+ writeFile(location: FsLocation, data: string | Uint8Array<ArrayBuffer>, options?: {
85
85
  mode: number;
86
86
  }): Promise<void>;
87
87
  }
@@ -68,7 +68,7 @@ export declare namespace TypePredicates {
68
68
  function isString(value: unknown): value is string;
69
69
  }
70
70
  export declare function promisifyAsyncIterable<T, U>(iterable: AsyncIterable<T>, joiner: (chunks: T[]) => U): Promise<U>;
71
- export declare function parseGzippedJson(externals: Externals, buffer: Uint8Array): Promise<unknown>;
71
+ export declare function parseGzippedJson(externals: Externals, buffer: Uint8Array<ArrayBuffer>): Promise<unknown>;
72
72
  /**
73
73
  * @returns Is Plain Old JavaScript Object (POJO).
74
74
  */
@@ -255,7 +255,7 @@ export declare class ConfigService implements ExternalEventEmitter {
255
255
  #private;
256
256
  private readonly project;
257
257
  private readonly defaultConfig;
258
- static readonly ConfigFileNames: readonly ["spyglass.json", ".spyglassrc.json"];
258
+ static readonly ConfigFileNames: readonly ["spyglass.json", ".spyglassrc", ".spyglassrc.json"];
259
259
  constructor(project: Project, defaultConfig?: Config);
260
260
  on(event: 'changed', callbackFn: (data: ConfigEvent) => void): this;
261
261
  on(event: 'error', callbackFn: (data: ErrorEvent) => void): this;
@@ -219,7 +219,7 @@ export const VanillaConfig = {
219
219
  export class ConfigService {
220
220
  project;
221
221
  defaultConfig;
222
- static ConfigFileNames = Object.freeze(['spyglass.json', '.spyglassrc.json']);
222
+ static ConfigFileNames = Object.freeze(['spyglass.json', '.spyglassrc', '.spyglassrc.json']);
223
223
  #eventEmitter;
224
224
  constructor(project, defaultConfig = VanillaConfig) {
225
225
  this.project = project;
@@ -8,7 +8,7 @@ export type Dependency = {
8
8
  } | {
9
9
  type: 'tarball-ram';
10
10
  name: string;
11
- data: Uint8Array;
11
+ data: Uint8Array<ArrayBuffer>;
12
12
  stripLevel?: number;
13
13
  };
14
14
  export type DependencyKey = `@${string}`;
@@ -15,7 +15,7 @@ export interface UriProtocolSupporter {
15
15
  * @returns The content of the file at `uri`.
16
16
  * @throws If the URI doesn't exist in the file system.
17
17
  */
18
- readFile(uri: string): Promise<Uint8Array>;
18
+ readFile(uri: string): Promise<Uint8Array<ArrayBuffer>>;
19
19
  listFiles(): Iterable<string>;
20
20
  /**
21
21
  * Each URI in this array must end with a slash (`/`).
@@ -58,7 +58,7 @@ export declare class FileServiceImpl implements FileService {
58
58
  * A two-way map from mapped physical URIs to virtual URIs.
59
59
  */
60
60
  private readonly map;
61
- constructor(externals: Externals, virtualUrisRoot?: `${string}/` | undefined);
61
+ constructor(externals: Externals, virtualUrisRoot?: RootUriString | undefined);
62
62
  register(protocol: Protocol, supporter: UriProtocolSupporter, force?: boolean): void;
63
63
  unregister(protocol: Protocol): void;
64
64
  /**
@@ -74,9 +74,9 @@ export declare class FileServiceImpl implements FileService {
74
74
  /**
75
75
  * @throws
76
76
  */
77
- readFile(uri: string): Promise<Uint8Array>;
78
- listFiles(): Generator<string, void, undefined>;
79
- listRoots(): Generator<`${string}/`, void, undefined>;
77
+ readFile(uri: string): Promise<Uint8Array<ArrayBuffer>>;
78
+ listFiles(): Generator<string, void, any>;
79
+ listRoots(): Generator<`${string}/`, void, any>;
80
80
  mapToDisk(virtualUri: string): Promise<string | undefined>;
81
81
  mapFromDisk(mappedUri: string): string;
82
82
  }
@@ -87,8 +87,8 @@ export declare class FileUriSupporter implements UriProtocolSupporter {
87
87
  readonly protocol = "file:";
88
88
  private constructor();
89
89
  hash(uri: string): Promise<string>;
90
- readFile(uri: string): Promise<Uint8Array>;
91
- listFiles(): Generator<string, void, undefined>;
90
+ readFile(uri: string): Promise<Uint8Array<ArrayBuffer>>;
91
+ listFiles(): Generator<string, void, unknown>;
92
92
  listRoots(): `${string}/`[];
93
93
  mapToDisk(uri: string): Promise<string | undefined>;
94
94
  static create(dependencies: readonly Dependency[], externals: Externals, logger: Logger): Promise<FileUriSupporter>;
@@ -98,14 +98,13 @@ export declare class ArchiveUriSupporter implements UriProtocolSupporter {
98
98
  private readonly logger;
99
99
  private readonly entries;
100
100
  static readonly Protocol = "archive:";
101
- private static readonly SupportedArchiveExtnames;
102
101
  readonly protocol = "archive:";
103
102
  /**
104
103
  * @param entries A map from archive names to unzipped entries.
105
104
  */
106
105
  private constructor();
107
106
  hash(uri: string): Promise<string>;
108
- readFile(uri: string): Promise<Uint8Array>;
107
+ readFile(uri: string): Promise<Uint8Array<ArrayBuffer>>;
109
108
  /**
110
109
  * @throws
111
110
  */
@@ -161,7 +161,6 @@ export class ArchiveUriSupporter {
161
161
  logger;
162
162
  entries;
163
163
  static Protocol = 'archive:';
164
- static SupportedArchiveExtnames = ['.tar', '.tar.bz2', '.tar.gz', '.zip'];
165
164
  protocol = ArchiveUriSupporter.Protocol;
166
165
  /**
167
166
  * @param entries A map from archive names to unzipped entries.
@@ -28,7 +28,7 @@ export declare class Service {
28
28
  getCodeActions(node: FileNode<AstNode>, doc: TextDocument, range: Range): readonly CodeAction[];
29
29
  getColorInfo(node: FileNode<AstNode>, doc: TextDocument): ColorInfo[];
30
30
  getColorPresentation(file: FileNode<AstNode>, doc: TextDocument, range: Range, color: Color): ColorPresentation[];
31
- complete(node: FileNode<AstNode>, doc: TextDocument, offset: number, triggerCharacter?: string): import("../processor/index.js").CompletionItem[];
31
+ complete(node: FileNode<AstNode>, doc: TextDocument, offset: number, triggerCharacter?: string): import("../index.js").CompletionItem[];
32
32
  dataHackPubify(initialism: string): string;
33
33
  format(node: FileNode<AstNode>, doc: TextDocument, tabSize: number, insertSpaces: boolean): string;
34
34
  getHover(file: FileNode<AstNode>, doc: TextDocument, offset: number): Hover | undefined;
@@ -72,7 +72,7 @@ export declare namespace fileUtil {
72
72
  function getAllFiles(externals: Externals, root: FsLocation, depth?: number): Promise<string[]>;
73
73
  function markReadOnly(externals: Externals, path: FsLocation): Promise<void>;
74
74
  function unlink(externals: Externals, path: FsLocation): Promise<void>;
75
- function readFile(externals: Externals, path: FsLocation): Promise<Uint8Array>;
75
+ function readFile(externals: Externals, path: FsLocation): Promise<Uint8Array<ArrayBuffer>>;
76
76
  /**
77
77
  * @throws
78
78
  *
@@ -85,7 +85,7 @@ export declare namespace fileUtil {
85
85
  * * Mode: `0o666` (`rw-rw-rw-`)
86
86
  * * Flag: `w`
87
87
  */
88
- function writeFile(externals: Externals, path: FsLocation, data: Uint8Array | string, mode?: number): Promise<void>;
88
+ function writeFile(externals: Externals, path: FsLocation, data: Uint8Array<ArrayBuffer> | string, mode?: number): Promise<void>;
89
89
  /**
90
90
  * @throws
91
91
  */
@@ -99,11 +99,11 @@ export declare namespace fileUtil {
99
99
  /**
100
100
  * @throws
101
101
  */
102
- function readGzippedFile(externals: Externals, path: FsLocation): Promise<Uint8Array>;
102
+ function readGzippedFile(externals: Externals, path: FsLocation): Promise<Uint8Array<ArrayBuffer>>;
103
103
  /**
104
104
  * @throws
105
105
  */
106
- function writeGzippedFile(externals: Externals, path: FsLocation, buffer: Uint8Array | string): Promise<void>;
106
+ function writeGzippedFile(externals: Externals, path: FsLocation, buffer: Uint8Array<ArrayBuffer> | string): Promise<void>;
107
107
  /**
108
108
  * @throws
109
109
  */
@@ -206,7 +206,7 @@ export declare class SymbolUtil implements ExternalEventEmitter {
206
206
  type: SymbolUsageType;
207
207
  location: SymbolLocation;
208
208
  }) => unknown): void;
209
- static isVisibilityInGlobal(v: SymbolVisibility | undefined): boolean;
209
+ static isVisibilityInGlobal(v: SymbolVisibility | undefined): v is SymbolVisibility.Public | SymbolVisibility.Restricted | undefined;
210
210
  static areVisibilitiesCompatible(v1: SymbolVisibility | undefined, v2: SymbolVisibility | undefined): boolean;
211
211
  }
212
212
  interface SymbolAddition {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spyglassmc/core",
3
- "version": "0.4.39",
3
+ "version": "0.4.40",
4
4
  "type": "module",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -11,7 +11,7 @@
11
11
  },
12
12
  "scripts": {
13
13
  "release": "npm publish",
14
- "release:dry": "npm publish --dry-run"
14
+ "release:dry": "npm publish --tag latest --dry-run"
15
15
  },
16
16
  "dependencies": {
17
17
  "base64-arraybuffer": "^1.0.2",
@@ -24,7 +24,7 @@
24
24
  "rfdc": "^1.3.0",
25
25
  "vscode-languageserver-textdocument": "^1.0.4",
26
26
  "whatwg-url": "^14.0.0",
27
- "@spyglassmc/locales": "0.3.19"
27
+ "@spyglassmc/locales": "0.3.20"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@types/decompress": "^4.2.3",