cspell-io 9.6.2 → 9.6.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/dist/index.d.ts +2 -2
- package/dist/index.js +63 -63
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -153,7 +153,7 @@ declare enum FileType {
|
|
|
153
153
|
/**
|
|
154
154
|
* A symbolic link.
|
|
155
155
|
*/
|
|
156
|
-
SymbolicLink = 64
|
|
156
|
+
SymbolicLink = 64
|
|
157
157
|
}
|
|
158
158
|
interface DirEntry {
|
|
159
159
|
name: string;
|
|
@@ -301,7 +301,7 @@ declare enum FSCapabilityFlags {
|
|
|
301
301
|
ReadWrite = 6,
|
|
302
302
|
ReadDir = 8,
|
|
303
303
|
WriteDir = 16,
|
|
304
|
-
ReadWriteDir = 24
|
|
304
|
+
ReadWriteDir = 24
|
|
305
305
|
}
|
|
306
306
|
interface FileSystemProviderInfo {
|
|
307
307
|
name: string;
|
package/dist/index.js
CHANGED
|
@@ -300,8 +300,8 @@ var CFileResource = class CFileResource {
|
|
|
300
300
|
static from(urlOrFileResource, content, encoding, baseFilename, gz) {
|
|
301
301
|
if (CFileResource.isCFileResource(urlOrFileResource)) {
|
|
302
302
|
if (content) {
|
|
303
|
-
const { url, encoding
|
|
304
|
-
return new CFileResource(url, content, encoding
|
|
303
|
+
const { url, encoding, baseFilename, gz } = urlOrFileResource;
|
|
304
|
+
return new CFileResource(url, content, encoding, baseFilename, gz);
|
|
305
305
|
}
|
|
306
306
|
return urlOrFileResource;
|
|
307
307
|
}
|
|
@@ -370,24 +370,24 @@ function toError$1(e) {
|
|
|
370
370
|
|
|
371
371
|
//#endregion
|
|
372
372
|
//#region src/models/Stats.ts
|
|
373
|
-
let FileType = /* @__PURE__ */ function(FileType
|
|
373
|
+
let FileType = /* @__PURE__ */ function(FileType) {
|
|
374
374
|
/**
|
|
375
375
|
* The file type is unknown.
|
|
376
376
|
*/
|
|
377
|
-
FileType
|
|
377
|
+
FileType[FileType["Unknown"] = 0] = "Unknown";
|
|
378
378
|
/**
|
|
379
379
|
* A regular file.
|
|
380
380
|
*/
|
|
381
|
-
FileType
|
|
381
|
+
FileType[FileType["File"] = 1] = "File";
|
|
382
382
|
/**
|
|
383
383
|
* A directory.
|
|
384
384
|
*/
|
|
385
|
-
FileType
|
|
385
|
+
FileType[FileType["Directory"] = 2] = "Directory";
|
|
386
386
|
/**
|
|
387
387
|
* A symbolic link.
|
|
388
388
|
*/
|
|
389
|
-
FileType
|
|
390
|
-
return FileType
|
|
389
|
+
FileType[FileType["SymbolicLink"] = 64] = "SymbolicLink";
|
|
390
|
+
return FileType;
|
|
391
391
|
}({});
|
|
392
392
|
|
|
393
393
|
//#endregion
|
|
@@ -866,10 +866,10 @@ const debug = false;
|
|
|
866
866
|
//#endregion
|
|
867
867
|
//#region src/VirtualFS/findUpFromUrl.ts
|
|
868
868
|
async function findUpFromUrl(name, from, options) {
|
|
869
|
-
const { type: entryType = "file", stopAt, fs
|
|
869
|
+
const { type: entryType = "file", stopAt, fs } = options;
|
|
870
870
|
let dir = new URL(".", from);
|
|
871
871
|
const root = new URL("/", dir);
|
|
872
|
-
const predicate = makePredicate(fs
|
|
872
|
+
const predicate = makePredicate(fs, name, entryType);
|
|
873
873
|
const stopAtHrefs = new Set((Array.isArray(stopAt) ? stopAt : [stopAt || root]).map((p) => new URL(".", p).href));
|
|
874
874
|
let last = "";
|
|
875
875
|
while (dir.href !== last) {
|
|
@@ -880,13 +880,13 @@ async function findUpFromUrl(name, from, options) {
|
|
|
880
880
|
dir = new URL("..", dir);
|
|
881
881
|
}
|
|
882
882
|
}
|
|
883
|
-
function makePredicate(fs
|
|
883
|
+
function makePredicate(fs, name, entryType) {
|
|
884
884
|
if (typeof name === "function") return name;
|
|
885
885
|
const checkStat = entryType === "file" || entryType === "!file" ? "isFile" : "isDirectory";
|
|
886
886
|
const checkValue = entryType.startsWith("!") ? false : true;
|
|
887
|
-
function checkName(dir, name
|
|
888
|
-
const f = new URL(name
|
|
889
|
-
return fs
|
|
887
|
+
function checkName(dir, name) {
|
|
888
|
+
const f = new URL(name, dir);
|
|
889
|
+
return fs.stat(f).then((stats) => (stats.isUnknown() || stats[checkStat]() === checkValue) && f || void 0).catch(() => void 0);
|
|
890
890
|
}
|
|
891
891
|
if (!Array.isArray(name)) return (dir) => checkName(dir, name);
|
|
892
892
|
return async (dir) => {
|
|
@@ -931,16 +931,16 @@ var CVFileSystem = class {
|
|
|
931
931
|
|
|
932
932
|
//#endregion
|
|
933
933
|
//#region src/VFileSystem.ts
|
|
934
|
-
let FSCapabilityFlags = /* @__PURE__ */ function(FSCapabilityFlags
|
|
935
|
-
FSCapabilityFlags
|
|
936
|
-
FSCapabilityFlags
|
|
937
|
-
FSCapabilityFlags
|
|
938
|
-
FSCapabilityFlags
|
|
939
|
-
FSCapabilityFlags
|
|
940
|
-
FSCapabilityFlags
|
|
941
|
-
FSCapabilityFlags
|
|
942
|
-
FSCapabilityFlags
|
|
943
|
-
return FSCapabilityFlags
|
|
934
|
+
let FSCapabilityFlags = /* @__PURE__ */ function(FSCapabilityFlags) {
|
|
935
|
+
FSCapabilityFlags[FSCapabilityFlags["None"] = 0] = "None";
|
|
936
|
+
FSCapabilityFlags[FSCapabilityFlags["Stat"] = 1] = "Stat";
|
|
937
|
+
FSCapabilityFlags[FSCapabilityFlags["Read"] = 2] = "Read";
|
|
938
|
+
FSCapabilityFlags[FSCapabilityFlags["Write"] = 4] = "Write";
|
|
939
|
+
FSCapabilityFlags[FSCapabilityFlags["ReadWrite"] = 6] = "ReadWrite";
|
|
940
|
+
FSCapabilityFlags[FSCapabilityFlags["ReadDir"] = 8] = "ReadDir";
|
|
941
|
+
FSCapabilityFlags[FSCapabilityFlags["WriteDir"] = 16] = "WriteDir";
|
|
942
|
+
FSCapabilityFlags[FSCapabilityFlags["ReadWriteDir"] = 24] = "ReadWriteDir";
|
|
943
|
+
return FSCapabilityFlags;
|
|
944
944
|
}({});
|
|
945
945
|
|
|
946
946
|
//#endregion
|
|
@@ -959,7 +959,7 @@ function cspellIOToFsProvider(cspellIO) {
|
|
|
959
959
|
"http:",
|
|
960
960
|
"https:"
|
|
961
961
|
]);
|
|
962
|
-
const fs
|
|
962
|
+
const fs = {
|
|
963
963
|
providerInfo: { name },
|
|
964
964
|
stat: (url) => cspellIO.getStat(url),
|
|
965
965
|
readFile: (url, options) => cspellIO.readFile(url, options),
|
|
@@ -974,7 +974,7 @@ function cspellIOToFsProvider(cspellIO) {
|
|
|
974
974
|
return {
|
|
975
975
|
name,
|
|
976
976
|
getFileSystem: (url, _next) => {
|
|
977
|
-
return supportedProtocols.has(url.protocol) ? fs
|
|
977
|
+
return supportedProtocols.has(url.protocol) ? fs : void 0;
|
|
978
978
|
}
|
|
979
979
|
};
|
|
980
980
|
}
|
|
@@ -1024,13 +1024,13 @@ var WrappedProviderFs = class WrappedProviderFs {
|
|
|
1024
1024
|
capabilities;
|
|
1025
1025
|
providerInfo;
|
|
1026
1026
|
_capabilities;
|
|
1027
|
-
constructor(fs
|
|
1028
|
-
this.fs = fs
|
|
1027
|
+
constructor(fs, eventLogger) {
|
|
1028
|
+
this.fs = fs;
|
|
1029
1029
|
this.eventLogger = eventLogger;
|
|
1030
|
-
this.hasProvider = !!fs
|
|
1031
|
-
this.capabilities = fs
|
|
1030
|
+
this.hasProvider = !!fs;
|
|
1031
|
+
this.capabilities = fs?.capabilities || FSCapabilityFlags.None;
|
|
1032
1032
|
this._capabilities = fsCapabilities(this.capabilities);
|
|
1033
|
-
this.providerInfo = fs
|
|
1033
|
+
this.providerInfo = fs?.providerInfo || { name: "unknown" };
|
|
1034
1034
|
}
|
|
1035
1035
|
logEvent(method, event, traceID, url, message) {
|
|
1036
1036
|
this.eventLogger({
|
|
@@ -1102,11 +1102,11 @@ var WrappedProviderFs = class WrappedProviderFs {
|
|
|
1102
1102
|
this.logEvent("writeFile", "end", traceID, url);
|
|
1103
1103
|
}
|
|
1104
1104
|
}
|
|
1105
|
-
static disposeOf(fs
|
|
1106
|
-
fs
|
|
1105
|
+
static disposeOf(fs) {
|
|
1106
|
+
fs instanceof WrappedProviderFs && fs.fs?.dispose();
|
|
1107
1107
|
}
|
|
1108
1108
|
};
|
|
1109
|
-
function checkCapabilityOrThrow(fs
|
|
1109
|
+
function checkCapabilityOrThrow(fs, capabilities, flag, name, url) {
|
|
1110
1110
|
if (!(capabilities & flag)) throw new VFSErrorUnsupportedRequest(name, url);
|
|
1111
1111
|
}
|
|
1112
1112
|
var CFileType = class {
|
|
@@ -1227,35 +1227,35 @@ var CVirtualFS = class {
|
|
|
1227
1227
|
const key = `${url.protocol}${url.hostname}`;
|
|
1228
1228
|
const cached = this.cachedFs.get(key);
|
|
1229
1229
|
if (cached) return cached;
|
|
1230
|
-
const fnNext = (provider, next
|
|
1231
|
-
return (url
|
|
1230
|
+
const fnNext = (provider, next) => {
|
|
1231
|
+
return (url) => {
|
|
1232
1232
|
let calledNext = false;
|
|
1233
|
-
const fs
|
|
1234
|
-
calledNext = calledNext || url
|
|
1235
|
-
return next
|
|
1233
|
+
const fs = provider.getFileSystem(url, (_url) => {
|
|
1234
|
+
calledNext = calledNext || url === _url;
|
|
1235
|
+
return next(_url);
|
|
1236
1236
|
});
|
|
1237
|
-
if (fs
|
|
1237
|
+
if (fs) {
|
|
1238
1238
|
const s = this.revCacheFs.get(provider) || /* @__PURE__ */ new Set();
|
|
1239
1239
|
s.add(key);
|
|
1240
1240
|
this.revCacheFs.set(provider, s);
|
|
1241
|
-
return fs
|
|
1241
|
+
return fs;
|
|
1242
1242
|
}
|
|
1243
|
-
if (!calledNext) return next
|
|
1243
|
+
if (!calledNext) return next(url);
|
|
1244
1244
|
};
|
|
1245
1245
|
};
|
|
1246
1246
|
let next = (_url) => void 0;
|
|
1247
1247
|
for (const provider of this.providers) next = fnNext(provider, next);
|
|
1248
|
-
const fs
|
|
1249
|
-
this.cachedFs.set(key, fs
|
|
1250
|
-
return fs
|
|
1248
|
+
const fs = new WrappedProviderFs(next(url), this.logEvent);
|
|
1249
|
+
this.cachedFs.set(key, fs);
|
|
1250
|
+
return fs;
|
|
1251
1251
|
}
|
|
1252
1252
|
reset() {
|
|
1253
1253
|
this.disposeOfCachedFs();
|
|
1254
1254
|
}
|
|
1255
1255
|
disposeOfCachedFs() {
|
|
1256
|
-
for (const [key, fs
|
|
1256
|
+
for (const [key, fs] of [...this.cachedFs].reverse()) {
|
|
1257
1257
|
try {
|
|
1258
|
-
WrappedProviderFs.disposeOf(fs
|
|
1258
|
+
WrappedProviderFs.disposeOf(fs);
|
|
1259
1259
|
} catch {}
|
|
1260
1260
|
this.cachedFs.delete(key);
|
|
1261
1261
|
}
|
|
@@ -1270,10 +1270,10 @@ var CVirtualFS = class {
|
|
|
1270
1270
|
} catch {}
|
|
1271
1271
|
}
|
|
1272
1272
|
};
|
|
1273
|
-
function fsPassThroughCore(fs
|
|
1273
|
+
function fsPassThroughCore(fs) {
|
|
1274
1274
|
function gfs(ur, name) {
|
|
1275
1275
|
const url = urlOrReferenceToUrl(ur);
|
|
1276
|
-
const f = fs
|
|
1276
|
+
const f = fs(url);
|
|
1277
1277
|
if (!f.hasProvider) throw new VFSErrorUnsupportedRequest(name, url, ur instanceof URL ? void 0 : {
|
|
1278
1278
|
url: ur.url.toString(),
|
|
1279
1279
|
encoding: ur.encoding
|
|
@@ -1409,7 +1409,7 @@ function createRedirectProvider(name, publicRoot, privateRoot, options) {
|
|
|
1409
1409
|
* @param privateRoot - the root of the private file system.
|
|
1410
1410
|
* @returns ProviderFileSystem
|
|
1411
1411
|
*/
|
|
1412
|
-
function remapFS(name, fs
|
|
1412
|
+
function remapFS(name, fs, shadowFs, publicRoot, privateRoot, options) {
|
|
1413
1413
|
const { capabilitiesMask = -1, capabilities } = options;
|
|
1414
1414
|
function mapToPrivate(url) {
|
|
1415
1415
|
const relativePath = url.pathname.slice(publicRoot.pathname.length);
|
|
@@ -1444,32 +1444,32 @@ function remapFS(name, fs$1, shadowFs, publicRoot, privateRoot, options) {
|
|
|
1444
1444
|
return fsPassThrough({
|
|
1445
1445
|
stat: async (url) => {
|
|
1446
1446
|
const url2 = mapUrlOrReferenceToPrivate(url);
|
|
1447
|
-
return await fs
|
|
1447
|
+
return await fs.stat(url2);
|
|
1448
1448
|
},
|
|
1449
|
-
readFile: async (url, options
|
|
1449
|
+
readFile: async (url, options) => {
|
|
1450
1450
|
const url2 = mapUrlOrReferenceToPrivate(url);
|
|
1451
|
-
return mapFileResourceToPublic(await fs
|
|
1451
|
+
return mapFileResourceToPublic(await fs.readFile(url2, options));
|
|
1452
1452
|
},
|
|
1453
1453
|
readDirectory: async (url) => {
|
|
1454
1454
|
const url2 = mapToPrivate(url);
|
|
1455
|
-
return (await fs
|
|
1455
|
+
return (await fs.readDirectory(url2)).map(mapDirEntryToPublic);
|
|
1456
1456
|
},
|
|
1457
1457
|
writeFile: async (file) => {
|
|
1458
1458
|
const fileRef2 = mapFileResourceToPrivate(file);
|
|
1459
|
-
return mapFileReferenceToPublic(await fs
|
|
1459
|
+
return mapFileReferenceToPublic(await fs.writeFile(fileRef2));
|
|
1460
1460
|
},
|
|
1461
1461
|
providerInfo: {
|
|
1462
|
-
...fs
|
|
1462
|
+
...fs.providerInfo,
|
|
1463
1463
|
name
|
|
1464
1464
|
},
|
|
1465
|
-
capabilities: capabilities ?? fs
|
|
1466
|
-
dispose: () => fs
|
|
1465
|
+
capabilities: capabilities ?? fs.capabilities & capabilitiesMask,
|
|
1466
|
+
dispose: () => fs.dispose()
|
|
1467
1467
|
}, shadowFs, publicRoot);
|
|
1468
1468
|
}
|
|
1469
|
-
function fsPassThrough(fs
|
|
1469
|
+
function fsPassThrough(fs, shadowFs, root) {
|
|
1470
1470
|
function gfs(ur, name) {
|
|
1471
1471
|
const url = urlOrReferenceToUrl(ur);
|
|
1472
|
-
const f = url.href.startsWith(root.href) ? fs
|
|
1472
|
+
const f = url.href.startsWith(root.href) ? fs : shadowFs;
|
|
1473
1473
|
if (!f) throw new VFSErrorUnsupportedRequest(name, url, ur instanceof URL ? void 0 : {
|
|
1474
1474
|
url: ur.url.toString(),
|
|
1475
1475
|
encoding: ur.encoding
|
|
@@ -1478,10 +1478,10 @@ function fsPassThrough(fs$1, shadowFs, root) {
|
|
|
1478
1478
|
}
|
|
1479
1479
|
return {
|
|
1480
1480
|
get providerInfo() {
|
|
1481
|
-
return fs
|
|
1481
|
+
return fs.providerInfo;
|
|
1482
1482
|
},
|
|
1483
1483
|
get capabilities() {
|
|
1484
|
-
return fs
|
|
1484
|
+
return fs.capabilities;
|
|
1485
1485
|
},
|
|
1486
1486
|
stat: async (url) => gfs(url, "stat").stat(url),
|
|
1487
1487
|
readFile: async (url) => gfs(url, "readFile").readFile(url),
|
|
@@ -1492,7 +1492,7 @@ function fsPassThrough(fs$1, shadowFs, root) {
|
|
|
1492
1492
|
return f.getCapabilities ? f.getCapabilities(url) : fsCapabilities(f.capabilities);
|
|
1493
1493
|
},
|
|
1494
1494
|
dispose: () => {
|
|
1495
|
-
fs
|
|
1495
|
+
fs.dispose();
|
|
1496
1496
|
shadowFs?.dispose();
|
|
1497
1497
|
}
|
|
1498
1498
|
};
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public",
|
|
5
5
|
"provenance": true
|
|
6
6
|
},
|
|
7
|
-
"version": "9.6.
|
|
7
|
+
"version": "9.6.3",
|
|
8
8
|
"description": "A library of useful I/O functions used across various cspell tools.",
|
|
9
9
|
"type": "module",
|
|
10
10
|
"sideEffects": false,
|
|
@@ -56,8 +56,8 @@
|
|
|
56
56
|
"vitest-fetch-mock": "^0.4.5"
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@cspell/cspell-service-bus": "9.6.
|
|
60
|
-
"@cspell/url": "9.6.
|
|
59
|
+
"@cspell/cspell-service-bus": "9.6.3",
|
|
60
|
+
"@cspell/url": "9.6.3"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "500b996b6c0a6ff025c42ef98db44776f43a9e72"
|
|
63
63
|
}
|