@rivetkit/engine-runner-protocol 2.0.4-rc.1
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/LICENSE +203 -0
- package/dist/index.d.ts +662 -0
- package/dist/index.js +1667 -0
- package/package.json +36 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,1667 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import * as bare from "@rivetkit/bare-ts";
|
|
3
|
+
var DEFAULT_CONFIG = /* @__PURE__ */ bare.Config({});
|
|
4
|
+
function readId(bc) {
|
|
5
|
+
return bare.readString(bc);
|
|
6
|
+
}
|
|
7
|
+
function writeId(bc, x) {
|
|
8
|
+
bare.writeString(bc, x);
|
|
9
|
+
}
|
|
10
|
+
function readJson(bc) {
|
|
11
|
+
return bare.readString(bc);
|
|
12
|
+
}
|
|
13
|
+
function writeJson(bc, x) {
|
|
14
|
+
bare.writeString(bc, x);
|
|
15
|
+
}
|
|
16
|
+
function readGatewayId(bc) {
|
|
17
|
+
return bare.readFixedData(bc, 4);
|
|
18
|
+
}
|
|
19
|
+
function writeGatewayId(bc, x) {
|
|
20
|
+
assert(x.byteLength === 4);
|
|
21
|
+
bare.writeFixedData(bc, x);
|
|
22
|
+
}
|
|
23
|
+
function readRequestId(bc) {
|
|
24
|
+
return bare.readFixedData(bc, 4);
|
|
25
|
+
}
|
|
26
|
+
function writeRequestId(bc, x) {
|
|
27
|
+
assert(x.byteLength === 4);
|
|
28
|
+
bare.writeFixedData(bc, x);
|
|
29
|
+
}
|
|
30
|
+
function readMessageIndex(bc) {
|
|
31
|
+
return bare.readU16(bc);
|
|
32
|
+
}
|
|
33
|
+
function writeMessageIndex(bc, x) {
|
|
34
|
+
bare.writeU16(bc, x);
|
|
35
|
+
}
|
|
36
|
+
function readKvKey(bc) {
|
|
37
|
+
return bare.readData(bc);
|
|
38
|
+
}
|
|
39
|
+
function writeKvKey(bc, x) {
|
|
40
|
+
bare.writeData(bc, x);
|
|
41
|
+
}
|
|
42
|
+
function readKvValue(bc) {
|
|
43
|
+
return bare.readData(bc);
|
|
44
|
+
}
|
|
45
|
+
function writeKvValue(bc, x) {
|
|
46
|
+
bare.writeData(bc, x);
|
|
47
|
+
}
|
|
48
|
+
function readKvMetadata(bc) {
|
|
49
|
+
return {
|
|
50
|
+
version: bare.readData(bc),
|
|
51
|
+
updateTs: bare.readI64(bc)
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function writeKvMetadata(bc, x) {
|
|
55
|
+
bare.writeData(bc, x.version);
|
|
56
|
+
bare.writeI64(bc, x.updateTs);
|
|
57
|
+
}
|
|
58
|
+
function readKvListRangeQuery(bc) {
|
|
59
|
+
return {
|
|
60
|
+
start: readKvKey(bc),
|
|
61
|
+
end: readKvKey(bc),
|
|
62
|
+
exclusive: bare.readBool(bc)
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function writeKvListRangeQuery(bc, x) {
|
|
66
|
+
writeKvKey(bc, x.start);
|
|
67
|
+
writeKvKey(bc, x.end);
|
|
68
|
+
bare.writeBool(bc, x.exclusive);
|
|
69
|
+
}
|
|
70
|
+
function readKvListPrefixQuery(bc) {
|
|
71
|
+
return {
|
|
72
|
+
key: readKvKey(bc)
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function writeKvListPrefixQuery(bc, x) {
|
|
76
|
+
writeKvKey(bc, x.key);
|
|
77
|
+
}
|
|
78
|
+
function readKvListQuery(bc) {
|
|
79
|
+
const offset = bc.offset;
|
|
80
|
+
const tag = bare.readU8(bc);
|
|
81
|
+
switch (tag) {
|
|
82
|
+
case 0:
|
|
83
|
+
return { tag: "KvListAllQuery", val: null };
|
|
84
|
+
case 1:
|
|
85
|
+
return { tag: "KvListRangeQuery", val: readKvListRangeQuery(bc) };
|
|
86
|
+
case 2:
|
|
87
|
+
return { tag: "KvListPrefixQuery", val: readKvListPrefixQuery(bc) };
|
|
88
|
+
default: {
|
|
89
|
+
bc.offset = offset;
|
|
90
|
+
throw new bare.BareError(offset, "invalid tag");
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
function writeKvListQuery(bc, x) {
|
|
95
|
+
switch (x.tag) {
|
|
96
|
+
case "KvListAllQuery": {
|
|
97
|
+
bare.writeU8(bc, 0);
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
case "KvListRangeQuery": {
|
|
101
|
+
bare.writeU8(bc, 1);
|
|
102
|
+
writeKvListRangeQuery(bc, x.val);
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
case "KvListPrefixQuery": {
|
|
106
|
+
bare.writeU8(bc, 2);
|
|
107
|
+
writeKvListPrefixQuery(bc, x.val);
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
function read0(bc) {
|
|
113
|
+
const len = bare.readUintSafe(bc);
|
|
114
|
+
if (len === 0) {
|
|
115
|
+
return [];
|
|
116
|
+
}
|
|
117
|
+
const result = [readKvKey(bc)];
|
|
118
|
+
for (let i = 1; i < len; i++) {
|
|
119
|
+
result[i] = readKvKey(bc);
|
|
120
|
+
}
|
|
121
|
+
return result;
|
|
122
|
+
}
|
|
123
|
+
function write0(bc, x) {
|
|
124
|
+
bare.writeUintSafe(bc, x.length);
|
|
125
|
+
for (let i = 0; i < x.length; i++) {
|
|
126
|
+
writeKvKey(bc, x[i]);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
function readKvGetRequest(bc) {
|
|
130
|
+
return {
|
|
131
|
+
keys: read0(bc)
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
function writeKvGetRequest(bc, x) {
|
|
135
|
+
write0(bc, x.keys);
|
|
136
|
+
}
|
|
137
|
+
function read1(bc) {
|
|
138
|
+
return bare.readBool(bc) ? bare.readBool(bc) : null;
|
|
139
|
+
}
|
|
140
|
+
function write1(bc, x) {
|
|
141
|
+
bare.writeBool(bc, x != null);
|
|
142
|
+
if (x != null) {
|
|
143
|
+
bare.writeBool(bc, x);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
function read2(bc) {
|
|
147
|
+
return bare.readBool(bc) ? bare.readU64(bc) : null;
|
|
148
|
+
}
|
|
149
|
+
function write2(bc, x) {
|
|
150
|
+
bare.writeBool(bc, x != null);
|
|
151
|
+
if (x != null) {
|
|
152
|
+
bare.writeU64(bc, x);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
function readKvListRequest(bc) {
|
|
156
|
+
return {
|
|
157
|
+
query: readKvListQuery(bc),
|
|
158
|
+
reverse: read1(bc),
|
|
159
|
+
limit: read2(bc)
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
function writeKvListRequest(bc, x) {
|
|
163
|
+
writeKvListQuery(bc, x.query);
|
|
164
|
+
write1(bc, x.reverse);
|
|
165
|
+
write2(bc, x.limit);
|
|
166
|
+
}
|
|
167
|
+
function read3(bc) {
|
|
168
|
+
const len = bare.readUintSafe(bc);
|
|
169
|
+
if (len === 0) {
|
|
170
|
+
return [];
|
|
171
|
+
}
|
|
172
|
+
const result = [readKvValue(bc)];
|
|
173
|
+
for (let i = 1; i < len; i++) {
|
|
174
|
+
result[i] = readKvValue(bc);
|
|
175
|
+
}
|
|
176
|
+
return result;
|
|
177
|
+
}
|
|
178
|
+
function write3(bc, x) {
|
|
179
|
+
bare.writeUintSafe(bc, x.length);
|
|
180
|
+
for (let i = 0; i < x.length; i++) {
|
|
181
|
+
writeKvValue(bc, x[i]);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
function readKvPutRequest(bc) {
|
|
185
|
+
return {
|
|
186
|
+
keys: read0(bc),
|
|
187
|
+
values: read3(bc)
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
function writeKvPutRequest(bc, x) {
|
|
191
|
+
write0(bc, x.keys);
|
|
192
|
+
write3(bc, x.values);
|
|
193
|
+
}
|
|
194
|
+
function readKvDeleteRequest(bc) {
|
|
195
|
+
return {
|
|
196
|
+
keys: read0(bc)
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
function writeKvDeleteRequest(bc, x) {
|
|
200
|
+
write0(bc, x.keys);
|
|
201
|
+
}
|
|
202
|
+
function readKvErrorResponse(bc) {
|
|
203
|
+
return {
|
|
204
|
+
message: bare.readString(bc)
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
function writeKvErrorResponse(bc, x) {
|
|
208
|
+
bare.writeString(bc, x.message);
|
|
209
|
+
}
|
|
210
|
+
function read4(bc) {
|
|
211
|
+
const len = bare.readUintSafe(bc);
|
|
212
|
+
if (len === 0) {
|
|
213
|
+
return [];
|
|
214
|
+
}
|
|
215
|
+
const result = [readKvMetadata(bc)];
|
|
216
|
+
for (let i = 1; i < len; i++) {
|
|
217
|
+
result[i] = readKvMetadata(bc);
|
|
218
|
+
}
|
|
219
|
+
return result;
|
|
220
|
+
}
|
|
221
|
+
function write4(bc, x) {
|
|
222
|
+
bare.writeUintSafe(bc, x.length);
|
|
223
|
+
for (let i = 0; i < x.length; i++) {
|
|
224
|
+
writeKvMetadata(bc, x[i]);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
function readKvGetResponse(bc) {
|
|
228
|
+
return {
|
|
229
|
+
keys: read0(bc),
|
|
230
|
+
values: read3(bc),
|
|
231
|
+
metadata: read4(bc)
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
function writeKvGetResponse(bc, x) {
|
|
235
|
+
write0(bc, x.keys);
|
|
236
|
+
write3(bc, x.values);
|
|
237
|
+
write4(bc, x.metadata);
|
|
238
|
+
}
|
|
239
|
+
function readKvListResponse(bc) {
|
|
240
|
+
return {
|
|
241
|
+
keys: read0(bc),
|
|
242
|
+
values: read3(bc),
|
|
243
|
+
metadata: read4(bc)
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
function writeKvListResponse(bc, x) {
|
|
247
|
+
write0(bc, x.keys);
|
|
248
|
+
write3(bc, x.values);
|
|
249
|
+
write4(bc, x.metadata);
|
|
250
|
+
}
|
|
251
|
+
function readKvRequestData(bc) {
|
|
252
|
+
const offset = bc.offset;
|
|
253
|
+
const tag = bare.readU8(bc);
|
|
254
|
+
switch (tag) {
|
|
255
|
+
case 0:
|
|
256
|
+
return { tag: "KvGetRequest", val: readKvGetRequest(bc) };
|
|
257
|
+
case 1:
|
|
258
|
+
return { tag: "KvListRequest", val: readKvListRequest(bc) };
|
|
259
|
+
case 2:
|
|
260
|
+
return { tag: "KvPutRequest", val: readKvPutRequest(bc) };
|
|
261
|
+
case 3:
|
|
262
|
+
return { tag: "KvDeleteRequest", val: readKvDeleteRequest(bc) };
|
|
263
|
+
case 4:
|
|
264
|
+
return { tag: "KvDropRequest", val: null };
|
|
265
|
+
default: {
|
|
266
|
+
bc.offset = offset;
|
|
267
|
+
throw new bare.BareError(offset, "invalid tag");
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
function writeKvRequestData(bc, x) {
|
|
272
|
+
switch (x.tag) {
|
|
273
|
+
case "KvGetRequest": {
|
|
274
|
+
bare.writeU8(bc, 0);
|
|
275
|
+
writeKvGetRequest(bc, x.val);
|
|
276
|
+
break;
|
|
277
|
+
}
|
|
278
|
+
case "KvListRequest": {
|
|
279
|
+
bare.writeU8(bc, 1);
|
|
280
|
+
writeKvListRequest(bc, x.val);
|
|
281
|
+
break;
|
|
282
|
+
}
|
|
283
|
+
case "KvPutRequest": {
|
|
284
|
+
bare.writeU8(bc, 2);
|
|
285
|
+
writeKvPutRequest(bc, x.val);
|
|
286
|
+
break;
|
|
287
|
+
}
|
|
288
|
+
case "KvDeleteRequest": {
|
|
289
|
+
bare.writeU8(bc, 3);
|
|
290
|
+
writeKvDeleteRequest(bc, x.val);
|
|
291
|
+
break;
|
|
292
|
+
}
|
|
293
|
+
case "KvDropRequest": {
|
|
294
|
+
bare.writeU8(bc, 4);
|
|
295
|
+
break;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
function readKvResponseData(bc) {
|
|
300
|
+
const offset = bc.offset;
|
|
301
|
+
const tag = bare.readU8(bc);
|
|
302
|
+
switch (tag) {
|
|
303
|
+
case 0:
|
|
304
|
+
return { tag: "KvErrorResponse", val: readKvErrorResponse(bc) };
|
|
305
|
+
case 1:
|
|
306
|
+
return { tag: "KvGetResponse", val: readKvGetResponse(bc) };
|
|
307
|
+
case 2:
|
|
308
|
+
return { tag: "KvListResponse", val: readKvListResponse(bc) };
|
|
309
|
+
case 3:
|
|
310
|
+
return { tag: "KvPutResponse", val: null };
|
|
311
|
+
case 4:
|
|
312
|
+
return { tag: "KvDeleteResponse", val: null };
|
|
313
|
+
case 5:
|
|
314
|
+
return { tag: "KvDropResponse", val: null };
|
|
315
|
+
default: {
|
|
316
|
+
bc.offset = offset;
|
|
317
|
+
throw new bare.BareError(offset, "invalid tag");
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
function writeKvResponseData(bc, x) {
|
|
322
|
+
switch (x.tag) {
|
|
323
|
+
case "KvErrorResponse": {
|
|
324
|
+
bare.writeU8(bc, 0);
|
|
325
|
+
writeKvErrorResponse(bc, x.val);
|
|
326
|
+
break;
|
|
327
|
+
}
|
|
328
|
+
case "KvGetResponse": {
|
|
329
|
+
bare.writeU8(bc, 1);
|
|
330
|
+
writeKvGetResponse(bc, x.val);
|
|
331
|
+
break;
|
|
332
|
+
}
|
|
333
|
+
case "KvListResponse": {
|
|
334
|
+
bare.writeU8(bc, 2);
|
|
335
|
+
writeKvListResponse(bc, x.val);
|
|
336
|
+
break;
|
|
337
|
+
}
|
|
338
|
+
case "KvPutResponse": {
|
|
339
|
+
bare.writeU8(bc, 3);
|
|
340
|
+
break;
|
|
341
|
+
}
|
|
342
|
+
case "KvDeleteResponse": {
|
|
343
|
+
bare.writeU8(bc, 4);
|
|
344
|
+
break;
|
|
345
|
+
}
|
|
346
|
+
case "KvDropResponse": {
|
|
347
|
+
bare.writeU8(bc, 5);
|
|
348
|
+
break;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
var StopCode = /* @__PURE__ */ ((StopCode2) => {
|
|
353
|
+
StopCode2["Ok"] = "Ok";
|
|
354
|
+
StopCode2["Error"] = "Error";
|
|
355
|
+
return StopCode2;
|
|
356
|
+
})(StopCode || {});
|
|
357
|
+
function readStopCode(bc) {
|
|
358
|
+
const offset = bc.offset;
|
|
359
|
+
const tag = bare.readU8(bc);
|
|
360
|
+
switch (tag) {
|
|
361
|
+
case 0:
|
|
362
|
+
return "Ok" /* Ok */;
|
|
363
|
+
case 1:
|
|
364
|
+
return "Error" /* Error */;
|
|
365
|
+
default: {
|
|
366
|
+
bc.offset = offset;
|
|
367
|
+
throw new bare.BareError(offset, "invalid tag");
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
function writeStopCode(bc, x) {
|
|
372
|
+
switch (x) {
|
|
373
|
+
case "Ok" /* Ok */: {
|
|
374
|
+
bare.writeU8(bc, 0);
|
|
375
|
+
break;
|
|
376
|
+
}
|
|
377
|
+
case "Error" /* Error */: {
|
|
378
|
+
bare.writeU8(bc, 1);
|
|
379
|
+
break;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
function readActorName(bc) {
|
|
384
|
+
return {
|
|
385
|
+
metadata: readJson(bc)
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
function writeActorName(bc, x) {
|
|
389
|
+
writeJson(bc, x.metadata);
|
|
390
|
+
}
|
|
391
|
+
function read5(bc) {
|
|
392
|
+
return bare.readBool(bc) ? bare.readString(bc) : null;
|
|
393
|
+
}
|
|
394
|
+
function write5(bc, x) {
|
|
395
|
+
bare.writeBool(bc, x != null);
|
|
396
|
+
if (x != null) {
|
|
397
|
+
bare.writeString(bc, x);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
function read6(bc) {
|
|
401
|
+
return bare.readBool(bc) ? bare.readData(bc) : null;
|
|
402
|
+
}
|
|
403
|
+
function write6(bc, x) {
|
|
404
|
+
bare.writeBool(bc, x != null);
|
|
405
|
+
if (x != null) {
|
|
406
|
+
bare.writeData(bc, x);
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
function readActorConfig(bc) {
|
|
410
|
+
return {
|
|
411
|
+
name: bare.readString(bc),
|
|
412
|
+
key: read5(bc),
|
|
413
|
+
createTs: bare.readI64(bc),
|
|
414
|
+
input: read6(bc)
|
|
415
|
+
};
|
|
416
|
+
}
|
|
417
|
+
function writeActorConfig(bc, x) {
|
|
418
|
+
bare.writeString(bc, x.name);
|
|
419
|
+
write5(bc, x.key);
|
|
420
|
+
bare.writeI64(bc, x.createTs);
|
|
421
|
+
write6(bc, x.input);
|
|
422
|
+
}
|
|
423
|
+
function readActorCheckpoint(bc) {
|
|
424
|
+
return {
|
|
425
|
+
actorId: readId(bc),
|
|
426
|
+
generation: bare.readU32(bc),
|
|
427
|
+
index: bare.readI64(bc)
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
function writeActorCheckpoint(bc, x) {
|
|
431
|
+
writeId(bc, x.actorId);
|
|
432
|
+
bare.writeU32(bc, x.generation);
|
|
433
|
+
bare.writeI64(bc, x.index);
|
|
434
|
+
}
|
|
435
|
+
function readActorIntent(bc) {
|
|
436
|
+
const offset = bc.offset;
|
|
437
|
+
const tag = bare.readU8(bc);
|
|
438
|
+
switch (tag) {
|
|
439
|
+
case 0:
|
|
440
|
+
return { tag: "ActorIntentSleep", val: null };
|
|
441
|
+
case 1:
|
|
442
|
+
return { tag: "ActorIntentStop", val: null };
|
|
443
|
+
default: {
|
|
444
|
+
bc.offset = offset;
|
|
445
|
+
throw new bare.BareError(offset, "invalid tag");
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
function writeActorIntent(bc, x) {
|
|
450
|
+
switch (x.tag) {
|
|
451
|
+
case "ActorIntentSleep": {
|
|
452
|
+
bare.writeU8(bc, 0);
|
|
453
|
+
break;
|
|
454
|
+
}
|
|
455
|
+
case "ActorIntentStop": {
|
|
456
|
+
bare.writeU8(bc, 1);
|
|
457
|
+
break;
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
function readActorStateStopped(bc) {
|
|
462
|
+
return {
|
|
463
|
+
code: readStopCode(bc),
|
|
464
|
+
message: read5(bc)
|
|
465
|
+
};
|
|
466
|
+
}
|
|
467
|
+
function writeActorStateStopped(bc, x) {
|
|
468
|
+
writeStopCode(bc, x.code);
|
|
469
|
+
write5(bc, x.message);
|
|
470
|
+
}
|
|
471
|
+
function readActorState(bc) {
|
|
472
|
+
const offset = bc.offset;
|
|
473
|
+
const tag = bare.readU8(bc);
|
|
474
|
+
switch (tag) {
|
|
475
|
+
case 0:
|
|
476
|
+
return { tag: "ActorStateRunning", val: null };
|
|
477
|
+
case 1:
|
|
478
|
+
return { tag: "ActorStateStopped", val: readActorStateStopped(bc) };
|
|
479
|
+
default: {
|
|
480
|
+
bc.offset = offset;
|
|
481
|
+
throw new bare.BareError(offset, "invalid tag");
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
function writeActorState(bc, x) {
|
|
486
|
+
switch (x.tag) {
|
|
487
|
+
case "ActorStateRunning": {
|
|
488
|
+
bare.writeU8(bc, 0);
|
|
489
|
+
break;
|
|
490
|
+
}
|
|
491
|
+
case "ActorStateStopped": {
|
|
492
|
+
bare.writeU8(bc, 1);
|
|
493
|
+
writeActorStateStopped(bc, x.val);
|
|
494
|
+
break;
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
function readEventActorIntent(bc) {
|
|
499
|
+
return {
|
|
500
|
+
intent: readActorIntent(bc)
|
|
501
|
+
};
|
|
502
|
+
}
|
|
503
|
+
function writeEventActorIntent(bc, x) {
|
|
504
|
+
writeActorIntent(bc, x.intent);
|
|
505
|
+
}
|
|
506
|
+
function readEventActorStateUpdate(bc) {
|
|
507
|
+
return {
|
|
508
|
+
state: readActorState(bc)
|
|
509
|
+
};
|
|
510
|
+
}
|
|
511
|
+
function writeEventActorStateUpdate(bc, x) {
|
|
512
|
+
writeActorState(bc, x.state);
|
|
513
|
+
}
|
|
514
|
+
function read7(bc) {
|
|
515
|
+
return bare.readBool(bc) ? bare.readI64(bc) : null;
|
|
516
|
+
}
|
|
517
|
+
function write7(bc, x) {
|
|
518
|
+
bare.writeBool(bc, x != null);
|
|
519
|
+
if (x != null) {
|
|
520
|
+
bare.writeI64(bc, x);
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
function readEventActorSetAlarm(bc) {
|
|
524
|
+
return {
|
|
525
|
+
alarmTs: read7(bc)
|
|
526
|
+
};
|
|
527
|
+
}
|
|
528
|
+
function writeEventActorSetAlarm(bc, x) {
|
|
529
|
+
write7(bc, x.alarmTs);
|
|
530
|
+
}
|
|
531
|
+
function readEvent(bc) {
|
|
532
|
+
const offset = bc.offset;
|
|
533
|
+
const tag = bare.readU8(bc);
|
|
534
|
+
switch (tag) {
|
|
535
|
+
case 0:
|
|
536
|
+
return { tag: "EventActorIntent", val: readEventActorIntent(bc) };
|
|
537
|
+
case 1:
|
|
538
|
+
return { tag: "EventActorStateUpdate", val: readEventActorStateUpdate(bc) };
|
|
539
|
+
case 2:
|
|
540
|
+
return { tag: "EventActorSetAlarm", val: readEventActorSetAlarm(bc) };
|
|
541
|
+
default: {
|
|
542
|
+
bc.offset = offset;
|
|
543
|
+
throw new bare.BareError(offset, "invalid tag");
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
function writeEvent(bc, x) {
|
|
548
|
+
switch (x.tag) {
|
|
549
|
+
case "EventActorIntent": {
|
|
550
|
+
bare.writeU8(bc, 0);
|
|
551
|
+
writeEventActorIntent(bc, x.val);
|
|
552
|
+
break;
|
|
553
|
+
}
|
|
554
|
+
case "EventActorStateUpdate": {
|
|
555
|
+
bare.writeU8(bc, 1);
|
|
556
|
+
writeEventActorStateUpdate(bc, x.val);
|
|
557
|
+
break;
|
|
558
|
+
}
|
|
559
|
+
case "EventActorSetAlarm": {
|
|
560
|
+
bare.writeU8(bc, 2);
|
|
561
|
+
writeEventActorSetAlarm(bc, x.val);
|
|
562
|
+
break;
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
function readEventWrapper(bc) {
|
|
567
|
+
return {
|
|
568
|
+
checkpoint: readActorCheckpoint(bc),
|
|
569
|
+
inner: readEvent(bc)
|
|
570
|
+
};
|
|
571
|
+
}
|
|
572
|
+
function writeEventWrapper(bc, x) {
|
|
573
|
+
writeActorCheckpoint(bc, x.checkpoint);
|
|
574
|
+
writeEvent(bc, x.inner);
|
|
575
|
+
}
|
|
576
|
+
function readHibernatingRequest(bc) {
|
|
577
|
+
return {
|
|
578
|
+
gatewayId: readGatewayId(bc),
|
|
579
|
+
requestId: readRequestId(bc)
|
|
580
|
+
};
|
|
581
|
+
}
|
|
582
|
+
function writeHibernatingRequest(bc, x) {
|
|
583
|
+
writeGatewayId(bc, x.gatewayId);
|
|
584
|
+
writeRequestId(bc, x.requestId);
|
|
585
|
+
}
|
|
586
|
+
function read8(bc) {
|
|
587
|
+
const len = bare.readUintSafe(bc);
|
|
588
|
+
if (len === 0) {
|
|
589
|
+
return [];
|
|
590
|
+
}
|
|
591
|
+
const result = [readHibernatingRequest(bc)];
|
|
592
|
+
for (let i = 1; i < len; i++) {
|
|
593
|
+
result[i] = readHibernatingRequest(bc);
|
|
594
|
+
}
|
|
595
|
+
return result;
|
|
596
|
+
}
|
|
597
|
+
function write8(bc, x) {
|
|
598
|
+
bare.writeUintSafe(bc, x.length);
|
|
599
|
+
for (let i = 0; i < x.length; i++) {
|
|
600
|
+
writeHibernatingRequest(bc, x[i]);
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
function readCommandStartActor(bc) {
|
|
604
|
+
return {
|
|
605
|
+
config: readActorConfig(bc),
|
|
606
|
+
hibernatingRequests: read8(bc)
|
|
607
|
+
};
|
|
608
|
+
}
|
|
609
|
+
function writeCommandStartActor(bc, x) {
|
|
610
|
+
writeActorConfig(bc, x.config);
|
|
611
|
+
write8(bc, x.hibernatingRequests);
|
|
612
|
+
}
|
|
613
|
+
function readCommand(bc) {
|
|
614
|
+
const offset = bc.offset;
|
|
615
|
+
const tag = bare.readU8(bc);
|
|
616
|
+
switch (tag) {
|
|
617
|
+
case 0:
|
|
618
|
+
return { tag: "CommandStartActor", val: readCommandStartActor(bc) };
|
|
619
|
+
case 1:
|
|
620
|
+
return { tag: "CommandStopActor", val: null };
|
|
621
|
+
default: {
|
|
622
|
+
bc.offset = offset;
|
|
623
|
+
throw new bare.BareError(offset, "invalid tag");
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
function writeCommand(bc, x) {
|
|
628
|
+
switch (x.tag) {
|
|
629
|
+
case "CommandStartActor": {
|
|
630
|
+
bare.writeU8(bc, 0);
|
|
631
|
+
writeCommandStartActor(bc, x.val);
|
|
632
|
+
break;
|
|
633
|
+
}
|
|
634
|
+
case "CommandStopActor": {
|
|
635
|
+
bare.writeU8(bc, 1);
|
|
636
|
+
break;
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
function readCommandWrapper(bc) {
|
|
641
|
+
return {
|
|
642
|
+
checkpoint: readActorCheckpoint(bc),
|
|
643
|
+
inner: readCommand(bc)
|
|
644
|
+
};
|
|
645
|
+
}
|
|
646
|
+
function writeCommandWrapper(bc, x) {
|
|
647
|
+
writeActorCheckpoint(bc, x.checkpoint);
|
|
648
|
+
writeCommand(bc, x.inner);
|
|
649
|
+
}
|
|
650
|
+
function readActorCommandKeyData(bc) {
|
|
651
|
+
const offset = bc.offset;
|
|
652
|
+
const tag = bare.readU8(bc);
|
|
653
|
+
switch (tag) {
|
|
654
|
+
case 0:
|
|
655
|
+
return { tag: "CommandStartActor", val: readCommandStartActor(bc) };
|
|
656
|
+
case 1:
|
|
657
|
+
return { tag: "CommandStopActor", val: null };
|
|
658
|
+
default: {
|
|
659
|
+
bc.offset = offset;
|
|
660
|
+
throw new bare.BareError(offset, "invalid tag");
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
function writeActorCommandKeyData(bc, x) {
|
|
665
|
+
switch (x.tag) {
|
|
666
|
+
case "CommandStartActor": {
|
|
667
|
+
bare.writeU8(bc, 0);
|
|
668
|
+
writeCommandStartActor(bc, x.val);
|
|
669
|
+
break;
|
|
670
|
+
}
|
|
671
|
+
case "CommandStopActor": {
|
|
672
|
+
bare.writeU8(bc, 1);
|
|
673
|
+
break;
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
function encodeActorCommandKeyData(x, config) {
|
|
678
|
+
const fullConfig = config != null ? bare.Config(config) : DEFAULT_CONFIG;
|
|
679
|
+
const bc = new bare.ByteCursor(
|
|
680
|
+
new Uint8Array(fullConfig.initialBufferLength),
|
|
681
|
+
fullConfig
|
|
682
|
+
);
|
|
683
|
+
writeActorCommandKeyData(bc, x);
|
|
684
|
+
return new Uint8Array(bc.view.buffer, bc.view.byteOffset, bc.offset);
|
|
685
|
+
}
|
|
686
|
+
function decodeActorCommandKeyData(bytes) {
|
|
687
|
+
const bc = new bare.ByteCursor(bytes, DEFAULT_CONFIG);
|
|
688
|
+
const result = readActorCommandKeyData(bc);
|
|
689
|
+
if (bc.offset < bc.view.byteLength) {
|
|
690
|
+
throw new bare.BareError(bc.offset, "remaining bytes");
|
|
691
|
+
}
|
|
692
|
+
return result;
|
|
693
|
+
}
|
|
694
|
+
function readMessageId(bc) {
|
|
695
|
+
return {
|
|
696
|
+
gatewayId: readGatewayId(bc),
|
|
697
|
+
requestId: readRequestId(bc),
|
|
698
|
+
messageIndex: readMessageIndex(bc)
|
|
699
|
+
};
|
|
700
|
+
}
|
|
701
|
+
function writeMessageId(bc, x) {
|
|
702
|
+
writeGatewayId(bc, x.gatewayId);
|
|
703
|
+
writeRequestId(bc, x.requestId);
|
|
704
|
+
writeMessageIndex(bc, x.messageIndex);
|
|
705
|
+
}
|
|
706
|
+
function read9(bc) {
|
|
707
|
+
const len = bare.readUintSafe(bc);
|
|
708
|
+
const result = /* @__PURE__ */ new Map();
|
|
709
|
+
for (let i = 0; i < len; i++) {
|
|
710
|
+
const offset = bc.offset;
|
|
711
|
+
const key = bare.readString(bc);
|
|
712
|
+
if (result.has(key)) {
|
|
713
|
+
bc.offset = offset;
|
|
714
|
+
throw new bare.BareError(offset, "duplicated key");
|
|
715
|
+
}
|
|
716
|
+
result.set(key, bare.readString(bc));
|
|
717
|
+
}
|
|
718
|
+
return result;
|
|
719
|
+
}
|
|
720
|
+
function write9(bc, x) {
|
|
721
|
+
bare.writeUintSafe(bc, x.size);
|
|
722
|
+
for (const kv of x) {
|
|
723
|
+
bare.writeString(bc, kv[0]);
|
|
724
|
+
bare.writeString(bc, kv[1]);
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
function readToClientRequestStart(bc) {
|
|
728
|
+
return {
|
|
729
|
+
actorId: readId(bc),
|
|
730
|
+
method: bare.readString(bc),
|
|
731
|
+
path: bare.readString(bc),
|
|
732
|
+
headers: read9(bc),
|
|
733
|
+
body: read6(bc),
|
|
734
|
+
stream: bare.readBool(bc)
|
|
735
|
+
};
|
|
736
|
+
}
|
|
737
|
+
function writeToClientRequestStart(bc, x) {
|
|
738
|
+
writeId(bc, x.actorId);
|
|
739
|
+
bare.writeString(bc, x.method);
|
|
740
|
+
bare.writeString(bc, x.path);
|
|
741
|
+
write9(bc, x.headers);
|
|
742
|
+
write6(bc, x.body);
|
|
743
|
+
bare.writeBool(bc, x.stream);
|
|
744
|
+
}
|
|
745
|
+
function readToClientRequestChunk(bc) {
|
|
746
|
+
return {
|
|
747
|
+
body: bare.readData(bc),
|
|
748
|
+
finish: bare.readBool(bc)
|
|
749
|
+
};
|
|
750
|
+
}
|
|
751
|
+
function writeToClientRequestChunk(bc, x) {
|
|
752
|
+
bare.writeData(bc, x.body);
|
|
753
|
+
bare.writeBool(bc, x.finish);
|
|
754
|
+
}
|
|
755
|
+
function readToServerResponseStart(bc) {
|
|
756
|
+
return {
|
|
757
|
+
status: bare.readU16(bc),
|
|
758
|
+
headers: read9(bc),
|
|
759
|
+
body: read6(bc),
|
|
760
|
+
stream: bare.readBool(bc)
|
|
761
|
+
};
|
|
762
|
+
}
|
|
763
|
+
function writeToServerResponseStart(bc, x) {
|
|
764
|
+
bare.writeU16(bc, x.status);
|
|
765
|
+
write9(bc, x.headers);
|
|
766
|
+
write6(bc, x.body);
|
|
767
|
+
bare.writeBool(bc, x.stream);
|
|
768
|
+
}
|
|
769
|
+
function readToServerResponseChunk(bc) {
|
|
770
|
+
return {
|
|
771
|
+
body: bare.readData(bc),
|
|
772
|
+
finish: bare.readBool(bc)
|
|
773
|
+
};
|
|
774
|
+
}
|
|
775
|
+
function writeToServerResponseChunk(bc, x) {
|
|
776
|
+
bare.writeData(bc, x.body);
|
|
777
|
+
bare.writeBool(bc, x.finish);
|
|
778
|
+
}
|
|
779
|
+
function readToClientWebSocketOpen(bc) {
|
|
780
|
+
return {
|
|
781
|
+
actorId: readId(bc),
|
|
782
|
+
path: bare.readString(bc),
|
|
783
|
+
headers: read9(bc)
|
|
784
|
+
};
|
|
785
|
+
}
|
|
786
|
+
function writeToClientWebSocketOpen(bc, x) {
|
|
787
|
+
writeId(bc, x.actorId);
|
|
788
|
+
bare.writeString(bc, x.path);
|
|
789
|
+
write9(bc, x.headers);
|
|
790
|
+
}
|
|
791
|
+
function readToClientWebSocketMessage(bc) {
|
|
792
|
+
return {
|
|
793
|
+
data: bare.readData(bc),
|
|
794
|
+
binary: bare.readBool(bc)
|
|
795
|
+
};
|
|
796
|
+
}
|
|
797
|
+
function writeToClientWebSocketMessage(bc, x) {
|
|
798
|
+
bare.writeData(bc, x.data);
|
|
799
|
+
bare.writeBool(bc, x.binary);
|
|
800
|
+
}
|
|
801
|
+
function read10(bc) {
|
|
802
|
+
return bare.readBool(bc) ? bare.readU16(bc) : null;
|
|
803
|
+
}
|
|
804
|
+
function write10(bc, x) {
|
|
805
|
+
bare.writeBool(bc, x != null);
|
|
806
|
+
if (x != null) {
|
|
807
|
+
bare.writeU16(bc, x);
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
function readToClientWebSocketClose(bc) {
|
|
811
|
+
return {
|
|
812
|
+
code: read10(bc),
|
|
813
|
+
reason: read5(bc)
|
|
814
|
+
};
|
|
815
|
+
}
|
|
816
|
+
function writeToClientWebSocketClose(bc, x) {
|
|
817
|
+
write10(bc, x.code);
|
|
818
|
+
write5(bc, x.reason);
|
|
819
|
+
}
|
|
820
|
+
function readToServerWebSocketOpen(bc) {
|
|
821
|
+
return {
|
|
822
|
+
canHibernate: bare.readBool(bc)
|
|
823
|
+
};
|
|
824
|
+
}
|
|
825
|
+
function writeToServerWebSocketOpen(bc, x) {
|
|
826
|
+
bare.writeBool(bc, x.canHibernate);
|
|
827
|
+
}
|
|
828
|
+
function readToServerWebSocketMessage(bc) {
|
|
829
|
+
return {
|
|
830
|
+
data: bare.readData(bc),
|
|
831
|
+
binary: bare.readBool(bc)
|
|
832
|
+
};
|
|
833
|
+
}
|
|
834
|
+
function writeToServerWebSocketMessage(bc, x) {
|
|
835
|
+
bare.writeData(bc, x.data);
|
|
836
|
+
bare.writeBool(bc, x.binary);
|
|
837
|
+
}
|
|
838
|
+
function readToServerWebSocketMessageAck(bc) {
|
|
839
|
+
return {
|
|
840
|
+
index: readMessageIndex(bc)
|
|
841
|
+
};
|
|
842
|
+
}
|
|
843
|
+
function writeToServerWebSocketMessageAck(bc, x) {
|
|
844
|
+
writeMessageIndex(bc, x.index);
|
|
845
|
+
}
|
|
846
|
+
function readToServerWebSocketClose(bc) {
|
|
847
|
+
return {
|
|
848
|
+
code: read10(bc),
|
|
849
|
+
reason: read5(bc),
|
|
850
|
+
hibernate: bare.readBool(bc)
|
|
851
|
+
};
|
|
852
|
+
}
|
|
853
|
+
function writeToServerWebSocketClose(bc, x) {
|
|
854
|
+
write10(bc, x.code);
|
|
855
|
+
write5(bc, x.reason);
|
|
856
|
+
bare.writeBool(bc, x.hibernate);
|
|
857
|
+
}
|
|
858
|
+
function readToServerTunnelMessageKind(bc) {
|
|
859
|
+
const offset = bc.offset;
|
|
860
|
+
const tag = bare.readU8(bc);
|
|
861
|
+
switch (tag) {
|
|
862
|
+
case 0:
|
|
863
|
+
return { tag: "ToServerResponseStart", val: readToServerResponseStart(bc) };
|
|
864
|
+
case 1:
|
|
865
|
+
return { tag: "ToServerResponseChunk", val: readToServerResponseChunk(bc) };
|
|
866
|
+
case 2:
|
|
867
|
+
return { tag: "ToServerResponseAbort", val: null };
|
|
868
|
+
case 3:
|
|
869
|
+
return { tag: "ToServerWebSocketOpen", val: readToServerWebSocketOpen(bc) };
|
|
870
|
+
case 4:
|
|
871
|
+
return { tag: "ToServerWebSocketMessage", val: readToServerWebSocketMessage(bc) };
|
|
872
|
+
case 5:
|
|
873
|
+
return { tag: "ToServerWebSocketMessageAck", val: readToServerWebSocketMessageAck(bc) };
|
|
874
|
+
case 6:
|
|
875
|
+
return { tag: "ToServerWebSocketClose", val: readToServerWebSocketClose(bc) };
|
|
876
|
+
default: {
|
|
877
|
+
bc.offset = offset;
|
|
878
|
+
throw new bare.BareError(offset, "invalid tag");
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
function writeToServerTunnelMessageKind(bc, x) {
|
|
883
|
+
switch (x.tag) {
|
|
884
|
+
case "ToServerResponseStart": {
|
|
885
|
+
bare.writeU8(bc, 0);
|
|
886
|
+
writeToServerResponseStart(bc, x.val);
|
|
887
|
+
break;
|
|
888
|
+
}
|
|
889
|
+
case "ToServerResponseChunk": {
|
|
890
|
+
bare.writeU8(bc, 1);
|
|
891
|
+
writeToServerResponseChunk(bc, x.val);
|
|
892
|
+
break;
|
|
893
|
+
}
|
|
894
|
+
case "ToServerResponseAbort": {
|
|
895
|
+
bare.writeU8(bc, 2);
|
|
896
|
+
break;
|
|
897
|
+
}
|
|
898
|
+
case "ToServerWebSocketOpen": {
|
|
899
|
+
bare.writeU8(bc, 3);
|
|
900
|
+
writeToServerWebSocketOpen(bc, x.val);
|
|
901
|
+
break;
|
|
902
|
+
}
|
|
903
|
+
case "ToServerWebSocketMessage": {
|
|
904
|
+
bare.writeU8(bc, 4);
|
|
905
|
+
writeToServerWebSocketMessage(bc, x.val);
|
|
906
|
+
break;
|
|
907
|
+
}
|
|
908
|
+
case "ToServerWebSocketMessageAck": {
|
|
909
|
+
bare.writeU8(bc, 5);
|
|
910
|
+
writeToServerWebSocketMessageAck(bc, x.val);
|
|
911
|
+
break;
|
|
912
|
+
}
|
|
913
|
+
case "ToServerWebSocketClose": {
|
|
914
|
+
bare.writeU8(bc, 6);
|
|
915
|
+
writeToServerWebSocketClose(bc, x.val);
|
|
916
|
+
break;
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
function readToServerTunnelMessage(bc) {
|
|
921
|
+
return {
|
|
922
|
+
messageId: readMessageId(bc),
|
|
923
|
+
messageKind: readToServerTunnelMessageKind(bc)
|
|
924
|
+
};
|
|
925
|
+
}
|
|
926
|
+
function writeToServerTunnelMessage(bc, x) {
|
|
927
|
+
writeMessageId(bc, x.messageId);
|
|
928
|
+
writeToServerTunnelMessageKind(bc, x.messageKind);
|
|
929
|
+
}
|
|
930
|
+
function readToClientTunnelMessageKind(bc) {
|
|
931
|
+
const offset = bc.offset;
|
|
932
|
+
const tag = bare.readU8(bc);
|
|
933
|
+
switch (tag) {
|
|
934
|
+
case 0:
|
|
935
|
+
return { tag: "ToClientRequestStart", val: readToClientRequestStart(bc) };
|
|
936
|
+
case 1:
|
|
937
|
+
return { tag: "ToClientRequestChunk", val: readToClientRequestChunk(bc) };
|
|
938
|
+
case 2:
|
|
939
|
+
return { tag: "ToClientRequestAbort", val: null };
|
|
940
|
+
case 3:
|
|
941
|
+
return { tag: "ToClientWebSocketOpen", val: readToClientWebSocketOpen(bc) };
|
|
942
|
+
case 4:
|
|
943
|
+
return { tag: "ToClientWebSocketMessage", val: readToClientWebSocketMessage(bc) };
|
|
944
|
+
case 5:
|
|
945
|
+
return { tag: "ToClientWebSocketClose", val: readToClientWebSocketClose(bc) };
|
|
946
|
+
default: {
|
|
947
|
+
bc.offset = offset;
|
|
948
|
+
throw new bare.BareError(offset, "invalid tag");
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
function writeToClientTunnelMessageKind(bc, x) {
|
|
953
|
+
switch (x.tag) {
|
|
954
|
+
case "ToClientRequestStart": {
|
|
955
|
+
bare.writeU8(bc, 0);
|
|
956
|
+
writeToClientRequestStart(bc, x.val);
|
|
957
|
+
break;
|
|
958
|
+
}
|
|
959
|
+
case "ToClientRequestChunk": {
|
|
960
|
+
bare.writeU8(bc, 1);
|
|
961
|
+
writeToClientRequestChunk(bc, x.val);
|
|
962
|
+
break;
|
|
963
|
+
}
|
|
964
|
+
case "ToClientRequestAbort": {
|
|
965
|
+
bare.writeU8(bc, 2);
|
|
966
|
+
break;
|
|
967
|
+
}
|
|
968
|
+
case "ToClientWebSocketOpen": {
|
|
969
|
+
bare.writeU8(bc, 3);
|
|
970
|
+
writeToClientWebSocketOpen(bc, x.val);
|
|
971
|
+
break;
|
|
972
|
+
}
|
|
973
|
+
case "ToClientWebSocketMessage": {
|
|
974
|
+
bare.writeU8(bc, 4);
|
|
975
|
+
writeToClientWebSocketMessage(bc, x.val);
|
|
976
|
+
break;
|
|
977
|
+
}
|
|
978
|
+
case "ToClientWebSocketClose": {
|
|
979
|
+
bare.writeU8(bc, 5);
|
|
980
|
+
writeToClientWebSocketClose(bc, x.val);
|
|
981
|
+
break;
|
|
982
|
+
}
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
function readToClientTunnelMessage(bc) {
|
|
986
|
+
return {
|
|
987
|
+
messageId: readMessageId(bc),
|
|
988
|
+
messageKind: readToClientTunnelMessageKind(bc)
|
|
989
|
+
};
|
|
990
|
+
}
|
|
991
|
+
function writeToClientTunnelMessage(bc, x) {
|
|
992
|
+
writeMessageId(bc, x.messageId);
|
|
993
|
+
writeToClientTunnelMessageKind(bc, x.messageKind);
|
|
994
|
+
}
|
|
995
|
+
function readToClientPing(bc) {
|
|
996
|
+
return {
|
|
997
|
+
ts: bare.readI64(bc)
|
|
998
|
+
};
|
|
999
|
+
}
|
|
1000
|
+
function writeToClientPing(bc, x) {
|
|
1001
|
+
bare.writeI64(bc, x.ts);
|
|
1002
|
+
}
|
|
1003
|
+
function read11(bc) {
|
|
1004
|
+
const len = bare.readUintSafe(bc);
|
|
1005
|
+
const result = /* @__PURE__ */ new Map();
|
|
1006
|
+
for (let i = 0; i < len; i++) {
|
|
1007
|
+
const offset = bc.offset;
|
|
1008
|
+
const key = bare.readString(bc);
|
|
1009
|
+
if (result.has(key)) {
|
|
1010
|
+
bc.offset = offset;
|
|
1011
|
+
throw new bare.BareError(offset, "duplicated key");
|
|
1012
|
+
}
|
|
1013
|
+
result.set(key, readActorName(bc));
|
|
1014
|
+
}
|
|
1015
|
+
return result;
|
|
1016
|
+
}
|
|
1017
|
+
function write11(bc, x) {
|
|
1018
|
+
bare.writeUintSafe(bc, x.size);
|
|
1019
|
+
for (const kv of x) {
|
|
1020
|
+
bare.writeString(bc, kv[0]);
|
|
1021
|
+
writeActorName(bc, kv[1]);
|
|
1022
|
+
}
|
|
1023
|
+
}
|
|
1024
|
+
function read12(bc) {
|
|
1025
|
+
return bare.readBool(bc) ? read11(bc) : null;
|
|
1026
|
+
}
|
|
1027
|
+
function write12(bc, x) {
|
|
1028
|
+
bare.writeBool(bc, x != null);
|
|
1029
|
+
if (x != null) {
|
|
1030
|
+
write11(bc, x);
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
function read13(bc) {
|
|
1034
|
+
return bare.readBool(bc) ? readJson(bc) : null;
|
|
1035
|
+
}
|
|
1036
|
+
function write13(bc, x) {
|
|
1037
|
+
bare.writeBool(bc, x != null);
|
|
1038
|
+
if (x != null) {
|
|
1039
|
+
writeJson(bc, x);
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
function readToServerInit(bc) {
|
|
1043
|
+
return {
|
|
1044
|
+
name: bare.readString(bc),
|
|
1045
|
+
version: bare.readU32(bc),
|
|
1046
|
+
totalSlots: bare.readU32(bc),
|
|
1047
|
+
prepopulateActorNames: read12(bc),
|
|
1048
|
+
metadata: read13(bc)
|
|
1049
|
+
};
|
|
1050
|
+
}
|
|
1051
|
+
function writeToServerInit(bc, x) {
|
|
1052
|
+
bare.writeString(bc, x.name);
|
|
1053
|
+
bare.writeU32(bc, x.version);
|
|
1054
|
+
bare.writeU32(bc, x.totalSlots);
|
|
1055
|
+
write12(bc, x.prepopulateActorNames);
|
|
1056
|
+
write13(bc, x.metadata);
|
|
1057
|
+
}
|
|
1058
|
+
function readToServerEvents(bc) {
|
|
1059
|
+
const len = bare.readUintSafe(bc);
|
|
1060
|
+
if (len === 0) {
|
|
1061
|
+
return [];
|
|
1062
|
+
}
|
|
1063
|
+
const result = [readEventWrapper(bc)];
|
|
1064
|
+
for (let i = 1; i < len; i++) {
|
|
1065
|
+
result[i] = readEventWrapper(bc);
|
|
1066
|
+
}
|
|
1067
|
+
return result;
|
|
1068
|
+
}
|
|
1069
|
+
function writeToServerEvents(bc, x) {
|
|
1070
|
+
bare.writeUintSafe(bc, x.length);
|
|
1071
|
+
for (let i = 0; i < x.length; i++) {
|
|
1072
|
+
writeEventWrapper(bc, x[i]);
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
function read14(bc) {
|
|
1076
|
+
const len = bare.readUintSafe(bc);
|
|
1077
|
+
if (len === 0) {
|
|
1078
|
+
return [];
|
|
1079
|
+
}
|
|
1080
|
+
const result = [readActorCheckpoint(bc)];
|
|
1081
|
+
for (let i = 1; i < len; i++) {
|
|
1082
|
+
result[i] = readActorCheckpoint(bc);
|
|
1083
|
+
}
|
|
1084
|
+
return result;
|
|
1085
|
+
}
|
|
1086
|
+
function write14(bc, x) {
|
|
1087
|
+
bare.writeUintSafe(bc, x.length);
|
|
1088
|
+
for (let i = 0; i < x.length; i++) {
|
|
1089
|
+
writeActorCheckpoint(bc, x[i]);
|
|
1090
|
+
}
|
|
1091
|
+
}
|
|
1092
|
+
function readToServerAckCommands(bc) {
|
|
1093
|
+
return {
|
|
1094
|
+
lastCommandCheckpoints: read14(bc)
|
|
1095
|
+
};
|
|
1096
|
+
}
|
|
1097
|
+
function writeToServerAckCommands(bc, x) {
|
|
1098
|
+
write14(bc, x.lastCommandCheckpoints);
|
|
1099
|
+
}
|
|
1100
|
+
function readToServerPong(bc) {
|
|
1101
|
+
return {
|
|
1102
|
+
ts: bare.readI64(bc)
|
|
1103
|
+
};
|
|
1104
|
+
}
|
|
1105
|
+
function writeToServerPong(bc, x) {
|
|
1106
|
+
bare.writeI64(bc, x.ts);
|
|
1107
|
+
}
|
|
1108
|
+
function readToServerKvRequest(bc) {
|
|
1109
|
+
return {
|
|
1110
|
+
actorId: readId(bc),
|
|
1111
|
+
requestId: bare.readU32(bc),
|
|
1112
|
+
data: readKvRequestData(bc)
|
|
1113
|
+
};
|
|
1114
|
+
}
|
|
1115
|
+
function writeToServerKvRequest(bc, x) {
|
|
1116
|
+
writeId(bc, x.actorId);
|
|
1117
|
+
bare.writeU32(bc, x.requestId);
|
|
1118
|
+
writeKvRequestData(bc, x.data);
|
|
1119
|
+
}
|
|
1120
|
+
function readToServer(bc) {
|
|
1121
|
+
const offset = bc.offset;
|
|
1122
|
+
const tag = bare.readU8(bc);
|
|
1123
|
+
switch (tag) {
|
|
1124
|
+
case 0:
|
|
1125
|
+
return { tag: "ToServerInit", val: readToServerInit(bc) };
|
|
1126
|
+
case 1:
|
|
1127
|
+
return { tag: "ToServerEvents", val: readToServerEvents(bc) };
|
|
1128
|
+
case 2:
|
|
1129
|
+
return { tag: "ToServerAckCommands", val: readToServerAckCommands(bc) };
|
|
1130
|
+
case 3:
|
|
1131
|
+
return { tag: "ToServerStopping", val: null };
|
|
1132
|
+
case 4:
|
|
1133
|
+
return { tag: "ToServerPong", val: readToServerPong(bc) };
|
|
1134
|
+
case 5:
|
|
1135
|
+
return { tag: "ToServerKvRequest", val: readToServerKvRequest(bc) };
|
|
1136
|
+
case 6:
|
|
1137
|
+
return { tag: "ToServerTunnelMessage", val: readToServerTunnelMessage(bc) };
|
|
1138
|
+
default: {
|
|
1139
|
+
bc.offset = offset;
|
|
1140
|
+
throw new bare.BareError(offset, "invalid tag");
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
1144
|
+
function writeToServer(bc, x) {
|
|
1145
|
+
switch (x.tag) {
|
|
1146
|
+
case "ToServerInit": {
|
|
1147
|
+
bare.writeU8(bc, 0);
|
|
1148
|
+
writeToServerInit(bc, x.val);
|
|
1149
|
+
break;
|
|
1150
|
+
}
|
|
1151
|
+
case "ToServerEvents": {
|
|
1152
|
+
bare.writeU8(bc, 1);
|
|
1153
|
+
writeToServerEvents(bc, x.val);
|
|
1154
|
+
break;
|
|
1155
|
+
}
|
|
1156
|
+
case "ToServerAckCommands": {
|
|
1157
|
+
bare.writeU8(bc, 2);
|
|
1158
|
+
writeToServerAckCommands(bc, x.val);
|
|
1159
|
+
break;
|
|
1160
|
+
}
|
|
1161
|
+
case "ToServerStopping": {
|
|
1162
|
+
bare.writeU8(bc, 3);
|
|
1163
|
+
break;
|
|
1164
|
+
}
|
|
1165
|
+
case "ToServerPong": {
|
|
1166
|
+
bare.writeU8(bc, 4);
|
|
1167
|
+
writeToServerPong(bc, x.val);
|
|
1168
|
+
break;
|
|
1169
|
+
}
|
|
1170
|
+
case "ToServerKvRequest": {
|
|
1171
|
+
bare.writeU8(bc, 5);
|
|
1172
|
+
writeToServerKvRequest(bc, x.val);
|
|
1173
|
+
break;
|
|
1174
|
+
}
|
|
1175
|
+
case "ToServerTunnelMessage": {
|
|
1176
|
+
bare.writeU8(bc, 6);
|
|
1177
|
+
writeToServerTunnelMessage(bc, x.val);
|
|
1178
|
+
break;
|
|
1179
|
+
}
|
|
1180
|
+
}
|
|
1181
|
+
}
|
|
1182
|
+
function encodeToServer(x, config) {
|
|
1183
|
+
const fullConfig = config != null ? bare.Config(config) : DEFAULT_CONFIG;
|
|
1184
|
+
const bc = new bare.ByteCursor(
|
|
1185
|
+
new Uint8Array(fullConfig.initialBufferLength),
|
|
1186
|
+
fullConfig
|
|
1187
|
+
);
|
|
1188
|
+
writeToServer(bc, x);
|
|
1189
|
+
return new Uint8Array(bc.view.buffer, bc.view.byteOffset, bc.offset);
|
|
1190
|
+
}
|
|
1191
|
+
function decodeToServer(bytes) {
|
|
1192
|
+
const bc = new bare.ByteCursor(bytes, DEFAULT_CONFIG);
|
|
1193
|
+
const result = readToServer(bc);
|
|
1194
|
+
if (bc.offset < bc.view.byteLength) {
|
|
1195
|
+
throw new bare.BareError(bc.offset, "remaining bytes");
|
|
1196
|
+
}
|
|
1197
|
+
return result;
|
|
1198
|
+
}
|
|
1199
|
+
function readProtocolMetadata(bc) {
|
|
1200
|
+
return {
|
|
1201
|
+
runnerLostThreshold: bare.readI64(bc)
|
|
1202
|
+
};
|
|
1203
|
+
}
|
|
1204
|
+
function writeProtocolMetadata(bc, x) {
|
|
1205
|
+
bare.writeI64(bc, x.runnerLostThreshold);
|
|
1206
|
+
}
|
|
1207
|
+
function readToClientInit(bc) {
|
|
1208
|
+
return {
|
|
1209
|
+
runnerId: readId(bc),
|
|
1210
|
+
metadata: readProtocolMetadata(bc)
|
|
1211
|
+
};
|
|
1212
|
+
}
|
|
1213
|
+
function writeToClientInit(bc, x) {
|
|
1214
|
+
writeId(bc, x.runnerId);
|
|
1215
|
+
writeProtocolMetadata(bc, x.metadata);
|
|
1216
|
+
}
|
|
1217
|
+
function readToClientCommands(bc) {
|
|
1218
|
+
const len = bare.readUintSafe(bc);
|
|
1219
|
+
if (len === 0) {
|
|
1220
|
+
return [];
|
|
1221
|
+
}
|
|
1222
|
+
const result = [readCommandWrapper(bc)];
|
|
1223
|
+
for (let i = 1; i < len; i++) {
|
|
1224
|
+
result[i] = readCommandWrapper(bc);
|
|
1225
|
+
}
|
|
1226
|
+
return result;
|
|
1227
|
+
}
|
|
1228
|
+
function writeToClientCommands(bc, x) {
|
|
1229
|
+
bare.writeUintSafe(bc, x.length);
|
|
1230
|
+
for (let i = 0; i < x.length; i++) {
|
|
1231
|
+
writeCommandWrapper(bc, x[i]);
|
|
1232
|
+
}
|
|
1233
|
+
}
|
|
1234
|
+
function readToClientAckEvents(bc) {
|
|
1235
|
+
return {
|
|
1236
|
+
lastEventCheckpoints: read14(bc)
|
|
1237
|
+
};
|
|
1238
|
+
}
|
|
1239
|
+
function writeToClientAckEvents(bc, x) {
|
|
1240
|
+
write14(bc, x.lastEventCheckpoints);
|
|
1241
|
+
}
|
|
1242
|
+
function readToClientKvResponse(bc) {
|
|
1243
|
+
return {
|
|
1244
|
+
requestId: bare.readU32(bc),
|
|
1245
|
+
data: readKvResponseData(bc)
|
|
1246
|
+
};
|
|
1247
|
+
}
|
|
1248
|
+
function writeToClientKvResponse(bc, x) {
|
|
1249
|
+
bare.writeU32(bc, x.requestId);
|
|
1250
|
+
writeKvResponseData(bc, x.data);
|
|
1251
|
+
}
|
|
1252
|
+
function readToClient(bc) {
|
|
1253
|
+
const offset = bc.offset;
|
|
1254
|
+
const tag = bare.readU8(bc);
|
|
1255
|
+
switch (tag) {
|
|
1256
|
+
case 0:
|
|
1257
|
+
return { tag: "ToClientInit", val: readToClientInit(bc) };
|
|
1258
|
+
case 1:
|
|
1259
|
+
return { tag: "ToClientCommands", val: readToClientCommands(bc) };
|
|
1260
|
+
case 2:
|
|
1261
|
+
return { tag: "ToClientAckEvents", val: readToClientAckEvents(bc) };
|
|
1262
|
+
case 3:
|
|
1263
|
+
return { tag: "ToClientKvResponse", val: readToClientKvResponse(bc) };
|
|
1264
|
+
case 4:
|
|
1265
|
+
return { tag: "ToClientTunnelMessage", val: readToClientTunnelMessage(bc) };
|
|
1266
|
+
case 5:
|
|
1267
|
+
return { tag: "ToClientPing", val: readToClientPing(bc) };
|
|
1268
|
+
default: {
|
|
1269
|
+
bc.offset = offset;
|
|
1270
|
+
throw new bare.BareError(offset, "invalid tag");
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1273
|
+
}
|
|
1274
|
+
function writeToClient(bc, x) {
|
|
1275
|
+
switch (x.tag) {
|
|
1276
|
+
case "ToClientInit": {
|
|
1277
|
+
bare.writeU8(bc, 0);
|
|
1278
|
+
writeToClientInit(bc, x.val);
|
|
1279
|
+
break;
|
|
1280
|
+
}
|
|
1281
|
+
case "ToClientCommands": {
|
|
1282
|
+
bare.writeU8(bc, 1);
|
|
1283
|
+
writeToClientCommands(bc, x.val);
|
|
1284
|
+
break;
|
|
1285
|
+
}
|
|
1286
|
+
case "ToClientAckEvents": {
|
|
1287
|
+
bare.writeU8(bc, 2);
|
|
1288
|
+
writeToClientAckEvents(bc, x.val);
|
|
1289
|
+
break;
|
|
1290
|
+
}
|
|
1291
|
+
case "ToClientKvResponse": {
|
|
1292
|
+
bare.writeU8(bc, 3);
|
|
1293
|
+
writeToClientKvResponse(bc, x.val);
|
|
1294
|
+
break;
|
|
1295
|
+
}
|
|
1296
|
+
case "ToClientTunnelMessage": {
|
|
1297
|
+
bare.writeU8(bc, 4);
|
|
1298
|
+
writeToClientTunnelMessage(bc, x.val);
|
|
1299
|
+
break;
|
|
1300
|
+
}
|
|
1301
|
+
case "ToClientPing": {
|
|
1302
|
+
bare.writeU8(bc, 5);
|
|
1303
|
+
writeToClientPing(bc, x.val);
|
|
1304
|
+
break;
|
|
1305
|
+
}
|
|
1306
|
+
}
|
|
1307
|
+
}
|
|
1308
|
+
function encodeToClient(x, config) {
|
|
1309
|
+
const fullConfig = config != null ? bare.Config(config) : DEFAULT_CONFIG;
|
|
1310
|
+
const bc = new bare.ByteCursor(
|
|
1311
|
+
new Uint8Array(fullConfig.initialBufferLength),
|
|
1312
|
+
fullConfig
|
|
1313
|
+
);
|
|
1314
|
+
writeToClient(bc, x);
|
|
1315
|
+
return new Uint8Array(bc.view.buffer, bc.view.byteOffset, bc.offset);
|
|
1316
|
+
}
|
|
1317
|
+
function decodeToClient(bytes) {
|
|
1318
|
+
const bc = new bare.ByteCursor(bytes, DEFAULT_CONFIG);
|
|
1319
|
+
const result = readToClient(bc);
|
|
1320
|
+
if (bc.offset < bc.view.byteLength) {
|
|
1321
|
+
throw new bare.BareError(bc.offset, "remaining bytes");
|
|
1322
|
+
}
|
|
1323
|
+
return result;
|
|
1324
|
+
}
|
|
1325
|
+
function readToRunnerPing(bc) {
|
|
1326
|
+
return {
|
|
1327
|
+
gatewayId: readGatewayId(bc),
|
|
1328
|
+
requestId: readRequestId(bc),
|
|
1329
|
+
ts: bare.readI64(bc)
|
|
1330
|
+
};
|
|
1331
|
+
}
|
|
1332
|
+
function writeToRunnerPing(bc, x) {
|
|
1333
|
+
writeGatewayId(bc, x.gatewayId);
|
|
1334
|
+
writeRequestId(bc, x.requestId);
|
|
1335
|
+
bare.writeI64(bc, x.ts);
|
|
1336
|
+
}
|
|
1337
|
+
function readToRunner(bc) {
|
|
1338
|
+
const offset = bc.offset;
|
|
1339
|
+
const tag = bare.readU8(bc);
|
|
1340
|
+
switch (tag) {
|
|
1341
|
+
case 0:
|
|
1342
|
+
return { tag: "ToRunnerPing", val: readToRunnerPing(bc) };
|
|
1343
|
+
case 1:
|
|
1344
|
+
return { tag: "ToRunnerClose", val: null };
|
|
1345
|
+
case 2:
|
|
1346
|
+
return { tag: "ToClientCommands", val: readToClientCommands(bc) };
|
|
1347
|
+
case 3:
|
|
1348
|
+
return { tag: "ToClientAckEvents", val: readToClientAckEvents(bc) };
|
|
1349
|
+
case 4:
|
|
1350
|
+
return { tag: "ToClientTunnelMessage", val: readToClientTunnelMessage(bc) };
|
|
1351
|
+
default: {
|
|
1352
|
+
bc.offset = offset;
|
|
1353
|
+
throw new bare.BareError(offset, "invalid tag");
|
|
1354
|
+
}
|
|
1355
|
+
}
|
|
1356
|
+
}
|
|
1357
|
+
function writeToRunner(bc, x) {
|
|
1358
|
+
switch (x.tag) {
|
|
1359
|
+
case "ToRunnerPing": {
|
|
1360
|
+
bare.writeU8(bc, 0);
|
|
1361
|
+
writeToRunnerPing(bc, x.val);
|
|
1362
|
+
break;
|
|
1363
|
+
}
|
|
1364
|
+
case "ToRunnerClose": {
|
|
1365
|
+
bare.writeU8(bc, 1);
|
|
1366
|
+
break;
|
|
1367
|
+
}
|
|
1368
|
+
case "ToClientCommands": {
|
|
1369
|
+
bare.writeU8(bc, 2);
|
|
1370
|
+
writeToClientCommands(bc, x.val);
|
|
1371
|
+
break;
|
|
1372
|
+
}
|
|
1373
|
+
case "ToClientAckEvents": {
|
|
1374
|
+
bare.writeU8(bc, 3);
|
|
1375
|
+
writeToClientAckEvents(bc, x.val);
|
|
1376
|
+
break;
|
|
1377
|
+
}
|
|
1378
|
+
case "ToClientTunnelMessage": {
|
|
1379
|
+
bare.writeU8(bc, 4);
|
|
1380
|
+
writeToClientTunnelMessage(bc, x.val);
|
|
1381
|
+
break;
|
|
1382
|
+
}
|
|
1383
|
+
}
|
|
1384
|
+
}
|
|
1385
|
+
function encodeToRunner(x, config) {
|
|
1386
|
+
const fullConfig = config != null ? bare.Config(config) : DEFAULT_CONFIG;
|
|
1387
|
+
const bc = new bare.ByteCursor(
|
|
1388
|
+
new Uint8Array(fullConfig.initialBufferLength),
|
|
1389
|
+
fullConfig
|
|
1390
|
+
);
|
|
1391
|
+
writeToRunner(bc, x);
|
|
1392
|
+
return new Uint8Array(bc.view.buffer, bc.view.byteOffset, bc.offset);
|
|
1393
|
+
}
|
|
1394
|
+
function decodeToRunner(bytes) {
|
|
1395
|
+
const bc = new bare.ByteCursor(bytes, DEFAULT_CONFIG);
|
|
1396
|
+
const result = readToRunner(bc);
|
|
1397
|
+
if (bc.offset < bc.view.byteLength) {
|
|
1398
|
+
throw new bare.BareError(bc.offset, "remaining bytes");
|
|
1399
|
+
}
|
|
1400
|
+
return result;
|
|
1401
|
+
}
|
|
1402
|
+
function readToGatewayPong(bc) {
|
|
1403
|
+
return {
|
|
1404
|
+
requestId: readRequestId(bc),
|
|
1405
|
+
ts: bare.readI64(bc)
|
|
1406
|
+
};
|
|
1407
|
+
}
|
|
1408
|
+
function writeToGatewayPong(bc, x) {
|
|
1409
|
+
writeRequestId(bc, x.requestId);
|
|
1410
|
+
bare.writeI64(bc, x.ts);
|
|
1411
|
+
}
|
|
1412
|
+
function readToGateway(bc) {
|
|
1413
|
+
const offset = bc.offset;
|
|
1414
|
+
const tag = bare.readU8(bc);
|
|
1415
|
+
switch (tag) {
|
|
1416
|
+
case 0:
|
|
1417
|
+
return { tag: "ToGatewayPong", val: readToGatewayPong(bc) };
|
|
1418
|
+
case 1:
|
|
1419
|
+
return { tag: "ToServerTunnelMessage", val: readToServerTunnelMessage(bc) };
|
|
1420
|
+
default: {
|
|
1421
|
+
bc.offset = offset;
|
|
1422
|
+
throw new bare.BareError(offset, "invalid tag");
|
|
1423
|
+
}
|
|
1424
|
+
}
|
|
1425
|
+
}
|
|
1426
|
+
function writeToGateway(bc, x) {
|
|
1427
|
+
switch (x.tag) {
|
|
1428
|
+
case "ToGatewayPong": {
|
|
1429
|
+
bare.writeU8(bc, 0);
|
|
1430
|
+
writeToGatewayPong(bc, x.val);
|
|
1431
|
+
break;
|
|
1432
|
+
}
|
|
1433
|
+
case "ToServerTunnelMessage": {
|
|
1434
|
+
bare.writeU8(bc, 1);
|
|
1435
|
+
writeToServerTunnelMessage(bc, x.val);
|
|
1436
|
+
break;
|
|
1437
|
+
}
|
|
1438
|
+
}
|
|
1439
|
+
}
|
|
1440
|
+
function encodeToGateway(x, config) {
|
|
1441
|
+
const fullConfig = config != null ? bare.Config(config) : DEFAULT_CONFIG;
|
|
1442
|
+
const bc = new bare.ByteCursor(
|
|
1443
|
+
new Uint8Array(fullConfig.initialBufferLength),
|
|
1444
|
+
fullConfig
|
|
1445
|
+
);
|
|
1446
|
+
writeToGateway(bc, x);
|
|
1447
|
+
return new Uint8Array(bc.view.buffer, bc.view.byteOffset, bc.offset);
|
|
1448
|
+
}
|
|
1449
|
+
function decodeToGateway(bytes) {
|
|
1450
|
+
const bc = new bare.ByteCursor(bytes, DEFAULT_CONFIG);
|
|
1451
|
+
const result = readToGateway(bc);
|
|
1452
|
+
if (bc.offset < bc.view.byteLength) {
|
|
1453
|
+
throw new bare.BareError(bc.offset, "remaining bytes");
|
|
1454
|
+
}
|
|
1455
|
+
return result;
|
|
1456
|
+
}
|
|
1457
|
+
function readToServerlessServerInit(bc) {
|
|
1458
|
+
return {
|
|
1459
|
+
runnerId: readId(bc),
|
|
1460
|
+
runnerProtocolVersion: bare.readU16(bc)
|
|
1461
|
+
};
|
|
1462
|
+
}
|
|
1463
|
+
function writeToServerlessServerInit(bc, x) {
|
|
1464
|
+
writeId(bc, x.runnerId);
|
|
1465
|
+
bare.writeU16(bc, x.runnerProtocolVersion);
|
|
1466
|
+
}
|
|
1467
|
+
function readToServerlessServer(bc) {
|
|
1468
|
+
const offset = bc.offset;
|
|
1469
|
+
const tag = bare.readU8(bc);
|
|
1470
|
+
switch (tag) {
|
|
1471
|
+
case 0:
|
|
1472
|
+
return { tag: "ToServerlessServerInit", val: readToServerlessServerInit(bc) };
|
|
1473
|
+
default: {
|
|
1474
|
+
bc.offset = offset;
|
|
1475
|
+
throw new bare.BareError(offset, "invalid tag");
|
|
1476
|
+
}
|
|
1477
|
+
}
|
|
1478
|
+
}
|
|
1479
|
+
function writeToServerlessServer(bc, x) {
|
|
1480
|
+
switch (x.tag) {
|
|
1481
|
+
case "ToServerlessServerInit": {
|
|
1482
|
+
bare.writeU8(bc, 0);
|
|
1483
|
+
writeToServerlessServerInit(bc, x.val);
|
|
1484
|
+
break;
|
|
1485
|
+
}
|
|
1486
|
+
}
|
|
1487
|
+
}
|
|
1488
|
+
function encodeToServerlessServer(x, config) {
|
|
1489
|
+
const fullConfig = config != null ? bare.Config(config) : DEFAULT_CONFIG;
|
|
1490
|
+
const bc = new bare.ByteCursor(
|
|
1491
|
+
new Uint8Array(fullConfig.initialBufferLength),
|
|
1492
|
+
fullConfig
|
|
1493
|
+
);
|
|
1494
|
+
writeToServerlessServer(bc, x);
|
|
1495
|
+
return new Uint8Array(bc.view.buffer, bc.view.byteOffset, bc.offset);
|
|
1496
|
+
}
|
|
1497
|
+
function decodeToServerlessServer(bytes) {
|
|
1498
|
+
const bc = new bare.ByteCursor(bytes, DEFAULT_CONFIG);
|
|
1499
|
+
const result = readToServerlessServer(bc);
|
|
1500
|
+
if (bc.offset < bc.view.byteLength) {
|
|
1501
|
+
throw new bare.BareError(bc.offset, "remaining bytes");
|
|
1502
|
+
}
|
|
1503
|
+
return result;
|
|
1504
|
+
}
|
|
1505
|
+
function assert(condition, message) {
|
|
1506
|
+
if (!condition) throw new Error(message ?? "Assertion failed");
|
|
1507
|
+
}
|
|
1508
|
+
export {
|
|
1509
|
+
StopCode,
|
|
1510
|
+
decodeActorCommandKeyData,
|
|
1511
|
+
decodeToClient,
|
|
1512
|
+
decodeToGateway,
|
|
1513
|
+
decodeToRunner,
|
|
1514
|
+
decodeToServer,
|
|
1515
|
+
decodeToServerlessServer,
|
|
1516
|
+
encodeActorCommandKeyData,
|
|
1517
|
+
encodeToClient,
|
|
1518
|
+
encodeToGateway,
|
|
1519
|
+
encodeToRunner,
|
|
1520
|
+
encodeToServer,
|
|
1521
|
+
encodeToServerlessServer,
|
|
1522
|
+
readActorCheckpoint,
|
|
1523
|
+
readActorCommandKeyData,
|
|
1524
|
+
readActorConfig,
|
|
1525
|
+
readActorIntent,
|
|
1526
|
+
readActorName,
|
|
1527
|
+
readActorState,
|
|
1528
|
+
readActorStateStopped,
|
|
1529
|
+
readCommand,
|
|
1530
|
+
readCommandStartActor,
|
|
1531
|
+
readCommandWrapper,
|
|
1532
|
+
readEvent,
|
|
1533
|
+
readEventActorIntent,
|
|
1534
|
+
readEventActorSetAlarm,
|
|
1535
|
+
readEventActorStateUpdate,
|
|
1536
|
+
readEventWrapper,
|
|
1537
|
+
readGatewayId,
|
|
1538
|
+
readHibernatingRequest,
|
|
1539
|
+
readId,
|
|
1540
|
+
readJson,
|
|
1541
|
+
readKvDeleteRequest,
|
|
1542
|
+
readKvErrorResponse,
|
|
1543
|
+
readKvGetRequest,
|
|
1544
|
+
readKvGetResponse,
|
|
1545
|
+
readKvKey,
|
|
1546
|
+
readKvListPrefixQuery,
|
|
1547
|
+
readKvListQuery,
|
|
1548
|
+
readKvListRangeQuery,
|
|
1549
|
+
readKvListRequest,
|
|
1550
|
+
readKvListResponse,
|
|
1551
|
+
readKvMetadata,
|
|
1552
|
+
readKvPutRequest,
|
|
1553
|
+
readKvRequestData,
|
|
1554
|
+
readKvResponseData,
|
|
1555
|
+
readKvValue,
|
|
1556
|
+
readMessageId,
|
|
1557
|
+
readMessageIndex,
|
|
1558
|
+
readProtocolMetadata,
|
|
1559
|
+
readRequestId,
|
|
1560
|
+
readStopCode,
|
|
1561
|
+
readToClient,
|
|
1562
|
+
readToClientAckEvents,
|
|
1563
|
+
readToClientCommands,
|
|
1564
|
+
readToClientInit,
|
|
1565
|
+
readToClientKvResponse,
|
|
1566
|
+
readToClientPing,
|
|
1567
|
+
readToClientRequestChunk,
|
|
1568
|
+
readToClientRequestStart,
|
|
1569
|
+
readToClientTunnelMessage,
|
|
1570
|
+
readToClientTunnelMessageKind,
|
|
1571
|
+
readToClientWebSocketClose,
|
|
1572
|
+
readToClientWebSocketMessage,
|
|
1573
|
+
readToClientWebSocketOpen,
|
|
1574
|
+
readToGateway,
|
|
1575
|
+
readToGatewayPong,
|
|
1576
|
+
readToRunner,
|
|
1577
|
+
readToRunnerPing,
|
|
1578
|
+
readToServer,
|
|
1579
|
+
readToServerAckCommands,
|
|
1580
|
+
readToServerEvents,
|
|
1581
|
+
readToServerInit,
|
|
1582
|
+
readToServerKvRequest,
|
|
1583
|
+
readToServerPong,
|
|
1584
|
+
readToServerResponseChunk,
|
|
1585
|
+
readToServerResponseStart,
|
|
1586
|
+
readToServerTunnelMessage,
|
|
1587
|
+
readToServerTunnelMessageKind,
|
|
1588
|
+
readToServerWebSocketClose,
|
|
1589
|
+
readToServerWebSocketMessage,
|
|
1590
|
+
readToServerWebSocketMessageAck,
|
|
1591
|
+
readToServerWebSocketOpen,
|
|
1592
|
+
readToServerlessServer,
|
|
1593
|
+
readToServerlessServerInit,
|
|
1594
|
+
writeActorCheckpoint,
|
|
1595
|
+
writeActorCommandKeyData,
|
|
1596
|
+
writeActorConfig,
|
|
1597
|
+
writeActorIntent,
|
|
1598
|
+
writeActorName,
|
|
1599
|
+
writeActorState,
|
|
1600
|
+
writeActorStateStopped,
|
|
1601
|
+
writeCommand,
|
|
1602
|
+
writeCommandStartActor,
|
|
1603
|
+
writeCommandWrapper,
|
|
1604
|
+
writeEvent,
|
|
1605
|
+
writeEventActorIntent,
|
|
1606
|
+
writeEventActorSetAlarm,
|
|
1607
|
+
writeEventActorStateUpdate,
|
|
1608
|
+
writeEventWrapper,
|
|
1609
|
+
writeGatewayId,
|
|
1610
|
+
writeHibernatingRequest,
|
|
1611
|
+
writeId,
|
|
1612
|
+
writeJson,
|
|
1613
|
+
writeKvDeleteRequest,
|
|
1614
|
+
writeKvErrorResponse,
|
|
1615
|
+
writeKvGetRequest,
|
|
1616
|
+
writeKvGetResponse,
|
|
1617
|
+
writeKvKey,
|
|
1618
|
+
writeKvListPrefixQuery,
|
|
1619
|
+
writeKvListQuery,
|
|
1620
|
+
writeKvListRangeQuery,
|
|
1621
|
+
writeKvListRequest,
|
|
1622
|
+
writeKvListResponse,
|
|
1623
|
+
writeKvMetadata,
|
|
1624
|
+
writeKvPutRequest,
|
|
1625
|
+
writeKvRequestData,
|
|
1626
|
+
writeKvResponseData,
|
|
1627
|
+
writeKvValue,
|
|
1628
|
+
writeMessageId,
|
|
1629
|
+
writeMessageIndex,
|
|
1630
|
+
writeProtocolMetadata,
|
|
1631
|
+
writeRequestId,
|
|
1632
|
+
writeStopCode,
|
|
1633
|
+
writeToClient,
|
|
1634
|
+
writeToClientAckEvents,
|
|
1635
|
+
writeToClientCommands,
|
|
1636
|
+
writeToClientInit,
|
|
1637
|
+
writeToClientKvResponse,
|
|
1638
|
+
writeToClientPing,
|
|
1639
|
+
writeToClientRequestChunk,
|
|
1640
|
+
writeToClientRequestStart,
|
|
1641
|
+
writeToClientTunnelMessage,
|
|
1642
|
+
writeToClientTunnelMessageKind,
|
|
1643
|
+
writeToClientWebSocketClose,
|
|
1644
|
+
writeToClientWebSocketMessage,
|
|
1645
|
+
writeToClientWebSocketOpen,
|
|
1646
|
+
writeToGateway,
|
|
1647
|
+
writeToGatewayPong,
|
|
1648
|
+
writeToRunner,
|
|
1649
|
+
writeToRunnerPing,
|
|
1650
|
+
writeToServer,
|
|
1651
|
+
writeToServerAckCommands,
|
|
1652
|
+
writeToServerEvents,
|
|
1653
|
+
writeToServerInit,
|
|
1654
|
+
writeToServerKvRequest,
|
|
1655
|
+
writeToServerPong,
|
|
1656
|
+
writeToServerResponseChunk,
|
|
1657
|
+
writeToServerResponseStart,
|
|
1658
|
+
writeToServerTunnelMessage,
|
|
1659
|
+
writeToServerTunnelMessageKind,
|
|
1660
|
+
writeToServerWebSocketClose,
|
|
1661
|
+
writeToServerWebSocketMessage,
|
|
1662
|
+
writeToServerWebSocketMessageAck,
|
|
1663
|
+
writeToServerWebSocketOpen,
|
|
1664
|
+
writeToServerlessServer,
|
|
1665
|
+
writeToServerlessServerInit
|
|
1666
|
+
};
|
|
1667
|
+
//# sourceMappingURL=index.js.map
|