@lvce-editor/file-search-worker 1.13.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 +22 -65
- package/package.json +1 -1
|
@@ -111,18 +111,20 @@ const Slash$1 = '/';
|
|
|
111
111
|
|
|
112
112
|
const Slash = Slash$1;
|
|
113
113
|
|
|
114
|
+
// TODO move all of this to an extension
|
|
115
|
+
|
|
114
116
|
const readFile$1 = async uri => {
|
|
115
117
|
const fetchUri = `${assetDir}${uri}`;
|
|
116
118
|
const text = await getText(fetchUri);
|
|
117
119
|
return text;
|
|
118
120
|
};
|
|
119
|
-
const writeFile$1 = (
|
|
121
|
+
const writeFile$1 = () => {
|
|
120
122
|
throw new Error('not implemented');
|
|
121
123
|
};
|
|
122
|
-
const mkdir$1 =
|
|
124
|
+
const mkdir$1 = () => {
|
|
123
125
|
throw new Error('not implemented');
|
|
124
126
|
};
|
|
125
|
-
const remove$2 =
|
|
127
|
+
const remove$2 = () => {
|
|
126
128
|
throw new Error('not implemented');
|
|
127
129
|
};
|
|
128
130
|
const readDirWithFileTypes$1 = async uri => {
|
|
@@ -150,7 +152,7 @@ const readDirWithFileTypes$1 = async uri => {
|
|
|
150
152
|
}
|
|
151
153
|
return dirents;
|
|
152
154
|
};
|
|
153
|
-
const chmod$1 = (
|
|
155
|
+
const chmod$1 = () => {
|
|
154
156
|
throw new Error('[memfs] chmod not implemented');
|
|
155
157
|
};
|
|
156
158
|
const getBlob$1 = async uri => {
|
|
@@ -166,6 +168,8 @@ class FileNotFoundError extends Error {
|
|
|
166
168
|
}
|
|
167
169
|
}
|
|
168
170
|
|
|
171
|
+
// TODO move this to an extension?
|
|
172
|
+
|
|
169
173
|
const state$4 = {
|
|
170
174
|
files: Object.create(null)
|
|
171
175
|
};
|
|
@@ -281,7 +285,7 @@ const Memfs = 'memfs';
|
|
|
281
285
|
const Html = 'html';
|
|
282
286
|
const Fetch = 'fetch';
|
|
283
287
|
|
|
284
|
-
const RE_PROTOCOL = /^([a-z
|
|
288
|
+
const RE_PROTOCOL = /^([a-z-]+):\/\//;
|
|
285
289
|
const getProtocol = uri => {
|
|
286
290
|
const protocolMatch = uri.match(RE_PROTOCOL);
|
|
287
291
|
if (protocolMatch) {
|
|
@@ -290,7 +294,7 @@ const getProtocol = uri => {
|
|
|
290
294
|
return '';
|
|
291
295
|
};
|
|
292
296
|
|
|
293
|
-
const searchFile$4 = async (
|
|
297
|
+
const searchFile$4 = async () => {
|
|
294
298
|
const files = await getFiles();
|
|
295
299
|
const keys = Object.keys(files);
|
|
296
300
|
return keys;
|
|
@@ -311,10 +315,10 @@ const removeLeadingSlash = path => {
|
|
|
311
315
|
// TODO simplify code
|
|
312
316
|
// 1. don't have playground prefix in fileMap json
|
|
313
317
|
// 2. remove code here that removes the prefix
|
|
314
|
-
const searchFile$3 = async
|
|
318
|
+
const searchFile$3 = async path => {
|
|
315
319
|
const fileList = await getJson(fileMapUrl);
|
|
316
320
|
const result = fileList.map(removeLeadingSlash);
|
|
317
|
-
const prefixLength = path.
|
|
321
|
+
const prefixLength = path.length - 'file:///'.length;
|
|
318
322
|
const final = [];
|
|
319
323
|
for (const item of result) {
|
|
320
324
|
final.push(item.slice(prefixLength));
|
|
@@ -340,41 +344,6 @@ const fromAsync = async asyncIterable => {
|
|
|
340
344
|
return children;
|
|
341
345
|
};
|
|
342
346
|
|
|
343
|
-
let AssertionError$1 = class AssertionError extends Error {
|
|
344
|
-
constructor(message) {
|
|
345
|
-
super(message);
|
|
346
|
-
this.name = 'AssertionError';
|
|
347
|
-
}
|
|
348
|
-
};
|
|
349
|
-
const getType$2 = value => {
|
|
350
|
-
switch (typeof value) {
|
|
351
|
-
case 'number':
|
|
352
|
-
return 'number';
|
|
353
|
-
case 'function':
|
|
354
|
-
return 'function';
|
|
355
|
-
case 'string':
|
|
356
|
-
return 'string';
|
|
357
|
-
case 'object':
|
|
358
|
-
if (value === null) {
|
|
359
|
-
return 'null';
|
|
360
|
-
}
|
|
361
|
-
if (Array.isArray(value)) {
|
|
362
|
-
return 'array';
|
|
363
|
-
}
|
|
364
|
-
return 'object';
|
|
365
|
-
case 'boolean':
|
|
366
|
-
return 'boolean';
|
|
367
|
-
default:
|
|
368
|
-
return 'unknown';
|
|
369
|
-
}
|
|
370
|
-
};
|
|
371
|
-
const object = value => {
|
|
372
|
-
const type = getType$2(value);
|
|
373
|
-
if (type !== 'object') {
|
|
374
|
-
throw new AssertionError$1('expected value to be of type object');
|
|
375
|
-
}
|
|
376
|
-
};
|
|
377
|
-
|
|
378
347
|
/**
|
|
379
348
|
* Do not use directly, use FileSystemHtml.getChildHandles
|
|
380
349
|
* instead which prompts for the required permission to
|
|
@@ -382,7 +351,6 @@ const object = value => {
|
|
|
382
351
|
*
|
|
383
352
|
*/
|
|
384
353
|
const getChildHandles = async handle => {
|
|
385
|
-
object(handle);
|
|
386
354
|
// @ts-ignore
|
|
387
355
|
const handles = await fromAsync(handle.values());
|
|
388
356
|
return handles;
|
|
@@ -662,9 +630,8 @@ const state$3 = {
|
|
|
662
630
|
const getHandleDb = async () => {
|
|
663
631
|
// @ts-ignore
|
|
664
632
|
const db = await openDB('handle', state$3.dbVersion, {
|
|
665
|
-
async upgrade(db
|
|
633
|
+
async upgrade(db) {
|
|
666
634
|
if (!db.objectStoreNames.contains('file-handles-store')) {
|
|
667
|
-
// @ts-ignore
|
|
668
635
|
await db.createObjectStore('file-handles-store', {});
|
|
669
636
|
}
|
|
670
637
|
}
|
|
@@ -948,7 +915,7 @@ class AssertionError extends Error {
|
|
|
948
915
|
this.name = 'AssertionError';
|
|
949
916
|
}
|
|
950
917
|
}
|
|
951
|
-
const getType
|
|
918
|
+
const getType = value => {
|
|
952
919
|
switch (typeof value) {
|
|
953
920
|
case 'number':
|
|
954
921
|
return 'number';
|
|
@@ -971,7 +938,7 @@ const getType$1 = value => {
|
|
|
971
938
|
}
|
|
972
939
|
};
|
|
973
940
|
const number = value => {
|
|
974
|
-
const type = getType
|
|
941
|
+
const type = getType(value);
|
|
975
942
|
if (type !== 'number') {
|
|
976
943
|
throw new AssertionError('expected value to be of type number');
|
|
977
944
|
}
|
|
@@ -997,25 +964,12 @@ const create$3 = () => {
|
|
|
997
964
|
const warn = (...args) => {
|
|
998
965
|
console.warn(...args);
|
|
999
966
|
};
|
|
1000
|
-
const withResolvers$1 = () => {
|
|
1001
|
-
/**
|
|
1002
|
-
* @type {any}
|
|
1003
|
-
*/
|
|
1004
|
-
let _resolve;
|
|
1005
|
-
const promise = new Promise(resolve => {
|
|
1006
|
-
_resolve = resolve;
|
|
1007
|
-
});
|
|
1008
|
-
return {
|
|
1009
|
-
resolve: _resolve,
|
|
1010
|
-
promise
|
|
1011
|
-
};
|
|
1012
|
-
};
|
|
1013
967
|
const registerPromise = () => {
|
|
1014
968
|
const id = create$3();
|
|
1015
969
|
const {
|
|
1016
970
|
resolve,
|
|
1017
971
|
promise
|
|
1018
|
-
} = withResolvers
|
|
972
|
+
} = Promise.withResolvers();
|
|
1019
973
|
set(id, resolve);
|
|
1020
974
|
return {
|
|
1021
975
|
id,
|
|
@@ -1181,7 +1135,7 @@ const unwrapJsonRpcResult = responseMessage => {
|
|
|
1181
1135
|
throw new JsonRpcError('unexpected response message');
|
|
1182
1136
|
};
|
|
1183
1137
|
const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
|
|
1184
|
-
const
|
|
1138
|
+
const getErrorType = prettyError => {
|
|
1185
1139
|
if (prettyError && prettyError.type) {
|
|
1186
1140
|
return prettyError.type;
|
|
1187
1141
|
}
|
|
@@ -1204,7 +1158,7 @@ const getErrorProperty = (error, prettyError) => {
|
|
|
1204
1158
|
data: {
|
|
1205
1159
|
stack: prettyError.stack,
|
|
1206
1160
|
codeFrame: prettyError.codeFrame,
|
|
1207
|
-
type:
|
|
1161
|
+
type: getErrorType(prettyError),
|
|
1208
1162
|
code: prettyError.code,
|
|
1209
1163
|
name: prettyError.name
|
|
1210
1164
|
}
|
|
@@ -1322,6 +1276,9 @@ const invoke = (method, ...params) => {
|
|
|
1322
1276
|
};
|
|
1323
1277
|
|
|
1324
1278
|
const splitLines$1 = lines => {
|
|
1279
|
+
if (!lines) {
|
|
1280
|
+
return [];
|
|
1281
|
+
}
|
|
1325
1282
|
return lines.split('\n');
|
|
1326
1283
|
};
|
|
1327
1284
|
|
|
@@ -1397,7 +1354,7 @@ const requiresSocket = () => {
|
|
|
1397
1354
|
const preparePrettyError = error => {
|
|
1398
1355
|
return error;
|
|
1399
1356
|
};
|
|
1400
|
-
const logError =
|
|
1357
|
+
const logError = () => {
|
|
1401
1358
|
// handled by renderer worker
|
|
1402
1359
|
};
|
|
1403
1360
|
const handleMessage = event => {
|