cspell-io 9.7.0 → 10.0.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/dist/index.js +9 -72
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -9,7 +9,6 @@ import { fileURLToPath } from "node:url";
|
|
|
9
9
|
import { promisify } from "node:util";
|
|
10
10
|
import * as Stream from "node:stream";
|
|
11
11
|
import assert from "node:assert";
|
|
12
|
-
|
|
13
12
|
//#region src/async/asyncIterable.ts
|
|
14
13
|
/**
|
|
15
14
|
* Reads an entire iterable and converts it into a promise.
|
|
@@ -20,7 +19,6 @@ async function toArray(asyncIterable) {
|
|
|
20
19
|
for await (const item of asyncIterable) data.push(item);
|
|
21
20
|
return data;
|
|
22
21
|
}
|
|
23
|
-
|
|
24
22
|
//#endregion
|
|
25
23
|
//#region src/common/CFileReference.ts
|
|
26
24
|
var CFileReference = class CFileReference {
|
|
@@ -85,7 +83,6 @@ function toFileResourceRequest(file, encoding, signal) {
|
|
|
85
83
|
signal
|
|
86
84
|
};
|
|
87
85
|
}
|
|
88
|
-
|
|
89
86
|
//#endregion
|
|
90
87
|
//#region src/errors/errors.ts
|
|
91
88
|
var ErrorNotImplemented = class extends Error {
|
|
@@ -100,13 +97,11 @@ var AssertionError = class extends Error {
|
|
|
100
97
|
this.message = message;
|
|
101
98
|
}
|
|
102
99
|
};
|
|
103
|
-
|
|
104
100
|
//#endregion
|
|
105
101
|
//#region src/errors/assert.ts
|
|
106
102
|
function assert$1(value, message) {
|
|
107
103
|
if (!value) throw new AssertionError(message ?? "Assertion failed");
|
|
108
104
|
}
|
|
109
|
-
|
|
110
105
|
//#endregion
|
|
111
106
|
//#region src/common/arrayBuffers.ts
|
|
112
107
|
function toUint8Array(data) {
|
|
@@ -127,7 +122,6 @@ function swap16(data) {
|
|
|
127
122
|
function swapBytes(data) {
|
|
128
123
|
return swap16(copyArrayBufferView(data));
|
|
129
124
|
}
|
|
130
|
-
|
|
131
125
|
//#endregion
|
|
132
126
|
//#region src/common/encode-decode.ts
|
|
133
127
|
const BOM_BE = 65279;
|
|
@@ -243,7 +237,6 @@ async function decompress(data, method = "gzip") {
|
|
|
243
237
|
}
|
|
244
238
|
return result;
|
|
245
239
|
}
|
|
246
|
-
|
|
247
240
|
//#endregion
|
|
248
241
|
//#region src/common/CFileResource.ts
|
|
249
242
|
var CFileResource = class CFileResource {
|
|
@@ -330,7 +323,6 @@ function renameFileResource(fileResource, url) {
|
|
|
330
323
|
url
|
|
331
324
|
});
|
|
332
325
|
}
|
|
333
|
-
|
|
334
326
|
//#endregion
|
|
335
327
|
//#region src/common/stat.ts
|
|
336
328
|
/**
|
|
@@ -345,13 +337,11 @@ function compareStats(left, right) {
|
|
|
345
337
|
const diff = left.size - right.size || left.mtimeMs - right.mtimeMs;
|
|
346
338
|
return diff < 0 ? -1 : diff > 0 ? 1 : 0;
|
|
347
339
|
}
|
|
348
|
-
|
|
349
340
|
//#endregion
|
|
350
341
|
//#region src/common/urlOrReferenceToUrl.ts
|
|
351
342
|
function urlOrReferenceToUrl(urlOrReference) {
|
|
352
343
|
return urlOrReference instanceof URL ? urlOrReference : urlOrReference.url;
|
|
353
344
|
}
|
|
354
|
-
|
|
355
345
|
//#endregion
|
|
356
346
|
//#region src/CSpellIO.ts
|
|
357
347
|
function toReadFileOptions(options) {
|
|
@@ -359,7 +349,6 @@ function toReadFileOptions(options) {
|
|
|
359
349
|
if (typeof options === "string") return { encoding: options };
|
|
360
350
|
return options;
|
|
361
351
|
}
|
|
362
|
-
|
|
363
352
|
//#endregion
|
|
364
353
|
//#region src/errors/error.ts
|
|
365
354
|
function toError$1(e) {
|
|
@@ -367,7 +356,6 @@ function toError$1(e) {
|
|
|
367
356
|
if (typeof e === "object" && e && "message" in e && typeof e.message === "string") return new Error(e.message, { cause: e });
|
|
368
357
|
return new Error(e && e.toString());
|
|
369
358
|
}
|
|
370
|
-
|
|
371
359
|
//#endregion
|
|
372
360
|
//#region src/models/Stats.ts
|
|
373
361
|
let FileType = /* @__PURE__ */ function(FileType) {
|
|
@@ -389,7 +377,6 @@ let FileType = /* @__PURE__ */ function(FileType) {
|
|
|
389
377
|
FileType[FileType["SymbolicLink"] = 64] = "SymbolicLink";
|
|
390
378
|
return FileType;
|
|
391
379
|
}({});
|
|
392
|
-
|
|
393
380
|
//#endregion
|
|
394
381
|
//#region src/node/dataUrl.ts
|
|
395
382
|
/**
|
|
@@ -463,12 +450,10 @@ function guessMimeType(filename) {
|
|
|
463
450
|
encoding: "utf-8"
|
|
464
451
|
};
|
|
465
452
|
}
|
|
466
|
-
|
|
467
453
|
//#endregion
|
|
468
454
|
//#region src/node/file/_fetch.ts
|
|
469
455
|
/** alias of global.fetch, useful for mocking */
|
|
470
456
|
const _fetch = globalThis.fetch;
|
|
471
|
-
|
|
472
457
|
//#endregion
|
|
473
458
|
//#region src/node/file/FetchError.ts
|
|
474
459
|
var FetchUrlError = class FetchUrlError extends Error {
|
|
@@ -511,7 +496,6 @@ function toFetchUrlError(err, url) {
|
|
|
511
496
|
function toError(err) {
|
|
512
497
|
return err instanceof Error ? err : new Error("Unknown Error", { cause: err });
|
|
513
498
|
}
|
|
514
|
-
|
|
515
499
|
//#endregion
|
|
516
500
|
//#region src/node/file/fetch.ts
|
|
517
501
|
async function fetchHead(request) {
|
|
@@ -536,7 +520,6 @@ async function fetchURL(url, signal) {
|
|
|
536
520
|
function toURL$1(url) {
|
|
537
521
|
return typeof url === "string" ? new URL(url) : url;
|
|
538
522
|
}
|
|
539
|
-
|
|
540
523
|
//#endregion
|
|
541
524
|
//#region src/node/file/stat.ts
|
|
542
525
|
async function getStatHttp(url) {
|
|
@@ -549,39 +532,13 @@ async function getStatHttp(url) {
|
|
|
549
532
|
eTag
|
|
550
533
|
};
|
|
551
534
|
}
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
const
|
|
556
|
-
const
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
//#region src/requests/RequestFsReadFileSync.ts
|
|
560
|
-
const RequestType$3 = "fs:readFileSync";
|
|
561
|
-
const RequestFsReadFileTextSync = requestFactory(RequestType$3);
|
|
562
|
-
|
|
563
|
-
//#endregion
|
|
564
|
-
//#region src/requests/RequestFsStat.ts
|
|
565
|
-
const RequestTypeStat = "fs:stat";
|
|
566
|
-
const RequestFsStat = requestFactory(RequestTypeStat);
|
|
567
|
-
const RequestTypeStatSync = "fs:statSync";
|
|
568
|
-
const RequestFsStatSync = requestFactory(RequestTypeStatSync);
|
|
569
|
-
|
|
570
|
-
//#endregion
|
|
571
|
-
//#region src/requests/RequestFsWriteFile.ts
|
|
572
|
-
const RequestType$2 = "fs:writeFile";
|
|
573
|
-
const RequestFsWriteFile = requestFactory(RequestType$2);
|
|
574
|
-
|
|
575
|
-
//#endregion
|
|
576
|
-
//#region src/requests/RequestZlibInflate.ts
|
|
577
|
-
const RequestType$1 = "zlib:inflate";
|
|
578
|
-
const RequestZlibInflate = requestFactory(RequestType$1);
|
|
579
|
-
|
|
580
|
-
//#endregion
|
|
581
|
-
//#region src/requests/RequestFsReadDirectory.ts
|
|
582
|
-
const RequestType = "fs:readDir";
|
|
583
|
-
const RequestFsReadDirectory = requestFactory(RequestType);
|
|
584
|
-
|
|
535
|
+
const RequestFsReadFile = requestFactory("fs:readFile");
|
|
536
|
+
const RequestFsReadFileTextSync = requestFactory("fs:readFileSync");
|
|
537
|
+
const RequestFsStat = requestFactory("fs:stat");
|
|
538
|
+
const RequestFsStatSync = requestFactory("fs:statSync");
|
|
539
|
+
const RequestFsWriteFile = requestFactory("fs:writeFile");
|
|
540
|
+
const RequestZlibInflate = requestFactory("zlib:inflate");
|
|
541
|
+
const RequestFsReadDirectory = requestFactory("fs:readDir");
|
|
585
542
|
//#endregion
|
|
586
543
|
//#region src/handlers/node/file.ts
|
|
587
544
|
const isGzFileRegExp = /\.gz($|[?#])/;
|
|
@@ -784,7 +741,6 @@ function toFileType(statLike) {
|
|
|
784
741
|
const t = statLike.isFile() ? FileType.File : statLike.isDirectory() ? FileType.Directory : FileType.Unknown;
|
|
785
742
|
return statLike.isSymbolicLink() ? t | FileType.SymbolicLink : t;
|
|
786
743
|
}
|
|
787
|
-
|
|
788
744
|
//#endregion
|
|
789
745
|
//#region src/CSpellIONode.ts
|
|
790
746
|
let defaultCSpellIONode = void 0;
|
|
@@ -858,7 +814,6 @@ function getDefaultCSpellIO() {
|
|
|
858
814
|
defaultCSpellIONode = cspellIO;
|
|
859
815
|
return cspellIO;
|
|
860
816
|
}
|
|
861
|
-
|
|
862
817
|
//#endregion
|
|
863
818
|
//#region src/common/transformers.ts
|
|
864
819
|
function encoderTransformer(iterable, encoding) {
|
|
@@ -881,7 +836,6 @@ async function* encoderAsyncIterable(iterable, encoding) {
|
|
|
881
836
|
function isAsyncIterable(v) {
|
|
882
837
|
return v && typeof v === "object" && !!v[Symbol.asyncIterator];
|
|
883
838
|
}
|
|
884
|
-
|
|
885
839
|
//#endregion
|
|
886
840
|
//#region src/node/file/fileWriter.ts
|
|
887
841
|
const pipeline = promisify(Stream.pipeline);
|
|
@@ -891,7 +845,6 @@ function writeToFile(filename, data, encoding) {
|
|
|
891
845
|
function writeToFileIterable(filename, data, encoding) {
|
|
892
846
|
return pipeline(Stream.Readable.from(encoderTransformer(data, encoding)), /\.gz$/.test(filename) ? zlib.createGzip() : new Stream.PassThrough(), fs.createWriteStream(filename));
|
|
893
847
|
}
|
|
894
|
-
|
|
895
848
|
//#endregion
|
|
896
849
|
//#region src/file/file.ts
|
|
897
850
|
async function readFileText(filename, encoding) {
|
|
@@ -914,11 +867,9 @@ function getStatSync(filenameOrUri) {
|
|
|
914
867
|
return toError$1(e);
|
|
915
868
|
}
|
|
916
869
|
}
|
|
917
|
-
|
|
918
870
|
//#endregion
|
|
919
871
|
//#region src/VirtualFS/constants.ts
|
|
920
872
|
const CSPELL_VFS_PROTOCOL = "cspell-vfs:";
|
|
921
|
-
|
|
922
873
|
//#endregion
|
|
923
874
|
//#region src/VirtualFS/findUpFromUrl.ts
|
|
924
875
|
async function findUpFromUrl(name, from, options) {
|
|
@@ -953,7 +904,6 @@ function makePredicate(fs, name, entryType) {
|
|
|
953
904
|
}
|
|
954
905
|
};
|
|
955
906
|
}
|
|
956
|
-
|
|
957
907
|
//#endregion
|
|
958
908
|
//#region src/VirtualFS/CVFileSystem.ts
|
|
959
909
|
var CVFileSystem = class {
|
|
@@ -984,7 +934,6 @@ var CVFileSystem = class {
|
|
|
984
934
|
});
|
|
985
935
|
}
|
|
986
936
|
};
|
|
987
|
-
|
|
988
937
|
//#endregion
|
|
989
938
|
//#region src/VirtualFS/errors.ts
|
|
990
939
|
var VFSError = class extends Error {
|
|
@@ -1018,7 +967,6 @@ var VFSErrorUnsupportedRequest = class extends VFSError {
|
|
|
1018
967
|
this.parameters = parameters;
|
|
1019
968
|
}
|
|
1020
969
|
};
|
|
1021
|
-
|
|
1022
970
|
//#endregion
|
|
1023
971
|
//#region src/VirtualFS/VFileSystem.ts
|
|
1024
972
|
let FSCapabilityFlags = /* @__PURE__ */ function(FSCapabilityFlags) {
|
|
@@ -1032,7 +980,6 @@ let FSCapabilityFlags = /* @__PURE__ */ function(FSCapabilityFlags) {
|
|
|
1032
980
|
FSCapabilityFlags[FSCapabilityFlags["ReadWriteDir"] = 24] = "ReadWriteDir";
|
|
1033
981
|
return FSCapabilityFlags;
|
|
1034
982
|
}({});
|
|
1035
|
-
|
|
1036
983
|
//#endregion
|
|
1037
984
|
//#region src/VirtualFS/MemVfsProvider.ts
|
|
1038
985
|
var MemFileSystemProvider = class {
|
|
@@ -1132,11 +1079,6 @@ var MemVFileSystem = class {
|
|
|
1132
1079
|
this.dispose();
|
|
1133
1080
|
}
|
|
1134
1081
|
};
|
|
1135
|
-
|
|
1136
|
-
//#endregion
|
|
1137
|
-
//#region src/VirtualFS/VirtualFS.ts
|
|
1138
|
-
const debug = false;
|
|
1139
|
-
|
|
1140
1082
|
//#endregion
|
|
1141
1083
|
//#region src/VirtualFS/capabilities.ts
|
|
1142
1084
|
var CFsCapabilities = class {
|
|
@@ -1162,7 +1104,6 @@ var CFsCapabilities = class {
|
|
|
1162
1104
|
function fsCapabilities(flags) {
|
|
1163
1105
|
return new CFsCapabilities(flags);
|
|
1164
1106
|
}
|
|
1165
|
-
|
|
1166
1107
|
//#endregion
|
|
1167
1108
|
//#region src/VirtualFS/CFileType.ts
|
|
1168
1109
|
var CFileType = class {
|
|
@@ -1182,7 +1123,6 @@ var CFileType = class {
|
|
|
1182
1123
|
return !!(this.fileType & FileType.SymbolicLink);
|
|
1183
1124
|
}
|
|
1184
1125
|
};
|
|
1185
|
-
|
|
1186
1126
|
//#endregion
|
|
1187
1127
|
//#region src/VirtualFS/CVfsStat.ts
|
|
1188
1128
|
var CVfsStat = class extends CFileType {
|
|
@@ -1200,7 +1140,6 @@ var CVfsStat = class extends CFileType {
|
|
|
1200
1140
|
return this.stat.eTag;
|
|
1201
1141
|
}
|
|
1202
1142
|
};
|
|
1203
|
-
|
|
1204
1143
|
//#endregion
|
|
1205
1144
|
//#region src/VirtualFS/WrappedProviderFs.ts
|
|
1206
1145
|
function cspellIOToFsProvider(cspellIO) {
|
|
@@ -1382,7 +1321,6 @@ function rPad(str, len, ch = " ") {
|
|
|
1382
1321
|
function toOptions(val) {
|
|
1383
1322
|
return typeof val === "string" ? { encoding: val } : val;
|
|
1384
1323
|
}
|
|
1385
|
-
|
|
1386
1324
|
//#endregion
|
|
1387
1325
|
//#region src/VirtualFS/CVirtualFS.ts
|
|
1388
1326
|
var CVirtualFS = class {
|
|
@@ -1391,7 +1329,7 @@ var CVirtualFS = class {
|
|
|
1391
1329
|
revCacheFs = /* @__PURE__ */ new Map();
|
|
1392
1330
|
fsc;
|
|
1393
1331
|
fs;
|
|
1394
|
-
loggingEnabled =
|
|
1332
|
+
loggingEnabled = false;
|
|
1395
1333
|
constructor() {
|
|
1396
1334
|
this.fsc = fsPassThroughCore((url) => this._getFS(url));
|
|
1397
1335
|
this.fs = new CVFileSystem(this.fsc);
|
|
@@ -1508,7 +1446,6 @@ function getDefaultVirtualFs() {
|
|
|
1508
1446
|
if (!defaultVirtualFs) defaultVirtualFs = createVirtualFS();
|
|
1509
1447
|
return defaultVirtualFs;
|
|
1510
1448
|
}
|
|
1511
|
-
|
|
1512
1449
|
//#endregion
|
|
1513
1450
|
//#region src/VirtualFS/redirectProvider.ts
|
|
1514
1451
|
var RedirectProvider = class {
|
|
@@ -1653,7 +1590,7 @@ function fsPassThrough(fs, shadowFs, root) {
|
|
|
1653
1590
|
}
|
|
1654
1591
|
};
|
|
1655
1592
|
}
|
|
1656
|
-
|
|
1657
1593
|
//#endregion
|
|
1658
1594
|
export { CFileReference, CFileResource, CSPELL_VFS_PROTOCOL, CSpellIONode, FSCapabilityFlags, FileType as VFileType, toArray as asyncIterableToArray, compareStats, createRedirectProvider, fromFileResource as createTextFileResource, createVirtualFS, encodeDataUrl, getDefaultCSpellIO, getDefaultVirtualFs, getStat, getStatSync, isFileURL, isUrlLike, readFileText, readFileTextSync, renameFileReference, renameFileResource, toDataUrl, toFileURL, toURL, urlBasename, urlDirname, urlOrReferenceToUrl, writeToFile, writeToFileIterable, writeToFileIterable as writeToFileIterableP };
|
|
1595
|
+
|
|
1659
1596
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public",
|
|
5
5
|
"provenance": true
|
|
6
6
|
},
|
|
7
|
-
"version": "
|
|
7
|
+
"version": "10.0.0",
|
|
8
8
|
"description": "A library of useful I/O functions used across various cspell tools.",
|
|
9
9
|
"type": "module",
|
|
10
10
|
"sideEffects": false,
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
},
|
|
49
49
|
"homepage": "https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell-io#readme",
|
|
50
50
|
"engines": {
|
|
51
|
-
"node": ">=
|
|
51
|
+
"node": ">=22.18.0"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"lorem-ipsum": "^2.0.8",
|
|
@@ -56,8 +56,8 @@
|
|
|
56
56
|
"vitest-fetch-mock": "^0.4.5"
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@cspell/cspell-service-bus": "
|
|
60
|
-
"@cspell/url": "
|
|
59
|
+
"@cspell/cspell-service-bus": "10.0.0",
|
|
60
|
+
"@cspell/url": "10.0.0"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "6ddfd576b6bb554a7cb8dba1ab053a0b6ff8021f"
|
|
63
63
|
}
|