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