cspell-io 9.8.0 → 10.0.1
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 +44 -23
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -22,6 +22,9 @@ async function toArray(asyncIterable) {
|
|
|
22
22
|
//#endregion
|
|
23
23
|
//#region src/common/CFileReference.ts
|
|
24
24
|
var CFileReference = class CFileReference {
|
|
25
|
+
url;
|
|
26
|
+
encoding;
|
|
27
|
+
baseFilename;
|
|
25
28
|
/**
|
|
26
29
|
* Use to ensure the nominal type separation between CFileReference and FileReference
|
|
27
30
|
* See: https://github.com/microsoft/TypeScript/wiki/FAQ#when-and-why-are-classes-nominal
|
|
@@ -86,12 +89,14 @@ function toFileResourceRequest(file, encoding, signal) {
|
|
|
86
89
|
//#endregion
|
|
87
90
|
//#region src/errors/errors.ts
|
|
88
91
|
var ErrorNotImplemented = class extends Error {
|
|
92
|
+
method;
|
|
89
93
|
constructor(method, options) {
|
|
90
94
|
super(`Method ${method} is not supported.`, options);
|
|
91
95
|
this.method = method;
|
|
92
96
|
}
|
|
93
97
|
};
|
|
94
98
|
var AssertionError = class extends Error {
|
|
99
|
+
message;
|
|
95
100
|
constructor(message, options) {
|
|
96
101
|
super(message, options);
|
|
97
102
|
this.message = message;
|
|
@@ -457,6 +462,9 @@ const _fetch = globalThis.fetch;
|
|
|
457
462
|
//#endregion
|
|
458
463
|
//#region src/node/file/FetchError.ts
|
|
459
464
|
var FetchUrlError = class FetchUrlError extends Error {
|
|
465
|
+
code;
|
|
466
|
+
status;
|
|
467
|
+
url;
|
|
460
468
|
constructor(message, code, status, url) {
|
|
461
469
|
super(message);
|
|
462
470
|
this.code = code;
|
|
@@ -738,13 +746,14 @@ function direntToDirEntry(dir, dirent) {
|
|
|
738
746
|
};
|
|
739
747
|
}
|
|
740
748
|
function toFileType(statLike) {
|
|
741
|
-
const t = statLike.isFile() ?
|
|
742
|
-
return statLike.isSymbolicLink() ? t |
|
|
749
|
+
const t = statLike.isFile() ? 1 : statLike.isDirectory() ? 2 : 0;
|
|
750
|
+
return statLike.isSymbolicLink() ? t | 64 : t;
|
|
743
751
|
}
|
|
744
752
|
//#endregion
|
|
745
753
|
//#region src/CSpellIONode.ts
|
|
746
754
|
let defaultCSpellIONode = void 0;
|
|
747
755
|
var CSpellIONode = class {
|
|
756
|
+
serviceBus;
|
|
748
757
|
constructor(serviceBus = new ServiceBus()) {
|
|
749
758
|
this.serviceBus = serviceBus;
|
|
750
759
|
registerHandlers(serviceBus);
|
|
@@ -961,6 +970,8 @@ var VFSNotFoundError = class extends VFSError {
|
|
|
961
970
|
}
|
|
962
971
|
};
|
|
963
972
|
var VFSErrorUnsupportedRequest = class extends VFSError {
|
|
973
|
+
request;
|
|
974
|
+
parameters;
|
|
964
975
|
constructor(request, url, parameters) {
|
|
965
976
|
super(`Unsupported request: ${request}`, { url });
|
|
966
977
|
this.request = request;
|
|
@@ -1012,7 +1023,7 @@ var MemFileSystemProvider = class {
|
|
|
1012
1023
|
var MemVFileSystem = class {
|
|
1013
1024
|
name;
|
|
1014
1025
|
protocol;
|
|
1015
|
-
capabilities =
|
|
1026
|
+
capabilities = 7;
|
|
1016
1027
|
#files = /* @__PURE__ */ new Map();
|
|
1017
1028
|
constructor(name, protocol) {
|
|
1018
1029
|
this.name = name;
|
|
@@ -1037,7 +1048,7 @@ var MemVFileSystem = class {
|
|
|
1037
1048
|
const stats = {
|
|
1038
1049
|
size: file.content.length,
|
|
1039
1050
|
mtimeMs: performance.now(),
|
|
1040
|
-
fileType:
|
|
1051
|
+
fileType: 1
|
|
1041
1052
|
};
|
|
1042
1053
|
const u = urlOrReferenceToUrl(file);
|
|
1043
1054
|
this.#files.set(u.href, {
|
|
@@ -1082,23 +1093,24 @@ var MemVFileSystem = class {
|
|
|
1082
1093
|
//#endregion
|
|
1083
1094
|
//#region src/VirtualFS/capabilities.ts
|
|
1084
1095
|
var CFsCapabilities = class {
|
|
1096
|
+
flags;
|
|
1085
1097
|
constructor(flags) {
|
|
1086
1098
|
this.flags = flags;
|
|
1087
1099
|
}
|
|
1088
1100
|
get readFile() {
|
|
1089
|
-
return !!(this.flags &
|
|
1101
|
+
return !!(this.flags & 2);
|
|
1090
1102
|
}
|
|
1091
1103
|
get writeFile() {
|
|
1092
|
-
return !!(this.flags &
|
|
1104
|
+
return !!(this.flags & 4);
|
|
1093
1105
|
}
|
|
1094
1106
|
get readDirectory() {
|
|
1095
|
-
return !!(this.flags &
|
|
1107
|
+
return !!(this.flags & 8);
|
|
1096
1108
|
}
|
|
1097
1109
|
get writeDirectory() {
|
|
1098
|
-
return !!(this.flags &
|
|
1110
|
+
return !!(this.flags & 16);
|
|
1099
1111
|
}
|
|
1100
1112
|
get stat() {
|
|
1101
|
-
return !!(this.flags &
|
|
1113
|
+
return !!(this.flags & 1);
|
|
1102
1114
|
}
|
|
1103
1115
|
};
|
|
1104
1116
|
function fsCapabilities(flags) {
|
|
@@ -1107,27 +1119,29 @@ function fsCapabilities(flags) {
|
|
|
1107
1119
|
//#endregion
|
|
1108
1120
|
//#region src/VirtualFS/CFileType.ts
|
|
1109
1121
|
var CFileType = class {
|
|
1122
|
+
fileType;
|
|
1110
1123
|
constructor(fileType) {
|
|
1111
1124
|
this.fileType = fileType;
|
|
1112
1125
|
}
|
|
1113
1126
|
isFile() {
|
|
1114
|
-
return this.fileType ===
|
|
1127
|
+
return this.fileType === 1;
|
|
1115
1128
|
}
|
|
1116
1129
|
isDirectory() {
|
|
1117
|
-
return this.fileType ===
|
|
1130
|
+
return this.fileType === 2;
|
|
1118
1131
|
}
|
|
1119
1132
|
isUnknown() {
|
|
1120
1133
|
return !this.fileType;
|
|
1121
1134
|
}
|
|
1122
1135
|
isSymbolicLink() {
|
|
1123
|
-
return !!(this.fileType &
|
|
1136
|
+
return !!(this.fileType & 64);
|
|
1124
1137
|
}
|
|
1125
1138
|
};
|
|
1126
1139
|
//#endregion
|
|
1127
1140
|
//#region src/VirtualFS/CVfsStat.ts
|
|
1128
1141
|
var CVfsStat = class extends CFileType {
|
|
1142
|
+
stat;
|
|
1129
1143
|
constructor(stat) {
|
|
1130
|
-
super(stat.fileType ||
|
|
1144
|
+
super(stat.fileType || 0);
|
|
1131
1145
|
this.stat = stat;
|
|
1132
1146
|
}
|
|
1133
1147
|
get size() {
|
|
@@ -1143,8 +1157,8 @@ var CVfsStat = class extends CFileType {
|
|
|
1143
1157
|
//#endregion
|
|
1144
1158
|
//#region src/VirtualFS/WrappedProviderFs.ts
|
|
1145
1159
|
function cspellIOToFsProvider(cspellIO) {
|
|
1146
|
-
const capabilities =
|
|
1147
|
-
const capabilitiesHttp =
|
|
1160
|
+
const capabilities = 15;
|
|
1161
|
+
const capabilitiesHttp = 3;
|
|
1148
1162
|
const capMap = {
|
|
1149
1163
|
"file:": capabilities,
|
|
1150
1164
|
"http:": capabilitiesHttp,
|
|
@@ -1166,7 +1180,7 @@ function cspellIOToFsProvider(cspellIO) {
|
|
|
1166
1180
|
dispose,
|
|
1167
1181
|
capabilities,
|
|
1168
1182
|
getCapabilities(url) {
|
|
1169
|
-
return fsCapabilities(capMap[url.protocol] ||
|
|
1183
|
+
return fsCapabilities(capMap[url.protocol] || 0);
|
|
1170
1184
|
},
|
|
1171
1185
|
[Symbol.dispose]: dispose
|
|
1172
1186
|
};
|
|
@@ -1182,6 +1196,8 @@ function wrapError(e) {
|
|
|
1182
1196
|
return e;
|
|
1183
1197
|
}
|
|
1184
1198
|
var WrappedProviderFs = class WrappedProviderFs {
|
|
1199
|
+
fs;
|
|
1200
|
+
eventLogger;
|
|
1185
1201
|
hasProvider;
|
|
1186
1202
|
capabilities;
|
|
1187
1203
|
providerInfo;
|
|
@@ -1190,7 +1206,7 @@ var WrappedProviderFs = class WrappedProviderFs {
|
|
|
1190
1206
|
this.fs = fs;
|
|
1191
1207
|
this.eventLogger = eventLogger;
|
|
1192
1208
|
this.hasProvider = !!fs;
|
|
1193
|
-
this.capabilities = fs?.capabilities ||
|
|
1209
|
+
this.capabilities = fs?.capabilities || 0;
|
|
1194
1210
|
this._capabilities = fsCapabilities(this.capabilities);
|
|
1195
1211
|
this.providerInfo = fs?.providerInfo || { name: "unknown" };
|
|
1196
1212
|
}
|
|
@@ -1213,7 +1229,7 @@ var WrappedProviderFs = class WrappedProviderFs {
|
|
|
1213
1229
|
const url = urlOrReferenceToUrl(urlRef);
|
|
1214
1230
|
this.logEvent("stat", "start", traceID, url);
|
|
1215
1231
|
try {
|
|
1216
|
-
checkCapabilityOrThrow(this.fs, this.capabilities,
|
|
1232
|
+
checkCapabilityOrThrow(this.fs, this.capabilities, 1, "stat", url);
|
|
1217
1233
|
return new CVfsStat(await this.fs.stat(urlRef));
|
|
1218
1234
|
} catch (e) {
|
|
1219
1235
|
this.logEvent("stat", "error", traceID, url, e instanceof Error ? e.message : "");
|
|
@@ -1227,7 +1243,7 @@ var WrappedProviderFs = class WrappedProviderFs {
|
|
|
1227
1243
|
const url = urlOrReferenceToUrl(urlRef);
|
|
1228
1244
|
this.logEvent("readFile", "start", traceID, url);
|
|
1229
1245
|
try {
|
|
1230
|
-
checkCapabilityOrThrow(this.fs, this.capabilities,
|
|
1246
|
+
checkCapabilityOrThrow(this.fs, this.capabilities, 2, "readFile", url);
|
|
1231
1247
|
const readOptions = toOptions(optionsOrEncoding);
|
|
1232
1248
|
return fromFileResource(await this.fs.readFile(urlRef, readOptions), readOptions?.encoding);
|
|
1233
1249
|
} catch (e) {
|
|
@@ -1241,7 +1257,7 @@ var WrappedProviderFs = class WrappedProviderFs {
|
|
|
1241
1257
|
const traceID = performance.now();
|
|
1242
1258
|
this.logEvent("readDir", "start", traceID, url);
|
|
1243
1259
|
try {
|
|
1244
|
-
checkCapabilityOrThrow(this.fs, this.capabilities,
|
|
1260
|
+
checkCapabilityOrThrow(this.fs, this.capabilities, 8, "readDirectory", url);
|
|
1245
1261
|
return (await this.fs.readDirectory(url)).map((e) => new CVfsDirEntry(e));
|
|
1246
1262
|
} catch (e) {
|
|
1247
1263
|
this.logEvent("readDir", "error", traceID, url, e instanceof Error ? e.message : "");
|
|
@@ -1255,7 +1271,7 @@ var WrappedProviderFs = class WrappedProviderFs {
|
|
|
1255
1271
|
const url = file.url;
|
|
1256
1272
|
this.logEvent("writeFile", "start", traceID, url);
|
|
1257
1273
|
try {
|
|
1258
|
-
checkCapabilityOrThrow(this.fs, this.capabilities,
|
|
1274
|
+
checkCapabilityOrThrow(this.fs, this.capabilities, 4, "writeFile", file.url);
|
|
1259
1275
|
return await this.fs.writeFile(file);
|
|
1260
1276
|
} catch (e) {
|
|
1261
1277
|
this.logEvent("writeFile", "error", traceID, url, e instanceof Error ? e.message : "");
|
|
@@ -1269,9 +1285,10 @@ var WrappedProviderFs = class WrappedProviderFs {
|
|
|
1269
1285
|
}
|
|
1270
1286
|
};
|
|
1271
1287
|
function checkCapabilityOrThrow(fs, capabilities, flag, name, url) {
|
|
1272
|
-
if (!(capabilities & flag)) throw new VFSErrorUnsupportedRequest(name, url);
|
|
1288
|
+
if (!(capabilities & flag) || !fs) throw new VFSErrorUnsupportedRequest(name, url);
|
|
1273
1289
|
}
|
|
1274
1290
|
var CVfsDirEntry = class extends CFileType {
|
|
1291
|
+
entry;
|
|
1275
1292
|
_url;
|
|
1276
1293
|
constructor(entry) {
|
|
1277
1294
|
super(entry.fileType);
|
|
@@ -1438,7 +1455,7 @@ function createVirtualFS(cspellIO) {
|
|
|
1438
1455
|
const cspell = cspellIO || getDefaultCSpellIO();
|
|
1439
1456
|
const vfs = new CVirtualFS();
|
|
1440
1457
|
vfs.registerFileSystemProvider(cspellIOToFsProvider(cspell));
|
|
1441
|
-
vfs.registerFileSystemProvider(new MemFileSystemProvider(
|
|
1458
|
+
vfs.registerFileSystemProvider(new MemFileSystemProvider("cspell-vfs:default", CSPELL_VFS_PROTOCOL));
|
|
1442
1459
|
return vfs;
|
|
1443
1460
|
}
|
|
1444
1461
|
let defaultVirtualFs = void 0;
|
|
@@ -1449,6 +1466,10 @@ function getDefaultVirtualFs() {
|
|
|
1449
1466
|
//#endregion
|
|
1450
1467
|
//#region src/VirtualFS/redirectProvider.ts
|
|
1451
1468
|
var RedirectProvider = class {
|
|
1469
|
+
name;
|
|
1470
|
+
publicRoot;
|
|
1471
|
+
privateRoot;
|
|
1472
|
+
options;
|
|
1452
1473
|
constructor(name, publicRoot, privateRoot, options = { capabilitiesMask: -1 }) {
|
|
1453
1474
|
this.name = name;
|
|
1454
1475
|
this.publicRoot = publicRoot;
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public",
|
|
5
5
|
"provenance": true
|
|
6
6
|
},
|
|
7
|
-
"version": "
|
|
7
|
+
"version": "10.0.1",
|
|
8
8
|
"description": "A library of useful I/O functions used across various cspell tools.",
|
|
9
9
|
"type": "module",
|
|
10
10
|
"sideEffects": false,
|
|
@@ -48,16 +48,16 @@
|
|
|
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
|
-
"lorem-ipsum": "^2.0.
|
|
54
|
+
"lorem-ipsum": "^2.0.10",
|
|
55
55
|
"typescript": "~5.9.3",
|
|
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.1",
|
|
60
|
+
"@cspell/url": "10.0.1"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "0f43abf29e5da0ecbcb08214055cdc1e3267c3ea"
|
|
63
63
|
}
|