@lvce-editor/file-search-worker 1.11.0 → 1.12.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 +131 -60
- package/package.json +1 -1
|
@@ -18,9 +18,133 @@ const execute = (command, ...args) => {
|
|
|
18
18
|
return fn(...args);
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
+
const assetDir = '';
|
|
22
|
+
|
|
21
23
|
const Directory$1 = 3;
|
|
22
24
|
const File$1 = 7;
|
|
23
25
|
|
|
26
|
+
const normalizeLine$1 = line => {
|
|
27
|
+
if (line.startsWith('Error: ')) {
|
|
28
|
+
return line.slice(`Error: `.length);
|
|
29
|
+
}
|
|
30
|
+
if (line.startsWith('VError: ')) {
|
|
31
|
+
return line.slice(`VError: `.length);
|
|
32
|
+
}
|
|
33
|
+
return line;
|
|
34
|
+
};
|
|
35
|
+
const getCombinedMessage$1 = (error, message) => {
|
|
36
|
+
const stringifiedError = normalizeLine$1(`${error}`);
|
|
37
|
+
if (message) {
|
|
38
|
+
return `${message}: ${stringifiedError}`;
|
|
39
|
+
}
|
|
40
|
+
return stringifiedError;
|
|
41
|
+
};
|
|
42
|
+
const NewLine$3 = '\n';
|
|
43
|
+
const getNewLineIndex$2 = (string, startIndex = undefined) => {
|
|
44
|
+
return string.indexOf(NewLine$3, startIndex);
|
|
45
|
+
};
|
|
46
|
+
const mergeStacks$1 = (parent, child) => {
|
|
47
|
+
if (!child) {
|
|
48
|
+
return parent;
|
|
49
|
+
}
|
|
50
|
+
const parentNewLineIndex = getNewLineIndex$2(parent);
|
|
51
|
+
const childNewLineIndex = getNewLineIndex$2(child);
|
|
52
|
+
if (childNewLineIndex === -1) {
|
|
53
|
+
return parent;
|
|
54
|
+
}
|
|
55
|
+
const parentFirstLine = parent.slice(0, parentNewLineIndex);
|
|
56
|
+
const childRest = child.slice(childNewLineIndex);
|
|
57
|
+
const childFirstLine = normalizeLine$1(child.slice(0, childNewLineIndex));
|
|
58
|
+
if (parentFirstLine.includes(childFirstLine)) {
|
|
59
|
+
return parentFirstLine + childRest;
|
|
60
|
+
}
|
|
61
|
+
return child;
|
|
62
|
+
};
|
|
63
|
+
let VError$1 = class VError extends Error {
|
|
64
|
+
constructor(error, message) {
|
|
65
|
+
const combinedMessage = getCombinedMessage$1(error, message);
|
|
66
|
+
super(combinedMessage);
|
|
67
|
+
this.name = 'VError';
|
|
68
|
+
if (error instanceof Error) {
|
|
69
|
+
this.stack = mergeStacks$1(this.stack, error.stack);
|
|
70
|
+
}
|
|
71
|
+
if (error.codeFrame) {
|
|
72
|
+
// @ts-ignore
|
|
73
|
+
this.codeFrame = error.codeFrame;
|
|
74
|
+
}
|
|
75
|
+
if (error.code) {
|
|
76
|
+
// @ts-ignore
|
|
77
|
+
this.code = error.code;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const getText = async url => {
|
|
83
|
+
try {
|
|
84
|
+
const response = await fetch(url);
|
|
85
|
+
if (!response.ok) {
|
|
86
|
+
throw new Error(response.statusText);
|
|
87
|
+
}
|
|
88
|
+
const text = await response.text();
|
|
89
|
+
return text;
|
|
90
|
+
} catch (error) {
|
|
91
|
+
throw new VError$1(error, `Failed to request text for ${url}`);
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const Slash$1 = '/';
|
|
96
|
+
|
|
97
|
+
const Slash = Slash$1;
|
|
98
|
+
|
|
99
|
+
const readFile$1 = async uri => {
|
|
100
|
+
const fetchUri = `${assetDir}${uri}`;
|
|
101
|
+
const text = await getText(fetchUri);
|
|
102
|
+
return text;
|
|
103
|
+
};
|
|
104
|
+
const writeFile$1 = (uri, content) => {
|
|
105
|
+
throw new Error('not implemented');
|
|
106
|
+
};
|
|
107
|
+
const mkdir$1 = uri => {
|
|
108
|
+
throw new Error('not implemented');
|
|
109
|
+
};
|
|
110
|
+
const remove$2 = uri => {
|
|
111
|
+
throw new Error('not implemented');
|
|
112
|
+
};
|
|
113
|
+
const readDirWithFileTypes$1 = async uri => {
|
|
114
|
+
const fetchUri = `${assetDir}/config/fileMap.json`;
|
|
115
|
+
const fileList = await getText(fetchUri);
|
|
116
|
+
const dirents = [];
|
|
117
|
+
for (const fileUri of fileList) {
|
|
118
|
+
if (fileUri.startsWith(uri)) {
|
|
119
|
+
const rest = fileUri.slice(uri.length + 1);
|
|
120
|
+
if (rest.includes(Slash)) {
|
|
121
|
+
const name = rest.slice(0, rest.indexOf(Slash));
|
|
122
|
+
if (dirents.some(dirent => dirent.name === name)) {
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
dirents.push({
|
|
126
|
+
type: Directory$1,
|
|
127
|
+
name
|
|
128
|
+
});
|
|
129
|
+
} else {
|
|
130
|
+
dirents.push({
|
|
131
|
+
type: File$1,
|
|
132
|
+
name: rest
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return dirents;
|
|
138
|
+
};
|
|
139
|
+
const chmod$1 = (path, permissions) => {
|
|
140
|
+
throw new Error('[memfs] chmod not implemented');
|
|
141
|
+
};
|
|
142
|
+
const getBlob$1 = async uri => {
|
|
143
|
+
const content = await readFile$1(uri);
|
|
144
|
+
const blob = new Blob([content]);
|
|
145
|
+
return blob;
|
|
146
|
+
};
|
|
147
|
+
|
|
24
148
|
class FileNotFoundError extends Error {
|
|
25
149
|
constructor(uri) {
|
|
26
150
|
super(`File not found: ${uri}`);
|
|
@@ -28,10 +152,6 @@ class FileNotFoundError extends Error {
|
|
|
28
152
|
}
|
|
29
153
|
}
|
|
30
154
|
|
|
31
|
-
const Slash$1 = '/';
|
|
32
|
-
|
|
33
|
-
const Slash = Slash$1;
|
|
34
|
-
|
|
35
155
|
const state$4 = {
|
|
36
156
|
files: Object.create(null)
|
|
37
157
|
};
|
|
@@ -512,62 +632,6 @@ replaceTraps(oldTraps => ({
|
|
|
512
632
|
}
|
|
513
633
|
}));
|
|
514
634
|
|
|
515
|
-
const normalizeLine$1 = line => {
|
|
516
|
-
if (line.startsWith('Error: ')) {
|
|
517
|
-
return line.slice(`Error: `.length);
|
|
518
|
-
}
|
|
519
|
-
if (line.startsWith('VError: ')) {
|
|
520
|
-
return line.slice(`VError: `.length);
|
|
521
|
-
}
|
|
522
|
-
return line;
|
|
523
|
-
};
|
|
524
|
-
const getCombinedMessage$1 = (error, message) => {
|
|
525
|
-
const stringifiedError = normalizeLine$1(`${error}`);
|
|
526
|
-
if (message) {
|
|
527
|
-
return `${message}: ${stringifiedError}`;
|
|
528
|
-
}
|
|
529
|
-
return stringifiedError;
|
|
530
|
-
};
|
|
531
|
-
const NewLine$3 = '\n';
|
|
532
|
-
const getNewLineIndex$2 = (string, startIndex = undefined) => {
|
|
533
|
-
return string.indexOf(NewLine$3, startIndex);
|
|
534
|
-
};
|
|
535
|
-
const mergeStacks$1 = (parent, child) => {
|
|
536
|
-
if (!child) {
|
|
537
|
-
return parent;
|
|
538
|
-
}
|
|
539
|
-
const parentNewLineIndex = getNewLineIndex$2(parent);
|
|
540
|
-
const childNewLineIndex = getNewLineIndex$2(child);
|
|
541
|
-
if (childNewLineIndex === -1) {
|
|
542
|
-
return parent;
|
|
543
|
-
}
|
|
544
|
-
const parentFirstLine = parent.slice(0, parentNewLineIndex);
|
|
545
|
-
const childRest = child.slice(childNewLineIndex);
|
|
546
|
-
const childFirstLine = normalizeLine$1(child.slice(0, childNewLineIndex));
|
|
547
|
-
if (parentFirstLine.includes(childFirstLine)) {
|
|
548
|
-
return parentFirstLine + childRest;
|
|
549
|
-
}
|
|
550
|
-
return child;
|
|
551
|
-
};
|
|
552
|
-
let VError$1 = class VError extends Error {
|
|
553
|
-
constructor(error, message) {
|
|
554
|
-
const combinedMessage = getCombinedMessage$1(error, message);
|
|
555
|
-
super(combinedMessage);
|
|
556
|
-
this.name = 'VError';
|
|
557
|
-
if (error instanceof Error) {
|
|
558
|
-
this.stack = mergeStacks$1(this.stack, error.stack);
|
|
559
|
-
}
|
|
560
|
-
if (error.codeFrame) {
|
|
561
|
-
// @ts-ignore
|
|
562
|
-
this.codeFrame = error.codeFrame;
|
|
563
|
-
}
|
|
564
|
-
if (error.code) {
|
|
565
|
-
// @ts-ignore
|
|
566
|
-
this.code = error.code;
|
|
567
|
-
}
|
|
568
|
-
}
|
|
569
|
-
};
|
|
570
|
-
|
|
571
635
|
const state$3 = {
|
|
572
636
|
databases: Object.create(null),
|
|
573
637
|
eventId: 0,
|
|
@@ -1287,6 +1351,13 @@ const searchFile = async (path, value, prepare, assetDir) => {
|
|
|
1287
1351
|
};
|
|
1288
1352
|
|
|
1289
1353
|
const commandMap = {
|
|
1354
|
+
'FileSystemFetch.chmod': chmod$1,
|
|
1355
|
+
'FileSystemFetch.getBlob': getBlob$1,
|
|
1356
|
+
'FileSystemFetch.mkdir': mkdir$1,
|
|
1357
|
+
'FileSystemFetch.readDirWithFileTypes': readDirWithFileTypes$1,
|
|
1358
|
+
'FileSystemFetch.readFile': readFile$1,
|
|
1359
|
+
'FileSystemFetch.remove': remove$2,
|
|
1360
|
+
'FileSystemFetch.writeFile': writeFile$1,
|
|
1290
1361
|
'FileSystemMemory.chmod': chmod,
|
|
1291
1362
|
'FileSystemMemory.getBlob': getBlob,
|
|
1292
1363
|
'FileSystemMemory.getBlobUrl': getBlobUrl,
|