@rstreamlabs/webtty 1.6.4 → 1.7.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.
package/dist/index.js CHANGED
@@ -30,16 +30,26 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/index.ts
31
31
  var index_exports = {};
32
32
  __export(index_exports, {
33
- WebTTY: () => WebTTY
33
+ WebTTY: () => WebTTY,
34
+ WebTTYCommand: () => WebTTYCommand,
35
+ WebTTYFileSystem: () => WebTTYFileSystem,
36
+ WebTTYFileSystemError: () => WebTTYFileSystemError,
37
+ WebTTYRemoteExecutor: () => WebTTYRemoteExecutor,
38
+ executeWebTTYCommand: () => executeWebTTYCommand,
39
+ openWebTTYCommand: () => openWebTTYCommand,
40
+ parseWebDAVMultiStatus: () => parseWebDAVMultiStatus,
41
+ resolveWebTTYExecutionURL: () => resolveWebTTYExecutionURL,
42
+ resolveWebTTYFileSystemURL: () => resolveWebTTYFileSystemURL,
43
+ runWebTTYCommand: () => runWebTTYCommand
34
44
  });
35
45
  module.exports = __toCommonJS(index_exports);
36
46
 
37
47
  // .generated/protobuf/webtty.js
38
- var $protobuf = __toESM(require("protobufjs/minimal"));
39
- var $Reader = $protobuf.Reader;
40
- var $Writer = $protobuf.Writer;
41
- var $util = $protobuf.util;
42
- var $root = $protobuf.roots["default"] || ($protobuf.roots["default"] = {});
48
+ var import_minimal = __toESM(require("protobufjs/minimal.js"));
49
+ var $Reader = import_minimal.default.Reader;
50
+ var $Writer = import_minimal.default.Writer;
51
+ var $util = import_minimal.default.util;
52
+ var $root = import_minimal.default.roots["default"] || (import_minimal.default.roots["default"] = {});
43
53
  var rstream = $root.rstream = (() => {
44
54
  const rstream2 = {};
45
55
  rstream2.webtty = (function() {
@@ -50,7 +60,7 @@ var rstream = $root.rstream = (() => {
50
60
  function Options(properties) {
51
61
  if (properties) {
52
62
  for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
53
- if (properties[keys[i]] != null)
63
+ if (properties[keys[i]] != null && keys[i] !== "__proto__")
54
64
  this[keys[i]] = properties[keys[i]];
55
65
  }
56
66
  }
@@ -78,37 +88,65 @@ var rstream = $root.rstream = (() => {
78
88
  /* id 3, wireType 0 =*/
79
89
  24
80
90
  ).bool(message.sendHeartbeat);
91
+ if (message.$unknowns != null && Object.hasOwnProperty.call(message, "$unknowns"))
92
+ for (let i = 0; i < message.$unknowns.length; ++i)
93
+ writer.raw(message.$unknowns[i]);
81
94
  return writer;
82
95
  };
83
96
  Options.encodeDelimited = function encodeDelimited(message, writer) {
84
97
  return this.encode(message, writer).ldelim();
85
98
  };
86
- Options.decode = function decode(reader, length, error) {
99
+ Options.decode = function decode(reader, length, _end, _depth, _target) {
87
100
  if (!(reader instanceof $Reader))
88
101
  reader = $Reader.create(reader);
89
- let end = length === void 0 ? reader.len : reader.pos + length, message = new $root.rstream.webtty.protobuf.Options();
102
+ if (_depth === void 0)
103
+ _depth = 0;
104
+ if (_depth > $Reader.recursionLimit)
105
+ throw Error("max depth exceeded");
106
+ let end = length === void 0 ? reader.len : reader.pos + length, message = _target || new $root.rstream.webtty.protobuf.Options(), value;
90
107
  while (reader.pos < end) {
91
- let tag = reader.uint32();
92
- if (tag === error)
108
+ let start = reader.pos;
109
+ let tag = reader.tag();
110
+ if (tag === _end) {
111
+ _end = void 0;
93
112
  break;
94
- switch (tag >>> 3) {
113
+ }
114
+ let wireType = tag & 7;
115
+ switch (tag >>>= 3) {
95
116
  case 1: {
96
- message.interactive = reader.bool();
97
- break;
117
+ if (wireType !== 0)
118
+ break;
119
+ if (value = reader.bool())
120
+ message.interactive = value;
121
+ else
122
+ delete message.interactive;
123
+ continue;
98
124
  }
99
125
  case 2: {
100
- message.allocateTty = reader.bool();
101
- break;
126
+ if (wireType !== 0)
127
+ break;
128
+ if (value = reader.bool())
129
+ message.allocateTty = value;
130
+ else
131
+ delete message.allocateTty;
132
+ continue;
102
133
  }
103
134
  case 3: {
104
- message.sendHeartbeat = reader.bool();
105
- break;
135
+ if (wireType !== 0)
136
+ break;
137
+ if (value = reader.bool())
138
+ message.sendHeartbeat = value;
139
+ else
140
+ delete message.sendHeartbeat;
141
+ continue;
106
142
  }
107
- default:
108
- reader.skipType(tag & 7);
109
- break;
110
143
  }
144
+ reader.skipType(wireType, _depth, tag);
145
+ $util.makeProp(message, "$unknowns", false);
146
+ (message.$unknowns || (message.$unknowns = [])).push(reader.raw(start, reader.pos));
111
147
  }
148
+ if (_end !== void 0)
149
+ throw Error("missing end group");
112
150
  return message;
113
151
  };
114
152
  Options.decodeDelimited = function decodeDelimited(reader) {
@@ -116,9 +154,13 @@ var rstream = $root.rstream = (() => {
116
154
  reader = new $Reader(reader);
117
155
  return this.decode(reader, reader.uint32());
118
156
  };
119
- Options.verify = function verify(message) {
157
+ Options.verify = function verify(message, _depth) {
120
158
  if (typeof message !== "object" || message === null)
121
159
  return "object expected";
160
+ if (_depth === void 0)
161
+ _depth = 0;
162
+ if (_depth > $util.recursionLimit)
163
+ return "max depth exceeded";
122
164
  if (message.interactive != null && message.hasOwnProperty("interactive")) {
123
165
  if (typeof message.interactive !== "boolean")
124
166
  return "interactive: boolean expected";
@@ -133,16 +175,26 @@ var rstream = $root.rstream = (() => {
133
175
  }
134
176
  return null;
135
177
  };
136
- Options.fromObject = function fromObject(object) {
178
+ Options.fromObject = function fromObject(object, _depth) {
137
179
  if (object instanceof $root.rstream.webtty.protobuf.Options)
138
180
  return object;
181
+ if (_depth === void 0)
182
+ _depth = 0;
183
+ if (_depth > $util.recursionLimit)
184
+ throw Error("max depth exceeded");
139
185
  let message = new $root.rstream.webtty.protobuf.Options();
140
- if (object.interactive != null)
141
- message.interactive = Boolean(object.interactive);
142
- if (object.allocateTty != null)
143
- message.allocateTty = Boolean(object.allocateTty);
144
- if (object.sendHeartbeat != null)
145
- message.sendHeartbeat = Boolean(object.sendHeartbeat);
186
+ if (object.interactive != null) {
187
+ if (object.interactive)
188
+ message.interactive = Boolean(object.interactive);
189
+ }
190
+ if (object.allocateTty != null) {
191
+ if (object.allocateTty)
192
+ message.allocateTty = Boolean(object.allocateTty);
193
+ }
194
+ if (object.sendHeartbeat != null) {
195
+ if (object.sendHeartbeat)
196
+ message.sendHeartbeat = Boolean(object.sendHeartbeat);
197
+ }
146
198
  return message;
147
199
  };
148
200
  Options.toObject = function toObject(message, options) {
@@ -163,13 +215,12 @@ var rstream = $root.rstream = (() => {
163
215
  return object;
164
216
  };
165
217
  Options.prototype.toJSON = function toJSON() {
166
- return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
218
+ return this.constructor.toObject(this, import_minimal.default.util.toJSONOptions);
167
219
  };
168
- Options.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
169
- if (typeUrlPrefix === void 0) {
170
- typeUrlPrefix = "type.googleapis.com";
171
- }
172
- return typeUrlPrefix + "/rstream.webtty.protobuf.Options";
220
+ Options.getTypeUrl = function getTypeUrl(prefix) {
221
+ if (prefix === void 0)
222
+ prefix = "type.googleapis.com";
223
+ return prefix + "/rstream.webtty.protobuf.Options";
173
224
  };
174
225
  return Options;
175
226
  })();
@@ -177,7 +228,7 @@ var rstream = $root.rstream = (() => {
177
228
  function Environment(properties) {
178
229
  if (properties) {
179
230
  for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
180
- if (properties[keys[i]] != null)
231
+ if (properties[keys[i]] != null && keys[i] !== "__proto__")
181
232
  this[keys[i]] = properties[keys[i]];
182
233
  }
183
234
  }
@@ -199,33 +250,56 @@ var rstream = $root.rstream = (() => {
199
250
  /* id 2, wireType 2 =*/
200
251
  18
201
252
  ).string(message.value);
253
+ if (message.$unknowns != null && Object.hasOwnProperty.call(message, "$unknowns"))
254
+ for (let i = 0; i < message.$unknowns.length; ++i)
255
+ writer.raw(message.$unknowns[i]);
202
256
  return writer;
203
257
  };
204
258
  Environment.encodeDelimited = function encodeDelimited(message, writer) {
205
259
  return this.encode(message, writer).ldelim();
206
260
  };
207
- Environment.decode = function decode(reader, length, error) {
261
+ Environment.decode = function decode(reader, length, _end, _depth, _target) {
208
262
  if (!(reader instanceof $Reader))
209
263
  reader = $Reader.create(reader);
210
- let end = length === void 0 ? reader.len : reader.pos + length, message = new $root.rstream.webtty.protobuf.Environment();
264
+ if (_depth === void 0)
265
+ _depth = 0;
266
+ if (_depth > $Reader.recursionLimit)
267
+ throw Error("max depth exceeded");
268
+ let end = length === void 0 ? reader.len : reader.pos + length, message = _target || new $root.rstream.webtty.protobuf.Environment(), value;
211
269
  while (reader.pos < end) {
212
- let tag = reader.uint32();
213
- if (tag === error)
270
+ let start = reader.pos;
271
+ let tag = reader.tag();
272
+ if (tag === _end) {
273
+ _end = void 0;
214
274
  break;
215
- switch (tag >>> 3) {
275
+ }
276
+ let wireType = tag & 7;
277
+ switch (tag >>>= 3) {
216
278
  case 1: {
217
- message.key = reader.string();
218
- break;
279
+ if (wireType !== 2)
280
+ break;
281
+ if ((value = reader.string()).length)
282
+ message.key = value;
283
+ else
284
+ delete message.key;
285
+ continue;
219
286
  }
220
287
  case 2: {
221
- message.value = reader.string();
222
- break;
288
+ if (wireType !== 2)
289
+ break;
290
+ if ((value = reader.string()).length)
291
+ message.value = value;
292
+ else
293
+ delete message.value;
294
+ continue;
223
295
  }
224
- default:
225
- reader.skipType(tag & 7);
226
- break;
227
296
  }
297
+ reader.skipType(wireType, _depth, tag);
298
+ $util.makeProp(message, "$unknowns", false);
299
+ (message.$unknowns || (message.$unknowns = [])).push(reader.raw(start, reader.pos));
228
300
  }
301
+ if (_end !== void 0)
302
+ throw Error("missing end group");
229
303
  return message;
230
304
  };
231
305
  Environment.decodeDelimited = function decodeDelimited(reader) {
@@ -233,9 +307,13 @@ var rstream = $root.rstream = (() => {
233
307
  reader = new $Reader(reader);
234
308
  return this.decode(reader, reader.uint32());
235
309
  };
236
- Environment.verify = function verify(message) {
310
+ Environment.verify = function verify(message, _depth) {
237
311
  if (typeof message !== "object" || message === null)
238
312
  return "object expected";
313
+ if (_depth === void 0)
314
+ _depth = 0;
315
+ if (_depth > $util.recursionLimit)
316
+ return "max depth exceeded";
239
317
  if (message.key != null && message.hasOwnProperty("key")) {
240
318
  if (!$util.isString(message.key))
241
319
  return "key: string expected";
@@ -246,14 +324,22 @@ var rstream = $root.rstream = (() => {
246
324
  }
247
325
  return null;
248
326
  };
249
- Environment.fromObject = function fromObject(object) {
327
+ Environment.fromObject = function fromObject(object, _depth) {
250
328
  if (object instanceof $root.rstream.webtty.protobuf.Environment)
251
329
  return object;
330
+ if (_depth === void 0)
331
+ _depth = 0;
332
+ if (_depth > $util.recursionLimit)
333
+ throw Error("max depth exceeded");
252
334
  let message = new $root.rstream.webtty.protobuf.Environment();
253
- if (object.key != null)
254
- message.key = String(object.key);
255
- if (object.value != null)
256
- message.value = String(object.value);
335
+ if (object.key != null) {
336
+ if (typeof object.key !== "string" || object.key.length)
337
+ message.key = String(object.key);
338
+ }
339
+ if (object.value != null) {
340
+ if (typeof object.value !== "string" || object.value.length)
341
+ message.value = String(object.value);
342
+ }
257
343
  return message;
258
344
  };
259
345
  Environment.toObject = function toObject(message, options) {
@@ -271,13 +357,12 @@ var rstream = $root.rstream = (() => {
271
357
  return object;
272
358
  };
273
359
  Environment.prototype.toJSON = function toJSON() {
274
- return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
360
+ return this.constructor.toObject(this, import_minimal.default.util.toJSONOptions);
275
361
  };
276
- Environment.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
277
- if (typeUrlPrefix === void 0) {
278
- typeUrlPrefix = "type.googleapis.com";
279
- }
280
- return typeUrlPrefix + "/rstream.webtty.protobuf.Environment";
362
+ Environment.getTypeUrl = function getTypeUrl(prefix) {
363
+ if (prefix === void 0)
364
+ prefix = "type.googleapis.com";
365
+ return prefix + "/rstream.webtty.protobuf.Environment";
281
366
  };
282
367
  return Environment;
283
368
  })();
@@ -285,7 +370,7 @@ var rstream = $root.rstream = (() => {
285
370
  function Username(properties) {
286
371
  if (properties) {
287
372
  for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
288
- if (properties[keys[i]] != null)
373
+ if (properties[keys[i]] != null && keys[i] !== "__proto__")
289
374
  this[keys[i]] = properties[keys[i]];
290
375
  }
291
376
  }
@@ -312,33 +397,52 @@ var rstream = $root.rstream = (() => {
312
397
  /* id 2, wireType 0 =*/
313
398
  16
314
399
  ).uint32(message.id);
400
+ if (message.$unknowns != null && Object.hasOwnProperty.call(message, "$unknowns"))
401
+ for (let i = 0; i < message.$unknowns.length; ++i)
402
+ writer.raw(message.$unknowns[i]);
315
403
  return writer;
316
404
  };
317
405
  Username.encodeDelimited = function encodeDelimited(message, writer) {
318
406
  return this.encode(message, writer).ldelim();
319
407
  };
320
- Username.decode = function decode(reader, length, error) {
408
+ Username.decode = function decode(reader, length, _end, _depth, _target) {
321
409
  if (!(reader instanceof $Reader))
322
410
  reader = $Reader.create(reader);
323
- let end = length === void 0 ? reader.len : reader.pos + length, message = new $root.rstream.webtty.protobuf.Username();
411
+ if (_depth === void 0)
412
+ _depth = 0;
413
+ if (_depth > $Reader.recursionLimit)
414
+ throw Error("max depth exceeded");
415
+ let end = length === void 0 ? reader.len : reader.pos + length, message = _target || new $root.rstream.webtty.protobuf.Username();
324
416
  while (reader.pos < end) {
325
- let tag = reader.uint32();
326
- if (tag === error)
417
+ let start = reader.pos;
418
+ let tag = reader.tag();
419
+ if (tag === _end) {
420
+ _end = void 0;
327
421
  break;
328
- switch (tag >>> 3) {
422
+ }
423
+ let wireType = tag & 7;
424
+ switch (tag >>>= 3) {
329
425
  case 1: {
426
+ if (wireType !== 2)
427
+ break;
330
428
  message.name = reader.string();
331
- break;
429
+ message.payload = "name";
430
+ continue;
332
431
  }
333
432
  case 2: {
433
+ if (wireType !== 0)
434
+ break;
334
435
  message.id = reader.uint32();
335
- break;
436
+ message.payload = "id";
437
+ continue;
336
438
  }
337
- default:
338
- reader.skipType(tag & 7);
339
- break;
340
439
  }
440
+ reader.skipType(wireType, _depth, tag);
441
+ $util.makeProp(message, "$unknowns", false);
442
+ (message.$unknowns || (message.$unknowns = [])).push(reader.raw(start, reader.pos));
341
443
  }
444
+ if (_end !== void 0)
445
+ throw Error("missing end group");
342
446
  return message;
343
447
  };
344
448
  Username.decodeDelimited = function decodeDelimited(reader) {
@@ -346,9 +450,13 @@ var rstream = $root.rstream = (() => {
346
450
  reader = new $Reader(reader);
347
451
  return this.decode(reader, reader.uint32());
348
452
  };
349
- Username.verify = function verify(message) {
453
+ Username.verify = function verify(message, _depth) {
350
454
  if (typeof message !== "object" || message === null)
351
455
  return "object expected";
456
+ if (_depth === void 0)
457
+ _depth = 0;
458
+ if (_depth > $util.recursionLimit)
459
+ return "max depth exceeded";
352
460
  let properties = {};
353
461
  if (message.name != null && message.hasOwnProperty("name")) {
354
462
  properties.payload = 1;
@@ -364,9 +472,13 @@ var rstream = $root.rstream = (() => {
364
472
  }
365
473
  return null;
366
474
  };
367
- Username.fromObject = function fromObject(object) {
475
+ Username.fromObject = function fromObject(object, _depth) {
368
476
  if (object instanceof $root.rstream.webtty.protobuf.Username)
369
477
  return object;
478
+ if (_depth === void 0)
479
+ _depth = 0;
480
+ if (_depth > $util.recursionLimit)
481
+ throw Error("max depth exceeded");
370
482
  let message = new $root.rstream.webtty.protobuf.Username();
371
483
  if (object.name != null)
372
484
  message.name = String(object.name);
@@ -391,13 +503,12 @@ var rstream = $root.rstream = (() => {
391
503
  return object;
392
504
  };
393
505
  Username.prototype.toJSON = function toJSON() {
394
- return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
506
+ return this.constructor.toObject(this, import_minimal.default.util.toJSONOptions);
395
507
  };
396
- Username.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
397
- if (typeUrlPrefix === void 0) {
398
- typeUrlPrefix = "type.googleapis.com";
399
- }
400
- return typeUrlPrefix + "/rstream.webtty.protobuf.Username";
508
+ Username.getTypeUrl = function getTypeUrl(prefix) {
509
+ if (prefix === void 0)
510
+ prefix = "type.googleapis.com";
511
+ return prefix + "/rstream.webtty.protobuf.Username";
401
512
  };
402
513
  return Username;
403
514
  })();
@@ -405,7 +516,7 @@ var rstream = $root.rstream = (() => {
405
516
  function Workdir(properties) {
406
517
  if (properties) {
407
518
  for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
408
- if (properties[keys[i]] != null)
519
+ if (properties[keys[i]] != null && keys[i] !== "__proto__")
409
520
  this[keys[i]] = properties[keys[i]];
410
521
  }
411
522
  }
@@ -421,29 +532,47 @@ var rstream = $root.rstream = (() => {
421
532
  /* id 1, wireType 2 =*/
422
533
  10
423
534
  ).string(message.value);
535
+ if (message.$unknowns != null && Object.hasOwnProperty.call(message, "$unknowns"))
536
+ for (let i = 0; i < message.$unknowns.length; ++i)
537
+ writer.raw(message.$unknowns[i]);
424
538
  return writer;
425
539
  };
426
540
  Workdir.encodeDelimited = function encodeDelimited(message, writer) {
427
541
  return this.encode(message, writer).ldelim();
428
542
  };
429
- Workdir.decode = function decode(reader, length, error) {
543
+ Workdir.decode = function decode(reader, length, _end, _depth, _target) {
430
544
  if (!(reader instanceof $Reader))
431
545
  reader = $Reader.create(reader);
432
- let end = length === void 0 ? reader.len : reader.pos + length, message = new $root.rstream.webtty.protobuf.Workdir();
546
+ if (_depth === void 0)
547
+ _depth = 0;
548
+ if (_depth > $Reader.recursionLimit)
549
+ throw Error("max depth exceeded");
550
+ let end = length === void 0 ? reader.len : reader.pos + length, message = _target || new $root.rstream.webtty.protobuf.Workdir(), value;
433
551
  while (reader.pos < end) {
434
- let tag = reader.uint32();
435
- if (tag === error)
552
+ let start = reader.pos;
553
+ let tag = reader.tag();
554
+ if (tag === _end) {
555
+ _end = void 0;
436
556
  break;
437
- switch (tag >>> 3) {
557
+ }
558
+ let wireType = tag & 7;
559
+ switch (tag >>>= 3) {
438
560
  case 1: {
439
- message.value = reader.string();
440
- break;
561
+ if (wireType !== 2)
562
+ break;
563
+ if ((value = reader.string()).length)
564
+ message.value = value;
565
+ else
566
+ delete message.value;
567
+ continue;
441
568
  }
442
- default:
443
- reader.skipType(tag & 7);
444
- break;
445
569
  }
570
+ reader.skipType(wireType, _depth, tag);
571
+ $util.makeProp(message, "$unknowns", false);
572
+ (message.$unknowns || (message.$unknowns = [])).push(reader.raw(start, reader.pos));
446
573
  }
574
+ if (_end !== void 0)
575
+ throw Error("missing end group");
447
576
  return message;
448
577
  };
449
578
  Workdir.decodeDelimited = function decodeDelimited(reader) {
@@ -451,21 +580,31 @@ var rstream = $root.rstream = (() => {
451
580
  reader = new $Reader(reader);
452
581
  return this.decode(reader, reader.uint32());
453
582
  };
454
- Workdir.verify = function verify(message) {
583
+ Workdir.verify = function verify(message, _depth) {
455
584
  if (typeof message !== "object" || message === null)
456
585
  return "object expected";
586
+ if (_depth === void 0)
587
+ _depth = 0;
588
+ if (_depth > $util.recursionLimit)
589
+ return "max depth exceeded";
457
590
  if (message.value != null && message.hasOwnProperty("value")) {
458
591
  if (!$util.isString(message.value))
459
592
  return "value: string expected";
460
593
  }
461
594
  return null;
462
595
  };
463
- Workdir.fromObject = function fromObject(object) {
596
+ Workdir.fromObject = function fromObject(object, _depth) {
464
597
  if (object instanceof $root.rstream.webtty.protobuf.Workdir)
465
598
  return object;
599
+ if (_depth === void 0)
600
+ _depth = 0;
601
+ if (_depth > $util.recursionLimit)
602
+ throw Error("max depth exceeded");
466
603
  let message = new $root.rstream.webtty.protobuf.Workdir();
467
- if (object.value != null)
468
- message.value = String(object.value);
604
+ if (object.value != null) {
605
+ if (typeof object.value !== "string" || object.value.length)
606
+ message.value = String(object.value);
607
+ }
469
608
  return message;
470
609
  };
471
610
  Workdir.toObject = function toObject(message, options) {
@@ -479,13 +618,12 @@ var rstream = $root.rstream = (() => {
479
618
  return object;
480
619
  };
481
620
  Workdir.prototype.toJSON = function toJSON() {
482
- return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
621
+ return this.constructor.toObject(this, import_minimal.default.util.toJSONOptions);
483
622
  };
484
- Workdir.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
485
- if (typeUrlPrefix === void 0) {
486
- typeUrlPrefix = "type.googleapis.com";
487
- }
488
- return typeUrlPrefix + "/rstream.webtty.protobuf.Workdir";
623
+ Workdir.getTypeUrl = function getTypeUrl(prefix) {
624
+ if (prefix === void 0)
625
+ prefix = "type.googleapis.com";
626
+ return prefix + "/rstream.webtty.protobuf.Workdir";
489
627
  };
490
628
  return Workdir;
491
629
  })();
@@ -495,7 +633,7 @@ var rstream = $root.rstream = (() => {
495
633
  this.envVars = [];
496
634
  if (properties) {
497
635
  for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
498
- if (properties[keys[i]] != null)
636
+ if (properties[keys[i]] != null && keys[i] !== "__proto__")
499
637
  this[keys[i]] = properties[keys[i]];
500
638
  }
501
639
  }
@@ -537,49 +675,72 @@ var rstream = $root.rstream = (() => {
537
675
  /* id 5, wireType 2 =*/
538
676
  42
539
677
  ).fork()).ldelim();
678
+ if (message.$unknowns != null && Object.hasOwnProperty.call(message, "$unknowns"))
679
+ for (let i = 0; i < message.$unknowns.length; ++i)
680
+ writer.raw(message.$unknowns[i]);
540
681
  return writer;
541
682
  };
542
683
  Config.encodeDelimited = function encodeDelimited(message, writer) {
543
684
  return this.encode(message, writer).ldelim();
544
685
  };
545
- Config.decode = function decode(reader, length, error) {
686
+ Config.decode = function decode(reader, length, _end, _depth, _target) {
546
687
  if (!(reader instanceof $Reader))
547
688
  reader = $Reader.create(reader);
548
- let end = length === void 0 ? reader.len : reader.pos + length, message = new $root.rstream.webtty.protobuf.Config();
689
+ if (_depth === void 0)
690
+ _depth = 0;
691
+ if (_depth > $Reader.recursionLimit)
692
+ throw Error("max depth exceeded");
693
+ let end = length === void 0 ? reader.len : reader.pos + length, message = _target || new $root.rstream.webtty.protobuf.Config(), value;
549
694
  while (reader.pos < end) {
550
- let tag = reader.uint32();
551
- if (tag === error)
695
+ let start = reader.pos;
696
+ let tag = reader.tag();
697
+ if (tag === _end) {
698
+ _end = void 0;
552
699
  break;
553
- switch (tag >>> 3) {
700
+ }
701
+ let wireType = tag & 7;
702
+ switch (tag >>>= 3) {
554
703
  case 1: {
555
- message.options = $root.rstream.webtty.protobuf.Options.decode(reader, reader.uint32());
556
- break;
704
+ if (wireType !== 2)
705
+ break;
706
+ message.options = $root.rstream.webtty.protobuf.Options.decode(reader, reader.uint32(), void 0, _depth + 1, message.options);
707
+ continue;
557
708
  }
558
709
  case 2: {
710
+ if (wireType !== 2)
711
+ break;
559
712
  if (!(message.cmdArgs && message.cmdArgs.length))
560
713
  message.cmdArgs = [];
561
714
  message.cmdArgs.push(reader.string());
562
- break;
715
+ continue;
563
716
  }
564
717
  case 3: {
718
+ if (wireType !== 2)
719
+ break;
565
720
  if (!(message.envVars && message.envVars.length))
566
721
  message.envVars = [];
567
- message.envVars.push($root.rstream.webtty.protobuf.Environment.decode(reader, reader.uint32()));
568
- break;
722
+ message.envVars.push($root.rstream.webtty.protobuf.Environment.decode(reader, reader.uint32(), void 0, _depth + 1));
723
+ continue;
569
724
  }
570
725
  case 4: {
571
- message.workdir = $root.rstream.webtty.protobuf.Workdir.decode(reader, reader.uint32());
572
- break;
726
+ if (wireType !== 2)
727
+ break;
728
+ message.workdir = $root.rstream.webtty.protobuf.Workdir.decode(reader, reader.uint32(), void 0, _depth + 1, message.workdir);
729
+ continue;
573
730
  }
574
731
  case 5: {
575
- message.username = $root.rstream.webtty.protobuf.Username.decode(reader, reader.uint32());
576
- break;
732
+ if (wireType !== 2)
733
+ break;
734
+ message.username = $root.rstream.webtty.protobuf.Username.decode(reader, reader.uint32(), void 0, _depth + 1, message.username);
735
+ continue;
577
736
  }
578
- default:
579
- reader.skipType(tag & 7);
580
- break;
581
737
  }
738
+ reader.skipType(wireType, _depth, tag);
739
+ $util.makeProp(message, "$unknowns", false);
740
+ (message.$unknowns || (message.$unknowns = [])).push(reader.raw(start, reader.pos));
582
741
  }
742
+ if (_end !== void 0)
743
+ throw Error("missing end group");
583
744
  return message;
584
745
  };
585
746
  Config.decodeDelimited = function decodeDelimited(reader) {
@@ -587,11 +748,15 @@ var rstream = $root.rstream = (() => {
587
748
  reader = new $Reader(reader);
588
749
  return this.decode(reader, reader.uint32());
589
750
  };
590
- Config.verify = function verify(message) {
751
+ Config.verify = function verify(message, _depth) {
591
752
  if (typeof message !== "object" || message === null)
592
753
  return "object expected";
754
+ if (_depth === void 0)
755
+ _depth = 0;
756
+ if (_depth > $util.recursionLimit)
757
+ return "max depth exceeded";
593
758
  if (message.options != null && message.hasOwnProperty("options")) {
594
- let error = $root.rstream.webtty.protobuf.Options.verify(message.options);
759
+ let error = $root.rstream.webtty.protobuf.Options.verify(message.options, _depth + 1);
595
760
  if (error)
596
761
  return "options." + error;
597
762
  }
@@ -606,58 +771,62 @@ var rstream = $root.rstream = (() => {
606
771
  if (!Array.isArray(message.envVars))
607
772
  return "envVars: array expected";
608
773
  for (let i = 0; i < message.envVars.length; ++i) {
609
- let error = $root.rstream.webtty.protobuf.Environment.verify(message.envVars[i]);
774
+ let error = $root.rstream.webtty.protobuf.Environment.verify(message.envVars[i], _depth + 1);
610
775
  if (error)
611
776
  return "envVars." + error;
612
777
  }
613
778
  }
614
779
  if (message.workdir != null && message.hasOwnProperty("workdir")) {
615
- let error = $root.rstream.webtty.protobuf.Workdir.verify(message.workdir);
780
+ let error = $root.rstream.webtty.protobuf.Workdir.verify(message.workdir, _depth + 1);
616
781
  if (error)
617
782
  return "workdir." + error;
618
783
  }
619
784
  if (message.username != null && message.hasOwnProperty("username")) {
620
- let error = $root.rstream.webtty.protobuf.Username.verify(message.username);
785
+ let error = $root.rstream.webtty.protobuf.Username.verify(message.username, _depth + 1);
621
786
  if (error)
622
787
  return "username." + error;
623
788
  }
624
789
  return null;
625
790
  };
626
- Config.fromObject = function fromObject(object) {
791
+ Config.fromObject = function fromObject(object, _depth) {
627
792
  if (object instanceof $root.rstream.webtty.protobuf.Config)
628
793
  return object;
794
+ if (_depth === void 0)
795
+ _depth = 0;
796
+ if (_depth > $util.recursionLimit)
797
+ throw Error("max depth exceeded");
629
798
  let message = new $root.rstream.webtty.protobuf.Config();
630
799
  if (object.options != null) {
631
800
  if (typeof object.options !== "object")
632
801
  throw TypeError(".rstream.webtty.protobuf.Config.options: object expected");
633
- message.options = $root.rstream.webtty.protobuf.Options.fromObject(object.options);
802
+ message.options = $root.rstream.webtty.protobuf.Options.fromObject(object.options, _depth + 1);
634
803
  }
635
804
  if (object.cmdArgs) {
636
805
  if (!Array.isArray(object.cmdArgs))
637
806
  throw TypeError(".rstream.webtty.protobuf.Config.cmdArgs: array expected");
638
- message.cmdArgs = [];
807
+ message.cmdArgs = Array(object.cmdArgs.length);
639
808
  for (let i = 0; i < object.cmdArgs.length; ++i)
640
809
  message.cmdArgs[i] = String(object.cmdArgs[i]);
641
810
  }
642
811
  if (object.envVars) {
643
812
  if (!Array.isArray(object.envVars))
644
813
  throw TypeError(".rstream.webtty.protobuf.Config.envVars: array expected");
645
- message.envVars = [];
814
+ message.envVars = Array(object.envVars.length);
646
815
  for (let i = 0; i < object.envVars.length; ++i) {
647
816
  if (typeof object.envVars[i] !== "object")
648
817
  throw TypeError(".rstream.webtty.protobuf.Config.envVars: object expected");
649
- message.envVars[i] = $root.rstream.webtty.protobuf.Environment.fromObject(object.envVars[i]);
818
+ message.envVars[i] = $root.rstream.webtty.protobuf.Environment.fromObject(object.envVars[i], _depth + 1);
650
819
  }
651
820
  }
652
821
  if (object.workdir != null) {
653
822
  if (typeof object.workdir !== "object")
654
823
  throw TypeError(".rstream.webtty.protobuf.Config.workdir: object expected");
655
- message.workdir = $root.rstream.webtty.protobuf.Workdir.fromObject(object.workdir);
824
+ message.workdir = $root.rstream.webtty.protobuf.Workdir.fromObject(object.workdir, _depth + 1);
656
825
  }
657
826
  if (object.username != null) {
658
827
  if (typeof object.username !== "object")
659
828
  throw TypeError(".rstream.webtty.protobuf.Config.username: object expected");
660
- message.username = $root.rstream.webtty.protobuf.Username.fromObject(object.username);
829
+ message.username = $root.rstream.webtty.protobuf.Username.fromObject(object.username, _depth + 1);
661
830
  }
662
831
  return message;
663
832
  };
@@ -677,12 +846,12 @@ var rstream = $root.rstream = (() => {
677
846
  if (message.options != null && message.hasOwnProperty("options"))
678
847
  object.options = $root.rstream.webtty.protobuf.Options.toObject(message.options, options);
679
848
  if (message.cmdArgs && message.cmdArgs.length) {
680
- object.cmdArgs = [];
849
+ object.cmdArgs = Array(message.cmdArgs.length);
681
850
  for (let j = 0; j < message.cmdArgs.length; ++j)
682
851
  object.cmdArgs[j] = message.cmdArgs[j];
683
852
  }
684
853
  if (message.envVars && message.envVars.length) {
685
- object.envVars = [];
854
+ object.envVars = Array(message.envVars.length);
686
855
  for (let j = 0; j < message.envVars.length; ++j)
687
856
  object.envVars[j] = $root.rstream.webtty.protobuf.Environment.toObject(message.envVars[j], options);
688
857
  }
@@ -693,13 +862,12 @@ var rstream = $root.rstream = (() => {
693
862
  return object;
694
863
  };
695
864
  Config.prototype.toJSON = function toJSON() {
696
- return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
865
+ return this.constructor.toObject(this, import_minimal.default.util.toJSONOptions);
697
866
  };
698
- Config.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
699
- if (typeUrlPrefix === void 0) {
700
- typeUrlPrefix = "type.googleapis.com";
701
- }
702
- return typeUrlPrefix + "/rstream.webtty.protobuf.Config";
867
+ Config.getTypeUrl = function getTypeUrl(prefix) {
868
+ if (prefix === void 0)
869
+ prefix = "type.googleapis.com";
870
+ return prefix + "/rstream.webtty.protobuf.Config";
703
871
  };
704
872
  return Config;
705
873
  })();
@@ -707,7 +875,7 @@ var rstream = $root.rstream = (() => {
707
875
  function Open(properties) {
708
876
  if (properties) {
709
877
  for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
710
- if (properties[keys[i]] != null)
878
+ if (properties[keys[i]] != null && keys[i] !== "__proto__")
711
879
  this[keys[i]] = properties[keys[i]];
712
880
  }
713
881
  }
@@ -723,29 +891,44 @@ var rstream = $root.rstream = (() => {
723
891
  /* id 1, wireType 2 =*/
724
892
  10
725
893
  ).fork()).ldelim();
894
+ if (message.$unknowns != null && Object.hasOwnProperty.call(message, "$unknowns"))
895
+ for (let i = 0; i < message.$unknowns.length; ++i)
896
+ writer.raw(message.$unknowns[i]);
726
897
  return writer;
727
898
  };
728
899
  Open.encodeDelimited = function encodeDelimited(message, writer) {
729
900
  return this.encode(message, writer).ldelim();
730
901
  };
731
- Open.decode = function decode(reader, length, error) {
902
+ Open.decode = function decode(reader, length, _end, _depth, _target) {
732
903
  if (!(reader instanceof $Reader))
733
904
  reader = $Reader.create(reader);
734
- let end = length === void 0 ? reader.len : reader.pos + length, message = new $root.rstream.webtty.protobuf.Open();
905
+ if (_depth === void 0)
906
+ _depth = 0;
907
+ if (_depth > $Reader.recursionLimit)
908
+ throw Error("max depth exceeded");
909
+ let end = length === void 0 ? reader.len : reader.pos + length, message = _target || new $root.rstream.webtty.protobuf.Open(), value;
735
910
  while (reader.pos < end) {
736
- let tag = reader.uint32();
737
- if (tag === error)
911
+ let start = reader.pos;
912
+ let tag = reader.tag();
913
+ if (tag === _end) {
914
+ _end = void 0;
738
915
  break;
739
- switch (tag >>> 3) {
916
+ }
917
+ let wireType = tag & 7;
918
+ switch (tag >>>= 3) {
740
919
  case 1: {
741
- message.config = $root.rstream.webtty.protobuf.Config.decode(reader, reader.uint32());
742
- break;
920
+ if (wireType !== 2)
921
+ break;
922
+ message.config = $root.rstream.webtty.protobuf.Config.decode(reader, reader.uint32(), void 0, _depth + 1, message.config);
923
+ continue;
743
924
  }
744
- default:
745
- reader.skipType(tag & 7);
746
- break;
747
925
  }
926
+ reader.skipType(wireType, _depth, tag);
927
+ $util.makeProp(message, "$unknowns", false);
928
+ (message.$unknowns || (message.$unknowns = [])).push(reader.raw(start, reader.pos));
748
929
  }
930
+ if (_end !== void 0)
931
+ throw Error("missing end group");
749
932
  return message;
750
933
  };
751
934
  Open.decodeDelimited = function decodeDelimited(reader) {
@@ -753,24 +936,32 @@ var rstream = $root.rstream = (() => {
753
936
  reader = new $Reader(reader);
754
937
  return this.decode(reader, reader.uint32());
755
938
  };
756
- Open.verify = function verify(message) {
939
+ Open.verify = function verify(message, _depth) {
757
940
  if (typeof message !== "object" || message === null)
758
941
  return "object expected";
942
+ if (_depth === void 0)
943
+ _depth = 0;
944
+ if (_depth > $util.recursionLimit)
945
+ return "max depth exceeded";
759
946
  if (message.config != null && message.hasOwnProperty("config")) {
760
- let error = $root.rstream.webtty.protobuf.Config.verify(message.config);
947
+ let error = $root.rstream.webtty.protobuf.Config.verify(message.config, _depth + 1);
761
948
  if (error)
762
949
  return "config." + error;
763
950
  }
764
951
  return null;
765
952
  };
766
- Open.fromObject = function fromObject(object) {
953
+ Open.fromObject = function fromObject(object, _depth) {
767
954
  if (object instanceof $root.rstream.webtty.protobuf.Open)
768
955
  return object;
956
+ if (_depth === void 0)
957
+ _depth = 0;
958
+ if (_depth > $util.recursionLimit)
959
+ throw Error("max depth exceeded");
769
960
  let message = new $root.rstream.webtty.protobuf.Open();
770
961
  if (object.config != null) {
771
962
  if (typeof object.config !== "object")
772
963
  throw TypeError(".rstream.webtty.protobuf.Open.config: object expected");
773
- message.config = $root.rstream.webtty.protobuf.Config.fromObject(object.config);
964
+ message.config = $root.rstream.webtty.protobuf.Config.fromObject(object.config, _depth + 1);
774
965
  }
775
966
  return message;
776
967
  };
@@ -785,13 +976,12 @@ var rstream = $root.rstream = (() => {
785
976
  return object;
786
977
  };
787
978
  Open.prototype.toJSON = function toJSON() {
788
- return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
979
+ return this.constructor.toObject(this, import_minimal.default.util.toJSONOptions);
789
980
  };
790
- Open.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
791
- if (typeUrlPrefix === void 0) {
792
- typeUrlPrefix = "type.googleapis.com";
793
- }
794
- return typeUrlPrefix + "/rstream.webtty.protobuf.Open";
981
+ Open.getTypeUrl = function getTypeUrl(prefix) {
982
+ if (prefix === void 0)
983
+ prefix = "type.googleapis.com";
984
+ return prefix + "/rstream.webtty.protobuf.Open";
795
985
  };
796
986
  return Open;
797
987
  })();
@@ -799,7 +989,7 @@ var rstream = $root.rstream = (() => {
799
989
  function Ack(properties) {
800
990
  if (properties) {
801
991
  for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
802
- if (properties[keys[i]] != null)
992
+ if (properties[keys[i]] != null && keys[i] !== "__proto__")
803
993
  this[keys[i]] = properties[keys[i]];
804
994
  }
805
995
  }
@@ -809,25 +999,35 @@ var rstream = $root.rstream = (() => {
809
999
  Ack.encode = function encode(message, writer) {
810
1000
  if (!writer)
811
1001
  writer = $Writer.create();
1002
+ if (message.$unknowns != null && Object.hasOwnProperty.call(message, "$unknowns"))
1003
+ for (let i = 0; i < message.$unknowns.length; ++i)
1004
+ writer.raw(message.$unknowns[i]);
812
1005
  return writer;
813
1006
  };
814
1007
  Ack.encodeDelimited = function encodeDelimited(message, writer) {
815
1008
  return this.encode(message, writer).ldelim();
816
1009
  };
817
- Ack.decode = function decode(reader, length, error) {
1010
+ Ack.decode = function decode(reader, length, _end, _depth, _target) {
818
1011
  if (!(reader instanceof $Reader))
819
1012
  reader = $Reader.create(reader);
820
- let end = length === void 0 ? reader.len : reader.pos + length, message = new $root.rstream.webtty.protobuf.Ack();
1013
+ if (_depth === void 0)
1014
+ _depth = 0;
1015
+ if (_depth > $Reader.recursionLimit)
1016
+ throw Error("max depth exceeded");
1017
+ let end = length === void 0 ? reader.len : reader.pos + length, message = _target || new $root.rstream.webtty.protobuf.Ack();
821
1018
  while (reader.pos < end) {
822
- let tag = reader.uint32();
823
- if (tag === error)
1019
+ let start = reader.pos;
1020
+ let tag = reader.tag();
1021
+ if (tag === _end) {
1022
+ _end = void 0;
824
1023
  break;
825
- switch (tag >>> 3) {
826
- default:
827
- reader.skipType(tag & 7);
828
- break;
829
1024
  }
1025
+ reader.skipType(tag & 7, _depth, tag);
1026
+ $util.makeProp(message, "$unknowns", false);
1027
+ (message.$unknowns || (message.$unknowns = [])).push(reader.raw(start, reader.pos));
830
1028
  }
1029
+ if (_end !== void 0)
1030
+ throw Error("missing end group");
831
1031
  return message;
832
1032
  };
833
1033
  Ack.decodeDelimited = function decodeDelimited(reader) {
@@ -835,27 +1035,34 @@ var rstream = $root.rstream = (() => {
835
1035
  reader = new $Reader(reader);
836
1036
  return this.decode(reader, reader.uint32());
837
1037
  };
838
- Ack.verify = function verify(message) {
1038
+ Ack.verify = function verify(message, _depth) {
839
1039
  if (typeof message !== "object" || message === null)
840
1040
  return "object expected";
1041
+ if (_depth === void 0)
1042
+ _depth = 0;
1043
+ if (_depth > $util.recursionLimit)
1044
+ return "max depth exceeded";
841
1045
  return null;
842
1046
  };
843
- Ack.fromObject = function fromObject(object) {
1047
+ Ack.fromObject = function fromObject(object, _depth) {
844
1048
  if (object instanceof $root.rstream.webtty.protobuf.Ack)
845
1049
  return object;
1050
+ if (_depth === void 0)
1051
+ _depth = 0;
1052
+ if (_depth > $util.recursionLimit)
1053
+ throw Error("max depth exceeded");
846
1054
  return new $root.rstream.webtty.protobuf.Ack();
847
1055
  };
848
1056
  Ack.toObject = function toObject() {
849
1057
  return {};
850
1058
  };
851
1059
  Ack.prototype.toJSON = function toJSON() {
852
- return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
1060
+ return this.constructor.toObject(this, import_minimal.default.util.toJSONOptions);
853
1061
  };
854
- Ack.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
855
- if (typeUrlPrefix === void 0) {
856
- typeUrlPrefix = "type.googleapis.com";
857
- }
858
- return typeUrlPrefix + "/rstream.webtty.protobuf.Ack";
1062
+ Ack.getTypeUrl = function getTypeUrl(prefix) {
1063
+ if (prefix === void 0)
1064
+ prefix = "type.googleapis.com";
1065
+ return prefix + "/rstream.webtty.protobuf.Ack";
859
1066
  };
860
1067
  return Ack;
861
1068
  })();
@@ -863,7 +1070,7 @@ var rstream = $root.rstream = (() => {
863
1070
  function Error2(properties) {
864
1071
  if (properties) {
865
1072
  for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
866
- if (properties[keys[i]] != null)
1073
+ if (properties[keys[i]] != null && keys[i] !== "__proto__")
867
1074
  this[keys[i]] = properties[keys[i]];
868
1075
  }
869
1076
  }
@@ -879,29 +1086,47 @@ var rstream = $root.rstream = (() => {
879
1086
  /* id 1, wireType 2 =*/
880
1087
  10
881
1088
  ).string(message.msg);
1089
+ if (message.$unknowns != null && Object.hasOwnProperty.call(message, "$unknowns"))
1090
+ for (let i = 0; i < message.$unknowns.length; ++i)
1091
+ writer.raw(message.$unknowns[i]);
882
1092
  return writer;
883
1093
  };
884
1094
  Error2.encodeDelimited = function encodeDelimited(message, writer) {
885
1095
  return this.encode(message, writer).ldelim();
886
1096
  };
887
- Error2.decode = function decode(reader, length, error) {
1097
+ Error2.decode = function decode(reader, length, _end, _depth, _target) {
888
1098
  if (!(reader instanceof $Reader))
889
1099
  reader = $Reader.create(reader);
890
- let end = length === void 0 ? reader.len : reader.pos + length, message = new $root.rstream.webtty.protobuf.Error();
1100
+ if (_depth === void 0)
1101
+ _depth = 0;
1102
+ if (_depth > $Reader.recursionLimit)
1103
+ throw Error2("max depth exceeded");
1104
+ let end = length === void 0 ? reader.len : reader.pos + length, message = _target || new $root.rstream.webtty.protobuf.Error(), value;
891
1105
  while (reader.pos < end) {
892
- let tag = reader.uint32();
893
- if (tag === error)
1106
+ let start = reader.pos;
1107
+ let tag = reader.tag();
1108
+ if (tag === _end) {
1109
+ _end = void 0;
894
1110
  break;
895
- switch (tag >>> 3) {
1111
+ }
1112
+ let wireType = tag & 7;
1113
+ switch (tag >>>= 3) {
896
1114
  case 1: {
897
- message.msg = reader.string();
898
- break;
1115
+ if (wireType !== 2)
1116
+ break;
1117
+ if ((value = reader.string()).length)
1118
+ message.msg = value;
1119
+ else
1120
+ delete message.msg;
1121
+ continue;
899
1122
  }
900
- default:
901
- reader.skipType(tag & 7);
902
- break;
903
1123
  }
1124
+ reader.skipType(wireType, _depth, tag);
1125
+ $util.makeProp(message, "$unknowns", false);
1126
+ (message.$unknowns || (message.$unknowns = [])).push(reader.raw(start, reader.pos));
904
1127
  }
1128
+ if (_end !== void 0)
1129
+ throw Error2("missing end group");
905
1130
  return message;
906
1131
  };
907
1132
  Error2.decodeDelimited = function decodeDelimited(reader) {
@@ -909,21 +1134,31 @@ var rstream = $root.rstream = (() => {
909
1134
  reader = new $Reader(reader);
910
1135
  return this.decode(reader, reader.uint32());
911
1136
  };
912
- Error2.verify = function verify(message) {
1137
+ Error2.verify = function verify(message, _depth) {
913
1138
  if (typeof message !== "object" || message === null)
914
1139
  return "object expected";
1140
+ if (_depth === void 0)
1141
+ _depth = 0;
1142
+ if (_depth > $util.recursionLimit)
1143
+ return "max depth exceeded";
915
1144
  if (message.msg != null && message.hasOwnProperty("msg")) {
916
1145
  if (!$util.isString(message.msg))
917
1146
  return "msg: string expected";
918
1147
  }
919
1148
  return null;
920
1149
  };
921
- Error2.fromObject = function fromObject(object) {
1150
+ Error2.fromObject = function fromObject(object, _depth) {
922
1151
  if (object instanceof $root.rstream.webtty.protobuf.Error)
923
1152
  return object;
1153
+ if (_depth === void 0)
1154
+ _depth = 0;
1155
+ if (_depth > $util.recursionLimit)
1156
+ throw Error2("max depth exceeded");
924
1157
  let message = new $root.rstream.webtty.protobuf.Error();
925
- if (object.msg != null)
926
- message.msg = String(object.msg);
1158
+ if (object.msg != null) {
1159
+ if (typeof object.msg !== "string" || object.msg.length)
1160
+ message.msg = String(object.msg);
1161
+ }
927
1162
  return message;
928
1163
  };
929
1164
  Error2.toObject = function toObject(message, options) {
@@ -937,13 +1172,12 @@ var rstream = $root.rstream = (() => {
937
1172
  return object;
938
1173
  };
939
1174
  Error2.prototype.toJSON = function toJSON() {
940
- return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
1175
+ return this.constructor.toObject(this, import_minimal.default.util.toJSONOptions);
941
1176
  };
942
- Error2.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
943
- if (typeUrlPrefix === void 0) {
944
- typeUrlPrefix = "type.googleapis.com";
945
- }
946
- return typeUrlPrefix + "/rstream.webtty.protobuf.Error";
1177
+ Error2.getTypeUrl = function getTypeUrl(prefix) {
1178
+ if (prefix === void 0)
1179
+ prefix = "type.googleapis.com";
1180
+ return prefix + "/rstream.webtty.protobuf.Error";
947
1181
  };
948
1182
  return Error2;
949
1183
  })();
@@ -951,7 +1185,7 @@ var rstream = $root.rstream = (() => {
951
1185
  function Close(properties) {
952
1186
  if (properties) {
953
1187
  for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
954
- if (properties[keys[i]] != null)
1188
+ if (properties[keys[i]] != null && keys[i] !== "__proto__")
955
1189
  this[keys[i]] = properties[keys[i]];
956
1190
  }
957
1191
  }
@@ -967,29 +1201,47 @@ var rstream = $root.rstream = (() => {
967
1201
  /* id 1, wireType 0 =*/
968
1202
  8
969
1203
  ).int32(message.returnCode);
1204
+ if (message.$unknowns != null && Object.hasOwnProperty.call(message, "$unknowns"))
1205
+ for (let i = 0; i < message.$unknowns.length; ++i)
1206
+ writer.raw(message.$unknowns[i]);
970
1207
  return writer;
971
1208
  };
972
1209
  Close.encodeDelimited = function encodeDelimited(message, writer) {
973
1210
  return this.encode(message, writer).ldelim();
974
1211
  };
975
- Close.decode = function decode(reader, length, error) {
1212
+ Close.decode = function decode(reader, length, _end, _depth, _target) {
976
1213
  if (!(reader instanceof $Reader))
977
1214
  reader = $Reader.create(reader);
978
- let end = length === void 0 ? reader.len : reader.pos + length, message = new $root.rstream.webtty.protobuf.Close();
1215
+ if (_depth === void 0)
1216
+ _depth = 0;
1217
+ if (_depth > $Reader.recursionLimit)
1218
+ throw Error("max depth exceeded");
1219
+ let end = length === void 0 ? reader.len : reader.pos + length, message = _target || new $root.rstream.webtty.protobuf.Close(), value;
979
1220
  while (reader.pos < end) {
980
- let tag = reader.uint32();
981
- if (tag === error)
1221
+ let start = reader.pos;
1222
+ let tag = reader.tag();
1223
+ if (tag === _end) {
1224
+ _end = void 0;
982
1225
  break;
983
- switch (tag >>> 3) {
1226
+ }
1227
+ let wireType = tag & 7;
1228
+ switch (tag >>>= 3) {
984
1229
  case 1: {
985
- message.returnCode = reader.int32();
986
- break;
1230
+ if (wireType !== 0)
1231
+ break;
1232
+ if (value = reader.int32())
1233
+ message.returnCode = value;
1234
+ else
1235
+ delete message.returnCode;
1236
+ continue;
987
1237
  }
988
- default:
989
- reader.skipType(tag & 7);
990
- break;
991
1238
  }
1239
+ reader.skipType(wireType, _depth, tag);
1240
+ $util.makeProp(message, "$unknowns", false);
1241
+ (message.$unknowns || (message.$unknowns = [])).push(reader.raw(start, reader.pos));
992
1242
  }
1243
+ if (_end !== void 0)
1244
+ throw Error("missing end group");
993
1245
  return message;
994
1246
  };
995
1247
  Close.decodeDelimited = function decodeDelimited(reader) {
@@ -997,21 +1249,31 @@ var rstream = $root.rstream = (() => {
997
1249
  reader = new $Reader(reader);
998
1250
  return this.decode(reader, reader.uint32());
999
1251
  };
1000
- Close.verify = function verify(message) {
1252
+ Close.verify = function verify(message, _depth) {
1001
1253
  if (typeof message !== "object" || message === null)
1002
1254
  return "object expected";
1255
+ if (_depth === void 0)
1256
+ _depth = 0;
1257
+ if (_depth > $util.recursionLimit)
1258
+ return "max depth exceeded";
1003
1259
  if (message.returnCode != null && message.hasOwnProperty("returnCode")) {
1004
1260
  if (!$util.isInteger(message.returnCode))
1005
1261
  return "returnCode: integer expected";
1006
1262
  }
1007
1263
  return null;
1008
1264
  };
1009
- Close.fromObject = function fromObject(object) {
1265
+ Close.fromObject = function fromObject(object, _depth) {
1010
1266
  if (object instanceof $root.rstream.webtty.protobuf.Close)
1011
1267
  return object;
1268
+ if (_depth === void 0)
1269
+ _depth = 0;
1270
+ if (_depth > $util.recursionLimit)
1271
+ throw Error("max depth exceeded");
1012
1272
  let message = new $root.rstream.webtty.protobuf.Close();
1013
- if (object.returnCode != null)
1014
- message.returnCode = object.returnCode | 0;
1273
+ if (object.returnCode != null) {
1274
+ if (Number(object.returnCode) !== 0)
1275
+ message.returnCode = object.returnCode | 0;
1276
+ }
1015
1277
  return message;
1016
1278
  };
1017
1279
  Close.toObject = function toObject(message, options) {
@@ -1025,13 +1287,12 @@ var rstream = $root.rstream = (() => {
1025
1287
  return object;
1026
1288
  };
1027
1289
  Close.prototype.toJSON = function toJSON() {
1028
- return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
1290
+ return this.constructor.toObject(this, import_minimal.default.util.toJSONOptions);
1029
1291
  };
1030
- Close.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
1031
- if (typeUrlPrefix === void 0) {
1032
- typeUrlPrefix = "type.googleapis.com";
1033
- }
1034
- return typeUrlPrefix + "/rstream.webtty.protobuf.Close";
1292
+ Close.getTypeUrl = function getTypeUrl(prefix) {
1293
+ if (prefix === void 0)
1294
+ prefix = "type.googleapis.com";
1295
+ return prefix + "/rstream.webtty.protobuf.Close";
1035
1296
  };
1036
1297
  return Close;
1037
1298
  })();
@@ -1039,7 +1300,7 @@ var rstream = $root.rstream = (() => {
1039
1300
  function EndOfStream(properties) {
1040
1301
  if (properties) {
1041
1302
  for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
1042
- if (properties[keys[i]] != null)
1303
+ if (properties[keys[i]] != null && keys[i] !== "__proto__")
1043
1304
  this[keys[i]] = properties[keys[i]];
1044
1305
  }
1045
1306
  }
@@ -1049,25 +1310,35 @@ var rstream = $root.rstream = (() => {
1049
1310
  EndOfStream.encode = function encode(message, writer) {
1050
1311
  if (!writer)
1051
1312
  writer = $Writer.create();
1313
+ if (message.$unknowns != null && Object.hasOwnProperty.call(message, "$unknowns"))
1314
+ for (let i = 0; i < message.$unknowns.length; ++i)
1315
+ writer.raw(message.$unknowns[i]);
1052
1316
  return writer;
1053
1317
  };
1054
1318
  EndOfStream.encodeDelimited = function encodeDelimited(message, writer) {
1055
1319
  return this.encode(message, writer).ldelim();
1056
1320
  };
1057
- EndOfStream.decode = function decode(reader, length, error) {
1321
+ EndOfStream.decode = function decode(reader, length, _end, _depth, _target) {
1058
1322
  if (!(reader instanceof $Reader))
1059
1323
  reader = $Reader.create(reader);
1060
- let end = length === void 0 ? reader.len : reader.pos + length, message = new $root.rstream.webtty.protobuf.EndOfStream();
1324
+ if (_depth === void 0)
1325
+ _depth = 0;
1326
+ if (_depth > $Reader.recursionLimit)
1327
+ throw Error("max depth exceeded");
1328
+ let end = length === void 0 ? reader.len : reader.pos + length, message = _target || new $root.rstream.webtty.protobuf.EndOfStream();
1061
1329
  while (reader.pos < end) {
1062
- let tag = reader.uint32();
1063
- if (tag === error)
1330
+ let start = reader.pos;
1331
+ let tag = reader.tag();
1332
+ if (tag === _end) {
1333
+ _end = void 0;
1064
1334
  break;
1065
- switch (tag >>> 3) {
1066
- default:
1067
- reader.skipType(tag & 7);
1068
- break;
1069
1335
  }
1336
+ reader.skipType(tag & 7, _depth, tag);
1337
+ $util.makeProp(message, "$unknowns", false);
1338
+ (message.$unknowns || (message.$unknowns = [])).push(reader.raw(start, reader.pos));
1070
1339
  }
1340
+ if (_end !== void 0)
1341
+ throw Error("missing end group");
1071
1342
  return message;
1072
1343
  };
1073
1344
  EndOfStream.decodeDelimited = function decodeDelimited(reader) {
@@ -1075,27 +1346,34 @@ var rstream = $root.rstream = (() => {
1075
1346
  reader = new $Reader(reader);
1076
1347
  return this.decode(reader, reader.uint32());
1077
1348
  };
1078
- EndOfStream.verify = function verify(message) {
1349
+ EndOfStream.verify = function verify(message, _depth) {
1079
1350
  if (typeof message !== "object" || message === null)
1080
1351
  return "object expected";
1352
+ if (_depth === void 0)
1353
+ _depth = 0;
1354
+ if (_depth > $util.recursionLimit)
1355
+ return "max depth exceeded";
1081
1356
  return null;
1082
1357
  };
1083
- EndOfStream.fromObject = function fromObject(object) {
1358
+ EndOfStream.fromObject = function fromObject(object, _depth) {
1084
1359
  if (object instanceof $root.rstream.webtty.protobuf.EndOfStream)
1085
1360
  return object;
1361
+ if (_depth === void 0)
1362
+ _depth = 0;
1363
+ if (_depth > $util.recursionLimit)
1364
+ throw Error("max depth exceeded");
1086
1365
  return new $root.rstream.webtty.protobuf.EndOfStream();
1087
1366
  };
1088
1367
  EndOfStream.toObject = function toObject() {
1089
1368
  return {};
1090
1369
  };
1091
1370
  EndOfStream.prototype.toJSON = function toJSON() {
1092
- return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
1371
+ return this.constructor.toObject(this, import_minimal.default.util.toJSONOptions);
1093
1372
  };
1094
- EndOfStream.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
1095
- if (typeUrlPrefix === void 0) {
1096
- typeUrlPrefix = "type.googleapis.com";
1097
- }
1098
- return typeUrlPrefix + "/rstream.webtty.protobuf.EndOfStream";
1373
+ EndOfStream.getTypeUrl = function getTypeUrl(prefix) {
1374
+ if (prefix === void 0)
1375
+ prefix = "type.googleapis.com";
1376
+ return prefix + "/rstream.webtty.protobuf.EndOfStream";
1099
1377
  };
1100
1378
  return EndOfStream;
1101
1379
  })();
@@ -1103,7 +1381,7 @@ var rstream = $root.rstream = (() => {
1103
1381
  function Data(properties) {
1104
1382
  if (properties) {
1105
1383
  for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
1106
- if (properties[keys[i]] != null)
1384
+ if (properties[keys[i]] != null && keys[i] !== "__proto__")
1107
1385
  this[keys[i]] = properties[keys[i]];
1108
1386
  }
1109
1387
  }
@@ -1136,37 +1414,61 @@ var rstream = $root.rstream = (() => {
1136
1414
  /* id 3, wireType 2 =*/
1137
1415
  26
1138
1416
  ).fork()).ldelim();
1417
+ if (message.$unknowns != null && Object.hasOwnProperty.call(message, "$unknowns"))
1418
+ for (let i = 0; i < message.$unknowns.length; ++i)
1419
+ writer.raw(message.$unknowns[i]);
1139
1420
  return writer;
1140
1421
  };
1141
1422
  Data.encodeDelimited = function encodeDelimited(message, writer) {
1142
1423
  return this.encode(message, writer).ldelim();
1143
1424
  };
1144
- Data.decode = function decode(reader, length, error) {
1425
+ Data.decode = function decode(reader, length, _end, _depth, _target) {
1145
1426
  if (!(reader instanceof $Reader))
1146
1427
  reader = $Reader.create(reader);
1147
- let end = length === void 0 ? reader.len : reader.pos + length, message = new $root.rstream.webtty.protobuf.Data();
1428
+ if (_depth === void 0)
1429
+ _depth = 0;
1430
+ if (_depth > $Reader.recursionLimit)
1431
+ throw Error("max depth exceeded");
1432
+ let end = length === void 0 ? reader.len : reader.pos + length, message = _target || new $root.rstream.webtty.protobuf.Data(), value;
1148
1433
  while (reader.pos < end) {
1149
- let tag = reader.uint32();
1150
- if (tag === error)
1434
+ let start = reader.pos;
1435
+ let tag = reader.tag();
1436
+ if (tag === _end) {
1437
+ _end = void 0;
1151
1438
  break;
1152
- switch (tag >>> 3) {
1439
+ }
1440
+ let wireType = tag & 7;
1441
+ switch (tag >>>= 3) {
1153
1442
  case 1: {
1154
- message.type = reader.int32();
1155
- break;
1443
+ if (wireType !== 0)
1444
+ break;
1445
+ if (value = reader.int32())
1446
+ message.type = value;
1447
+ else
1448
+ delete message.type;
1449
+ continue;
1156
1450
  }
1157
1451
  case 2: {
1452
+ if (wireType !== 2)
1453
+ break;
1158
1454
  message.data = reader.bytes();
1159
- break;
1455
+ message.payload = "data";
1456
+ continue;
1160
1457
  }
1161
1458
  case 3: {
1162
- message.eos = $root.rstream.webtty.protobuf.EndOfStream.decode(reader, reader.uint32());
1163
- break;
1459
+ if (wireType !== 2)
1460
+ break;
1461
+ message.eos = $root.rstream.webtty.protobuf.EndOfStream.decode(reader, reader.uint32(), void 0, _depth + 1, message.eos);
1462
+ message.payload = "eos";
1463
+ continue;
1164
1464
  }
1165
- default:
1166
- reader.skipType(tag & 7);
1167
- break;
1168
1465
  }
1466
+ reader.skipType(wireType, _depth, tag);
1467
+ $util.makeProp(message, "$unknowns", false);
1468
+ (message.$unknowns || (message.$unknowns = [])).push(reader.raw(start, reader.pos));
1169
1469
  }
1470
+ if (_end !== void 0)
1471
+ throw Error("missing end group");
1170
1472
  return message;
1171
1473
  };
1172
1474
  Data.decodeDelimited = function decodeDelimited(reader) {
@@ -1174,9 +1476,13 @@ var rstream = $root.rstream = (() => {
1174
1476
  reader = new $Reader(reader);
1175
1477
  return this.decode(reader, reader.uint32());
1176
1478
  };
1177
- Data.verify = function verify(message) {
1479
+ Data.verify = function verify(message, _depth) {
1178
1480
  if (typeof message !== "object" || message === null)
1179
1481
  return "object expected";
1482
+ if (_depth === void 0)
1483
+ _depth = 0;
1484
+ if (_depth > $util.recursionLimit)
1485
+ return "max depth exceeded";
1180
1486
  let properties = {};
1181
1487
  if (message.type != null && message.hasOwnProperty("type"))
1182
1488
  switch (message.type) {
@@ -1197,37 +1503,42 @@ var rstream = $root.rstream = (() => {
1197
1503
  return "payload: multiple values";
1198
1504
  properties.payload = 1;
1199
1505
  {
1200
- let error = $root.rstream.webtty.protobuf.EndOfStream.verify(message.eos);
1506
+ let error = $root.rstream.webtty.protobuf.EndOfStream.verify(message.eos, _depth + 1);
1201
1507
  if (error)
1202
1508
  return "eos." + error;
1203
1509
  }
1204
1510
  }
1205
1511
  return null;
1206
1512
  };
1207
- Data.fromObject = function fromObject(object) {
1513
+ Data.fromObject = function fromObject(object, _depth) {
1208
1514
  if (object instanceof $root.rstream.webtty.protobuf.Data)
1209
1515
  return object;
1516
+ if (_depth === void 0)
1517
+ _depth = 0;
1518
+ if (_depth > $util.recursionLimit)
1519
+ throw Error("max depth exceeded");
1210
1520
  let message = new $root.rstream.webtty.protobuf.Data();
1211
- switch (object.type) {
1212
- default:
1213
- if (typeof object.type === "number") {
1214
- message.type = object.type;
1521
+ if (object.type !== 0 && (typeof object.type !== "string" || $root.rstream.webtty.protobuf.Data.Type[object.type] !== 0))
1522
+ switch (object.type) {
1523
+ default:
1524
+ if (typeof object.type === "number") {
1525
+ message.type = object.type;
1526
+ break;
1527
+ }
1215
1528
  break;
1216
- }
1217
- break;
1218
- case "TYPE_STDIN":
1219
- case 0:
1220
- message.type = 0;
1221
- break;
1222
- case "TYPE_STDOUT":
1223
- case 1:
1224
- message.type = 1;
1225
- break;
1226
- case "TYPE_STDERR":
1227
- case 2:
1228
- message.type = 2;
1229
- break;
1230
- }
1529
+ case "TYPE_STDIN":
1530
+ case 0:
1531
+ message.type = 0;
1532
+ break;
1533
+ case "TYPE_STDOUT":
1534
+ case 1:
1535
+ message.type = 1;
1536
+ break;
1537
+ case "TYPE_STDERR":
1538
+ case 2:
1539
+ message.type = 2;
1540
+ break;
1541
+ }
1231
1542
  if (object.data != null) {
1232
1543
  if (typeof object.data === "string")
1233
1544
  $util.base64.decode(object.data, message.data = $util.newBuffer($util.base64.length(object.data)), 0);
@@ -1237,7 +1548,7 @@ var rstream = $root.rstream = (() => {
1237
1548
  if (object.eos != null) {
1238
1549
  if (typeof object.eos !== "object")
1239
1550
  throw TypeError(".rstream.webtty.protobuf.Data.eos: object expected");
1240
- message.eos = $root.rstream.webtty.protobuf.EndOfStream.fromObject(object.eos);
1551
+ message.eos = $root.rstream.webtty.protobuf.EndOfStream.fromObject(object.eos, _depth + 1);
1241
1552
  }
1242
1553
  return message;
1243
1554
  };
@@ -1262,13 +1573,12 @@ var rstream = $root.rstream = (() => {
1262
1573
  return object;
1263
1574
  };
1264
1575
  Data.prototype.toJSON = function toJSON() {
1265
- return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
1576
+ return this.constructor.toObject(this, import_minimal.default.util.toJSONOptions);
1266
1577
  };
1267
- Data.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
1268
- if (typeUrlPrefix === void 0) {
1269
- typeUrlPrefix = "type.googleapis.com";
1270
- }
1271
- return typeUrlPrefix + "/rstream.webtty.protobuf.Data";
1578
+ Data.getTypeUrl = function getTypeUrl(prefix) {
1579
+ if (prefix === void 0)
1580
+ prefix = "type.googleapis.com";
1581
+ return prefix + "/rstream.webtty.protobuf.Data";
1272
1582
  };
1273
1583
  Data.Type = (function() {
1274
1584
  const valuesById = {}, values = Object.create(valuesById);
@@ -1283,7 +1593,7 @@ var rstream = $root.rstream = (() => {
1283
1593
  function TerminalSize(properties) {
1284
1594
  if (properties) {
1285
1595
  for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
1286
- if (properties[keys[i]] != null)
1596
+ if (properties[keys[i]] != null && keys[i] !== "__proto__")
1287
1597
  this[keys[i]] = properties[keys[i]];
1288
1598
  }
1289
1599
  }
@@ -1317,41 +1627,74 @@ var rstream = $root.rstream = (() => {
1317
1627
  /* id 4, wireType 0 =*/
1318
1628
  32
1319
1629
  ).uint32(message.ypixel);
1630
+ if (message.$unknowns != null && Object.hasOwnProperty.call(message, "$unknowns"))
1631
+ for (let i = 0; i < message.$unknowns.length; ++i)
1632
+ writer.raw(message.$unknowns[i]);
1320
1633
  return writer;
1321
1634
  };
1322
1635
  TerminalSize.encodeDelimited = function encodeDelimited(message, writer) {
1323
1636
  return this.encode(message, writer).ldelim();
1324
1637
  };
1325
- TerminalSize.decode = function decode(reader, length, error) {
1638
+ TerminalSize.decode = function decode(reader, length, _end, _depth, _target) {
1326
1639
  if (!(reader instanceof $Reader))
1327
1640
  reader = $Reader.create(reader);
1328
- let end = length === void 0 ? reader.len : reader.pos + length, message = new $root.rstream.webtty.protobuf.TerminalSize();
1641
+ if (_depth === void 0)
1642
+ _depth = 0;
1643
+ if (_depth > $Reader.recursionLimit)
1644
+ throw Error("max depth exceeded");
1645
+ let end = length === void 0 ? reader.len : reader.pos + length, message = _target || new $root.rstream.webtty.protobuf.TerminalSize(), value;
1329
1646
  while (reader.pos < end) {
1330
- let tag = reader.uint32();
1331
- if (tag === error)
1647
+ let start = reader.pos;
1648
+ let tag = reader.tag();
1649
+ if (tag === _end) {
1650
+ _end = void 0;
1332
1651
  break;
1333
- switch (tag >>> 3) {
1652
+ }
1653
+ let wireType = tag & 7;
1654
+ switch (tag >>>= 3) {
1334
1655
  case 1: {
1335
- message.row = reader.uint32();
1336
- break;
1656
+ if (wireType !== 0)
1657
+ break;
1658
+ if (value = reader.uint32())
1659
+ message.row = value;
1660
+ else
1661
+ delete message.row;
1662
+ continue;
1337
1663
  }
1338
1664
  case 2: {
1339
- message.col = reader.uint32();
1340
- break;
1665
+ if (wireType !== 0)
1666
+ break;
1667
+ if (value = reader.uint32())
1668
+ message.col = value;
1669
+ else
1670
+ delete message.col;
1671
+ continue;
1341
1672
  }
1342
1673
  case 3: {
1343
- message.xpixel = reader.uint32();
1344
- break;
1674
+ if (wireType !== 0)
1675
+ break;
1676
+ if (value = reader.uint32())
1677
+ message.xpixel = value;
1678
+ else
1679
+ delete message.xpixel;
1680
+ continue;
1345
1681
  }
1346
1682
  case 4: {
1347
- message.ypixel = reader.uint32();
1348
- break;
1683
+ if (wireType !== 0)
1684
+ break;
1685
+ if (value = reader.uint32())
1686
+ message.ypixel = value;
1687
+ else
1688
+ delete message.ypixel;
1689
+ continue;
1349
1690
  }
1350
- default:
1351
- reader.skipType(tag & 7);
1352
- break;
1353
1691
  }
1692
+ reader.skipType(wireType, _depth, tag);
1693
+ $util.makeProp(message, "$unknowns", false);
1694
+ (message.$unknowns || (message.$unknowns = [])).push(reader.raw(start, reader.pos));
1354
1695
  }
1696
+ if (_end !== void 0)
1697
+ throw Error("missing end group");
1355
1698
  return message;
1356
1699
  };
1357
1700
  TerminalSize.decodeDelimited = function decodeDelimited(reader) {
@@ -1359,9 +1702,13 @@ var rstream = $root.rstream = (() => {
1359
1702
  reader = new $Reader(reader);
1360
1703
  return this.decode(reader, reader.uint32());
1361
1704
  };
1362
- TerminalSize.verify = function verify(message) {
1705
+ TerminalSize.verify = function verify(message, _depth) {
1363
1706
  if (typeof message !== "object" || message === null)
1364
1707
  return "object expected";
1708
+ if (_depth === void 0)
1709
+ _depth = 0;
1710
+ if (_depth > $util.recursionLimit)
1711
+ return "max depth exceeded";
1365
1712
  if (message.row != null && message.hasOwnProperty("row")) {
1366
1713
  if (!$util.isInteger(message.row))
1367
1714
  return "row: integer expected";
@@ -1380,18 +1727,30 @@ var rstream = $root.rstream = (() => {
1380
1727
  }
1381
1728
  return null;
1382
1729
  };
1383
- TerminalSize.fromObject = function fromObject(object) {
1730
+ TerminalSize.fromObject = function fromObject(object, _depth) {
1384
1731
  if (object instanceof $root.rstream.webtty.protobuf.TerminalSize)
1385
1732
  return object;
1733
+ if (_depth === void 0)
1734
+ _depth = 0;
1735
+ if (_depth > $util.recursionLimit)
1736
+ throw Error("max depth exceeded");
1386
1737
  let message = new $root.rstream.webtty.protobuf.TerminalSize();
1387
- if (object.row != null)
1388
- message.row = object.row >>> 0;
1389
- if (object.col != null)
1390
- message.col = object.col >>> 0;
1391
- if (object.xpixel != null)
1392
- message.xpixel = object.xpixel >>> 0;
1393
- if (object.ypixel != null)
1394
- message.ypixel = object.ypixel >>> 0;
1738
+ if (object.row != null) {
1739
+ if (Number(object.row) !== 0)
1740
+ message.row = object.row >>> 0;
1741
+ }
1742
+ if (object.col != null) {
1743
+ if (Number(object.col) !== 0)
1744
+ message.col = object.col >>> 0;
1745
+ }
1746
+ if (object.xpixel != null) {
1747
+ if (Number(object.xpixel) !== 0)
1748
+ message.xpixel = object.xpixel >>> 0;
1749
+ }
1750
+ if (object.ypixel != null) {
1751
+ if (Number(object.ypixel) !== 0)
1752
+ message.ypixel = object.ypixel >>> 0;
1753
+ }
1395
1754
  return message;
1396
1755
  };
1397
1756
  TerminalSize.toObject = function toObject(message, options) {
@@ -1415,13 +1774,12 @@ var rstream = $root.rstream = (() => {
1415
1774
  return object;
1416
1775
  };
1417
1776
  TerminalSize.prototype.toJSON = function toJSON() {
1418
- return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
1777
+ return this.constructor.toObject(this, import_minimal.default.util.toJSONOptions);
1419
1778
  };
1420
- TerminalSize.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
1421
- if (typeUrlPrefix === void 0) {
1422
- typeUrlPrefix = "type.googleapis.com";
1423
- }
1424
- return typeUrlPrefix + "/rstream.webtty.protobuf.TerminalSize";
1779
+ TerminalSize.getTypeUrl = function getTypeUrl(prefix) {
1780
+ if (prefix === void 0)
1781
+ prefix = "type.googleapis.com";
1782
+ return prefix + "/rstream.webtty.protobuf.TerminalSize";
1425
1783
  };
1426
1784
  return TerminalSize;
1427
1785
  })();
@@ -1429,7 +1787,7 @@ var rstream = $root.rstream = (() => {
1429
1787
  function Parameter(properties) {
1430
1788
  if (properties) {
1431
1789
  for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
1432
- if (properties[keys[i]] != null)
1790
+ if (properties[keys[i]] != null && keys[i] !== "__proto__")
1433
1791
  this[keys[i]] = properties[keys[i]];
1434
1792
  }
1435
1793
  }
@@ -1450,29 +1808,45 @@ var rstream = $root.rstream = (() => {
1450
1808
  /* id 1, wireType 2 =*/
1451
1809
  10
1452
1810
  ).fork()).ldelim();
1811
+ if (message.$unknowns != null && Object.hasOwnProperty.call(message, "$unknowns"))
1812
+ for (let i = 0; i < message.$unknowns.length; ++i)
1813
+ writer.raw(message.$unknowns[i]);
1453
1814
  return writer;
1454
1815
  };
1455
1816
  Parameter.encodeDelimited = function encodeDelimited(message, writer) {
1456
1817
  return this.encode(message, writer).ldelim();
1457
1818
  };
1458
- Parameter.decode = function decode(reader, length, error) {
1819
+ Parameter.decode = function decode(reader, length, _end, _depth, _target) {
1459
1820
  if (!(reader instanceof $Reader))
1460
1821
  reader = $Reader.create(reader);
1461
- let end = length === void 0 ? reader.len : reader.pos + length, message = new $root.rstream.webtty.protobuf.Parameter();
1822
+ if (_depth === void 0)
1823
+ _depth = 0;
1824
+ if (_depth > $Reader.recursionLimit)
1825
+ throw Error("max depth exceeded");
1826
+ let end = length === void 0 ? reader.len : reader.pos + length, message = _target || new $root.rstream.webtty.protobuf.Parameter();
1462
1827
  while (reader.pos < end) {
1463
- let tag = reader.uint32();
1464
- if (tag === error)
1828
+ let start = reader.pos;
1829
+ let tag = reader.tag();
1830
+ if (tag === _end) {
1831
+ _end = void 0;
1465
1832
  break;
1466
- switch (tag >>> 3) {
1833
+ }
1834
+ let wireType = tag & 7;
1835
+ switch (tag >>>= 3) {
1467
1836
  case 1: {
1468
- message.terminalSize = $root.rstream.webtty.protobuf.TerminalSize.decode(reader, reader.uint32());
1469
- break;
1837
+ if (wireType !== 2)
1838
+ break;
1839
+ message.terminalSize = $root.rstream.webtty.protobuf.TerminalSize.decode(reader, reader.uint32(), void 0, _depth + 1, message.terminalSize);
1840
+ message.parameter = "terminalSize";
1841
+ continue;
1470
1842
  }
1471
- default:
1472
- reader.skipType(tag & 7);
1473
- break;
1474
1843
  }
1844
+ reader.skipType(wireType, _depth, tag);
1845
+ $util.makeProp(message, "$unknowns", false);
1846
+ (message.$unknowns || (message.$unknowns = [])).push(reader.raw(start, reader.pos));
1475
1847
  }
1848
+ if (_end !== void 0)
1849
+ throw Error("missing end group");
1476
1850
  return message;
1477
1851
  };
1478
1852
  Parameter.decodeDelimited = function decodeDelimited(reader) {
@@ -1480,28 +1854,36 @@ var rstream = $root.rstream = (() => {
1480
1854
  reader = new $Reader(reader);
1481
1855
  return this.decode(reader, reader.uint32());
1482
1856
  };
1483
- Parameter.verify = function verify(message) {
1857
+ Parameter.verify = function verify(message, _depth) {
1484
1858
  if (typeof message !== "object" || message === null)
1485
1859
  return "object expected";
1860
+ if (_depth === void 0)
1861
+ _depth = 0;
1862
+ if (_depth > $util.recursionLimit)
1863
+ return "max depth exceeded";
1486
1864
  let properties = {};
1487
1865
  if (message.terminalSize != null && message.hasOwnProperty("terminalSize")) {
1488
1866
  properties.parameter = 1;
1489
1867
  {
1490
- let error = $root.rstream.webtty.protobuf.TerminalSize.verify(message.terminalSize);
1868
+ let error = $root.rstream.webtty.protobuf.TerminalSize.verify(message.terminalSize, _depth + 1);
1491
1869
  if (error)
1492
1870
  return "terminalSize." + error;
1493
1871
  }
1494
1872
  }
1495
1873
  return null;
1496
1874
  };
1497
- Parameter.fromObject = function fromObject(object) {
1875
+ Parameter.fromObject = function fromObject(object, _depth) {
1498
1876
  if (object instanceof $root.rstream.webtty.protobuf.Parameter)
1499
1877
  return object;
1878
+ if (_depth === void 0)
1879
+ _depth = 0;
1880
+ if (_depth > $util.recursionLimit)
1881
+ throw Error("max depth exceeded");
1500
1882
  let message = new $root.rstream.webtty.protobuf.Parameter();
1501
1883
  if (object.terminalSize != null) {
1502
1884
  if (typeof object.terminalSize !== "object")
1503
1885
  throw TypeError(".rstream.webtty.protobuf.Parameter.terminalSize: object expected");
1504
- message.terminalSize = $root.rstream.webtty.protobuf.TerminalSize.fromObject(object.terminalSize);
1886
+ message.terminalSize = $root.rstream.webtty.protobuf.TerminalSize.fromObject(object.terminalSize, _depth + 1);
1505
1887
  }
1506
1888
  return message;
1507
1889
  };
@@ -1517,13 +1899,12 @@ var rstream = $root.rstream = (() => {
1517
1899
  return object;
1518
1900
  };
1519
1901
  Parameter.prototype.toJSON = function toJSON() {
1520
- return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
1902
+ return this.constructor.toObject(this, import_minimal.default.util.toJSONOptions);
1521
1903
  };
1522
- Parameter.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
1523
- if (typeUrlPrefix === void 0) {
1524
- typeUrlPrefix = "type.googleapis.com";
1525
- }
1526
- return typeUrlPrefix + "/rstream.webtty.protobuf.Parameter";
1904
+ Parameter.getTypeUrl = function getTypeUrl(prefix) {
1905
+ if (prefix === void 0)
1906
+ prefix = "type.googleapis.com";
1907
+ return prefix + "/rstream.webtty.protobuf.Parameter";
1527
1908
  };
1528
1909
  return Parameter;
1529
1910
  })();
@@ -1531,7 +1912,7 @@ var rstream = $root.rstream = (() => {
1531
1912
  function Heartbeat(properties) {
1532
1913
  if (properties) {
1533
1914
  for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
1534
- if (properties[keys[i]] != null)
1915
+ if (properties[keys[i]] != null && keys[i] !== "__proto__")
1535
1916
  this[keys[i]] = properties[keys[i]];
1536
1917
  }
1537
1918
  }
@@ -1541,25 +1922,35 @@ var rstream = $root.rstream = (() => {
1541
1922
  Heartbeat.encode = function encode(message, writer) {
1542
1923
  if (!writer)
1543
1924
  writer = $Writer.create();
1925
+ if (message.$unknowns != null && Object.hasOwnProperty.call(message, "$unknowns"))
1926
+ for (let i = 0; i < message.$unknowns.length; ++i)
1927
+ writer.raw(message.$unknowns[i]);
1544
1928
  return writer;
1545
1929
  };
1546
1930
  Heartbeat.encodeDelimited = function encodeDelimited(message, writer) {
1547
1931
  return this.encode(message, writer).ldelim();
1548
1932
  };
1549
- Heartbeat.decode = function decode(reader, length, error) {
1933
+ Heartbeat.decode = function decode(reader, length, _end, _depth, _target) {
1550
1934
  if (!(reader instanceof $Reader))
1551
1935
  reader = $Reader.create(reader);
1552
- let end = length === void 0 ? reader.len : reader.pos + length, message = new $root.rstream.webtty.protobuf.Heartbeat();
1936
+ if (_depth === void 0)
1937
+ _depth = 0;
1938
+ if (_depth > $Reader.recursionLimit)
1939
+ throw Error("max depth exceeded");
1940
+ let end = length === void 0 ? reader.len : reader.pos + length, message = _target || new $root.rstream.webtty.protobuf.Heartbeat();
1553
1941
  while (reader.pos < end) {
1554
- let tag = reader.uint32();
1555
- if (tag === error)
1942
+ let start = reader.pos;
1943
+ let tag = reader.tag();
1944
+ if (tag === _end) {
1945
+ _end = void 0;
1556
1946
  break;
1557
- switch (tag >>> 3) {
1558
- default:
1559
- reader.skipType(tag & 7);
1560
- break;
1561
1947
  }
1948
+ reader.skipType(tag & 7, _depth, tag);
1949
+ $util.makeProp(message, "$unknowns", false);
1950
+ (message.$unknowns || (message.$unknowns = [])).push(reader.raw(start, reader.pos));
1562
1951
  }
1952
+ if (_end !== void 0)
1953
+ throw Error("missing end group");
1563
1954
  return message;
1564
1955
  };
1565
1956
  Heartbeat.decodeDelimited = function decodeDelimited(reader) {
@@ -1567,27 +1958,34 @@ var rstream = $root.rstream = (() => {
1567
1958
  reader = new $Reader(reader);
1568
1959
  return this.decode(reader, reader.uint32());
1569
1960
  };
1570
- Heartbeat.verify = function verify(message) {
1961
+ Heartbeat.verify = function verify(message, _depth) {
1571
1962
  if (typeof message !== "object" || message === null)
1572
1963
  return "object expected";
1964
+ if (_depth === void 0)
1965
+ _depth = 0;
1966
+ if (_depth > $util.recursionLimit)
1967
+ return "max depth exceeded";
1573
1968
  return null;
1574
1969
  };
1575
- Heartbeat.fromObject = function fromObject(object) {
1970
+ Heartbeat.fromObject = function fromObject(object, _depth) {
1576
1971
  if (object instanceof $root.rstream.webtty.protobuf.Heartbeat)
1577
1972
  return object;
1973
+ if (_depth === void 0)
1974
+ _depth = 0;
1975
+ if (_depth > $util.recursionLimit)
1976
+ throw Error("max depth exceeded");
1578
1977
  return new $root.rstream.webtty.protobuf.Heartbeat();
1579
1978
  };
1580
1979
  Heartbeat.toObject = function toObject() {
1581
1980
  return {};
1582
1981
  };
1583
1982
  Heartbeat.prototype.toJSON = function toJSON() {
1584
- return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
1983
+ return this.constructor.toObject(this, import_minimal.default.util.toJSONOptions);
1585
1984
  };
1586
- Heartbeat.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
1587
- if (typeUrlPrefix === void 0) {
1588
- typeUrlPrefix = "type.googleapis.com";
1589
- }
1590
- return typeUrlPrefix + "/rstream.webtty.protobuf.Heartbeat";
1985
+ Heartbeat.getTypeUrl = function getTypeUrl(prefix) {
1986
+ if (prefix === void 0)
1987
+ prefix = "type.googleapis.com";
1988
+ return prefix + "/rstream.webtty.protobuf.Heartbeat";
1591
1989
  };
1592
1990
  return Heartbeat;
1593
1991
  })();
@@ -1595,7 +1993,7 @@ var rstream = $root.rstream = (() => {
1595
1993
  function Message(properties) {
1596
1994
  if (properties) {
1597
1995
  for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
1598
- if (properties[keys[i]] != null)
1996
+ if (properties[keys[i]] != null && keys[i] !== "__proto__")
1599
1997
  this[keys[i]] = properties[keys[i]];
1600
1998
  }
1601
1999
  }
@@ -1652,53 +2050,87 @@ var rstream = $root.rstream = (() => {
1652
2050
  /* id 7, wireType 2 =*/
1653
2051
  58
1654
2052
  ).fork()).ldelim();
2053
+ if (message.$unknowns != null && Object.hasOwnProperty.call(message, "$unknowns"))
2054
+ for (let i = 0; i < message.$unknowns.length; ++i)
2055
+ writer.raw(message.$unknowns[i]);
1655
2056
  return writer;
1656
2057
  };
1657
2058
  Message.encodeDelimited = function encodeDelimited(message, writer) {
1658
2059
  return this.encode(message, writer).ldelim();
1659
2060
  };
1660
- Message.decode = function decode(reader, length, error) {
2061
+ Message.decode = function decode(reader, length, _end, _depth, _target) {
1661
2062
  if (!(reader instanceof $Reader))
1662
2063
  reader = $Reader.create(reader);
1663
- let end = length === void 0 ? reader.len : reader.pos + length, message = new $root.rstream.webtty.protobuf.Message();
2064
+ if (_depth === void 0)
2065
+ _depth = 0;
2066
+ if (_depth > $Reader.recursionLimit)
2067
+ throw Error("max depth exceeded");
2068
+ let end = length === void 0 ? reader.len : reader.pos + length, message = _target || new $root.rstream.webtty.protobuf.Message();
1664
2069
  while (reader.pos < end) {
1665
- let tag = reader.uint32();
1666
- if (tag === error)
2070
+ let start = reader.pos;
2071
+ let tag = reader.tag();
2072
+ if (tag === _end) {
2073
+ _end = void 0;
1667
2074
  break;
1668
- switch (tag >>> 3) {
2075
+ }
2076
+ let wireType = tag & 7;
2077
+ switch (tag >>>= 3) {
1669
2078
  case 1: {
1670
- message.open = $root.rstream.webtty.protobuf.Open.decode(reader, reader.uint32());
1671
- break;
2079
+ if (wireType !== 2)
2080
+ break;
2081
+ message.open = $root.rstream.webtty.protobuf.Open.decode(reader, reader.uint32(), void 0, _depth + 1, message.open);
2082
+ message.payload = "open";
2083
+ continue;
1672
2084
  }
1673
2085
  case 2: {
1674
- message.ack = $root.rstream.webtty.protobuf.Ack.decode(reader, reader.uint32());
1675
- break;
2086
+ if (wireType !== 2)
2087
+ break;
2088
+ message.ack = $root.rstream.webtty.protobuf.Ack.decode(reader, reader.uint32(), void 0, _depth + 1, message.ack);
2089
+ message.payload = "ack";
2090
+ continue;
1676
2091
  }
1677
2092
  case 3: {
1678
- message.error = $root.rstream.webtty.protobuf.Error.decode(reader, reader.uint32());
1679
- break;
2093
+ if (wireType !== 2)
2094
+ break;
2095
+ message.error = $root.rstream.webtty.protobuf.Error.decode(reader, reader.uint32(), void 0, _depth + 1, message.error);
2096
+ message.payload = "error";
2097
+ continue;
1680
2098
  }
1681
2099
  case 4: {
1682
- message.close = $root.rstream.webtty.protobuf.Close.decode(reader, reader.uint32());
1683
- break;
2100
+ if (wireType !== 2)
2101
+ break;
2102
+ message.close = $root.rstream.webtty.protobuf.Close.decode(reader, reader.uint32(), void 0, _depth + 1, message.close);
2103
+ message.payload = "close";
2104
+ continue;
1684
2105
  }
1685
2106
  case 5: {
1686
- message.data = $root.rstream.webtty.protobuf.Data.decode(reader, reader.uint32());
1687
- break;
2107
+ if (wireType !== 2)
2108
+ break;
2109
+ message.data = $root.rstream.webtty.protobuf.Data.decode(reader, reader.uint32(), void 0, _depth + 1, message.data);
2110
+ message.payload = "data";
2111
+ continue;
1688
2112
  }
1689
2113
  case 6: {
1690
- message.parameter = $root.rstream.webtty.protobuf.Parameter.decode(reader, reader.uint32());
1691
- break;
2114
+ if (wireType !== 2)
2115
+ break;
2116
+ message.parameter = $root.rstream.webtty.protobuf.Parameter.decode(reader, reader.uint32(), void 0, _depth + 1, message.parameter);
2117
+ message.payload = "parameter";
2118
+ continue;
1692
2119
  }
1693
2120
  case 7: {
1694
- message.heartbeat = $root.rstream.webtty.protobuf.Heartbeat.decode(reader, reader.uint32());
1695
- break;
2121
+ if (wireType !== 2)
2122
+ break;
2123
+ message.heartbeat = $root.rstream.webtty.protobuf.Heartbeat.decode(reader, reader.uint32(), void 0, _depth + 1, message.heartbeat);
2124
+ message.payload = "heartbeat";
2125
+ continue;
1696
2126
  }
1697
- default:
1698
- reader.skipType(tag & 7);
1699
- break;
1700
2127
  }
2128
+ reader.skipType(wireType, _depth, tag);
2129
+ $util.makeProp(message, "$unknowns", false);
2130
+ (message.$unknowns || (message.$unknowns = [])).push(reader.raw(start, reader.pos));
1701
2131
  }
2132
+ if (_end !== void 0)
2133
+ throw Error("missing end group");
1702
2134
  return message;
1703
2135
  };
1704
2136
  Message.decodeDelimited = function decodeDelimited(reader) {
@@ -1706,14 +2138,18 @@ var rstream = $root.rstream = (() => {
1706
2138
  reader = new $Reader(reader);
1707
2139
  return this.decode(reader, reader.uint32());
1708
2140
  };
1709
- Message.verify = function verify(message) {
2141
+ Message.verify = function verify(message, _depth) {
1710
2142
  if (typeof message !== "object" || message === null)
1711
2143
  return "object expected";
2144
+ if (_depth === void 0)
2145
+ _depth = 0;
2146
+ if (_depth > $util.recursionLimit)
2147
+ return "max depth exceeded";
1712
2148
  let properties = {};
1713
2149
  if (message.open != null && message.hasOwnProperty("open")) {
1714
2150
  properties.payload = 1;
1715
2151
  {
1716
- let error = $root.rstream.webtty.protobuf.Open.verify(message.open);
2152
+ let error = $root.rstream.webtty.protobuf.Open.verify(message.open, _depth + 1);
1717
2153
  if (error)
1718
2154
  return "open." + error;
1719
2155
  }
@@ -1723,7 +2159,7 @@ var rstream = $root.rstream = (() => {
1723
2159
  return "payload: multiple values";
1724
2160
  properties.payload = 1;
1725
2161
  {
1726
- let error = $root.rstream.webtty.protobuf.Ack.verify(message.ack);
2162
+ let error = $root.rstream.webtty.protobuf.Ack.verify(message.ack, _depth + 1);
1727
2163
  if (error)
1728
2164
  return "ack." + error;
1729
2165
  }
@@ -1733,7 +2169,7 @@ var rstream = $root.rstream = (() => {
1733
2169
  return "payload: multiple values";
1734
2170
  properties.payload = 1;
1735
2171
  {
1736
- let error = $root.rstream.webtty.protobuf.Error.verify(message.error);
2172
+ let error = $root.rstream.webtty.protobuf.Error.verify(message.error, _depth + 1);
1737
2173
  if (error)
1738
2174
  return "error." + error;
1739
2175
  }
@@ -1743,7 +2179,7 @@ var rstream = $root.rstream = (() => {
1743
2179
  return "payload: multiple values";
1744
2180
  properties.payload = 1;
1745
2181
  {
1746
- let error = $root.rstream.webtty.protobuf.Close.verify(message.close);
2182
+ let error = $root.rstream.webtty.protobuf.Close.verify(message.close, _depth + 1);
1747
2183
  if (error)
1748
2184
  return "close." + error;
1749
2185
  }
@@ -1753,7 +2189,7 @@ var rstream = $root.rstream = (() => {
1753
2189
  return "payload: multiple values";
1754
2190
  properties.payload = 1;
1755
2191
  {
1756
- let error = $root.rstream.webtty.protobuf.Data.verify(message.data);
2192
+ let error = $root.rstream.webtty.protobuf.Data.verify(message.data, _depth + 1);
1757
2193
  if (error)
1758
2194
  return "data." + error;
1759
2195
  }
@@ -1763,7 +2199,7 @@ var rstream = $root.rstream = (() => {
1763
2199
  return "payload: multiple values";
1764
2200
  properties.payload = 1;
1765
2201
  {
1766
- let error = $root.rstream.webtty.protobuf.Parameter.verify(message.parameter);
2202
+ let error = $root.rstream.webtty.protobuf.Parameter.verify(message.parameter, _depth + 1);
1767
2203
  if (error)
1768
2204
  return "parameter." + error;
1769
2205
  }
@@ -1773,51 +2209,55 @@ var rstream = $root.rstream = (() => {
1773
2209
  return "payload: multiple values";
1774
2210
  properties.payload = 1;
1775
2211
  {
1776
- let error = $root.rstream.webtty.protobuf.Heartbeat.verify(message.heartbeat);
2212
+ let error = $root.rstream.webtty.protobuf.Heartbeat.verify(message.heartbeat, _depth + 1);
1777
2213
  if (error)
1778
2214
  return "heartbeat." + error;
1779
2215
  }
1780
2216
  }
1781
2217
  return null;
1782
2218
  };
1783
- Message.fromObject = function fromObject(object) {
2219
+ Message.fromObject = function fromObject(object, _depth) {
1784
2220
  if (object instanceof $root.rstream.webtty.protobuf.Message)
1785
2221
  return object;
2222
+ if (_depth === void 0)
2223
+ _depth = 0;
2224
+ if (_depth > $util.recursionLimit)
2225
+ throw Error("max depth exceeded");
1786
2226
  let message = new $root.rstream.webtty.protobuf.Message();
1787
2227
  if (object.open != null) {
1788
2228
  if (typeof object.open !== "object")
1789
2229
  throw TypeError(".rstream.webtty.protobuf.Message.open: object expected");
1790
- message.open = $root.rstream.webtty.protobuf.Open.fromObject(object.open);
2230
+ message.open = $root.rstream.webtty.protobuf.Open.fromObject(object.open, _depth + 1);
1791
2231
  }
1792
2232
  if (object.ack != null) {
1793
2233
  if (typeof object.ack !== "object")
1794
2234
  throw TypeError(".rstream.webtty.protobuf.Message.ack: object expected");
1795
- message.ack = $root.rstream.webtty.protobuf.Ack.fromObject(object.ack);
2235
+ message.ack = $root.rstream.webtty.protobuf.Ack.fromObject(object.ack, _depth + 1);
1796
2236
  }
1797
2237
  if (object.error != null) {
1798
2238
  if (typeof object.error !== "object")
1799
2239
  throw TypeError(".rstream.webtty.protobuf.Message.error: object expected");
1800
- message.error = $root.rstream.webtty.protobuf.Error.fromObject(object.error);
2240
+ message.error = $root.rstream.webtty.protobuf.Error.fromObject(object.error, _depth + 1);
1801
2241
  }
1802
2242
  if (object.close != null) {
1803
2243
  if (typeof object.close !== "object")
1804
2244
  throw TypeError(".rstream.webtty.protobuf.Message.close: object expected");
1805
- message.close = $root.rstream.webtty.protobuf.Close.fromObject(object.close);
2245
+ message.close = $root.rstream.webtty.protobuf.Close.fromObject(object.close, _depth + 1);
1806
2246
  }
1807
2247
  if (object.data != null) {
1808
2248
  if (typeof object.data !== "object")
1809
2249
  throw TypeError(".rstream.webtty.protobuf.Message.data: object expected");
1810
- message.data = $root.rstream.webtty.protobuf.Data.fromObject(object.data);
2250
+ message.data = $root.rstream.webtty.protobuf.Data.fromObject(object.data, _depth + 1);
1811
2251
  }
1812
2252
  if (object.parameter != null) {
1813
2253
  if (typeof object.parameter !== "object")
1814
2254
  throw TypeError(".rstream.webtty.protobuf.Message.parameter: object expected");
1815
- message.parameter = $root.rstream.webtty.protobuf.Parameter.fromObject(object.parameter);
2255
+ message.parameter = $root.rstream.webtty.protobuf.Parameter.fromObject(object.parameter, _depth + 1);
1816
2256
  }
1817
2257
  if (object.heartbeat != null) {
1818
2258
  if (typeof object.heartbeat !== "object")
1819
2259
  throw TypeError(".rstream.webtty.protobuf.Message.heartbeat: object expected");
1820
- message.heartbeat = $root.rstream.webtty.protobuf.Heartbeat.fromObject(object.heartbeat);
2260
+ message.heartbeat = $root.rstream.webtty.protobuf.Heartbeat.fromObject(object.heartbeat, _depth + 1);
1821
2261
  }
1822
2262
  return message;
1823
2263
  };
@@ -1863,13 +2303,12 @@ var rstream = $root.rstream = (() => {
1863
2303
  return object;
1864
2304
  };
1865
2305
  Message.prototype.toJSON = function toJSON() {
1866
- return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
2306
+ return this.constructor.toObject(this, import_minimal.default.util.toJSONOptions);
1867
2307
  };
1868
- Message.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
1869
- if (typeUrlPrefix === void 0) {
1870
- typeUrlPrefix = "type.googleapis.com";
1871
- }
1872
- return typeUrlPrefix + "/rstream.webtty.protobuf.Message";
2308
+ Message.getTypeUrl = function getTypeUrl(prefix) {
2309
+ if (prefix === void 0)
2310
+ prefix = "type.googleapis.com";
2311
+ return prefix + "/rstream.webtty.protobuf.Message";
1873
2312
  };
1874
2313
  return Message;
1875
2314
  })();
@@ -1901,11 +2340,11 @@ var WebTTY = class {
1901
2340
  * @param execConfig - Execution parameters.
1902
2341
  * @param events - Event callbacks for the session.
1903
2342
  */
1904
- constructor(clientConfig, execConfig, events) {
2343
+ constructor(clientConfig2, execConfig, events) {
1905
2344
  this.clientConfig = {
1906
- heartbeatIntervalMs: clientConfig.heartbeatIntervalMs ?? 5e3,
1907
- sendHeartbeat: clientConfig.sendHeartbeat ?? true,
1908
- url: clientConfig.url
2345
+ heartbeatIntervalMs: clientConfig2.heartbeatIntervalMs ?? 5e3,
2346
+ sendHeartbeat: clientConfig2.sendHeartbeat ?? true,
2347
+ url: clientConfig2.url
1909
2348
  };
1910
2349
  this.execConfig = {
1911
2350
  allocateTty: execConfig?.allocateTty ?? true,
@@ -2145,7 +2584,848 @@ var WebTTY = class {
2145
2584
  }
2146
2585
  }
2147
2586
  };
2587
+
2588
+ // src/execution.ts
2589
+ var Deferred = class {
2590
+ onReject = () => {
2591
+ };
2592
+ onResolve = () => {
2593
+ };
2594
+ promise;
2595
+ constructor() {
2596
+ this.promise = new Promise((resolve, reject) => {
2597
+ this.onResolve = resolve;
2598
+ this.onReject = reject;
2599
+ });
2600
+ this.promise.catch(() => void 0);
2601
+ }
2602
+ reject(error) {
2603
+ this.onReject(error);
2604
+ }
2605
+ resolve(value) {
2606
+ this.onResolve(value);
2607
+ }
2608
+ };
2609
+ var ReplayStreamSubscriber = class {
2610
+ controller = null;
2611
+ bind(controller) {
2612
+ this.controller = controller;
2613
+ }
2614
+ close() {
2615
+ this.controller?.close();
2616
+ }
2617
+ enqueue(value) {
2618
+ this.controller?.enqueue(value);
2619
+ }
2620
+ error(error) {
2621
+ this.controller?.error(error);
2622
+ }
2623
+ };
2624
+ var ReplayStreamChannel = class {
2625
+ completion = new Deferred();
2626
+ closed = false;
2627
+ failure = null;
2628
+ subscribers = [];
2629
+ values = [];
2630
+ append(value) {
2631
+ if (this.closed || this.failure) return;
2632
+ this.values = [...this.values, value];
2633
+ this.subscribers.forEach((subscriber) => subscriber.enqueue(value));
2634
+ }
2635
+ close() {
2636
+ if (this.closed || this.failure) return;
2637
+ this.closed = true;
2638
+ this.subscribers.forEach((subscriber) => subscriber.close());
2639
+ this.subscribers = [];
2640
+ this.completion.resolve();
2641
+ }
2642
+ error(error) {
2643
+ if (this.closed || this.failure) return;
2644
+ this.failure = error;
2645
+ this.subscribers.forEach((subscriber) => subscriber.error(error));
2646
+ this.subscribers = [];
2647
+ this.completion.reject(error);
2648
+ }
2649
+ stream() {
2650
+ const subscriber = new ReplayStreamSubscriber();
2651
+ return new ReadableStream({
2652
+ cancel: () => this.unsubscribe(subscriber),
2653
+ start: (controller) => this.subscribe(subscriber, controller)
2654
+ });
2655
+ }
2656
+ async valuesAfterClose(options = {}) {
2657
+ await withSignal(this.completion.promise, options.signal);
2658
+ return this.values;
2659
+ }
2660
+ subscribe(subscriber, controller) {
2661
+ subscriber.bind(controller);
2662
+ this.values.forEach((value) => controller.enqueue(value));
2663
+ if (this.failure) {
2664
+ controller.error(this.failure);
2665
+ return;
2666
+ }
2667
+ if (this.closed) {
2668
+ controller.close();
2669
+ return;
2670
+ }
2671
+ this.subscribers = [...this.subscribers, subscriber];
2672
+ }
2673
+ unsubscribe(subscriber) {
2674
+ this.subscribers = this.subscribers.filter((entry) => entry !== subscriber);
2675
+ }
2676
+ };
2677
+ function concatBytes(chunks) {
2678
+ const output = new Uint8Array(
2679
+ chunks.reduce((total, chunk) => total + chunk.byteLength, 0)
2680
+ );
2681
+ chunks.reduce((offset, chunk) => {
2682
+ output.set(chunk, offset);
2683
+ return offset + chunk.byteLength;
2684
+ }, 0);
2685
+ return output;
2686
+ }
2687
+ function encodeInput(input) {
2688
+ return typeof input === "string" ? new TextEncoder().encode(input) : input;
2689
+ }
2690
+ function resolveInteractive(options) {
2691
+ if (options.input !== void 0 && options.interactive === false) {
2692
+ throw new Error("Command input requires an interactive WebTTY session.");
2693
+ }
2694
+ return options.input === void 0 ? options.interactive ?? false : true;
2695
+ }
2696
+ function cleanTrailingSlashes(value) {
2697
+ return value.replace(/\/+$/, "");
2698
+ }
2699
+ function normalizeEndpointPath(path) {
2700
+ const trimmed = path.trim();
2701
+ const absolute = trimmed === "" || trimmed === "." ? "/" : trimmed;
2702
+ return new URL(
2703
+ absolute.startsWith("/") ? absolute : `/${absolute}`,
2704
+ "http://rstream.local"
2705
+ ).pathname;
2706
+ }
2707
+ function executionPath(pathname, execPath) {
2708
+ const endpoint = normalizeEndpointPath(execPath ?? "/");
2709
+ const basePath = cleanTrailingSlashes(pathname);
2710
+ if (endpoint === "/") return basePath === "" ? "/" : basePath;
2711
+ if (basePath === "") return endpoint;
2712
+ if (basePath === "/") return endpoint;
2713
+ if (basePath === endpoint || basePath.startsWith(`${endpoint}/`))
2714
+ return basePath;
2715
+ return `${basePath}${endpoint}`;
2716
+ }
2717
+ function resolveWebTTYExecutionURL(input, execPath = "/") {
2718
+ const url = new URL(input.toString());
2719
+ if (url.protocol === "rstrm:") {
2720
+ throw new Error(
2721
+ "rstrm:// WebTTY execution URLs require the native rstream dialer."
2722
+ );
2723
+ }
2724
+ if (url.protocol === "http:") url.protocol = "ws:";
2725
+ if (url.protocol === "https:") url.protocol = "wss:";
2726
+ if (url.protocol !== "ws:" && url.protocol !== "wss:") {
2727
+ throw new Error(
2728
+ `Unsupported WebTTY execution URL scheme "${url.protocol}".`
2729
+ );
2730
+ }
2731
+ url.pathname = executionPath(url.pathname, execPath);
2732
+ url.hash = "";
2733
+ return url;
2734
+ }
2735
+ function executionConfig(options, interactive) {
2736
+ return {
2737
+ allocateTty: options.allocateTty ?? false,
2738
+ cmdArgs: options.cmdArgs,
2739
+ envVars: options.envVars,
2740
+ interactive,
2741
+ username: options.username,
2742
+ workdir: options.workdir
2743
+ };
2744
+ }
2745
+ function textFromByteArray(value) {
2746
+ return new TextDecoder().decode(value);
2747
+ }
2748
+ function textFromLogBytes(chunks) {
2749
+ return chunks.map((chunk) => new TextDecoder().decode(chunk.data)).join("");
2750
+ }
2751
+ function timeoutHandle(timeoutMs, callback) {
2752
+ return timeoutMs === void 0 ? null : setTimeout(callback, timeoutMs);
2753
+ }
2754
+ function signalError(signal) {
2755
+ const reason = signal.reason;
2756
+ return reason instanceof Error ? reason : new Error(reason === void 0 ? "Operation aborted." : String(reason));
2757
+ }
2758
+ function signalPromise(signal) {
2759
+ return new Promise((_, reject) => {
2760
+ signal.addEventListener("abort", () => reject(signalError(signal)), {
2761
+ once: true
2762
+ });
2763
+ });
2764
+ }
2765
+ function withSignal(promise, signal) {
2766
+ if (signal === void 0) return promise;
2767
+ if (signal.aborted) return Promise.reject(signalError(signal));
2768
+ return Promise.race([promise, signalPromise(signal)]);
2769
+ }
2770
+ function stdinStream(command) {
2771
+ return new WritableStream({
2772
+ close: () => command.closeStdin(),
2773
+ write: (chunk) => command.writeStdin(chunk)
2774
+ });
2775
+ }
2776
+ function abortCleanup(signal, callback) {
2777
+ if (signal === void 0) return () => void 0;
2778
+ if (signal.aborted) {
2779
+ callback();
2780
+ return () => void 0;
2781
+ }
2782
+ const listener = () => callback();
2783
+ signal.addEventListener("abort", listener, { once: true });
2784
+ return () => signal.removeEventListener("abort", listener);
2785
+ }
2786
+ async function resolveURL(url) {
2787
+ return typeof url === "function" ? await url() : url;
2788
+ }
2789
+ function clientConfig(config, url, execPath) {
2790
+ return {
2791
+ heartbeatIntervalMs: config.heartbeatIntervalMs,
2792
+ sendHeartbeat: config.sendHeartbeat,
2793
+ url: execPath === void 0 ? url : resolveWebTTYExecutionURL(url, execPath)
2794
+ };
2795
+ }
2796
+ function executionClientConfig(client, execPath) {
2797
+ return execPath === void 0 ? client : { ...client, url: resolveWebTTYExecutionURL(client.url, execPath) };
2798
+ }
2799
+ async function* streamValues(stream) {
2800
+ const reader = stream.getReader();
2801
+ try {
2802
+ for (; ; ) {
2803
+ const result = await reader.read();
2804
+ if (result.done) return;
2805
+ yield result.value;
2806
+ }
2807
+ } finally {
2808
+ reader.releaseLock();
2809
+ }
2810
+ }
2811
+ function successStatus(exitCode) {
2812
+ return { exitCode, success: exitCode === 0 };
2813
+ }
2814
+ function envEntry(key, value) {
2815
+ return value === void 0 ? null : { key, value };
2816
+ }
2817
+ function presentEnvEntries(entries) {
2818
+ return entries.filter(
2819
+ (entry) => entry !== null
2820
+ );
2821
+ }
2822
+ function envVarsFromRecord(env) {
2823
+ return env === void 0 ? void 0 : presentEnvEntries(
2824
+ Object.entries(env).map(([key, value]) => envEntry(key, value))
2825
+ );
2826
+ }
2827
+ function commandExecutionOptions(command, args, options) {
2828
+ return {
2829
+ allocateTty: options.allocateTty,
2830
+ cmdArgs: [command, ...args],
2831
+ envVars: envVarsFromRecord(options.env),
2832
+ execPath: options.execPath,
2833
+ input: options.stdin,
2834
+ interactive: options.interactive,
2835
+ signal: options.signal,
2836
+ timeoutMs: options.timeoutMs,
2837
+ username: options.username,
2838
+ workdir: options.cwd
2839
+ };
2840
+ }
2841
+ var WebTTYCommand = class {
2842
+ abort;
2843
+ connected = new Deferred();
2844
+ completion = new Deferred();
2845
+ logsChannel = new ReplayStreamChannel();
2846
+ stderrChannel = new ReplayStreamChannel();
2847
+ stdoutChannel = new ReplayStreamChannel();
2848
+ timer;
2849
+ webtty;
2850
+ settled = false;
2851
+ exitCode = null;
2852
+ stdin;
2853
+ constructor(client, options) {
2854
+ const interactive = resolveInteractive(options);
2855
+ this.webtty = new WebTTY(
2856
+ executionClientConfig(client, options.execPath),
2857
+ executionConfig(options, interactive),
2858
+ {
2859
+ onComplete: (exitCode) => this.complete(exitCode),
2860
+ onConnect: () => this.connect(options.input),
2861
+ onError: (message) => this.fail(new Error(message)),
2862
+ onStderr: (chunk) => this.append("stderr", chunk),
2863
+ onStderrEos: () => this.stderrChannel.close(),
2864
+ onStdout: (chunk) => this.append("stdout", chunk),
2865
+ onStdoutEos: () => this.stdoutChannel.close()
2866
+ }
2867
+ );
2868
+ this.stdin = interactive ? stdinStream(this) : void 0;
2869
+ this.abort = abortCleanup(options.signal, () => {
2870
+ this.fail(new Error("WebTTY command was aborted."));
2871
+ });
2872
+ this.timer = timeoutHandle(options.timeoutMs, () => {
2873
+ this.fail(new Error("WebTTY command timed out."));
2874
+ });
2875
+ this.webtty.connect();
2876
+ }
2877
+ async closeStdin() {
2878
+ await this.connected.promise;
2879
+ this.webtty.closeStdin();
2880
+ }
2881
+ disconnect() {
2882
+ this.webtty.disconnect();
2883
+ }
2884
+ async kill() {
2885
+ this.disconnect();
2886
+ await this.completion.promise.catch(() => void 0);
2887
+ }
2888
+ async *logBytes() {
2889
+ yield* streamValues(this.logsChannel.stream());
2890
+ }
2891
+ async *logs() {
2892
+ for await (const entry of this.logBytes()) {
2893
+ yield {
2894
+ data: new TextDecoder().decode(entry.data),
2895
+ stream: entry.stream
2896
+ };
2897
+ }
2898
+ }
2899
+ output(stream = "both", options = {}) {
2900
+ if (stream === "stdout") return this.stdout(options);
2901
+ if (stream === "stderr") return this.stderr(options);
2902
+ return this.logsChannel.valuesAfterClose(options).then((chunks) => textFromLogBytes(chunks));
2903
+ }
2904
+ stderr(options = {}) {
2905
+ return this.stderrBytes(options).then(textFromByteArray);
2906
+ }
2907
+ stderrBytes(options = {}) {
2908
+ return this.stderrChannel.valuesAfterClose(options).then((chunks) => concatBytes(chunks));
2909
+ }
2910
+ stderrStream() {
2911
+ return this.stderrChannel.stream();
2912
+ }
2913
+ stdout(options = {}) {
2914
+ return this.stdoutBytes(options).then(textFromByteArray);
2915
+ }
2916
+ stdoutBytes(options = {}) {
2917
+ return this.stdoutChannel.valuesAfterClose(options).then((chunks) => concatBytes(chunks));
2918
+ }
2919
+ stdoutStream() {
2920
+ return this.stdoutChannel.stream();
2921
+ }
2922
+ async wait(options = {}) {
2923
+ return await withSignal(this.completion.promise, options.signal);
2924
+ }
2925
+ async terminate() {
2926
+ await this.kill();
2927
+ }
2928
+ async writeStdin(input) {
2929
+ await this.connected.promise;
2930
+ this.webtty.writeStdin(encodeInput(input));
2931
+ }
2932
+ append(stream, chunk) {
2933
+ if (stream === "stdout") this.stdoutChannel.append(chunk);
2934
+ if (stream === "stderr") this.stderrChannel.append(chunk);
2935
+ this.logsChannel.append({ data: chunk, stream });
2936
+ }
2937
+ clearTimer() {
2938
+ if (this.timer) clearTimeout(this.timer);
2939
+ }
2940
+ complete(exitCode) {
2941
+ if (this.settled) return;
2942
+ this.settled = true;
2943
+ this.exitCode = exitCode;
2944
+ this.abort();
2945
+ this.clearTimer();
2946
+ this.stdoutChannel.close();
2947
+ this.stderrChannel.close();
2948
+ this.logsChannel.close();
2949
+ this.completion.resolve(successStatus(exitCode));
2950
+ }
2951
+ connect(input) {
2952
+ this.connected.resolve();
2953
+ if (input === void 0) return;
2954
+ this.webtty.writeStdin(encodeInput(input));
2955
+ this.webtty.closeStdin();
2956
+ }
2957
+ fail(error) {
2958
+ if (this.settled) return;
2959
+ this.settled = true;
2960
+ this.abort();
2961
+ this.clearTimer();
2962
+ this.stdoutChannel.error(error);
2963
+ this.stderrChannel.error(error);
2964
+ this.logsChannel.error(error);
2965
+ this.connected.reject(error);
2966
+ this.completion.reject(error);
2967
+ this.webtty.disconnect();
2968
+ }
2969
+ };
2970
+ function openWebTTYCommand(client, options = {}) {
2971
+ return new WebTTYCommand(client, options);
2972
+ }
2973
+ async function runWebTTYCommand(client, command, args = [], options = {}) {
2974
+ return await executeWebTTYCommand(
2975
+ client,
2976
+ commandExecutionOptions(command, args, options)
2977
+ );
2978
+ }
2979
+ async function executeWebTTYCommand(client, options = {}) {
2980
+ const command = openWebTTYCommand(client, options);
2981
+ const [stdout, stderr, status] = await Promise.all([
2982
+ command.stdout(),
2983
+ command.stderr(),
2984
+ command.wait()
2985
+ ]);
2986
+ return { exitCode: status.exitCode, stderr, stdout, success: status.success };
2987
+ }
2988
+ var WebTTYRemoteExecutor = class {
2989
+ config;
2990
+ constructor(config) {
2991
+ this.config = config;
2992
+ }
2993
+ async execute(options = {}) {
2994
+ const execPath = options.execPath ?? this.config.execPath;
2995
+ return await executeWebTTYCommand(
2996
+ clientConfig(this.config, await resolveURL(this.config.url), execPath),
2997
+ { ...options, execPath: void 0 }
2998
+ );
2999
+ }
3000
+ async open(options = {}) {
3001
+ const execPath = options.execPath ?? this.config.execPath;
3002
+ return openWebTTYCommand(
3003
+ clientConfig(this.config, await resolveURL(this.config.url), execPath),
3004
+ { ...options, execPath: void 0 }
3005
+ );
3006
+ }
3007
+ async openCommand(command, args = [], options = {}) {
3008
+ const execPath = options.execPath ?? this.config.execPath;
3009
+ return openWebTTYCommand(
3010
+ clientConfig(this.config, await resolveURL(this.config.url), execPath),
3011
+ commandExecutionOptions(command, args, {
3012
+ ...options,
3013
+ execPath: void 0
3014
+ })
3015
+ );
3016
+ }
3017
+ async runCommand(command, args = [], options = {}) {
3018
+ const execPath = options.execPath ?? this.config.execPath;
3019
+ return await runWebTTYCommand(
3020
+ clientConfig(this.config, await resolveURL(this.config.url), execPath),
3021
+ command,
3022
+ args,
3023
+ { ...options, execPath: void 0 }
3024
+ );
3025
+ }
3026
+ };
3027
+
3028
+ // src/filesystem.ts
3029
+ var WebTTYFileSystemError = class extends Error {
3030
+ operation;
3031
+ status;
3032
+ constructor(operation, status, message) {
3033
+ super(`${operation} failed with status ${status}: ${message}`);
3034
+ this.name = "WebTTYFileSystemError";
3035
+ this.operation = operation;
3036
+ this.status = status;
3037
+ }
3038
+ };
3039
+ var webDAVPropfindBody = '<?xml version="1.0" encoding="utf-8"?><propfind xmlns="DAV:"><prop><resourcetype/><getcontentlength/><getlastmodified/></prop></propfind>';
3040
+ function cleanTrailingSlashes2(value) {
3041
+ return value.replace(/\/+$/, "");
3042
+ }
3043
+ function normalizeRemotePath(remotePath) {
3044
+ const trimmed = remotePath.trim();
3045
+ const absolute = trimmed === "" || trimmed === "." ? "/" : trimmed;
3046
+ return new URL(
3047
+ absolute.startsWith("/") ? absolute : `/${absolute}`,
3048
+ "http://rstream.local"
3049
+ ).pathname;
3050
+ }
3051
+ function comparableRemotePath(remotePath) {
3052
+ const normalized = cleanTrailingSlashes2(normalizeRemotePath(remotePath));
3053
+ return normalized === "" ? "/" : normalized;
3054
+ }
3055
+ function sidecarPath(fsPath) {
3056
+ return normalizeRemotePath(fsPath ?? "/fs");
3057
+ }
3058
+ function filesystemBasePath(pathname, fsPath) {
3059
+ const sidecar = sidecarPath(fsPath);
3060
+ const basePath = cleanTrailingSlashes2(pathname);
3061
+ if (basePath === "") return sidecar;
3062
+ if (basePath === "/") return sidecar;
3063
+ if (basePath === sidecar || basePath.startsWith(`${sidecar}/`))
3064
+ return basePath;
3065
+ return `${basePath}${sidecar}`;
3066
+ }
3067
+ function filesystemPath(pathname, remotePath, fsPath) {
3068
+ const basePath = filesystemBasePath(pathname, fsPath);
3069
+ const normalized = normalizeRemotePath(remotePath);
3070
+ return normalized === "/" ? basePath : `${cleanTrailingSlashes2(basePath)}${normalized}`;
3071
+ }
3072
+ function resolveWebTTYFileSystemURL(input, remotePath = "/", fsPath) {
3073
+ const url = new URL(input.toString());
3074
+ if (url.protocol === "rstrm:") {
3075
+ throw new Error(
3076
+ "rstrm:// WebTTY filesystem URLs require the native rstream dialer."
3077
+ );
3078
+ }
3079
+ if (url.protocol === "ws:") url.protocol = "http:";
3080
+ if (url.protocol === "wss:") url.protocol = "https:";
3081
+ if (url.protocol !== "http:" && url.protocol !== "https:") {
3082
+ throw new Error(
3083
+ `Unsupported WebTTY filesystem URL scheme "${url.protocol}".`
3084
+ );
3085
+ }
3086
+ url.pathname = filesystemPath(url.pathname, remotePath, fsPath);
3087
+ url.hash = "";
3088
+ return url;
3089
+ }
3090
+ function responseAllowed(response, expectedStatuses) {
3091
+ return expectedStatuses.includes(response.status);
3092
+ }
3093
+ async function responseErrorMessage(response) {
3094
+ const text = (await response.text()).trim().slice(0, 4096);
3095
+ return text === "" ? response.statusText : text;
3096
+ }
3097
+ async function requireResponseStatus(response, expectedStatuses, operation) {
3098
+ if (responseAllowed(response, expectedStatuses)) return response;
3099
+ throw new WebTTYFileSystemError(
3100
+ operation,
3101
+ response.status,
3102
+ await responseErrorMessage(response)
3103
+ );
3104
+ }
3105
+ function requireResponseBody(response, operation) {
3106
+ if (response.body) return response.body;
3107
+ throw new Error(
3108
+ `${operation} failed because the response body is unavailable.`
3109
+ );
3110
+ }
3111
+ function resolveFetch(config) {
3112
+ if (config.fetch) return config.fetch;
3113
+ if (typeof fetch === "undefined") {
3114
+ throw new Error("fetch is unavailable in this runtime.");
3115
+ }
3116
+ return fetch;
3117
+ }
3118
+ function applyHeaders(target, source) {
3119
+ const sourceHeaders = new Headers(source);
3120
+ sourceHeaders.forEach((value, key) => target.set(key, value));
3121
+ return target;
3122
+ }
3123
+ function requestHeaders(config, headers) {
3124
+ const result = applyHeaders(new Headers(config.headers), headers);
3125
+ if (config.authToken && config.authToken.trim() !== "") {
3126
+ result.set("Authorization", `Bearer ${config.authToken.trim()}`);
3127
+ }
3128
+ return result;
3129
+ }
3130
+ function contentHeaders(contentType) {
3131
+ return contentType === void 0 ? void 0 : { "Content-Type": contentType };
3132
+ }
3133
+ function deleteStatuses(force) {
3134
+ return force ? [200, 204, 404] : [200, 204];
3135
+ }
3136
+ function isNotFound(error) {
3137
+ return error instanceof WebTTYFileSystemError && error.status === 404;
3138
+ }
3139
+ function pathBaseName(path) {
3140
+ const normalized = normalizeRemotePath(path);
3141
+ const cleaned = cleanTrailingSlashes2(normalized);
3142
+ return cleaned.slice(cleaned.lastIndexOf("/") + 1);
3143
+ }
3144
+ function parentPath(path) {
3145
+ const normalized = cleanTrailingSlashes2(normalizeRemotePath(path));
3146
+ const index = normalized.lastIndexOf("/");
3147
+ if (index <= 0) return "/";
3148
+ return normalized.slice(0, index);
3149
+ }
3150
+ function readFileEncoding(options) {
3151
+ if (typeof options === "string") return options;
3152
+ return options?.encoding === void 0 ? null : options.encoding;
3153
+ }
3154
+ function readFileSignal(options) {
3155
+ return typeof options === "string" ? void 0 : options?.signal;
3156
+ }
3157
+ function textContentHeaders(contentType, data) {
3158
+ if (contentType !== void 0) return { "Content-Type": contentType };
3159
+ return typeof data === "string" ? { "Content-Type": "text/plain; charset=utf-8" } : void 0;
3160
+ }
3161
+ function bodyRequiresDuplex(body) {
3162
+ return typeof ReadableStream !== "undefined" && body instanceof ReadableStream;
3163
+ }
3164
+ function requestInit(config, method, options) {
3165
+ return {
3166
+ body: options.body,
3167
+ duplex: bodyRequiresDuplex(options.body) ? "half" : void 0,
3168
+ headers: requestHeaders(config, options.headers),
3169
+ method,
3170
+ signal: options.signal
3171
+ };
3172
+ }
3173
+ async function resolveURL2(url) {
3174
+ return typeof url === "function" ? await url() : url;
3175
+ }
3176
+ function elementBodies(xml, name) {
3177
+ return Array.from(
3178
+ xml.matchAll(
3179
+ new RegExp(
3180
+ `<[^>]*:?${name}\\b[^>]*>([\\s\\S]*?)<\\/[^>]*:?${name}>`,
3181
+ "gi"
3182
+ )
3183
+ ),
3184
+ (match) => match[1] ?? ""
3185
+ );
3186
+ }
3187
+ function hasElement(xml, name) {
3188
+ return new RegExp(`<[^>]*:?${name}(\\s|/|>)`, "i").test(xml);
3189
+ }
3190
+ function stripTags(xml) {
3191
+ return xml.replace(/<[^>]*>/g, "");
3192
+ }
3193
+ function decodeNumericEntity(value) {
3194
+ const parsed = value.startsWith("&#x") ? Number.parseInt(value.slice(3, -1), 16) : Number.parseInt(value.slice(2, -1), 10);
3195
+ return Number.isFinite(parsed) ? String.fromCodePoint(parsed) : value;
3196
+ }
3197
+ function decodeXmlText(value) {
3198
+ return value.replace(/&#x[0-9a-f]+;|&#\d+;/gi, decodeNumericEntity).replace(/&apos;/g, "'").replace(/&quot;/g, '"').replace(/&gt;/g, ">").replace(/&lt;/g, "<").replace(/&amp;/g, "&");
3199
+ }
3200
+ function elementText(xml, name) {
3201
+ return decodeXmlText(stripTags(elementBodies(xml, name)[0] ?? "")).trim();
3202
+ }
3203
+ function okPropstat(response) {
3204
+ return elementBodies(response, "propstat").find(
3205
+ (propstat) => elementText(propstat, "status").includes(" 200 ")
3206
+ ) ?? "";
3207
+ }
3208
+ function safeDecodePath(path) {
3209
+ try {
3210
+ return decodeURIComponent(path);
3211
+ } catch {
3212
+ return path;
3213
+ }
3214
+ }
3215
+ function hrefPath(href) {
3216
+ return safeDecodePath(new URL(href, "http://rstream.local").pathname);
3217
+ }
3218
+ function displayPath(href, fsPath) {
3219
+ const value = hrefPath(href);
3220
+ const sidecar = cleanTrailingSlashes2(sidecarPath(fsPath));
3221
+ const withoutFS = value === sidecar ? "/" : value.startsWith(`${sidecar}/`) ? value.slice(sidecar.length) : value;
3222
+ return withoutFS === "" ? "/" : withoutFS;
3223
+ }
3224
+ function itemSize(value) {
3225
+ const parsed = Number.parseInt(value, 10);
3226
+ return Number.isFinite(parsed) ? parsed : void 0;
3227
+ }
3228
+ function itemFromResponse(response, fsPath) {
3229
+ const propstat = okPropstat(response);
3230
+ const path = displayPath(elementText(response, "href"), fsPath);
3231
+ if (propstat === "" || path === "") return null;
3232
+ return {
3233
+ kind: hasElement(
3234
+ elementBodies(propstat, "resourcetype")[0] ?? "",
3235
+ "collection"
3236
+ ) ? "directory" : "file",
3237
+ modified: elementText(propstat, "getlastmodified") || void 0,
3238
+ path,
3239
+ size: itemSize(elementText(propstat, "getcontentlength"))
3240
+ };
3241
+ }
3242
+ function presentItems(items) {
3243
+ return items.filter((item) => item !== null);
3244
+ }
3245
+ function parseWebDAVMultiStatus(xml, fsPath = "/fs") {
3246
+ return presentItems(
3247
+ elementBodies(xml, "response").map(
3248
+ (response) => itemFromResponse(response, fsPath)
3249
+ )
3250
+ );
3251
+ }
3252
+ var WebTTYFileSystem = class {
3253
+ config;
3254
+ constructor(config) {
3255
+ this.config = config;
3256
+ }
3257
+ async list(path = "/", options = {}) {
3258
+ const response = await this.request("PROPFIND", path, {
3259
+ body: webDAVPropfindBody,
3260
+ expectedStatuses: [207],
3261
+ headers: { "Content-Type": "application/xml; charset=utf-8", Depth: "1" },
3262
+ operation: "WebTTY filesystem list",
3263
+ signal: options.signal
3264
+ });
3265
+ return parseWebDAVMultiStatus(
3266
+ await response.text(),
3267
+ sidecarPath(this.config.fsPath)
3268
+ );
3269
+ }
3270
+ async readBytes(path, options = {}) {
3271
+ const response = await this.request("GET", path, {
3272
+ expectedStatuses: [200],
3273
+ operation: "WebTTY filesystem read",
3274
+ signal: options.signal
3275
+ });
3276
+ return new Uint8Array(await response.arrayBuffer());
3277
+ }
3278
+ async readFile(path, options) {
3279
+ const bytes = await this.readBytes(path, {
3280
+ signal: readFileSignal(options)
3281
+ });
3282
+ const encoding = readFileEncoding(options);
3283
+ return encoding === null ? bytes : new TextDecoder(encoding).decode(bytes);
3284
+ }
3285
+ async readText(path, options = {}) {
3286
+ return new TextDecoder().decode(await this.readBytes(path, options));
3287
+ }
3288
+ async readStream(path, options = {}) {
3289
+ return requireResponseBody(
3290
+ await this.request("GET", path, {
3291
+ expectedStatuses: [200],
3292
+ operation: "WebTTY filesystem read",
3293
+ signal: options.signal
3294
+ }),
3295
+ "WebTTY filesystem read"
3296
+ );
3297
+ }
3298
+ async writeFile(path, data, options = {}) {
3299
+ await this.request("PUT", path, {
3300
+ body: data,
3301
+ expectedStatuses: [200, 201, 204],
3302
+ headers: textContentHeaders(options.contentType, data),
3303
+ operation: "WebTTY filesystem write",
3304
+ signal: options.signal
3305
+ });
3306
+ }
3307
+ async writeBytes(path, data, options = {}) {
3308
+ await this.writeFile(path, data, options);
3309
+ }
3310
+ async writeStream(path, data, options = {}) {
3311
+ await this.request("PUT", path, {
3312
+ body: data,
3313
+ expectedStatuses: [200, 201, 204],
3314
+ headers: contentHeaders(options.contentType),
3315
+ operation: "WebTTY filesystem write",
3316
+ signal: options.signal
3317
+ });
3318
+ }
3319
+ async writeText(path, data, options = {}) {
3320
+ await this.writeFile(path, data, options);
3321
+ }
3322
+ async copyFile(sourcePath, targetPath, options = {}) {
3323
+ await this.request("COPY", sourcePath, {
3324
+ expectedStatuses: [200, 201, 204],
3325
+ headers: { Destination: (await this.resourceURL(targetPath)).toString() },
3326
+ operation: "WebTTY filesystem copy",
3327
+ signal: options.signal
3328
+ });
3329
+ }
3330
+ async createDirectory(path, options = {}) {
3331
+ await this.request("MKCOL", path, {
3332
+ expectedStatuses: [201, 405],
3333
+ operation: "WebTTY filesystem mkdir",
3334
+ signal: options.signal
3335
+ });
3336
+ }
3337
+ async exists(path, options = {}) {
3338
+ return await this.stat(path, options).then(() => true).catch((error) => {
3339
+ if (isNotFound(error)) return false;
3340
+ throw error;
3341
+ });
3342
+ }
3343
+ async mkdir(path, options = {}) {
3344
+ if (options.recursive) {
3345
+ await this.createDirectoryRecursive(path, options.signal);
3346
+ return normalizeRemotePath(path);
3347
+ }
3348
+ await this.createDirectory(path, options);
3349
+ return void 0;
3350
+ }
3351
+ async readdir(path = "/", options = {}) {
3352
+ const items = (await this.list(path, options)).filter(
3353
+ (item) => comparableRemotePath(item.path) !== comparableRemotePath(path)
3354
+ );
3355
+ return options.withFileTypes ? items : items.map((item) => pathBaseName(item.path));
3356
+ }
3357
+ async rename(oldPath, newPath, options = {}) {
3358
+ await this.request("MOVE", oldPath, {
3359
+ expectedStatuses: [200, 201, 204],
3360
+ headers: { Destination: (await this.resourceURL(newPath)).toString() },
3361
+ operation: "WebTTY filesystem rename",
3362
+ signal: options.signal
3363
+ });
3364
+ }
3365
+ async rm(path, options = {}) {
3366
+ void options.recursive;
3367
+ await this.request("DELETE", path, {
3368
+ expectedStatuses: deleteStatuses(options.force),
3369
+ operation: "WebTTY filesystem delete",
3370
+ signal: options.signal
3371
+ });
3372
+ }
3373
+ async stat(path, options = {}) {
3374
+ const response = await this.request("PROPFIND", path, {
3375
+ body: webDAVPropfindBody,
3376
+ expectedStatuses: [207],
3377
+ headers: { "Content-Type": "application/xml; charset=utf-8", Depth: "0" },
3378
+ operation: "WebTTY filesystem stat",
3379
+ signal: options.signal
3380
+ });
3381
+ const item = parseWebDAVMultiStatus(
3382
+ await response.text(),
3383
+ sidecarPath(this.config.fsPath)
3384
+ )[0];
3385
+ if (item) return item;
3386
+ throw new Error(`WebTTY filesystem stat did not return ${path}.`);
3387
+ }
3388
+ async delete(path, options = {}) {
3389
+ await this.rm(path, options);
3390
+ }
3391
+ async createDirectoryRecursive(path, signal) {
3392
+ const normalized = normalizeRemotePath(path);
3393
+ if (normalized === "/") return;
3394
+ const parent = parentPath(normalized);
3395
+ if (parent !== normalized) {
3396
+ await this.createDirectoryRecursive(parent, signal);
3397
+ }
3398
+ await this.createDirectory(normalized, { signal });
3399
+ }
3400
+ async resourceURL(path) {
3401
+ return resolveWebTTYFileSystemURL(
3402
+ await resolveURL2(this.config.url),
3403
+ path,
3404
+ this.config.fsPath
3405
+ );
3406
+ }
3407
+ async request(method, path, options) {
3408
+ return await requireResponseStatus(
3409
+ await resolveFetch(this.config)(
3410
+ await this.resourceURL(path),
3411
+ requestInit(this.config, method, options)
3412
+ ),
3413
+ options.expectedStatuses,
3414
+ options.operation
3415
+ );
3416
+ }
3417
+ };
2148
3418
  // Annotate the CommonJS export names for ESM import in node:
2149
3419
  0 && (module.exports = {
2150
- WebTTY
3420
+ WebTTY,
3421
+ WebTTYCommand,
3422
+ WebTTYFileSystem,
3423
+ WebTTYFileSystemError,
3424
+ WebTTYRemoteExecutor,
3425
+ executeWebTTYCommand,
3426
+ openWebTTYCommand,
3427
+ parseWebDAVMultiStatus,
3428
+ resolveWebTTYExecutionURL,
3429
+ resolveWebTTYFileSystemURL,
3430
+ runWebTTYCommand
2151
3431
  });