rivetkit 2.3.0-rc.9 → 2.3.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/browser/client.d.ts +498 -62
- package/dist/browser/client.js +227 -171
- package/dist/browser/client.js.map +1 -1
- package/dist/browser/inspector/client.js +50 -20
- package/dist/browser/inspector/client.js.map +1 -1
- package/dist/tsup/actor/errors.cjs +2 -2
- package/dist/tsup/actor/errors.d.cts +1 -1
- package/dist/tsup/actor/errors.d.ts +1 -1
- package/dist/tsup/actor/errors.js +1 -1
- package/dist/tsup/agent-os/index.cjs +2163 -2087
- package/dist/tsup/agent-os/index.cjs.map +1 -1
- package/dist/tsup/agent-os/index.d.cts +496 -69
- package/dist/tsup/agent-os/index.d.ts +496 -69
- package/dist/tsup/agent-os/index.js +2163 -2087
- package/dist/tsup/agent-os/index.js.map +1 -1
- package/dist/tsup/{chunk-W7EYSYVI.js → chunk-2OTRTA3J.js} +134 -20
- package/dist/tsup/chunk-2OTRTA3J.js.map +1 -0
- package/dist/tsup/{chunk-VJFRBJVQ.cjs → chunk-3677IIOV.cjs} +138 -24
- package/dist/tsup/chunk-3677IIOV.cjs.map +1 -0
- package/dist/tsup/{chunk-4CGA6QJO.cjs → chunk-47HHIEXH.cjs} +24 -9
- package/dist/tsup/chunk-47HHIEXH.cjs.map +1 -0
- package/dist/tsup/{chunk-F3Q5BFQ6.js → chunk-4JDSFJS5.js} +66 -79
- package/dist/tsup/chunk-4JDSFJS5.js.map +1 -0
- package/dist/tsup/{chunk-GVTOE34S.cjs → chunk-7QKCIVAY.cjs} +222 -235
- package/dist/tsup/chunk-7QKCIVAY.cjs.map +1 -0
- package/dist/tsup/{chunk-CPA4Y3RG.cjs → chunk-B6VUNZUD.cjs} +10 -10
- package/dist/tsup/chunk-B6VUNZUD.cjs.map +1 -0
- package/dist/tsup/{chunk-H37XQU3I.js → chunk-BEI24WTI.js} +2 -2
- package/dist/tsup/{chunk-KIWH5H3K.js → chunk-BRP62GZC.js} +3 -3
- package/dist/tsup/chunk-BRP62GZC.js.map +1 -0
- package/dist/tsup/{chunk-T6YVRM4K.js → chunk-DPIMKYNB.js} +63 -2
- package/dist/tsup/chunk-DPIMKYNB.js.map +1 -0
- package/dist/tsup/{chunk-Y5NSCZA2.cjs → chunk-DXXJPH55.cjs} +44 -15
- package/dist/tsup/chunk-DXXJPH55.cjs.map +1 -0
- package/dist/tsup/{chunk-3YY5S6TV.js → chunk-HXUEHHJF.js} +2 -2
- package/dist/tsup/chunk-HXUEHHJF.js.map +1 -0
- package/dist/tsup/{chunk-4WPEZBK4.cjs → chunk-I4LN3FNT.cjs} +10 -10
- package/dist/tsup/chunk-I4LN3FNT.cjs.map +1 -0
- package/dist/tsup/{chunk-PCBNKI2J.js → chunk-JZ7TWV65.js} +1 -1
- package/dist/tsup/chunk-JZ7TWV65.js.map +1 -0
- package/dist/tsup/{chunk-QAZLM4WT.cjs → chunk-KORQB2IR.cjs} +3 -3
- package/dist/tsup/{chunk-QAZLM4WT.cjs.map → chunk-KORQB2IR.cjs.map} +1 -1
- package/dist/tsup/{chunk-MALSPBAF.cjs → chunk-LVTBW2RE.cjs} +3 -3
- package/dist/tsup/{chunk-MALSPBAF.cjs.map → chunk-LVTBW2RE.cjs.map} +1 -1
- package/dist/tsup/{chunk-H7P7WR2Y.js → chunk-MEHBWPLJ.js} +6 -6
- package/dist/tsup/chunk-MEHBWPLJ.js.map +1 -0
- package/dist/tsup/{chunk-WQ4HNA4W.cjs → chunk-NIY3RSPX.cjs} +64 -3
- package/dist/tsup/chunk-NIY3RSPX.cjs.map +1 -0
- package/dist/tsup/{chunk-MMMEZM5J.js → chunk-P2GNQ4RN.js} +4 -4
- package/dist/tsup/chunk-P2GNQ4RN.js.map +1 -0
- package/dist/tsup/{chunk-KJTA3ATT.js → chunk-UMZVD6DQ.js} +22 -7
- package/dist/tsup/chunk-UMZVD6DQ.js.map +1 -0
- package/dist/tsup/{chunk-LD5YASJU.cjs → chunk-VE2X4KMG.cjs} +2 -2
- package/dist/tsup/{chunk-LD5YASJU.cjs.map → chunk-VE2X4KMG.cjs.map} +1 -1
- package/dist/tsup/{chunk-VRCIXJRN.js → chunk-VTTFNQQI.js} +36 -7
- package/dist/tsup/chunk-VTTFNQQI.js.map +1 -0
- package/dist/tsup/{chunk-2NDZ7JCR.cjs → chunk-ZA7FLHKH.cjs} +1 -1
- package/dist/tsup/chunk-ZA7FLHKH.cjs.map +1 -0
- package/dist/tsup/client/mod.cjs +9 -9
- package/dist/tsup/client/mod.d.cts +5 -5
- package/dist/tsup/client/mod.d.ts +5 -5
- package/dist/tsup/client/mod.js +8 -8
- package/dist/tsup/common/log.cjs +3 -3
- package/dist/tsup/common/log.js +2 -2
- package/dist/tsup/common/websocket.cjs +4 -4
- package/dist/tsup/common/websocket.js +3 -3
- package/dist/tsup/{config-0Ta55UV0.d.ts → config-BxWAw3iH.d.ts} +529 -23
- package/dist/tsup/{config-Ca8dN4cS.d.cts → config-CZQQ-mso.d.cts} +529 -23
- package/dist/tsup/{config-CxjGYf4K.d.cts → config-D49x8NpL.d.cts} +1 -2
- package/dist/tsup/{config-CxjGYf4K.d.ts → config-D49x8NpL.d.ts} +1 -2
- package/dist/tsup/{context-B_IWbWne.d.ts → context-Bw7xq8w3.d.cts} +8 -8
- package/dist/tsup/{context-CUrQ9MHc.d.cts → context-D8QA76sV.d.ts} +8 -8
- package/dist/tsup/db/drizzle.cjs +3 -3
- package/dist/tsup/db/drizzle.d.cts +1 -1
- package/dist/tsup/db/drizzle.d.ts +1 -1
- package/dist/tsup/db/drizzle.js +1 -1
- package/dist/tsup/db/mod.cjs +2 -2
- package/dist/tsup/db/mod.d.cts +2 -2
- package/dist/tsup/db/mod.d.ts +2 -2
- package/dist/tsup/db/mod.js +1 -1
- package/dist/tsup/dynamic/mod.cjs +24 -0
- package/dist/tsup/dynamic/mod.cjs.map +1 -0
- package/dist/tsup/dynamic/mod.d.cts +37 -0
- package/dist/tsup/dynamic/mod.d.ts +37 -0
- package/dist/tsup/dynamic/mod.js +24 -0
- package/dist/tsup/dynamic/mod.js.map +1 -0
- package/dist/tsup/inspector/mod.cjs +6 -6
- package/dist/tsup/inspector/mod.js +5 -5
- package/dist/tsup/inspector-tab/mod.cjs +173 -0
- package/dist/tsup/inspector-tab/mod.cjs.map +1 -0
- package/dist/tsup/inspector-tab/mod.d.cts +250 -0
- package/dist/tsup/inspector-tab/mod.d.ts +250 -0
- package/dist/tsup/inspector-tab/mod.js +173 -0
- package/dist/tsup/inspector-tab/mod.js.map +1 -0
- package/dist/tsup/mod.cjs +730 -336
- package/dist/tsup/mod.cjs.map +1 -1
- package/dist/tsup/mod.d.cts +5 -5
- package/dist/tsup/mod.d.ts +5 -5
- package/dist/tsup/mod.js +633 -239
- package/dist/tsup/mod.js.map +1 -1
- package/dist/tsup/test/mod.cjs +21 -18
- package/dist/tsup/test/mod.cjs.map +1 -1
- package/dist/tsup/test/mod.d.cts +4 -4
- package/dist/tsup/test/mod.d.ts +4 -4
- package/dist/tsup/test/mod.js +18 -15
- package/dist/tsup/test/mod.js.map +1 -1
- package/dist/tsup/{utils-DVekpm4I.d.cts → utils-DQosb24I.d.cts} +1 -1
- package/dist/tsup/{utils-DVekpm4I.d.ts → utils-DQosb24I.d.ts} +1 -1
- package/dist/tsup/utils.cjs +3 -3
- package/dist/tsup/utils.d.cts +1 -1
- package/dist/tsup/utils.d.ts +1 -1
- package/dist/tsup/utils.js +2 -2
- package/dist/tsup/workflow/mod.cjs +307 -282
- package/dist/tsup/workflow/mod.cjs.map +1 -1
- package/dist/tsup/workflow/mod.d.cts +6 -6
- package/dist/tsup/workflow/mod.d.ts +6 -6
- package/dist/tsup/workflow/mod.js +501 -476
- package/dist/tsup/workflow/mod.js.map +1 -1
- package/package.json +32 -11
- package/src/actor/config.ts +159 -51
- package/src/actor/contexts/index.ts +7 -2
- package/src/actor/definition.ts +17 -19
- package/src/actor/driver.ts +3 -3
- package/src/actor/errors.ts +9 -3
- package/src/actor/instance/mod.ts +26 -34
- package/src/actor/keys.ts +1 -1
- package/src/actor/mod.ts +22 -20
- package/src/actor/schema.ts +2 -2
- package/src/agent-os/actor/index.ts +38 -18
- package/src/agent-os/actor/preview.ts +1 -2
- package/src/agent-os/actor/session.ts +2 -2
- package/src/agent-os/config.ts +1 -1
- package/src/agent-os/fs/database-vfs.ts +1 -1
- package/src/agent-os/index.ts +16 -15
- package/src/client/actor-common.ts +87 -54
- package/src/client/actor-conn.ts +8 -36
- package/src/client/actor-handle.ts +69 -51
- package/src/client/actor-query.ts +5 -5
- package/src/client/errors.ts +1 -1
- package/src/client/lifecycle-errors.ts +2 -4
- package/src/client/query.ts +1 -1
- package/src/client/queue.ts +8 -3
- package/src/client/raw-utils.ts +8 -6
- package/src/client/resolve-gateway-target.ts +1 -1
- package/src/client/utils.ts +2 -7
- package/src/common/actor-websocket.ts +3 -1
- package/src/common/bare/actor-persist/v1.ts +205 -163
- package/src/common/bare/actor-persist/v2.ts +265 -213
- package/src/common/bare/actor-persist/v3.ts +176 -172
- package/src/common/bare/actor-persist/v4.ts +254 -253
- package/src/common/bare/transport/v1.ts +659 -543
- package/src/common/client-protocol-versioned.ts +66 -64
- package/src/common/database/config.ts +2 -8
- package/src/common/database/native-database.ts +1 -1
- package/src/common/database/shared.ts +1 -0
- package/src/common/encoding.ts +250 -16
- package/src/common/engine.ts +28 -1
- package/src/common/eventsource.ts +1 -1
- package/src/common/inline-websocket-adapter.ts +14 -13
- package/src/common/log.ts +1 -0
- package/src/common/router.ts +13 -17
- package/src/common/utils.ts +1 -150
- package/src/common/websocket-interface.ts +1 -1
- package/src/db/mod.ts +1 -1
- package/src/devtools-loader/index.ts +4 -7
- package/src/devtools-loader/serve-devtools.ts +26 -0
- package/src/drivers/engine/actor-driver.ts +58 -56
- package/src/dynamic/instance.ts +32 -0
- package/src/dynamic/internal.ts +50 -0
- package/src/dynamic/isolate-runtime.ts +66 -0
- package/src/dynamic/mod.ts +32 -0
- package/src/engine-client/actor-http-client.ts +3 -3
- package/src/engine-client/actor-websocket-client.ts +6 -5
- package/src/engine-client/api-endpoints.ts +51 -2
- package/src/engine-client/api-utils.ts +2 -2
- package/src/engine-client/driver.ts +1 -1
- package/src/engine-client/mod.ts +6 -3
- package/src/engine-client/ws-proxy.ts +9 -4
- package/src/inspector/client.browser.ts +5 -11
- package/src/inspector/mod.ts +1 -3
- package/src/inspector-tab/mod.ts +315 -0
- package/src/registry/config/envoy.ts +1 -2
- package/src/registry/config/index.ts +40 -16
- package/src/registry/index.ts +154 -74
- package/src/registry/napi-runtime.ts +13 -2
- package/src/registry/native-validation.ts +10 -12
- package/src/registry/native.ts +367 -181
- package/src/registry/process-metrics.ts +250 -0
- package/src/registry/runtime.ts +41 -1
- package/src/registry/wasm-runtime.ts +18 -2
- package/src/registry/write-through-proxy.ts +40 -0
- package/src/serde.ts +2 -2
- package/src/serverless/configure.ts +18 -7
- package/src/test/mod.ts +11 -8
- package/src/utils/endpoint-parser.ts +1 -1
- package/src/utils/env-vars.ts +6 -0
- package/src/utils/router.ts +1 -1
- package/src/utils/serve.ts +4 -5
- package/src/utils.ts +1 -2
- package/src/workflow/context.ts +61 -33
- package/src/workflow/driver.ts +4 -6
- package/src/workflow/inspector.ts +4 -3
- package/src/workflow/mod.ts +15 -17
- package/dist/tsup/chunk-2NDZ7JCR.cjs.map +0 -1
- package/dist/tsup/chunk-3YY5S6TV.js.map +0 -1
- package/dist/tsup/chunk-4CGA6QJO.cjs.map +0 -1
- package/dist/tsup/chunk-4WPEZBK4.cjs.map +0 -1
- package/dist/tsup/chunk-CPA4Y3RG.cjs.map +0 -1
- package/dist/tsup/chunk-F3Q5BFQ6.js.map +0 -1
- package/dist/tsup/chunk-GVTOE34S.cjs.map +0 -1
- package/dist/tsup/chunk-H7P7WR2Y.js.map +0 -1
- package/dist/tsup/chunk-KIWH5H3K.js.map +0 -1
- package/dist/tsup/chunk-KJTA3ATT.js.map +0 -1
- package/dist/tsup/chunk-MMMEZM5J.js.map +0 -1
- package/dist/tsup/chunk-PCBNKI2J.js.map +0 -1
- package/dist/tsup/chunk-T6YVRM4K.js.map +0 -1
- package/dist/tsup/chunk-VJFRBJVQ.cjs.map +0 -1
- package/dist/tsup/chunk-VRCIXJRN.js.map +0 -1
- package/dist/tsup/chunk-W7EYSYVI.js.map +0 -1
- package/dist/tsup/chunk-WQ4HNA4W.cjs.map +0 -1
- package/dist/tsup/chunk-Y5NSCZA2.cjs.map +0 -1
- /package/dist/tsup/{chunk-H37XQU3I.js.map → chunk-BEI24WTI.js.map} +0 -0
|
@@ -1,225 +1,267 @@
|
|
|
1
1
|
// Vendored BARE codec. Keep the wire format compatible with the existing runtime.
|
|
2
|
-
import * as bare from "@rivetkit/bare-ts"
|
|
2
|
+
import * as bare from "@rivetkit/bare-ts";
|
|
3
3
|
|
|
4
|
-
const config = /* @__PURE__ */ bare.Config({})
|
|
4
|
+
const config = /* @__PURE__ */ bare.Config({});
|
|
5
5
|
|
|
6
|
-
export type u64 = bigint
|
|
6
|
+
export type u64 = bigint;
|
|
7
7
|
|
|
8
8
|
export type PersistedSubscription = {
|
|
9
|
-
|
|
9
|
+
readonly eventName: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export function readPersistedSubscription(
|
|
13
|
+
bc: bare.ByteCursor,
|
|
14
|
+
): PersistedSubscription {
|
|
15
|
+
return {
|
|
16
|
+
eventName: bare.readString(bc),
|
|
17
|
+
};
|
|
10
18
|
}
|
|
11
19
|
|
|
12
|
-
export function
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
export function writePersistedSubscription(bc: bare.ByteCursor, x: PersistedSubscription): void {
|
|
19
|
-
bare.writeString(bc, x.eventName)
|
|
20
|
+
export function writePersistedSubscription(
|
|
21
|
+
bc: bare.ByteCursor,
|
|
22
|
+
x: PersistedSubscription,
|
|
23
|
+
): void {
|
|
24
|
+
bare.writeString(bc, x.eventName);
|
|
20
25
|
}
|
|
21
26
|
|
|
22
27
|
function read0(bc: bare.ByteCursor): readonly PersistedSubscription[] {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
const len = bare.readUintSafe(bc);
|
|
29
|
+
if (len === 0) {
|
|
30
|
+
return [];
|
|
31
|
+
}
|
|
32
|
+
const result = [readPersistedSubscription(bc)];
|
|
33
|
+
for (let i = 1; i < len; i++) {
|
|
34
|
+
result[i] = readPersistedSubscription(bc);
|
|
35
|
+
}
|
|
36
|
+
return result;
|
|
30
37
|
}
|
|
31
38
|
|
|
32
|
-
function write0(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
39
|
+
function write0(
|
|
40
|
+
bc: bare.ByteCursor,
|
|
41
|
+
x: readonly PersistedSubscription[],
|
|
42
|
+
): void {
|
|
43
|
+
bare.writeUintSafe(bc, x.length);
|
|
44
|
+
for (let i = 0; i < x.length; i++) {
|
|
45
|
+
writePersistedSubscription(bc, x[i]);
|
|
46
|
+
}
|
|
37
47
|
}
|
|
38
48
|
|
|
39
49
|
export type PersistedConnection = {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export function readPersistedConnection(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
50
|
+
readonly id: string;
|
|
51
|
+
readonly token: string;
|
|
52
|
+
readonly parameters: ArrayBuffer;
|
|
53
|
+
readonly state: ArrayBuffer;
|
|
54
|
+
readonly subscriptions: readonly PersistedSubscription[];
|
|
55
|
+
readonly lastSeen: u64;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export function readPersistedConnection(
|
|
59
|
+
bc: bare.ByteCursor,
|
|
60
|
+
): PersistedConnection {
|
|
61
|
+
return {
|
|
62
|
+
id: bare.readString(bc),
|
|
63
|
+
token: bare.readString(bc),
|
|
64
|
+
parameters: bare.readData(bc),
|
|
65
|
+
state: bare.readData(bc),
|
|
66
|
+
subscriptions: read0(bc),
|
|
67
|
+
lastSeen: bare.readU64(bc),
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function writePersistedConnection(
|
|
72
|
+
bc: bare.ByteCursor,
|
|
73
|
+
x: PersistedConnection,
|
|
74
|
+
): void {
|
|
75
|
+
bare.writeString(bc, x.id);
|
|
76
|
+
bare.writeString(bc, x.token);
|
|
77
|
+
bare.writeData(bc, x.parameters);
|
|
78
|
+
bare.writeData(bc, x.state);
|
|
79
|
+
write0(bc, x.subscriptions);
|
|
80
|
+
bare.writeU64(bc, x.lastSeen);
|
|
66
81
|
}
|
|
67
82
|
|
|
68
83
|
function read1(bc: bare.ByteCursor): ArrayBuffer | null {
|
|
69
|
-
|
|
70
|
-
? bare.readData(bc)
|
|
71
|
-
: null
|
|
84
|
+
return bare.readBool(bc) ? bare.readData(bc) : null;
|
|
72
85
|
}
|
|
73
86
|
|
|
74
87
|
function write1(bc: bare.ByteCursor, x: ArrayBuffer | null): void {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
88
|
+
bare.writeBool(bc, x !== null);
|
|
89
|
+
if (x !== null) {
|
|
90
|
+
bare.writeData(bc, x);
|
|
91
|
+
}
|
|
79
92
|
}
|
|
80
93
|
|
|
81
94
|
export type GenericPersistedScheduleEvent = {
|
|
82
|
-
|
|
83
|
-
|
|
95
|
+
readonly action: string;
|
|
96
|
+
readonly args: ArrayBuffer | null;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
export function readGenericPersistedScheduleEvent(
|
|
100
|
+
bc: bare.ByteCursor,
|
|
101
|
+
): GenericPersistedScheduleEvent {
|
|
102
|
+
return {
|
|
103
|
+
action: bare.readString(bc),
|
|
104
|
+
args: read1(bc),
|
|
105
|
+
};
|
|
84
106
|
}
|
|
85
107
|
|
|
86
|
-
export function
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
108
|
+
export function writeGenericPersistedScheduleEvent(
|
|
109
|
+
bc: bare.ByteCursor,
|
|
110
|
+
x: GenericPersistedScheduleEvent,
|
|
111
|
+
): void {
|
|
112
|
+
bare.writeString(bc, x.action);
|
|
113
|
+
write1(bc, x.args);
|
|
91
114
|
}
|
|
92
115
|
|
|
93
|
-
export
|
|
94
|
-
|
|
95
|
-
|
|
116
|
+
export type PersistedScheduleEventKind = {
|
|
117
|
+
readonly tag: "GenericPersistedScheduleEvent";
|
|
118
|
+
readonly val: GenericPersistedScheduleEvent;
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
export function readPersistedScheduleEventKind(
|
|
122
|
+
bc: bare.ByteCursor,
|
|
123
|
+
): PersistedScheduleEventKind {
|
|
124
|
+
const offset = bc.offset;
|
|
125
|
+
const tag = bare.readU8(bc);
|
|
126
|
+
switch (tag) {
|
|
127
|
+
case 0:
|
|
128
|
+
return {
|
|
129
|
+
tag: "GenericPersistedScheduleEvent",
|
|
130
|
+
val: readGenericPersistedScheduleEvent(bc),
|
|
131
|
+
};
|
|
132
|
+
default: {
|
|
133
|
+
bc.offset = offset;
|
|
134
|
+
throw new bare.BareError(offset, "invalid tag");
|
|
135
|
+
}
|
|
136
|
+
}
|
|
96
137
|
}
|
|
97
138
|
|
|
98
|
-
export
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
throw new bare.BareError(offset, "invalid tag")
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
export function writePersistedScheduleEventKind(bc: bare.ByteCursor, x: PersistedScheduleEventKind): void {
|
|
115
|
-
switch (x.tag) {
|
|
116
|
-
case "GenericPersistedScheduleEvent": {
|
|
117
|
-
bare.writeU8(bc, 0)
|
|
118
|
-
writeGenericPersistedScheduleEvent(bc, x.val)
|
|
119
|
-
break
|
|
120
|
-
}
|
|
121
|
-
}
|
|
139
|
+
export function writePersistedScheduleEventKind(
|
|
140
|
+
bc: bare.ByteCursor,
|
|
141
|
+
x: PersistedScheduleEventKind,
|
|
142
|
+
): void {
|
|
143
|
+
switch (x.tag) {
|
|
144
|
+
case "GenericPersistedScheduleEvent": {
|
|
145
|
+
bare.writeU8(bc, 0);
|
|
146
|
+
writeGenericPersistedScheduleEvent(bc, x.val);
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
122
150
|
}
|
|
123
151
|
|
|
124
152
|
export type PersistedScheduleEvent = {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
export function readPersistedScheduleEvent(
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
153
|
+
readonly eventId: string;
|
|
154
|
+
readonly timestamp: u64;
|
|
155
|
+
readonly kind: PersistedScheduleEventKind;
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
export function readPersistedScheduleEvent(
|
|
159
|
+
bc: bare.ByteCursor,
|
|
160
|
+
): PersistedScheduleEvent {
|
|
161
|
+
return {
|
|
162
|
+
eventId: bare.readString(bc),
|
|
163
|
+
timestamp: bare.readU64(bc),
|
|
164
|
+
kind: readPersistedScheduleEventKind(bc),
|
|
165
|
+
};
|
|
136
166
|
}
|
|
137
167
|
|
|
138
|
-
export function writePersistedScheduleEvent(
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
168
|
+
export function writePersistedScheduleEvent(
|
|
169
|
+
bc: bare.ByteCursor,
|
|
170
|
+
x: PersistedScheduleEvent,
|
|
171
|
+
): void {
|
|
172
|
+
bare.writeString(bc, x.eventId);
|
|
173
|
+
bare.writeU64(bc, x.timestamp);
|
|
174
|
+
writePersistedScheduleEventKind(bc, x.kind);
|
|
142
175
|
}
|
|
143
176
|
|
|
144
177
|
function read2(bc: bare.ByteCursor): readonly PersistedConnection[] {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
178
|
+
const len = bare.readUintSafe(bc);
|
|
179
|
+
if (len === 0) {
|
|
180
|
+
return [];
|
|
181
|
+
}
|
|
182
|
+
const result = [readPersistedConnection(bc)];
|
|
183
|
+
for (let i = 1; i < len; i++) {
|
|
184
|
+
result[i] = readPersistedConnection(bc);
|
|
185
|
+
}
|
|
186
|
+
return result;
|
|
152
187
|
}
|
|
153
188
|
|
|
154
189
|
function write2(bc: bare.ByteCursor, x: readonly PersistedConnection[]): void {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
190
|
+
bare.writeUintSafe(bc, x.length);
|
|
191
|
+
for (let i = 0; i < x.length; i++) {
|
|
192
|
+
writePersistedConnection(bc, x[i]);
|
|
193
|
+
}
|
|
159
194
|
}
|
|
160
195
|
|
|
161
196
|
function read3(bc: bare.ByteCursor): readonly PersistedScheduleEvent[] {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
197
|
+
const len = bare.readUintSafe(bc);
|
|
198
|
+
if (len === 0) {
|
|
199
|
+
return [];
|
|
200
|
+
}
|
|
201
|
+
const result = [readPersistedScheduleEvent(bc)];
|
|
202
|
+
for (let i = 1; i < len; i++) {
|
|
203
|
+
result[i] = readPersistedScheduleEvent(bc);
|
|
204
|
+
}
|
|
205
|
+
return result;
|
|
169
206
|
}
|
|
170
207
|
|
|
171
|
-
function write3(
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
208
|
+
function write3(
|
|
209
|
+
bc: bare.ByteCursor,
|
|
210
|
+
x: readonly PersistedScheduleEvent[],
|
|
211
|
+
): void {
|
|
212
|
+
bare.writeUintSafe(bc, x.length);
|
|
213
|
+
for (let i = 0; i < x.length; i++) {
|
|
214
|
+
writePersistedScheduleEvent(bc, x[i]);
|
|
215
|
+
}
|
|
176
216
|
}
|
|
177
217
|
|
|
178
218
|
export type PersistedActor = {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
}
|
|
219
|
+
readonly input: ArrayBuffer | null;
|
|
220
|
+
readonly hasInitialized: boolean;
|
|
221
|
+
readonly state: ArrayBuffer;
|
|
222
|
+
readonly connections: readonly PersistedConnection[];
|
|
223
|
+
readonly scheduledEvents: readonly PersistedScheduleEvent[];
|
|
224
|
+
};
|
|
185
225
|
|
|
186
226
|
export function readPersistedActor(bc: bare.ByteCursor): PersistedActor {
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
227
|
+
return {
|
|
228
|
+
input: read1(bc),
|
|
229
|
+
hasInitialized: bare.readBool(bc),
|
|
230
|
+
state: bare.readData(bc),
|
|
231
|
+
connections: read2(bc),
|
|
232
|
+
scheduledEvents: read3(bc),
|
|
233
|
+
};
|
|
194
234
|
}
|
|
195
235
|
|
|
196
|
-
export function writePersistedActor(
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
236
|
+
export function writePersistedActor(
|
|
237
|
+
bc: bare.ByteCursor,
|
|
238
|
+
x: PersistedActor,
|
|
239
|
+
): void {
|
|
240
|
+
write1(bc, x.input);
|
|
241
|
+
bare.writeBool(bc, x.hasInitialized);
|
|
242
|
+
bare.writeData(bc, x.state);
|
|
243
|
+
write2(bc, x.connections);
|
|
244
|
+
write3(bc, x.scheduledEvents);
|
|
202
245
|
}
|
|
203
246
|
|
|
204
247
|
export function encodePersistedActor(x: PersistedActor): Uint8Array {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
248
|
+
const bc = new bare.ByteCursor(
|
|
249
|
+
new Uint8Array(config.initialBufferLength),
|
|
250
|
+
config,
|
|
251
|
+
);
|
|
252
|
+
writePersistedActor(bc, x);
|
|
253
|
+
return new Uint8Array(bc.view.buffer, bc.view.byteOffset, bc.offset);
|
|
211
254
|
}
|
|
212
255
|
|
|
213
256
|
export function decodePersistedActor(bytes: Uint8Array): PersistedActor {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
257
|
+
const bc = new bare.ByteCursor(bytes, config);
|
|
258
|
+
const result = readPersistedActor(bc);
|
|
259
|
+
if (bc.offset < bc.view.byteLength) {
|
|
260
|
+
throw new bare.BareError(bc.offset, "remaining bytes");
|
|
261
|
+
}
|
|
262
|
+
return result;
|
|
220
263
|
}
|
|
221
264
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
if (!condition) throw new Error(message ?? "Assertion failed")
|
|
265
|
+
function _assert(condition: boolean, message?: string): asserts condition {
|
|
266
|
+
if (!condition) throw new Error(message ?? "Assertion failed");
|
|
225
267
|
}
|