@maxbill/dsh-file-explorer 1.2.2 → 1.2.3

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 (29) hide show
  1. package/lib/client.js +25 -5
  2. package/lib/index.js +67 -22
  3. package/package.json +3 -5
  4. package/vendor/node-pty/LICENSE +69 -0
  5. package/vendor/node-pty/lib/conpty_console_list_agent.js +16 -0
  6. package/vendor/node-pty/lib/eventEmitter2.js +47 -0
  7. package/vendor/node-pty/lib/index.js +52 -0
  8. package/vendor/node-pty/lib/interfaces.js +7 -0
  9. package/vendor/node-pty/lib/shared/conout.js +11 -0
  10. package/vendor/node-pty/lib/terminal.js +190 -0
  11. package/vendor/node-pty/lib/types.js +7 -0
  12. package/vendor/node-pty/lib/unixTerminal.js +346 -0
  13. package/vendor/node-pty/lib/utils.js +39 -0
  14. package/vendor/node-pty/lib/windowsConoutConnection.js +125 -0
  15. package/vendor/node-pty/lib/windowsPtyAgent.js +320 -0
  16. package/vendor/node-pty/lib/windowsTerminal.js +199 -0
  17. package/vendor/node-pty/lib/worker/conoutSocketWorker.js +22 -0
  18. package/vendor/node-pty/package.json +41 -0
  19. package/vendor/node-pty/prebuilds/darwin-arm64/pty.node +0 -0
  20. package/vendor/node-pty/prebuilds/darwin-arm64/spawn-helper +0 -0
  21. package/vendor/node-pty/prebuilds/darwin-x64/pty.node +0 -0
  22. package/vendor/node-pty/prebuilds/darwin-x64/spawn-helper +0 -0
  23. package/vendor/node-pty/prebuilds/win32-x64/conpty/OpenConsole.exe +0 -0
  24. package/vendor/node-pty/prebuilds/win32-x64/conpty/conpty.dll +0 -0
  25. package/vendor/node-pty/prebuilds/win32-x64/conpty.node +0 -0
  26. package/vendor/node-pty/prebuilds/win32-x64/conpty_console_list.node +0 -0
  27. package/vendor/node-pty/prebuilds/win32-x64/pty.node +0 -0
  28. package/vendor/node-pty/prebuilds/win32-x64/winpty-agent.exe +0 -0
  29. package/vendor/node-pty/prebuilds/win32-x64/winpty.dll +0 -0
package/lib/client.js CHANGED
@@ -28,9 +28,9 @@ window.__ModuleLoader__.load({
28
28
  script.src = API + "/vendor?name=xterm.js";
29
29
  script.onload = function () {
30
30
  if (window.Terminal) resolve(window.Terminal);
31
- else reject(new Error("xterm did not register"));
31
+ else { xtermPromise = null; reject(new Error("xterm did not register")); }
32
32
  };
33
- script.onerror = function () { reject(new Error("xterm failed to load")); };
33
+ script.onerror = function () { xtermPromise = null; reject(new Error("xterm failed to load")); };
34
34
  document.head.appendChild(script);
35
35
  });
36
36
  return xtermPromise;
