@camera.ui/rpc 1.0.3 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/externals/nats.js/core/src/authenticator.ts +159 -0
  2. package/externals/nats.js/core/src/bench.ts +426 -0
  3. package/externals/nats.js/core/src/codec.ts +28 -0
  4. package/externals/nats.js/core/src/core.ts +1219 -0
  5. package/externals/nats.js/core/src/databuffer.ts +129 -0
  6. package/externals/nats.js/core/src/denobuffer.ts +248 -0
  7. package/externals/nats.js/core/src/encoders.ts +53 -0
  8. package/externals/nats.js/core/src/errors.ts +300 -0
  9. package/externals/nats.js/core/src/headers.ts +315 -0
  10. package/externals/nats.js/core/src/heartbeats.ts +114 -0
  11. package/externals/nats.js/core/src/idleheartbeat_monitor.ts +140 -0
  12. package/externals/nats.js/core/src/internal_mod.ts +167 -0
  13. package/externals/nats.js/core/src/ipparser.ts +215 -0
  14. package/externals/nats.js/core/src/mod.ts +113 -0
  15. package/externals/nats.js/core/src/msg.ts +120 -0
  16. package/externals/nats.js/core/src/muxsubscription.ts +111 -0
  17. package/externals/nats.js/core/src/nats.ts +650 -0
  18. package/externals/nats.js/core/src/nkeys.ts +1 -0
  19. package/externals/nats.js/core/src/nuid.ts +16 -0
  20. package/externals/nats.js/core/src/options.ts +202 -0
  21. package/externals/nats.js/core/src/parser.ts +756 -0
  22. package/externals/nats.js/core/src/protocol.ts +1304 -0
  23. package/externals/nats.js/core/src/queued_iterator.ts +171 -0
  24. package/externals/nats.js/core/src/request.ts +177 -0
  25. package/externals/nats.js/core/src/semver.ts +165 -0
  26. package/externals/nats.js/core/src/servers.ts +424 -0
  27. package/externals/nats.js/core/src/transport.ts +117 -0
  28. package/externals/nats.js/core/src/types.ts +17 -0
  29. package/externals/nats.js/core/src/util.ts +367 -0
  30. package/externals/nats.js/core/src/version.ts +2 -0
  31. package/externals/nats.js/core/src/ws_transport.ts +391 -0
  32. package/package.json +2 -1
