picosh 0.2.6 → 0.2.8

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/index.js +12 -9
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -50,6 +50,7 @@ const PROMPT_RE = /❯\s*\?/;
50
50
  const timers = {};
51
51
  const waitingState = {};
52
52
  let activeUid = null;
53
+ let promptActive = false;
53
54
 
54
55
  function setWaiting(uid, waiting) {
55
56
  if (!uid) return;
@@ -73,20 +74,22 @@ exports.middleware = () => (next) => (action) => {
73
74
  const uid = action.uid || activeUid;
74
75
  const {data} = action;
75
76
  const clean = data.replace(ANSI_RE, '');
76
- console.log('[picosh] SESSION_ADD_DATA uid:', uid ? uid.slice(0, 8) : 'NONE', 'data tail:', JSON.stringify(clean.slice(-40)));
77
+ console.log('[picosh] ADD_DATA uid:', uid ? uid.slice(0, 8) : 'NONE', JSON.stringify(clean.slice(-40)));
77
78
 
78
79
  clearTimeout(timers[uid]);
79
- setWaiting(uid, false);
80
-
81
80
  timers[uid] = setTimeout(() => {
82
- const matched = PROMPT_RE.test(clean);
83
- console.log('[picosh] timer fired, PROMPT_RE match:', matched, 'on:', JSON.stringify(clean.slice(-40)));
84
- if (matched) setWaiting(uid, true);
85
- }, 500);
81
+ if (PROMPT_RE.test(clean)) {
82
+ promptActive = true;
83
+ setWaiting(uid, true);
84
+ } else if (!promptActive) {
85
+ setWaiting(uid, false);
86
+ }
87
+ }, 300);
86
88
  }
87
89
 
88
- if (action.type === 'SESSION_PTY_DATA') {
89
- const uid = action.uid || activeUid;
90
+ if (action.type === 'SESSION_USER_DATA') {
91
+ const uid = activeUid;
92
+ promptActive = false;
90
93
  clearTimeout(timers[uid]);
91
94
  setWaiting(uid, false);
92
95
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "picosh",
3
- "version": "0.2.6",
3
+ "version": "0.2.8",
4
4
  "description": "Hyper plugin: paste clipboard images as file paths",
5
5
  "main": "index.js",
6
6
  "license": "MIT",