@@ -109,6 +109,8 @@ window.__ModuleLoader__.load({
109
109
  function TerminalDock(props) {
110
110
  var hostRef = useRef(null);
111
111
  var termRef = useRef(null);
112
+ var [loadFailed, setLoadFailed] = useState(false);
113
+ var [retryTick, setRetryTick] = useState(0);
112
114
  var [revision, setRevision] = useState(function () {
113
115
  if (termTabs.length === 0) termEnsureTab(props.cwd);
114
116
  else if (!termActiveKey) termActiveKey = termTabs[0].key;
@@ -136,6 +138,7 @@ window.__ModuleLoader__.load({
136
138
  useEffect(function () {
137
139
  var disposed = false;
138
140
  var terminal = null;
141
+ setLoadFailed(false);
139
142
  loadXterm().then(function (Terminal) {
140
143
  if (disposed) return;
141
144
  var host = hostRef.current;
@@ -155,13 +158,13 @@ window.__ModuleLoader__.load({
155
158
  terminal.resize(grid.cols, grid.rows);
156
159
  termCenter(host, terminal);
157
160
  setRevision(function (count) { return count + 1; });
158
- });
161
+ }).catch(function () { if (!disposed) setLoadFailed(true); });
159
162
  return function () {
160
163
  disposed = true;
161
164
  if (terminal) terminal.dispose();
162
165
  termRef.current = null;
163
166
  };
164
- }, []);
167
+ }, [retryTick]);
165
168
 
166
169
  // bind the reused terminal to the active tab: replay its screen, then
167
170
  // forward keys and poll its output
@@ -332,7 +335,18 @@ window.__ModuleLoader__.load({
332
335
  "aria-label": t("隐藏终端"),
333
336
  onClick: props.onClose,
334
337
  }, glyph("chevronDown", 15))),
335
- h("div", { className: "dfx-term-body", ref: hostRef }));
338
+ h("div", { className: "dfx-term-body", ref: hostRef },
339
+ loadFailed
340
+ ? h("div", { className: "dfx-term-fail" },
341
+ glyph("terminal", 18),
342
+ h("span", null, t("终端渲染器加载失败")),
343
+ h("span", { className: "dfx-term-fail-hint" }, t("插件里的 @xterm/xterm 没有找到,重装插件或刷新后重试")),
344
+ h("button", {
345
+ type: "button",
346
+ className: "dfx-btn",
347
+ onClick: function () { setLoadFailed(false); setRetryTick(function (count) { return count + 1; }); },
348
+ }, t("重试")))
349
+ : null));
336
350
  }
337
351
 
338
352
  /** Identity shared by the sidebar entry and the main panel it opens. */
@@ -555,6 +569,9 @@ window.__ModuleLoader__.load({
555
569
  "添加为工作区": "Add as workspace",
556
570
  "终端": "Terminal",
557
571
  "新建终端": "New terminal",
572
+ "终端渲染器加载失败": "The terminal renderer failed to load",
573
+ "插件里的 @xterm/xterm 没有找到,重装插件或刷新后重试": "@xterm/xterm was not found in the plugin; reinstall it or reload and retry",
574
+ "重试": "Retry",
558
575
  "隐藏终端": "Hide terminal",
559
576
  "双击重命名": "Double-click to rename",
560
577
  "在终端打开": "Open in terminal",
@@ -1075,6 +1092,9 @@ window.__ModuleLoader__.load({
1075
1092
  .dfx-term-spacer { flex: 1 1 auto; }
1076
1093
  .dfx-term-body { flex: 1 1 auto; min-height: 0; padding: 11px 10px 12px; overflow: hidden; }
1077
1094
  .dfx-term-body .xterm { height: 100%; }
1095
+ .dfx-term-fail { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; height: 100%; font-size: 12.5px; color: inherit; opacity: .75; text-align: center; }
1096
+ .dfx-term-fail-hint { font-size: 11.5px; opacity: .7; max-width: 420px; }
1097
+ .dfx-term-fail .dfx-btn { margin-top: 4px; }
1078
1098
  .dfx-term .dfx-navbtn { color: inherit; opacity: .7; }
1079
1099
  .dfx-term .dfx-navbtn:hover { opacity: 1; }
1080
1100
  .dfx-term .dfx-navbtn--active { opacity: 1; }
package/lib/index.js CHANGED
@@ -30,7 +30,7 @@ import { chmodSync, createWriteStream, existsSync } from 'node:fs'
30
30
  import { createRequire } from 'node:module'
31
31
  import { access, cp, lstat, mkdir, readFile, readdir, realpath, rename, rm, stat, writeFile } from 'node:fs/promises'
32
32
  import { homedir, platform } from 'node:os'
33
- import { pathToFileURL } from 'node:url'
33
+ import { fileURLToPath, pathToFileURL } from 'node:url'
34
34
  import { basename, dirname, extname, join, resolve, sep } from 'node:path'
35
35
  import { Readable } from 'node:stream'
36
36
  import { deflateRawSync, inflateRawSync } from 'node:zlib'
@@ -1186,30 +1186,47 @@ let termPtyModule = null
1186
1186
  let termPtyTried = false
1187
1187
 
1188
1188
  /**
1189
- * Load the optional pty backend. node-pty ships prebuilt binaries for
1190
- * macOS and Windows, so nothing is compiled; the macOS spawn helper loses
1191
- * its exec bit through some package managers, so it is repaired here.
1189
+ * Make the macOS spawn helper executable: some package managers drop the bit,
1190
+ * and a non-executable helper makes spawn fail with posix_spawnp.
1191
+ * @param {string|null} root - node-pty package directory
1192
+ * @returns {void}
1193
+ */
1194
+ function repairSpawnHelper(root) {
1195
+ if (!root) return
1196
+ for (const rel of ["prebuilds/" + process.platform + "-" + process.arch + "/spawn-helper", "build/Release/spawn-helper"]) {
1197
+ const helper = join(root, rel)
1198
+ try {
1199
+ if (existsSync(helper)) chmodSync(helper, 0o755)
1200
+ } catch {}
1201
+ }
1202
+ }
1203
+
1204
+ /**
1205
+ * Load the pty backend. The copy vendored into this package is used first,
1206
+ * so nothing has to be installed; a separately installed node-pty still works
1207
+ * as a fallback for older setups.
1192
1208
  * @returns {object|null} the node-pty module, or null when unavailable.
1193
1209
  */
1194
1210
  function loadNodePty() {
1195
1211
  if (termPtyTried) return termPtyModule
1196
1212
  termPtyTried = true
1213
+ const require = createRequire(import.meta.url)
1214
+ let vendored = null
1197
1215
  try {
1198
- const require = createRequire(import.meta.url)
1199
- const loaded = require("node-pty")
1216
+ vendored = fileURLToPath(new URL("../vendor/node-pty/lib/index.js", import.meta.url))
1217
+ } catch {}
1218
+ for (const candidate of [vendored, "node-pty"]) {
1219
+ if (!candidate) continue
1200
1220
  try {
1201
- const pkg = require.resolve("node-pty/package.json")
1202
- const root = dirname(pkg)
1203
- for (const rel of ["prebuilds/" + process.platform + "-" + process.arch + "/spawn-helper", "build/Release/spawn-helper"]) {
1204
- const helper = join(root, rel)
1205
- if (existsSync(helper)) {
1206
- try { chmodSync(helper, 0o755) } catch {}
1207
- }
1221
+ const loaded = require(candidate)
1222
+ termPtyModule = loaded
1223
+ if (candidate === vendored) {
1224
+ repairSpawnHelper(dirname(vendored))
1225
+ } else {
1226
+ try { repairSpawnHelper(dirname(require.resolve("node-pty/package.json"))) } catch {}
1208
1227
  }
1228
+ break
1209
1229
  } catch {}
1210
- termPtyModule = loaded
1211
- } catch {
1212
- termPtyModule = null
1213
1230
  }
1214
1231
  return termPtyModule
1215
1232
  }
@@ -1384,18 +1401,46 @@ function pollTerm(id, since) {
1384
1401
  return { gone: false, data: parts.join(""), since: session.nextSeq, exited: session.exited, code: session.code }
1385
1402
  }
1386
1403
 
1404
+ /**
1405
+ * Where @xterm/xterm may live. Node resolution comes first: a pnpm profile
1406
+ * with nodeLinker: hoisted keeps the package in the profile root rather than
1407
+ * inside the plugin, and only the resolver finds it there. The old plugin-
1408
+ * local path stays as a fallback.
1409
+ * @param {string} rel - path inside the package
1410
+ * @returns {string[]} candidate absolute paths, best first
1411
+ */
1412
+ function vendorCandidates(rel) {
1413
+ const files = []
1414
+ try {
1415
+ const require = createRequire(import.meta.url)
1416
+ let root = null
1417
+ try {
1418
+ root = dirname(require.resolve("@xterm/xterm/package.json"))
1419
+ } catch {
1420
+ const main = require.resolve("@xterm/xterm")
1421
+ root = join(dirname(main), "..")
1422
+ }
1423
+ if (root) files.push(join(root, rel))
1424
+ } catch {}
1425
+ try {
1426
+ files.push(fileURLToPath(new URL("../node_modules/@xterm/xterm/" + rel, import.meta.url)))
1427
+ } catch {}
1428
+ return files
1429
+ }
1430
+
1387
1431
  /** Serve the terminal renderer from our own dependency. */
1388
1432
  async function sendVendor(res, name) {
1389
1433
  const allowed = { "xterm.js": "lib/xterm.js", "xterm.css": "css/xterm.css" }
1390
1434
  const rel = allowed[name]
1391
1435
  if (!rel) throw new RouteError(404, "unknown asset")
1392
- const file = new URL("../node_modules/@xterm/xterm/" + rel, import.meta.url)
1393
- let data
1394
- try {
1395
- data = await readFile(file)
1396
- } catch {
1397
- throw new RouteError(404, "xterm is not installed")
1436
+ let data = null
1437
+ for (const file of vendorCandidates(rel)) {
1438
+ try {
1439
+ data = await readFile(file)
1440
+ break
1441
+ } catch {}
1398
1442
  }
1443
+ if (!data) throw new RouteError(404, "xterm is not installed")
1399
1444
  const type = name.endsWith(".css") ? "text/css; charset=utf-8" : "text/javascript; charset=utf-8"
1400
1445
  res.writeHead(200, { "Content-Type": type, "Content-Length": data.length, "Cache-Control": "no-store" })
1401
1446
  res.end(data)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maxbill/dsh-file-explorer",
3
- "version": "1.2.2",
3
+ "version": "1.2.3",
4
4
  "description": "文件管理器 — 浏览、预览并直接用起来:文件夹一键变成工作区,文档一键加进当前对话 · A file manager for DeepSeek Harness that turns folders into workspaces and documents into conversation attachments",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -22,7 +22,8 @@
22
22
  "README.en.md",
23
23
  "LICENSE",
24
24
  "docs",
25
- "screenshots.json"
25
+ "screenshots.json",
26
+ "vendor"
26
27
  ],
27
28
  "keywords": [
28
29
  "dsh",
@@ -66,8 +67,5 @@
66
67
  },
67
68
  "dependencies": {
68
69
  "@xterm/xterm": "^5.5.0"
69
- },
70
- "optionalDependencies": {
71
- "node-pty": "^1.1.0"
72
70
  }
73
71
  }
@@ -0,0 +1,69 @@
1
+ Copyright (c) 2012-2015, Christopher Jeffrey (https://github.com/chjj/)
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
20
+
21
+
22
+
23
+ The MIT License (MIT)
24
+
25
+ Copyright (c) 2016, Daniel Imms (http://www.growingwiththeweb.com)
26
+
27
+ Permission is hereby granted, free of charge, to any person obtaining a copy
28
+ of this software and associated documentation files (the "Software"), to deal
29
+ in the Software without restriction, including without limitation the rights
30
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
31
+ copies of the Software, and to permit persons to whom the Software is
32
+ furnished to do so, subject to the following conditions:
33
+
34
+ The above copyright notice and this permission notice shall be included in all
35
+ copies or substantial portions of the Software.
36
+
37
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
38
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
39
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
40
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
41
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
42
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
43
+ SOFTWARE.
44
+
45
+
46
+
47
+ MIT License
48
+
49
+ Copyright (c) 2018 - present Microsoft Corporation
50
+
51
+ All rights reserved.
52
+
53
+ Permission is hereby granted, free of charge, to any person obtaining a copy
54
+ of this software and associated documentation files (the "Software"), to deal
55
+ in the Software without restriction, including without limitation the rights
56
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
57
+ copies of the Software, and to permit persons to whom the Software is
58
+ furnished to do so, subject to the following conditions:
59
+
60
+ The above copyright notice and this permission notice shall be included in all
61
+ copies or substantial portions of the Software.
62
+
63
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
64
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
65
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
66
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
67
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
68
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
69
+ SOFTWARE.
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) 2019, Microsoft Corporation (MIT License).
4
+ *
5
+ * This module fetches the console process list for a particular PID. It must be
6
+ * called from a different process (child_process.fork) as there can only be a
7
+ * single console attached to a process.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ var utils_1 = require("./utils");
11
+ var getConsoleProcessList = utils_1.loadNativeModule('conpty_console_list').module.getConsoleProcessList;
12
+ var shellPid = parseInt(process.argv[2], 10);
13
+ var consoleProcessList = getConsoleProcessList(shellPid);
14
+ process.send({ consoleProcessList: consoleProcessList });
15
+ process.exit(0);
16
+ //# sourceMappingURL=conpty_console_list_agent.js.map
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) 2019, Microsoft Corporation (MIT License).
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.EventEmitter2 = void 0;
7
+ var EventEmitter2 = /** @class */ (function () {
8
+ function EventEmitter2() {
9
+ this._listeners = [];
10
+ }
11
+ Object.defineProperty(EventEmitter2.prototype, "event", {
12
+ get: function () {
13
+ var _this = this;
14
+ if (!this._event) {
15
+ this._event = function (listener) {
16
+ _this._listeners.push(listener);
17
+ var disposable = {
18
+ dispose: function () {
19
+ for (var i = 0; i < _this._listeners.length; i++) {
20
+ if (_this._listeners[i] === listener) {
21
+ _this._listeners.splice(i, 1);
22
+ return;
23
+ }
24
+ }
25
+ }
26
+ };
27
+ return disposable;
28
+ };
29
+ }
30
+ return this._event;
31
+ },
32
+ enumerable: false,
33
+ configurable: true
34
+ });
35
+ EventEmitter2.prototype.fire = function (data) {
36
+ var queue = [];
37
+ for (var i = 0; i < this._listeners.length; i++) {
38
+ queue.push(this._listeners[i]);
39
+ }
40
+ for (var i = 0; i < queue.length; i++) {
41
+ queue[i].call(undefined, data);
42
+ }
43
+ };
44
+ return EventEmitter2;
45
+ }());
46
+ exports.EventEmitter2 = EventEmitter2;
47
+ //# sourceMappingURL=eventEmitter2.js.map
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) 2012-2015, Christopher Jeffrey, Peter Sunde (MIT License)
4
+ * Copyright (c) 2016, Daniel Imms (MIT License).
5
+ * Copyright (c) 2018, Microsoft Corporation (MIT License).
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.native = exports.open = exports.createTerminal = exports.fork = exports.spawn = void 0;
9
+ var utils_1 = require("./utils");
10
+ var terminalCtor;
11
+ if (process.platform === 'win32') {
12
+ terminalCtor = require('./windowsTerminal').WindowsTerminal;
13
+ }
14
+ else {
15
+ terminalCtor = require('./unixTerminal').UnixTerminal;
16
+ }
17
+ /**
18
+ * Forks a process as a pseudoterminal.
19
+ * @param file The file to launch.
20
+ * @param args The file's arguments as argv (string[]) or in a pre-escaped
21
+ * CommandLine format (string). Note that the CommandLine option is only
22
+ * available on Windows and is expected to be escaped properly.
23
+ * @param options The options of the terminal.
24
+ * @throws When the file passed to spawn with does not exists.
25
+ * @see CommandLineToArgvW https://msdn.microsoft.com/en-us/library/windows/desktop/bb776391(v=vs.85).aspx
26
+ * @see Parsing C++ Comamnd-Line Arguments https://msdn.microsoft.com/en-us/library/17w5ykft.aspx
27
+ * @see GetCommandLine https://msdn.microsoft.com/en-us/library/windows/desktop/ms683156.aspx
28
+ */
29
+ function spawn(file, args, opt) {
30
+ return new terminalCtor(file, args, opt);
31
+ }
32
+ exports.spawn = spawn;
33
+ /** @deprecated */
34
+ function fork(file, args, opt) {
35
+ return new terminalCtor(file, args, opt);
36
+ }
37
+ exports.fork = fork;
38
+ /** @deprecated */
39
+ function createTerminal(file, args, opt) {
40
+ return new terminalCtor(file, args, opt);
41
+ }
42
+ exports.createTerminal = createTerminal;
43
+ function open(options) {
44
+ return terminalCtor.open(options);
45
+ }
46
+ exports.open = open;
47
+ /**
48
+ * Expose the native API when not Windows, note that this is not public API and
49
+ * could be removed at any time.
50
+ */
51
+ exports.native = (process.platform !== 'win32' ? utils_1.loadNativeModule('pty').module : null);
52
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) 2016, Daniel Imms (MIT License).
4
+ * Copyright (c) 2018, Microsoft Corporation (MIT License).
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ //# sourceMappingURL=interfaces.js.map
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) 2020, Microsoft Corporation (MIT License).
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getWorkerPipeName = void 0;
7
+ function getWorkerPipeName(conoutPipeName) {
8
+ return conoutPipeName + "-worker";
9
+ }
10
+ exports.getWorkerPipeName = getWorkerPipeName;
11
+ //# sourceMappingURL=conout.js.map
@@ -0,0 +1,190 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) 2012-2015, Christopher Jeffrey (MIT License)
4
+ * Copyright (c) 2016, Daniel Imms (MIT License).
5
+ * Copyright (c) 2018, Microsoft Corporation (MIT License).
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.Terminal = exports.DEFAULT_ROWS = exports.DEFAULT_COLS = void 0;
9
+ var events_1 = require("events");
10
+ var eventEmitter2_1 = require("./eventEmitter2");
11
+ exports.DEFAULT_COLS = 80;
12
+ exports.DEFAULT_ROWS = 24;
13
+ /**
14
+ * Default messages to indicate PAUSE/RESUME for automatic flow control.
15
+ * To avoid conflicts with rebound XON/XOFF control codes (such as on-my-zsh),
16
+ * the sequences can be customized in `IPtyForkOptions`.
17
+ */
18
+ var FLOW_CONTROL_PAUSE = '\x13'; // defaults to XOFF
19
+ var FLOW_CONTROL_RESUME = '\x11'; // defaults to XON
20
+ var Terminal = /** @class */ (function () {
21
+ function Terminal(opt) {
22
+ this._pid = 0;
23
+ this._fd = 0;
24
+ this._cols = 0;
25
+ this._rows = 0;
26
+ this._readable = false;
27
+ this._writable = false;
28
+ this._onData = new eventEmitter2_1.EventEmitter2();
29
+ this._onExit = new eventEmitter2_1.EventEmitter2();
30
+ // for 'close'
31
+ this._internalee = new events_1.EventEmitter();
32
+ // setup flow control handling
33
+ this.handleFlowControl = !!(opt === null || opt === void 0 ? void 0 : opt.handleFlowControl);
34
+ this._flowControlPause = (opt === null || opt === void 0 ? void 0 : opt.flowControlPause) || FLOW_CONTROL_PAUSE;
35
+ this._flowControlResume = (opt === null || opt === void 0 ? void 0 : opt.flowControlResume) || FLOW_CONTROL_RESUME;
36
+ if (!opt) {
37
+ return;
38
+ }
39
+ // Do basic type checks here in case node-pty is being used within JavaScript. If the wrong
40
+ // types go through to the C++ side it can lead to hard to diagnose exceptions.
41
+ this._checkType('name', opt.name ? opt.name : undefined, 'string');
42
+ this._checkType('cols', opt.cols ? opt.cols : undefined, 'number');
43
+ this._checkType('rows', opt.rows ? opt.rows : undefined, 'number');
44
+ this._checkType('cwd', opt.cwd ? opt.cwd : undefined, 'string');
45
+ this._checkType('env', opt.env ? opt.env : undefined, 'object');
46
+ this._checkType('uid', opt.uid ? opt.uid : undefined, 'number');
47
+ this._checkType('gid', opt.gid ? opt.gid : undefined, 'number');
48
+ this._checkType('encoding', opt.encoding ? opt.encoding : undefined, 'string');
49
+ }
50
+ Object.defineProperty(Terminal.prototype, "onData", {
51
+ get: function () { return this._onData.event; },
52
+ enumerable: false,
53
+ configurable: true
54
+ });
55
+ Object.defineProperty(Terminal.prototype, "onExit", {
56
+ get: function () { return this._onExit.event; },
57
+ enumerable: false,
58
+ configurable: true
59
+ });
60
+ Object.defineProperty(Terminal.prototype, "pid", {
61
+ get: function () { return this._pid; },
62
+ enumerable: false,
63
+ configurable: true
64
+ });
65
+ Object.defineProperty(Terminal.prototype, "cols", {
66
+ get: function () { return this._cols; },
67
+ enumerable: false,
68
+ configurable: true
69
+ });
70
+ Object.defineProperty(Terminal.prototype, "rows", {
71
+ get: function () { return this._rows; },
72
+ enumerable: false,
73
+ configurable: true
74
+ });
75
+ Terminal.prototype.write = function (data) {
76
+ if (this.handleFlowControl) {
77
+ // PAUSE/RESUME messages are not forwarded to the pty
78
+ if (data === this._flowControlPause) {
79
+ this.pause();
80
+ return;
81
+ }
82
+ if (data === this._flowControlResume) {
83
+ this.resume();
84
+ return;
85
+ }
86
+ }
87
+ // everything else goes to the real pty
88
+ this._write(data);
89
+ };
90
+ Terminal.prototype._forwardEvents = function () {
91
+ var _this = this;
92
+ this.on('data', function (e) { return _this._onData.fire(e); });
93
+ this.on('exit', function (exitCode, signal) { return _this._onExit.fire({ exitCode: exitCode, signal: signal }); });
94
+ };
95
+ Terminal.prototype._checkType = function (name, value, type, allowArray) {
96
+ if (allowArray === void 0) { allowArray = false; }
97
+ if (value === undefined) {
98
+ return;
99
+ }
100
+ if (allowArray) {
101
+ if (Array.isArray(value)) {
102
+ value.forEach(function (v, i) {
103
+ if (typeof v !== type) {
104
+ throw new Error(name + "[" + i + "] must be a " + type + " (not a " + typeof v[i] + ")");
105
+ }
106
+ });
107
+ return;
108
+ }
109
+ }
110
+ if (typeof value !== type) {
111
+ throw new Error(name + " must be a " + type + " (not a " + typeof value + ")");
112
+ }
113
+ };
114
+ /** See net.Socket.end */
115
+ Terminal.prototype.end = function (data) {
116
+ this._socket.end(data);
117
+ };
118
+ /** See stream.Readable.pipe */
119
+ Terminal.prototype.pipe = function (dest, options) {
120
+ return this._socket.pipe(dest, options);
121
+ };
122
+ /** See net.Socket.pause */
123
+ Terminal.prototype.pause = function () {
124
+ return this._socket.pause();
125
+ };
126
+ /** See net.Socket.resume */
127
+ Terminal.prototype.resume = function () {
128
+ return this._socket.resume();
129
+ };
130
+ /** See net.Socket.setEncoding */
131
+ Terminal.prototype.setEncoding = function (encoding) {
132
+ if (this._socket._decoder) {
133
+ delete this._socket._decoder;
134
+ }
135
+ if (encoding) {
136
+ this._socket.setEncoding(encoding);
137
+ }
138
+ };
139
+ Terminal.prototype.addListener = function (eventName, listener) { this.on(eventName, listener); };
140
+ Terminal.prototype.on = function (eventName, listener) {
141
+ if (eventName === 'close') {
142
+ this._internalee.on('close', listener);
143
+ return;
144
+ }
145
+ this._socket.on(eventName, listener);
146
+ };
147
+ Terminal.prototype.emit = function (eventName) {
148
+ var args = [];
149
+ for (var _i = 1; _i < arguments.length; _i++) {
150
+ args[_i - 1] = arguments[_i];
151
+ }
152
+ if (eventName === 'close') {
153
+ return this._internalee.emit.apply(this._internalee, arguments);
154
+ }
155
+ return this._socket.emit.apply(this._socket, arguments);
156
+ };
157
+ Terminal.prototype.listeners = function (eventName) {
158
+ return this._socket.listeners(eventName);
159
+ };
160
+ Terminal.prototype.removeListener = function (eventName, listener) {
161
+ this._socket.removeListener(eventName, listener);
162
+ };
163
+ Terminal.prototype.removeAllListeners = function (eventName) {
164
+ this._socket.removeAllListeners(eventName);
165
+ };
166
+ Terminal.prototype.once = function (eventName, listener) {
167
+ this._socket.once(eventName, listener);
168
+ };
169
+ Terminal.prototype._close = function () {
170
+ this._socket.readable = false;
171
+ this.write = function () { };
172
+ this.end = function () { };
173
+ this._writable = false;
174
+ this._readable = false;
175
+ };
176
+ Terminal.prototype._parseEnv = function (env) {
177
+ var keys = Object.keys(env || {});
178
+ var pairs = [];
179
+ for (var i = 0; i < keys.length; i++) {
180
+ if (keys[i] === undefined) {
181
+ continue;
182
+ }
183
+ pairs.push(keys[i] + '=' + env[keys[i]]);
184
+ }
185
+ return pairs;
186
+ };
187
+ return Terminal;
188
+ }());
189
+ exports.Terminal = Terminal;
190
+ //# sourceMappingURL=terminal.js.map
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) 2017, Daniel Imms (MIT License).
4
+ * Copyright (c) 2018, Microsoft Corporation (MIT License).
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ //# sourceMappingURL=types.js.map