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 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: encoding$1, baseFilename: baseFilename$1, gz: gz$1 } = urlOrFileResource;
304
- return new CFileResource(url, content, encoding$1, baseFilename$1, gz$1);
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$1) {
373
+ let FileType = /* @__PURE__ */ function(FileType) {
374
374
  /**
375
375
  * The file type is unknown.
376
376
  */
377
- FileType$1[FileType$1["Unknown"] = 0] = "Unknown";
377
+ FileType[FileType["Unknown"] = 0] = "Unknown";
378
378
  /**
379
379
  * A regular file.
380
380
  */
381
- FileType$1[FileType$1["File"] = 1] = "File";
381
+ FileType[FileType["File"] = 1] = "File";
382
382
  /**
383
383
  * A directory.
384
384
  */
385
- FileType$1[FileType$1["Directory"] = 2] = "Directory";
385
+ FileType[FileType["Directory"] = 2] = "Directory";
386
386
  /**
387
387
  * A symbolic link.
388
388
  */
389
- FileType$1[FileType$1["SymbolicLink"] = 64] = "SymbolicLink";
390
- return FileType$1;
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: fs$1 } = options;
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$1, name, entryType);
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$1, name, entryType) {
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$1) {
888
- const f = new URL(name$1, dir);
889
- return fs$1.stat(f).then((stats) => (stats.isUnknown() || stats[checkStat]() === checkValue) && f || void 0).catch(() => void 0);
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$1) {
935
- FSCapabilityFlags$1[FSCapabilityFlags$1["None"] = 0] = "None";
936
- FSCapabilityFlags$1[FSCapabilityFlags$1["Stat"] = 1] = "Stat";
937
- FSCapabilityFlags$1[FSCapabilityFlags$1["Read"] = 2] = "Read";
938
- FSCapabilityFlags$1[FSCapabilityFlags$1["Write"] = 4] = "Write";
939
- FSCapabilityFlags$1[FSCapabilityFlags$1["ReadWrite"] = 6] = "ReadWrite";
940
- FSCapabilityFlags$1[FSCapabilityFlags$1["ReadDir"] = 8] = "ReadDir";
941
- FSCapabilityFlags$1[FSCapabilityFlags$1["WriteDir"] = 16] = "WriteDir";
942
- FSCapabilityFlags$1[FSCapabilityFlags$1["ReadWriteDir"] = 24] = "ReadWriteDir";
943
- return FSCapabilityFlags$1;
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$1 = {
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$1 : void 0;
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$1, eventLogger) {
1028
- this.fs = fs$1;
1027
+ constructor(fs, eventLogger) {
1028
+ this.fs = fs;
1029
1029
  this.eventLogger = eventLogger;
1030
- this.hasProvider = !!fs$1;
1031
- this.capabilities = fs$1?.capabilities || FSCapabilityFlags.None;
1030
+ this.hasProvider = !!fs;
1031
+ this.capabilities = fs?.capabilities || FSCapabilityFlags.None;
1032
1032
  this._capabilities = fsCapabilities(this.capabilities);
1033
- this.providerInfo = fs$1?.providerInfo || { name: "unknown" };
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$1) {
1106
- fs$1 instanceof WrappedProviderFs && fs$1.fs?.dispose();
1105
+ static disposeOf(fs) {
1106
+ fs instanceof WrappedProviderFs && fs.fs?.dispose();
1107
1107
  }
1108
1108
  };
1109
- function checkCapabilityOrThrow(fs$1, capabilities, flag, name, url) {
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$1) => {
1231
- return (url$1) => {
1230
+ const fnNext = (provider, next) => {
1231
+ return (url) => {
1232
1232
  let calledNext = false;
1233
- const fs$2 = provider.getFileSystem(url$1, (_url) => {
1234
- calledNext = calledNext || url$1 === _url;
1235
- return next$1(_url);
1233
+ const fs = provider.getFileSystem(url, (_url) => {
1234
+ calledNext = calledNext || url === _url;
1235
+ return next(_url);
1236
1236
  });
1237
- if (fs$2) {
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$2;
1241
+ return fs;
1242
1242
  }
1243
- if (!calledNext) return next$1(url$1);
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$1 = new WrappedProviderFs(next(url), this.logEvent);
1249
- this.cachedFs.set(key, fs$1);
1250
- return fs$1;
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$1] of [...this.cachedFs].reverse()) {
1256
+ for (const [key, fs] of [...this.cachedFs].reverse()) {
1257
1257
  try {
1258
- WrappedProviderFs.disposeOf(fs$1);
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$1) {
1273
+ function fsPassThroughCore(fs) {
1274
1274
  function gfs(ur, name) {
1275
1275
  const url = urlOrReferenceToUrl(ur);
1276
- const f = fs$1(url);
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$1, shadowFs, publicRoot, privateRoot, options) {
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$1.stat(url2);
1447
+ return await fs.stat(url2);
1448
1448
  },
1449
- readFile: async (url, options$1) => {
1449
+ readFile: async (url, options) => {
1450
1450
  const url2 = mapUrlOrReferenceToPrivate(url);
1451
- return mapFileResourceToPublic(await fs$1.readFile(url2, options$1));
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$1.readDirectory(url2)).map(mapDirEntryToPublic);
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$1.writeFile(fileRef2));
1459
+ return mapFileReferenceToPublic(await fs.writeFile(fileRef2));
1460
1460
  },
1461
1461
  providerInfo: {
1462
- ...fs$1.providerInfo,
1462
+ ...fs.providerInfo,
1463
1463
  name
1464
1464
  },
1465
- capabilities: capabilities ?? fs$1.capabilities & capabilitiesMask,
1466
- dispose: () => fs$1.dispose()
1465
+ capabilities: capabilities ?? fs.capabilities & capabilitiesMask,
1466
+ dispose: () => fs.dispose()
1467
1467
  }, shadowFs, publicRoot);
1468
1468
  }
1469
- function fsPassThrough(fs$1, shadowFs, root) {
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$1 : shadowFs;
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$1.providerInfo;
1481
+ return fs.providerInfo;
1482
1482
  },
1483
1483
  get capabilities() {
1484
- return fs$1.capabilities;
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$1.dispose();
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.2",
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.2",
60
- "@cspell/url": "9.6.2"
59
+ "@cspell/cspell-service-bus": "9.6.3",
60
+ "@cspell/url": "9.6.3"
61
61
  },
62
- "gitHead": "646e18a04ff36d43f78a74e5055540e0f5297e91"
62
+ "gitHead": "500b996b6c0a6ff025c42ef98db44776f43a9e72"
63
63
  }