@lvce-editor/file-search-worker 2.1.0 → 2.2.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/fileSearchWorkerMain.js +58 -15
- package/package.json +1 -1
|
@@ -924,15 +924,66 @@ class FileNotFoundError extends Error {
|
|
|
924
924
|
}
|
|
925
925
|
}
|
|
926
926
|
|
|
927
|
-
const
|
|
928
|
-
|
|
929
|
-
|
|
927
|
+
const ApplicationJson = 'application/json';
|
|
928
|
+
const AudioMpeg = 'audio/mpeg';
|
|
929
|
+
const FontTtf = 'font/ttf';
|
|
930
|
+
const ImagePng = 'image/png';
|
|
931
|
+
const ImageSvgXml = 'image/svg+xml';
|
|
932
|
+
const TextCss = 'text/css';
|
|
933
|
+
const TextHtml = 'text/html';
|
|
934
|
+
const TextJavaScript = 'text/javascript';
|
|
935
|
+
const TextPlain = 'text/plain';
|
|
936
|
+
const VideoWebm = 'video/webm';
|
|
937
|
+
|
|
938
|
+
const getMimeType = fileExtension => {
|
|
939
|
+
switch (fileExtension) {
|
|
940
|
+
case '.html':
|
|
941
|
+
return TextHtml;
|
|
942
|
+
case '.css':
|
|
943
|
+
return TextCss;
|
|
944
|
+
case '.ttf':
|
|
945
|
+
return FontTtf;
|
|
946
|
+
case '.js':
|
|
947
|
+
case '.mjs':
|
|
948
|
+
case '.ts':
|
|
949
|
+
return TextJavaScript;
|
|
950
|
+
case '.svg':
|
|
951
|
+
return ImageSvgXml;
|
|
952
|
+
case '.png':
|
|
953
|
+
return ImagePng;
|
|
954
|
+
case '.json':
|
|
955
|
+
case '.map':
|
|
956
|
+
return ApplicationJson;
|
|
957
|
+
case '.mp3':
|
|
958
|
+
return AudioMpeg;
|
|
959
|
+
case '.webm':
|
|
960
|
+
return VideoWebm;
|
|
961
|
+
case '.txt':
|
|
962
|
+
return TextPlain;
|
|
963
|
+
default:
|
|
964
|
+
return '';
|
|
930
965
|
}
|
|
931
|
-
|
|
932
|
-
|
|
966
|
+
};
|
|
967
|
+
|
|
968
|
+
const dirname = (pathSeparator, path) => {
|
|
969
|
+
const index = path.lastIndexOf(pathSeparator);
|
|
970
|
+
if (index === -1) {
|
|
971
|
+
return path;
|
|
933
972
|
}
|
|
934
|
-
|
|
935
|
-
|
|
973
|
+
return path.slice(0, index);
|
|
974
|
+
};
|
|
975
|
+
const extname = path => {
|
|
976
|
+
const index = path.lastIndexOf('.');
|
|
977
|
+
if (index === -1) {
|
|
978
|
+
return '';
|
|
979
|
+
}
|
|
980
|
+
return path.slice(index);
|
|
981
|
+
};
|
|
982
|
+
|
|
983
|
+
const getContentType = uri => {
|
|
984
|
+
const extension = extname(uri);
|
|
985
|
+
const mime = getMimeType(extension);
|
|
986
|
+
return mime;
|
|
936
987
|
};
|
|
937
988
|
|
|
938
989
|
// TODO move this to an extension?
|
|
@@ -1125,14 +1176,6 @@ const getChildHandles = async handle => {
|
|
|
1125
1176
|
return handles;
|
|
1126
1177
|
};
|
|
1127
1178
|
|
|
1128
|
-
const dirname = (pathSeparator, path) => {
|
|
1129
|
-
const index = path.lastIndexOf(pathSeparator);
|
|
1130
|
-
if (index === -1) {
|
|
1131
|
-
return path;
|
|
1132
|
-
}
|
|
1133
|
-
return path.slice(0, index);
|
|
1134
|
-
};
|
|
1135
|
-
|
|
1136
1179
|
const instanceOfAny = (object, constructors) => constructors.some(c => object instanceof c);
|
|
1137
1180
|
let idbProxyableTypes;
|
|
1138
1181
|
let cursorAdvanceMethods;
|