@lvce-editor/file-search-worker 1.14.0 → 1.15.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 +10 -60
- package/package.json +1 -1
|
@@ -285,7 +285,7 @@ const Memfs = 'memfs';
|
|
|
285
285
|
const Html = 'html';
|
|
286
286
|
const Fetch = 'fetch';
|
|
287
287
|
|
|
288
|
-
const RE_PROTOCOL = /^([a-z
|
|
288
|
+
const RE_PROTOCOL = /^([a-z-]+):\/\//;
|
|
289
289
|
const getProtocol = uri => {
|
|
290
290
|
const protocolMatch = uri.match(RE_PROTOCOL);
|
|
291
291
|
if (protocolMatch) {
|
|
@@ -294,7 +294,7 @@ const getProtocol = uri => {
|
|
|
294
294
|
return '';
|
|
295
295
|
};
|
|
296
296
|
|
|
297
|
-
const searchFile$4 = async (
|
|
297
|
+
const searchFile$4 = async () => {
|
|
298
298
|
const files = await getFiles();
|
|
299
299
|
const keys = Object.keys(files);
|
|
300
300
|
return keys;
|
|
@@ -315,7 +315,7 @@ const removeLeadingSlash = path => {
|
|
|
315
315
|
// TODO simplify code
|
|
316
316
|
// 1. don't have playground prefix in fileMap json
|
|
317
317
|
// 2. remove code here that removes the prefix
|
|
318
|
-
const searchFile$3 = async
|
|
318
|
+
const searchFile$3 = async path => {
|
|
319
319
|
const fileList = await getJson(fileMapUrl);
|
|
320
320
|
const result = fileList.map(removeLeadingSlash);
|
|
321
321
|
const prefixLength = path.length - 'file:///'.length;
|
|
@@ -344,41 +344,6 @@ const fromAsync = async asyncIterable => {
|
|
|
344
344
|
return children;
|
|
345
345
|
};
|
|
346
346
|
|
|
347
|
-
let AssertionError$1 = class AssertionError extends Error {
|
|
348
|
-
constructor(message) {
|
|
349
|
-
super(message);
|
|
350
|
-
this.name = 'AssertionError';
|
|
351
|
-
}
|
|
352
|
-
};
|
|
353
|
-
const getType$2 = value => {
|
|
354
|
-
switch (typeof value) {
|
|
355
|
-
case 'number':
|
|
356
|
-
return 'number';
|
|
357
|
-
case 'function':
|
|
358
|
-
return 'function';
|
|
359
|
-
case 'string':
|
|
360
|
-
return 'string';
|
|
361
|
-
case 'object':
|
|
362
|
-
if (value === null) {
|
|
363
|
-
return 'null';
|
|
364
|
-
}
|
|
365
|
-
if (Array.isArray(value)) {
|
|
366
|
-
return 'array';
|
|
367
|
-
}
|
|
368
|
-
return 'object';
|
|
369
|
-
case 'boolean':
|
|
370
|
-
return 'boolean';
|
|
371
|
-
default:
|
|
372
|
-
return 'unknown';
|
|
373
|
-
}
|
|
374
|
-
};
|
|
375
|
-
const object = value => {
|
|
376
|
-
const type = getType$2(value);
|
|
377
|
-
if (type !== 'object') {
|
|
378
|
-
throw new AssertionError$1('expected value to be of type object');
|
|
379
|
-
}
|
|
380
|
-
};
|
|
381
|
-
|
|
382
347
|
/**
|
|
383
348
|
* Do not use directly, use FileSystemHtml.getChildHandles
|
|
384
349
|
* instead which prompts for the required permission to
|
|
@@ -386,7 +351,6 @@ const object = value => {
|
|
|
386
351
|
*
|
|
387
352
|
*/
|
|
388
353
|
const getChildHandles = async handle => {
|
|
389
|
-
object(handle);
|
|
390
354
|
// @ts-ignore
|
|
391
355
|
const handles = await fromAsync(handle.values());
|
|
392
356
|
return handles;
|
|
@@ -666,9 +630,8 @@ const state$3 = {
|
|
|
666
630
|
const getHandleDb = async () => {
|
|
667
631
|
// @ts-ignore
|
|
668
632
|
const db = await openDB('handle', state$3.dbVersion, {
|
|
669
|
-
async upgrade(db
|
|
633
|
+
async upgrade(db) {
|
|
670
634
|
if (!db.objectStoreNames.contains('file-handles-store')) {
|
|
671
|
-
// @ts-ignore
|
|
672
635
|
await db.createObjectStore('file-handles-store', {});
|
|
673
636
|
}
|
|
674
637
|
}
|
|
@@ -952,7 +915,7 @@ class AssertionError extends Error {
|
|
|
952
915
|
this.name = 'AssertionError';
|
|
953
916
|
}
|
|
954
917
|
}
|
|
955
|
-
const getType
|
|
918
|
+
const getType = value => {
|
|
956
919
|
switch (typeof value) {
|
|
957
920
|
case 'number':
|
|
958
921
|
return 'number';
|
|
@@ -975,7 +938,7 @@ const getType$1 = value => {
|
|
|
975
938
|
}
|
|
976
939
|
};
|
|
977
940
|
const number = value => {
|
|
978
|
-
const type = getType
|
|
941
|
+
const type = getType(value);
|
|
979
942
|
if (type !== 'number') {
|
|
980
943
|
throw new AssertionError('expected value to be of type number');
|
|
981
944
|
}
|
|
@@ -1001,25 +964,12 @@ const create$3 = () => {
|
|
|
1001
964
|
const warn = (...args) => {
|
|
1002
965
|
console.warn(...args);
|
|
1003
966
|
};
|
|
1004
|
-
const withResolvers$1 = () => {
|
|
1005
|
-
/**
|
|
1006
|
-
* @type {any}
|
|
1007
|
-
*/
|
|
1008
|
-
let _resolve;
|
|
1009
|
-
const promise = new Promise(resolve => {
|
|
1010
|
-
_resolve = resolve;
|
|
1011
|
-
});
|
|
1012
|
-
return {
|
|
1013
|
-
resolve: _resolve,
|
|
1014
|
-
promise
|
|
1015
|
-
};
|
|
1016
|
-
};
|
|
1017
967
|
const registerPromise = () => {
|
|
1018
968
|
const id = create$3();
|
|
1019
969
|
const {
|
|
1020
970
|
resolve,
|
|
1021
971
|
promise
|
|
1022
|
-
} = withResolvers
|
|
972
|
+
} = Promise.withResolvers();
|
|
1023
973
|
set(id, resolve);
|
|
1024
974
|
return {
|
|
1025
975
|
id,
|
|
@@ -1185,7 +1135,7 @@ const unwrapJsonRpcResult = responseMessage => {
|
|
|
1185
1135
|
throw new JsonRpcError('unexpected response message');
|
|
1186
1136
|
};
|
|
1187
1137
|
const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
|
|
1188
|
-
const
|
|
1138
|
+
const getErrorType = prettyError => {
|
|
1189
1139
|
if (prettyError && prettyError.type) {
|
|
1190
1140
|
return prettyError.type;
|
|
1191
1141
|
}
|
|
@@ -1208,7 +1158,7 @@ const getErrorProperty = (error, prettyError) => {
|
|
|
1208
1158
|
data: {
|
|
1209
1159
|
stack: prettyError.stack,
|
|
1210
1160
|
codeFrame: prettyError.codeFrame,
|
|
1211
|
-
type:
|
|
1161
|
+
type: getErrorType(prettyError),
|
|
1212
1162
|
code: prettyError.code,
|
|
1213
1163
|
name: prettyError.name
|
|
1214
1164
|
}
|
|
@@ -1404,7 +1354,7 @@ const requiresSocket = () => {
|
|
|
1404
1354
|
const preparePrettyError = error => {
|
|
1405
1355
|
return error;
|
|
1406
1356
|
};
|
|
1407
|
-
const logError =
|
|
1357
|
+
const logError = () => {
|
|
1408
1358
|
// handled by renderer worker
|
|
1409
1359
|
};
|
|
1410
1360
|
const handleMessage = event => {
|