@@ -0,0 +1,756 @@
1
+ // deno-lint-ignore-file no-undef
2
+ /*
3
+ * Copyright 2020-2021 The NATS Authors
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { DenoBuffer } from "./denobuffer.ts";
17
+ import { TD } from "./encoders.ts";
18
+ import type { Dispatcher } from "./core.ts";
19
+
20
+ export const Kind = {
21
+ OK: 0,
22
+ ERR: 1,
23
+ MSG: 2,
24
+ INFO: 3,
25
+ PING: 4,
26
+ PONG: 5,
27
+ } as const;
28
+
29
+ export type Kind = typeof Kind[keyof typeof Kind];
30
+
31
+ export interface ParserEvent {
32
+ kind: Kind;
33
+ msg?: MsgArg;
34
+ data?: Uint8Array;
35
+ }
36
+
37
+ export function describe(e: ParserEvent): string {
38
+ let ks: string;
39
+ let data = "";
40
+
41
+ switch (e.kind) {
42
+ case Kind.MSG:
43
+ ks = "MSG";
44
+ break;
45
+ case Kind.OK:
46
+ ks = "OK";
47
+ break;
48
+ case Kind.ERR:
49
+ ks = "ERR";
50
+ data = TD.decode(e.data);
51
+ break;
52
+ case Kind.PING:
53
+ ks = "PING";
54
+ break;
55
+ case Kind.PONG:
56
+ ks = "PONG";
57
+ break;
58
+ case Kind.INFO:
59
+ ks = "INFO";
60
+ data = TD.decode(e.data);
61
+ }
62
+ return `${ks}: ${data}`;
63
+ }
64
+
65
+ export interface MsgArg {
66
+ subject: Uint8Array;
67
+ reply?: Uint8Array;
68
+ sid: number;
69
+ hdr: number;
70
+ size: number;
71
+ }
72
+
73
+ function newMsgArg(): MsgArg {
74
+ const ma = {} as MsgArg;
75
+ ma.sid = -1;
76
+ ma.hdr = -1;
77
+ ma.size = -1;
78
+
79
+ return ma;
80
+ }
81
+
82
+ const ASCII_0 = 48;
83
+ const ASCII_9 = 57;
84
+ const MAX_64MB = 64 * 1024 * 1024;
85
+
86
+ // This is an almost verbatim port of the Go NATS parser
87
+ // https://github.com/nats-io/nats.go/blob/master/parser.go
88
+ export class Parser {
89
+ dispatcher: Dispatcher<ParserEvent>;
90
+ state: State;
91
+ as: number;
92
+ drop: number;
93
+ hdr: number;
94
+ ma!: MsgArg;
95
+ argBuf?: DenoBuffer;
96
+ msgBuf?: DenoBuffer;
97
+
98
+ constructor(dispatcher: Dispatcher<ParserEvent>) {
99
+ this.dispatcher = dispatcher;
100
+ this.state = State.OP_START;
101
+ this.as = 0;
102
+ this.drop = 0;
103
+ this.hdr = 0;
104
+ }
105
+
106
+ parse(buf: Uint8Array): void {
107
+ let i: number;
108
+ for (i = 0; i < buf.length; i++) {
109
+ const b = buf[i];
110
+ switch (this.state) {
111
+ case State.OP_START:
112
+ switch (b) {
113
+ case cc.M:
114
+ case cc.m:
115
+ this.state = State.OP_M;
116
+ this.hdr = -1;
117
+ this.ma = newMsgArg();
118
+ break;
119
+ case cc.H:
120
+ case cc.h:
121
+ this.state = State.OP_H;
122
+ this.hdr = 0;
123
+ this.ma = newMsgArg();
124
+ break;
125
+ case cc.P:
126
+ case cc.p:
127
+ this.state = State.OP_P;
128
+ break;
129
+ case cc.PLUS:
130
+ this.state = State.OP_PLUS;
131
+ break;
132
+ case cc.MINUS:
133
+ this.state = State.OP_MINUS;
134
+ break;
135
+ case cc.I:
136
+ case cc.i:
137
+ this.state = State.OP_I;
138
+ break;
139
+ default:
140
+ throw this.fail(buf.subarray(i));
141
+ }
142
+ break;
143
+ case State.OP_H:
144
+ switch (b) {
145
+ case cc.M:
146
+ case cc.m:
147
+ this.state = State.OP_M;
148
+ break;
149
+ default:
150
+ throw this.fail(buf.subarray(i));
151
+ }
152
+ break;
153
+ case State.OP_M:
154
+ switch (b) {
155
+ case cc.S:
156
+ case cc.s:
157
+ this.state = State.OP_MS;
158
+ break;
159
+ default:
160
+ throw this.fail(buf.subarray(i));
161
+ }
162
+ break;
163
+ case State.OP_MS:
164
+ switch (b) {
165
+ case cc.G:
166
+ case cc.g:
167
+ this.state = State.OP_MSG;
168
+ break;
169
+ default:
170
+ throw this.fail(buf.subarray(i));
171
+ }
172
+ break;
173
+ case State.OP_MSG:
174
+ switch (b) {
175
+ case cc.SPACE:
176
+ case cc.TAB:
177
+ this.state = State.OP_MSG_SPC;
178
+ break;
179
+ default:
180
+ throw this.fail(buf.subarray(i));
181
+ }
182
+ break;
183
+ case State.OP_MSG_SPC:
184
+ switch (b) {
185
+ case cc.SPACE:
186
+ case cc.TAB:
187
+ continue;
188
+ default:
189
+ this.state = State.MSG_ARG;
190
+ this.as = i;
191
+ }
192
+ break;
193
+ case State.MSG_ARG:
194
+ switch (b) {
195
+ case cc.CR:
196
+ this.drop = 1;
197
+ break;
198
+ case cc.NL: {
199
+ const arg: Uint8Array = this.argBuf
200
+ ? this.argBuf.bytes()
201
+ : buf.subarray(this.as, i - this.drop);
202
+ this.processMsgArgs(arg);
203
+ this.drop = 0;
204
+ this.as = i + 1;
205
+ this.state = State.MSG_PAYLOAD;
206
+
207
+ // jump ahead with the index. If this overruns
208
+ // what is left we fall out and process a split buffer.
209
+ i = this.as + this.ma.size - 1;
210
+ break;
211
+ }
212
+ default:
213
+ if (this.argBuf) {
214
+ this.argBuf.writeByte(b);
215
+ }
216
+ }
217
+ break;
218
+ case State.MSG_PAYLOAD:
219
+ if (this.msgBuf) {
220
+ if (this.msgBuf.length >= this.ma.size) {
221
+ const data = this.msgBuf.bytes({ copy: false });
222
+ this.dispatcher.push(
223
+ { kind: Kind.MSG, msg: this.ma, data: data },
224
+ );
225
+ this.argBuf = undefined;
226
+ this.msgBuf = undefined;
227
+ this.state = State.MSG_END;
228
+ } else {
229
+ let toCopy = this.ma.size - this.msgBuf.length;
230
+ const avail = buf.length - i;
231
+
232
+ if (avail < toCopy) {
233
+ toCopy = avail;
234
+ }
235
+
236
+ if (toCopy > 0) {
237
+ this.msgBuf.write(buf.subarray(i, i + toCopy));
238
+ i = (i + toCopy) - 1;
239
+ } else {
240
+ this.msgBuf.writeByte(b);
241
+ }
242
+ }
243
+ } else if (i - this.as >= this.ma.size) {
244
+ this.dispatcher.push(
245
+ { kind: Kind.MSG, msg: this.ma, data: buf.subarray(this.as, i) },
246
+ );
247
+ this.argBuf = undefined;
248
+ this.msgBuf = undefined;
249
+ this.state = State.MSG_END;
250
+ }
251
+ break;
252
+ case State.MSG_END:
253
+ switch (b) {
254
+ case cc.NL:
255
+ this.drop = 0;
256
+ this.as = i + 1;
257
+ this.state = State.OP_START;
258
+ break;
259
+ default:
260
+ continue;
261
+ }
262
+ break;
263
+ case State.OP_PLUS:
264
+ switch (b) {
265
+ case cc.O:
266
+ case cc.o:
267
+ this.state = State.OP_PLUS_O;
268
+ break;
269
+ default:
270
+ throw this.fail(buf.subarray(i));
271
+ }
272
+ break;
273
+ case State.OP_PLUS_O:
274
+ switch (b) {
275
+ case cc.K:
276
+ case cc.k:
277
+ this.state = State.OP_PLUS_OK;
278
+ break;
279
+ default:
280
+ throw this.fail(buf.subarray(i));
281
+ }
282
+ break;
283
+ case State.OP_PLUS_OK:
284
+ switch (b) {
285
+ case cc.NL:
286
+ this.dispatcher.push({ kind: Kind.OK });
287
+ this.drop = 0;
288
+ this.state = State.OP_START;
289
+ break;
290
+ }
291
+ break;
292
+ case State.OP_MINUS:
293
+ switch (b) {
294
+ case cc.E:
295
+ case cc.e:
296
+ this.state = State.OP_MINUS_E;
297
+ break;
298
+ default:
299
+ throw this.fail(buf.subarray(i));
300
+ }
301
+ break;
302
+ case State.OP_MINUS_E:
303
+ switch (b) {
304
+ case cc.R:
305
+ case cc.r:
306
+ this.state = State.OP_MINUS_ER;
307
+ break;
308
+ default:
309
+ throw this.fail(buf.subarray(i));
310
+ }
311
+ break;
312
+ case State.OP_MINUS_ER:
313
+ switch (b) {
314
+ case cc.R:
315
+ case cc.r:
316
+ this.state = State.OP_MINUS_ERR;
317
+ break;
318
+ default:
319
+ throw this.fail(buf.subarray(i));
320
+ }
321
+ break;
322
+ case State.OP_MINUS_ERR:
323
+ switch (b) {
324
+ case cc.SPACE:
325
+ case cc.TAB:
326
+ this.state = State.OP_MINUS_ERR_SPC;
327
+ break;
328
+ default:
329
+ throw this.fail(buf.subarray(i));
330
+ }
331
+ break;
332
+ case State.OP_MINUS_ERR_SPC:
333
+ switch (b) {
334
+ case cc.SPACE:
335
+ case cc.TAB:
336
+ continue;
337
+ default:
338
+ this.state = State.MINUS_ERR_ARG;
339
+ this.as = i;
340
+ }
341
+ break;
342
+ case State.MINUS_ERR_ARG:
343
+ switch (b) {
344
+ case cc.CR:
345
+ this.drop = 1;
346
+ break;
347
+ case cc.NL: {
348
+ let arg: Uint8Array;
349
+ if (this.argBuf) {
350
+ arg = this.argBuf.bytes();
351
+ this.argBuf = undefined;
352
+ } else {
353
+ arg = buf.subarray(this.as, i - this.drop);
354
+ }
355
+ this.dispatcher.push({ kind: Kind.ERR, data: arg });
356
+ this.drop = 0;
357
+ this.as = i + 1;
358
+ this.state = State.OP_START;
359
+ break;
360
+ }
361
+ default:
362
+ if (this.argBuf) {
363
+ this.argBuf.write(Uint8Array.of(b));
364
+ }
365
+ }
366
+ break;
367
+ case State.OP_P:
368
+ switch (b) {
369
+ case cc.I:
370
+ case cc.i:
371
+ this.state = State.OP_PI;
372
+ break;
373
+ case cc.O:
374
+ case cc.o:
375
+ this.state = State.OP_PO;
376
+ break;
377
+ default:
378
+ throw this.fail(buf.subarray(i));
379
+ }
380
+ break;
381
+ case State.OP_PO:
382
+ switch (b) {
383
+ case cc.N:
384
+ case cc.n:
385
+ this.state = State.OP_PON;
386
+ break;
387
+ default:
388
+ throw this.fail(buf.subarray(i));
389
+ }
390
+ break;
391
+ case State.OP_PON:
392
+ switch (b) {
393
+ case cc.G:
394
+ case cc.g:
395
+ this.state = State.OP_PONG;
396
+ break;
397
+ default:
398
+ throw this.fail(buf.subarray(i));
399
+ }
400
+ break;
401
+ case State.OP_PONG:
402
+ switch (b) {
403
+ case cc.NL:
404
+ this.dispatcher.push({ kind: Kind.PONG });
405
+ this.drop = 0;
406
+ this.state = State.OP_START;
407
+ break;
408
+ }
409
+ break;
410
+ case State.OP_PI:
411
+ switch (b) {
412
+ case cc.N:
413
+ case cc.n:
414
+ this.state = State.OP_PIN;
415
+ break;
416
+ default:
417
+ throw this.fail(buf.subarray(i));
418
+ }
419
+ break;
420
+ case State.OP_PIN:
421
+ switch (b) {
422
+ case cc.G:
423
+ case cc.g:
424
+ this.state = State.OP_PING;
425
+ break;
426
+ default:
427
+ throw this.fail(buf.subarray(i));
428
+ }
429
+ break;
430
+ case State.OP_PING:
431
+ switch (b) {
432
+ case cc.NL:
433
+ this.dispatcher.push({ kind: Kind.PING });
434
+ this.drop = 0;
435
+ this.state = State.OP_START;
436
+ break;
437
+ }
438
+ break;
439
+ case State.OP_I:
440
+ switch (b) {
441
+ case cc.N:
442
+ case cc.n:
443
+ this.state = State.OP_IN;
444
+ break;
445
+ default:
446
+ throw this.fail(buf.subarray(i));
447
+ }
448
+ break;
449
+ case State.OP_IN:
450
+ switch (b) {
451
+ case cc.F:
452
+ case cc.f:
453
+ this.state = State.OP_INF;
454
+ break;
455
+ default:
456
+ throw this.fail(buf.subarray(i));
457
+ }
458
+ break;
459
+ case State.OP_INF:
460
+ switch (b) {
461
+ case cc.O:
462
+ case cc.o:
463
+ this.state = State.OP_INFO;
464
+ break;
465
+ default:
466
+ throw this.fail(buf.subarray(i));
467
+ }
468
+ break;
469
+ case State.OP_INFO:
470
+ switch (b) {
471
+ case cc.SPACE:
472
+ case cc.TAB:
473
+ this.state = State.OP_INFO_SPC;
474
+ break;
475
+ default:
476
+ throw this.fail(buf.subarray(i));
477
+ }
478
+ break;
479
+ case State.OP_INFO_SPC:
480
+ switch (b) {
481
+ case cc.SPACE:
482
+ case cc.TAB:
483
+ continue;
484
+ default:
485
+ this.state = State.INFO_ARG;
486
+ this.as = i;
487
+ }
488
+ break;
489
+ case State.INFO_ARG:
490
+ switch (b) {
491
+ case cc.CR:
492
+ this.drop = 1;
493
+ break;
494
+ case cc.NL: {
495
+ let arg: Uint8Array;
496
+ if (this.argBuf) {
497
+ arg = this.argBuf.bytes();
498
+ this.argBuf = undefined;
499
+ } else {
500
+ arg = buf.subarray(this.as, i - this.drop);
501
+ }
502
+ this.dispatcher.push({ kind: Kind.INFO, data: arg });
503
+ this.drop = 0;
504
+ this.as = i + 1;
505
+ this.state = State.OP_START;
506
+ break;
507
+ }
508
+ default:
509
+ if (this.argBuf) {
510
+ this.argBuf.writeByte(b);
511
+ }
512
+ }
513
+ break;
514
+ default:
515
+ throw this.fail(buf.subarray(i));
516
+ }
517
+ }
518
+
519
+ if (
520
+ (this.state === State.MSG_ARG || this.state === State.MINUS_ERR_ARG ||
521
+ this.state === State.INFO_ARG) && !this.argBuf
522
+ ) {
523
+ this.argBuf = new DenoBuffer(buf.subarray(this.as, i - this.drop));
524
+ }
525
+
526
+ if (this.state === State.MSG_PAYLOAD && !this.msgBuf) {
527
+ if (!this.argBuf) {
528
+ this.cloneMsgArg();
529
+ }
530
+ this.msgBuf = new DenoBuffer(buf.subarray(this.as));
531
+ }
532
+ }
533
+
534
+ cloneMsgArg() {
535
+ const s = this.ma.subject.length;
536
+ const r = this.ma.reply ? this.ma.reply.length : 0;
537
+ const buf = new Uint8Array(s + r);
538
+ buf.set(this.ma.subject);
539
+ if (this.ma.reply) {
540
+ buf.set(this.ma.reply, s);
541
+ }
542
+ this.argBuf = new DenoBuffer(buf);
543
+ this.ma.subject = buf.subarray(0, s);
544
+ if (this.ma.reply) {
545
+ this.ma.reply = buf.subarray(s);
546
+ }
547
+ }
548
+
549
+ processMsgArgs(arg: Uint8Array): void {
550
+ if (this.hdr >= 0) {
551
+ return this.processHeaderMsgArgs(arg);
552
+ }
553
+
554
+ const args: Uint8Array[] = [];
555
+ let start = -1;
556
+ for (let i = 0; i < arg.length; i++) {
557
+ const b = arg[i];
558
+ switch (b) {
559
+ case cc.SPACE:
560
+ case cc.TAB:
561
+ case cc.CR:
562
+ case cc.NL:
563
+ if (start >= 0) {
564
+ args.push(arg.subarray(start, i));
565
+ start = -1;
566
+ }
567
+ break;
568
+ default:
569
+ if (start < 0) {
570
+ start = i;
571
+ }
572
+ }
573
+ }
574
+ if (start >= 0) {
575
+ args.push(arg.subarray(start));
576
+ }
577
+
578
+ switch (args.length) {
579
+ case 3:
580
+ this.ma.subject = args[0];
581
+ this.ma.sid = this.protoParseInt(args[1]);
582
+ this.ma.reply = undefined;
583
+ this.ma.size = this.protoParseInt(args[2], MAX_64MB);
584
+ break;
585
+ case 4:
586
+ this.ma.subject = args[0];
587
+ this.ma.sid = this.protoParseInt(args[1]);
588
+ this.ma.reply = args[2];
589
+ this.ma.size = this.protoParseInt(args[3], MAX_64MB);
590
+ break;
591
+ default:
592
+ throw this.fail(arg, "processMsgArgs Parse Error");
593
+ }
594
+
595
+ if (this.ma.sid < 0) {
596
+ throw this.fail(arg, "processMsgArgs Bad or Missing Sid Error");
597
+ }
598
+ if (this.ma.size < 0) {
599
+ throw this.fail(arg, "processMsgArgs Bad or Missing Size Error");
600
+ }
601
+ }
602
+
603
+ fail(data: Uint8Array, label = ""): Error {
604
+ if (!label) {
605
+ label = `parse error [${this.state}]`;
606
+ } else {
607
+ label = `${label} [${this.state}]`;
608
+ }
609
+
610
+ return new Error(`${label}: ${TD.decode(data)}`);
611
+ }
612
+
613
+ processHeaderMsgArgs(arg: Uint8Array): void {
614
+ const args: Uint8Array[] = [];
615
+ let start = -1;
616
+ for (let i = 0; i < arg.length; i++) {
617
+ const b = arg[i];
618
+ switch (b) {
619
+ case cc.SPACE:
620
+ case cc.TAB:
621
+ case cc.CR:
622
+ case cc.NL:
623
+ if (start >= 0) {
624
+ args.push(arg.subarray(start, i));
625
+ start = -1;
626
+ }
627
+ break;
628
+ default:
629
+ if (start < 0) {
630
+ start = i;
631
+ }
632
+ }
633
+ }
634
+ if (start >= 0) {
635
+ args.push(arg.subarray(start));
636
+ }
637
+
638
+ switch (args.length) {
639
+ case 4:
640
+ this.ma.subject = args[0];
641
+ this.ma.sid = this.protoParseInt(args[1]);
642
+ this.ma.reply = undefined;
643
+ this.ma.hdr = this.protoParseInt(args[2], MAX_64MB);
644
+ this.ma.size = this.protoParseInt(args[3], MAX_64MB);
645
+ break;
646
+ case 5:
647
+ this.ma.subject = args[0];
648
+ this.ma.sid = this.protoParseInt(args[1]);
649
+ this.ma.reply = args[2];
650
+ this.ma.hdr = this.protoParseInt(args[3], MAX_64MB);
651
+ this.ma.size = this.protoParseInt(args[4], MAX_64MB);
652
+ break;
653
+ default:
654
+ throw this.fail(arg, "processHeaderMsgArgs Parse Error");
655
+ }
656
+
657
+ if (this.ma.sid < 0) {
658
+ throw this.fail(arg, "processHeaderMsgArgs Bad or Missing Sid Error");
659
+ }
660
+ if (this.ma.hdr < 0 || this.ma.hdr > this.ma.size) {
661
+ throw this.fail(
662
+ arg,
663
+ "processHeaderMsgArgs Bad or Missing Header Size Error",
664
+ );
665
+ }
666
+ if (this.ma.size < 0) {
667
+ throw this.fail(arg, "processHeaderMsgArgs Bad or Missing Size Error");
668
+ }
669
+ }
670
+
671
+ protoParseInt(a: Uint8Array, max?: number): number {
672
+ // max 999_999_999_999_999 - one digit below MAX_SAFE_INTEGER
673
+ if (a.length === 0 || a.length > 15) {
674
+ return -1;
675
+ }
676
+ let n = 0;
677
+ for (let i = 0; i < a.length; i++) {
678
+ if (a[i] < ASCII_0 || a[i] > ASCII_9) {
679
+ return -1;
680
+ }
681
+ n = n * 10 + (a[i] - ASCII_0);
682
+ }
683
+ return max !== undefined && n > max ? -1 : n;
684
+ }
685
+ }
686
+
687
+ export const State = {
688
+ OP_START: 0,
689
+ OP_PLUS: 1,
690
+ OP_PLUS_O: 2,
691
+ OP_PLUS_OK: 3,
692
+ OP_MINUS: 4,
693
+ OP_MINUS_E: 5,
694
+ OP_MINUS_ER: 6,
695
+ OP_MINUS_ERR: 7,
696
+ OP_MINUS_ERR_SPC: 8,
697
+ MINUS_ERR_ARG: 9,
698
+ OP_M: 10,
699
+ OP_MS: 11,
700
+ OP_MSG: 12,
701
+ OP_MSG_SPC: 13,
702
+ MSG_ARG: 14,
703
+ MSG_PAYLOAD: 15,
704
+ MSG_END: 16,
705
+ OP_H: 17,
706
+ OP_P: 18,
707
+ OP_PI: 19,
708
+ OP_PIN: 20,
709
+ OP_PING: 21,
710
+ OP_PO: 22,
711
+ OP_PON: 23,
712
+ OP_PONG: 24,
713
+ OP_I: 25,
714
+ OP_IN: 26,
715
+ OP_INF: 27,
716
+ OP_INFO: 28,
717
+ OP_INFO_SPC: 29,
718
+ INFO_ARG: 30,
719
+ } as const;
720
+
721
+ export type State = typeof State[keyof typeof State];
722
+
723
+ export const cc = {
724
+ CR: "\r".charCodeAt(0),
725
+ E: "E".charCodeAt(0),
726
+ e: "e".charCodeAt(0),
727
+ F: "F".charCodeAt(0),
728
+ f: "f".charCodeAt(0),
729
+ G: "G".charCodeAt(0),
730
+ g: "g".charCodeAt(0),
731
+ H: "H".charCodeAt(0),
732
+ h: "h".charCodeAt(0),
733
+ I: "I".charCodeAt(0),
734
+ i: "i".charCodeAt(0),
735
+ K: "K".charCodeAt(0),
736
+ k: "k".charCodeAt(0),
737
+ M: "M".charCodeAt(0),
738
+ m: "m".charCodeAt(0),
739
+ MINUS: "-".charCodeAt(0),
740
+ N: "N".charCodeAt(0),
741
+ n: "n".charCodeAt(0),
742
+ NL: "\n".charCodeAt(0),
743
+ O: "O".charCodeAt(0),
744
+ o: "o".charCodeAt(0),
745
+ P: "P".charCodeAt(0),
746
+ p: "p".charCodeAt(0),
747
+ PLUS: "+".charCodeAt(0),
748
+ R: "R".charCodeAt(0),
749
+ r: "r".charCodeAt(0),
750
+ S: "S".charCodeAt(0),
751
+ s: "s".charCodeAt(0),
752
+ SPACE: " ".charCodeAt(0),
753
+ TAB: "\t".charCodeAt(0),
754
+ } as const;
755
+
756
+ export type cc = typeof cc[keyof typeof cc];