@lethevimlet/sshift 1.4.8 → 1.4.10

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.
@@ -110,6 +110,29 @@ self.onmessage = function(e) {
110
110
  break;
111
111
  }
112
112
 
113
+ case 'init': {
114
+ // Explicitly register a session ahead of the first data frame.
115
+ // Optional — `data` will lazily create the session state via
116
+ // getOrCreateSession(). `init` exists so callers can pre-warm the
117
+ // worker and verify the round-trip with an ack.
118
+ const sessionId = msg.sessionId;
119
+ if (!sessionId) break;
120
+ getOrCreateSession(sessionId);
121
+ self.postMessage({
122
+ type: 'ready',
123
+ sessionId: sessionId,
124
+ cols: msg.cols || 80,
125
+ rows: msg.rows || 24
126
+ });
127
+ break;
128
+ }
129
+
130
+ case 'ping': {
131
+ // Liveness probe — used by tests and health checks.
132
+ self.postMessage({ type: 'pong', sessionId: msg.sessionId });
133
+ break;
134
+ }
135
+
113
136
  case 'data': {
114
137
  const sessionId = msg.sessionId;
115
138
  if (!sessionId) break;
@@ -230,5 +253,18 @@ self.onmessage = function(e) {
230
253
  });
231
254
  break;
232
255
  }
256
+
257
+ default: {
258
+ // Unknown message types are explicitly rejected so callers can
259
+ // detect protocol drift rather than observing silent no-ops.
260
+ console.warn('[terminal-worker] Unknown message type:', msg.type);
261
+ self.postMessage({
262
+ type: 'error',
263
+ error: 'unknownMessage',
264
+ messageType: msg.type,
265
+ sessionId: msg.sessionId
266
+ });
267
+ break;
268
+ }
233
269
  }
234
270
  };