@lvce-editor/pty-host 6.1.0 → 7.1.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.
Files changed (2) hide show
  1. package/dist/ptyHostMain.js +32 -25
  2. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
+ import { fileURLToPath } from 'node:url';
1
2
  import { Console } from 'node:console';
2
3
  import { createWriteStream, readFileSync } from 'node:fs';
3
4
  import { tmpdir } from 'node:os';
4
- import { fileURLToPath } from 'node:url';
5
5
  import { Buffer } from 'node:buffer';
6
6
 
7
7
  class CommandNotFoundError extends Error {
@@ -1276,14 +1276,14 @@ const Auto = () => {
1276
1276
 
1277
1277
  const getModule = method => {
1278
1278
  switch (method) {
1279
+ case ElectronMessagePort:
1280
+ return ElectronMessagePortRpcClient;
1281
+ case ElectronUtilityProcess:
1282
+ return ElectronUtilityProcessRpcClient;
1279
1283
  case NodeForkedProcess:
1280
1284
  return NodeForkedProcessRpcClient;
1281
1285
  case WebSocket:
1282
1286
  return NodeWebSocketRpcClient;
1283
- case ElectronUtilityProcess:
1284
- return ElectronUtilityProcessRpcClient;
1285
- case ElectronMessagePort:
1286
- return ElectronMessagePortRpcClient;
1287
1287
  default:
1288
1288
  throw new Error('unexpected ipc type');
1289
1289
  }
@@ -1301,8 +1301,8 @@ const listen$1 = async ({
1301
1301
 
1302
1302
  const handleNodeMessagePort = async messagePort => {
1303
1303
  await listen$1({
1304
- method: NodeMessagePort,
1305
- messagePort
1304
+ messagePort,
1305
+ method: NodeMessagePort
1306
1306
  });
1307
1307
  };
1308
1308
 
@@ -1358,6 +1358,12 @@ class Pty extends EventTarget {
1358
1358
  this.pty.write(data);
1359
1359
  }
1360
1360
  }
1361
+ const toPath = pathOrUri => {
1362
+ if (pathOrUri && pathOrUri.startsWith('file://')) {
1363
+ return fileURLToPath(pathOrUri).toString();
1364
+ }
1365
+ return pathOrUri;
1366
+ };
1361
1367
 
1362
1368
  /**
1363
1369
  *
@@ -1365,9 +1371,9 @@ class Pty extends EventTarget {
1365
1371
  * @returns {Promise<any>}
1366
1372
  */
1367
1373
  const create$1 = async ({
1368
- cwd,
1374
+ args,
1369
1375
  command,
1370
- args
1376
+ cwd
1371
1377
  } = {}) => {
1372
1378
  try {
1373
1379
  string(cwd);
@@ -1376,9 +1382,10 @@ const create$1 = async ({
1376
1382
  const {
1377
1383
  spawn
1378
1384
  } = await import('node-pty');
1385
+ const cwdPath = toPath(cwd);
1379
1386
  const pty = spawn(command, args, {
1380
- encoding: null,
1381
- cwd
1387
+ cwd: cwdPath,
1388
+ encoding: null
1382
1389
  // cols: 10,
1383
1390
  // rows: 10,
1384
1391
  });
@@ -1411,9 +1418,9 @@ const create = async (ipc, id, cwd, command, args) => {
1411
1418
  object(ipc);
1412
1419
  // @ts-ignore
1413
1420
  const pty = await create$1({
1414
- cwd,
1421
+ args,
1415
1422
  command,
1416
- args
1423
+ cwd
1417
1424
  });
1418
1425
  const handleData = event => {
1419
1426
  ipc.send({
@@ -1461,9 +1468,9 @@ const commandMap = {
1461
1468
  [HandleNodeMessagePort]: handleNodeMessagePort,
1462
1469
  [HandleWebSocket]: handleWebSocket,
1463
1470
  [TerminalCreate]: create,
1471
+ [TerminalDispose]: dispose,
1464
1472
  [TerminalResize]: resize,
1465
- [TerminalWrite]: write,
1466
- [TerminalDispose]: dispose
1473
+ [TerminalWrite]: write
1467
1474
  };
1468
1475
 
1469
1476
  const listen = async () => {
@@ -1775,54 +1782,54 @@ var hasRequiredLib$1;
1775
1782
  function requireLib$1 () {
1776
1783
  if (hasRequiredLib$1) return lib;
1777
1784
  hasRequiredLib$1 = 1;
1778
- (function (exports) {
1785
+ (function (exports$1) {
1779
1786
 
1780
- Object.defineProperty(exports, "__esModule", {
1787
+ Object.defineProperty(exports$1, "__esModule", {
1781
1788
  value: true
1782
1789
  });
1783
- Object.defineProperty(exports, "isIdentifierChar", {
1790
+ Object.defineProperty(exports$1, "isIdentifierChar", {
1784
1791
  enumerable: true,
1785
1792
  get: function () {
1786
1793
  return _identifier.isIdentifierChar;
1787
1794
  }
1788
1795
  });
1789
- Object.defineProperty(exports, "isIdentifierName", {
1796
+ Object.defineProperty(exports$1, "isIdentifierName", {
1790
1797
  enumerable: true,
1791
1798
  get: function () {
1792
1799
  return _identifier.isIdentifierName;
1793
1800
  }
1794
1801
  });
1795
- Object.defineProperty(exports, "isIdentifierStart", {
1802
+ Object.defineProperty(exports$1, "isIdentifierStart", {
1796
1803
  enumerable: true,
1797
1804
  get: function () {
1798
1805
  return _identifier.isIdentifierStart;
1799
1806
  }
1800
1807
  });
1801
- Object.defineProperty(exports, "isKeyword", {
1808
+ Object.defineProperty(exports$1, "isKeyword", {
1802
1809
  enumerable: true,
1803
1810
  get: function () {
1804
1811
  return _keyword.isKeyword;
1805
1812
  }
1806
1813
  });
1807
- Object.defineProperty(exports, "isReservedWord", {
1814
+ Object.defineProperty(exports$1, "isReservedWord", {
1808
1815
  enumerable: true,
1809
1816
  get: function () {
1810
1817
  return _keyword.isReservedWord;
1811
1818
  }
1812
1819
  });
1813
- Object.defineProperty(exports, "isStrictBindOnlyReservedWord", {
1820
+ Object.defineProperty(exports$1, "isStrictBindOnlyReservedWord", {
1814
1821
  enumerable: true,
1815
1822
  get: function () {
1816
1823
  return _keyword.isStrictBindOnlyReservedWord;
1817
1824
  }
1818
1825
  });
1819
- Object.defineProperty(exports, "isStrictBindReservedWord", {
1826
+ Object.defineProperty(exports$1, "isStrictBindReservedWord", {
1820
1827
  enumerable: true,
1821
1828
  get: function () {
1822
1829
  return _keyword.isStrictBindReservedWord;
1823
1830
  }
1824
1831
  });
1825
- Object.defineProperty(exports, "isStrictReservedWord", {
1832
+ Object.defineProperty(exports$1, "isStrictReservedWord", {
1826
1833
  enumerable: true,
1827
1834
  get: function () {
1828
1835
  return _keyword.isStrictReservedWord;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/pty-host",
3
- "version": "6.1.0",
3
+ "version": "7.1.0",
4
4
  "keywords": [
5
5
  "lvce-editor",
6
6
  "pty-host"