@lvce-editor/file-system-worker 1.14.0 → 1.16.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.
@@ -634,7 +634,8 @@ const splitLines = lines => {
634
634
  return lines.split(NewLine);
635
635
  };
636
636
  const getCurrentStack = () => {
637
- const currentStack = joinLines(splitLines(new Error().stack || '').slice(2));
637
+ const stackLinesToSkip = 3;
638
+ const currentStack = joinLines(splitLines(new Error().stack || '').slice(stackLinesToSkip));
638
639
  return currentStack;
639
640
  };
640
641
  const getNewLineIndex = (string, startIndex = undefined) => {
@@ -905,6 +906,12 @@ const invokeAndTransfer$1 = (ipc, method, ...params) => {
905
906
  return invokeHelper(ipc, method, params, true);
906
907
  };
907
908
 
909
+ class CommandNotFoundError extends Error {
910
+ constructor(command) {
911
+ super(`Command not found ${command}`);
912
+ this.name = 'CommandNotFoundError';
913
+ }
914
+ }
908
915
  const commands = Object.create(null);
909
916
  const register = commandMap => {
910
917
  Object.assign(commands, commandMap);
@@ -915,7 +922,7 @@ const getCommand = key => {
915
922
  const execute = (command, ...args) => {
916
923
  const fn = getCommand(command);
917
924
  if (!fn) {
918
- throw new Error(`command not found ${command}`);
925
+ throw new CommandNotFoundError(command);
919
926
  }
920
927
  return fn(...args);
921
928
  };
@@ -1240,6 +1247,10 @@ const readFile = async uri => {
1240
1247
  }
1241
1248
  return readFile$1(uri);
1242
1249
  };
1250
+ const appendFile = async (uri, text) => {
1251
+ // @ts-ignore
1252
+ return undefined(uri, text);
1253
+ };
1243
1254
  const readDirWithFileTypes = async uri => {
1244
1255
  return readDirWithFileTypes$1(uri);
1245
1256
  };
@@ -1297,10 +1308,13 @@ const getFolderSize = async uri => {
1297
1308
  };
1298
1309
 
1299
1310
  const handleMessagePort = async (port, rpcId) => {
1300
- await PlainMessagePortRpc.create({
1311
+ const rpc = await PlainMessagePortRpc.create({
1301
1312
  commandMap: {},
1302
1313
  messagePort: port
1303
1314
  });
1315
+ if (rpcId) {
1316
+ set$g(rpcId, rpc);
1317
+ }
1304
1318
  };
1305
1319
 
1306
1320
  const getPortTuple = () => {
@@ -1399,6 +1413,7 @@ const commandMap = {
1399
1413
  'FileSystem.rename': rename,
1400
1414
  'FileSystem.stat': stat,
1401
1415
  'FileSystem.writeFile': writeFile,
1416
+ 'FileSystem.appendFile': appendFile,
1402
1417
  'FileSystem.handleMessagePort': handleMessagePort,
1403
1418
  'FileSystem.readFileAsBlob': readFileAsBlob,
1404
1419
  'Initialize.initialize': initialize
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/file-system-worker",
3
- "version": "1.14.0",
3
+ "version": "1.16.0",
4
4
  "description": "File System Worker",
5
5
  "keywords": [
6
6
  "Lvce Editor"