rivetkit 2.0.7-rc.1 → 2.0.7
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/tsup/{chunk-JD54PXWP.js → chunk-2NL3KGJ7.js} +4 -4
- package/dist/tsup/{chunk-TZGUSEIJ.cjs → chunk-3ALZ7EGX.cjs} +11 -11
- package/dist/tsup/{chunk-TZGUSEIJ.cjs.map → chunk-3ALZ7EGX.cjs.map} +1 -1
- package/dist/tsup/{chunk-G4ABMAQY.cjs → chunk-4EXJ4ITR.cjs} +3 -3
- package/dist/tsup/{chunk-G4ABMAQY.cjs.map → chunk-4EXJ4ITR.cjs.map} +1 -1
- package/dist/tsup/{chunk-GZVBFXBI.js → chunk-54MAHBLL.js} +2 -2
- package/dist/tsup/{chunk-DFS77KAA.cjs → chunk-7OOBMCQI.cjs} +22 -22
- package/dist/tsup/{chunk-DFS77KAA.cjs.map → chunk-7OOBMCQI.cjs.map} +1 -1
- package/dist/tsup/{chunk-E4UVJKSV.js → chunk-B6N6VM37.js} +2 -2
- package/dist/tsup/{chunk-7N56ZUC7.js → chunk-DIHKN7NM.js} +3 -3
- package/dist/tsup/{chunk-3MBP4WNC.cjs → chunk-ETDWYT2P.cjs} +7 -7
- package/dist/tsup/{chunk-3MBP4WNC.cjs.map → chunk-ETDWYT2P.cjs.map} +1 -1
- package/dist/tsup/{chunk-3Y45CIF4.cjs → chunk-F7YL5G7Q.cjs} +172 -172
- package/dist/tsup/{chunk-3Y45CIF4.cjs.map → chunk-F7YL5G7Q.cjs.map} +1 -1
- package/dist/tsup/{chunk-6OVKCDSH.cjs → chunk-GWJTWY3G.cjs} +6 -6
- package/dist/tsup/{chunk-6OVKCDSH.cjs.map → chunk-GWJTWY3G.cjs.map} +1 -1
- package/dist/tsup/{chunk-HPT3I7UU.js → chunk-KHRZPP5T.js} +8 -8
- package/dist/tsup/{chunk-6EUWRXLT.cjs → chunk-LXAVET4A.cjs} +2 -2
- package/dist/tsup/{chunk-6EUWRXLT.cjs.map → chunk-LXAVET4A.cjs.map} +1 -1
- package/dist/tsup/{chunk-SAZCNSVY.cjs → chunk-NDCVQZBS.cjs} +8 -8
- package/dist/tsup/{chunk-SAZCNSVY.cjs.map → chunk-NDCVQZBS.cjs.map} +1 -1
- package/dist/tsup/{chunk-BW5DPM6Z.js → chunk-NII4KKHD.js} +7 -7
- package/dist/tsup/{chunk-YQ4XQYPM.js → chunk-NRELKXIX.js} +3 -3
- package/dist/tsup/{chunk-5ZOHIKWG.cjs → chunk-NUA6LOOJ.cjs} +196 -196
- package/dist/tsup/{chunk-5ZOHIKWG.cjs.map → chunk-NUA6LOOJ.cjs.map} +1 -1
- package/dist/tsup/{chunk-B3TLRM4Q.cjs → chunk-OSK2VSJF.cjs} +12 -12
- package/dist/tsup/{chunk-B3TLRM4Q.cjs.map → chunk-OSK2VSJF.cjs.map} +1 -1
- package/dist/tsup/{chunk-4GP7BZSR.js → chunk-PD6HCAJE.js} +2 -2
- package/dist/tsup/{chunk-RVP5RUSC.js → chunk-RLBM6D4L.js} +2 -2
- package/dist/tsup/chunk-RLBM6D4L.js.map +1 -0
- package/dist/tsup/{chunk-K4ENQCC4.cjs → chunk-VAF63BEI.cjs} +3 -3
- package/dist/tsup/{chunk-K4ENQCC4.cjs.map → chunk-VAF63BEI.cjs.map} +1 -1
- package/dist/tsup/{chunk-SBKRVQS2.js → chunk-WAT5AE7S.js} +5 -5
- package/dist/tsup/{chunk-PUSQNDJG.js → chunk-YL4VZMMT.js} +2 -2
- package/dist/tsup/client/mod.cjs +9 -9
- 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/driver-helpers/mod.cjs +5 -5
- package/dist/tsup/driver-helpers/mod.js +4 -4
- package/dist/tsup/driver-test-suite/mod.cjs +69 -69
- package/dist/tsup/driver-test-suite/mod.js +11 -11
- package/dist/tsup/inspector/mod.cjs +6 -6
- package/dist/tsup/inspector/mod.js +5 -5
- package/dist/tsup/mod.cjs +10 -10
- package/dist/tsup/mod.js +9 -9
- package/dist/tsup/test/mod.cjs +11 -11
- package/dist/tsup/test/mod.js +10 -10
- package/dist/tsup/utils.cjs +2 -2
- package/dist/tsup/utils.js +1 -1
- package/package.json +1 -1
- package/dist/tsup/chunk-RVP5RUSC.js.map +0 -1
- /package/dist/tsup/{chunk-JD54PXWP.js.map → chunk-2NL3KGJ7.js.map} +0 -0
- /package/dist/tsup/{chunk-GZVBFXBI.js.map → chunk-54MAHBLL.js.map} +0 -0
- /package/dist/tsup/{chunk-E4UVJKSV.js.map → chunk-B6N6VM37.js.map} +0 -0
- /package/dist/tsup/{chunk-7N56ZUC7.js.map → chunk-DIHKN7NM.js.map} +0 -0
- /package/dist/tsup/{chunk-HPT3I7UU.js.map → chunk-KHRZPP5T.js.map} +0 -0
- /package/dist/tsup/{chunk-BW5DPM6Z.js.map → chunk-NII4KKHD.js.map} +0 -0
- /package/dist/tsup/{chunk-YQ4XQYPM.js.map → chunk-NRELKXIX.js.map} +0 -0
- /package/dist/tsup/{chunk-4GP7BZSR.js.map → chunk-PD6HCAJE.js.map} +0 -0
- /package/dist/tsup/{chunk-SBKRVQS2.js.map → chunk-WAT5AE7S.js.map} +0 -0
- /package/dist/tsup/{chunk-PUSQNDJG.js.map → chunk-YL4VZMMT.js.map} +0 -0
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkOSK2VSJFcjs = require('./chunk-OSK2VSJF.cjs');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkVAF63BEIcjs = require('./chunk-VAF63BEI.cjs');
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
@@ -17,7 +17,7 @@ var _chunkK4ENQCC4cjs = require('./chunk-K4ENQCC4.cjs');
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
var
|
|
20
|
+
var _chunk7OOBMCQIcjs = require('./chunk-7OOBMCQI.cjs');
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
|
|
@@ -48,12 +48,12 @@ var _chunkDFS77KAAcjs = require('./chunk-DFS77KAA.cjs');
|
|
|
48
48
|
|
|
49
49
|
|
|
50
50
|
|
|
51
|
-
var
|
|
51
|
+
var _chunkNDCVQZBScjs = require('./chunk-NDCVQZBS.cjs');
|
|
52
52
|
|
|
53
53
|
|
|
54
54
|
|
|
55
55
|
|
|
56
|
-
var
|
|
56
|
+
var _chunkETDWYT2Pcjs = require('./chunk-ETDWYT2P.cjs');
|
|
57
57
|
|
|
58
58
|
|
|
59
59
|
|
|
@@ -66,7 +66,7 @@ var _chunk3MBP4WNCcjs = require('./chunk-3MBP4WNC.cjs');
|
|
|
66
66
|
|
|
67
67
|
|
|
68
68
|
|
|
69
|
-
var
|
|
69
|
+
var _chunkLXAVET4Acjs = require('./chunk-LXAVET4A.cjs');
|
|
70
70
|
|
|
71
71
|
|
|
72
72
|
|
|
@@ -136,7 +136,7 @@ var WEBSOCKET_DRIVER = {
|
|
|
136
136
|
var SSE_DRIVER = {
|
|
137
137
|
sendMessage: (_actor, _conn, state, message) => {
|
|
138
138
|
state.stream.writeSSE({
|
|
139
|
-
data:
|
|
139
|
+
data: _chunkNDCVQZBScjs.encodeDataToString.call(void 0, message.serialize(state.encoding))
|
|
140
140
|
});
|
|
141
141
|
},
|
|
142
142
|
disconnect: async (_actor, _conn, state, _reason) => {
|
|
@@ -165,7 +165,7 @@ function getConnDriverKindFromState(state) {
|
|
|
165
165
|
if (0 /* WEBSOCKET */ in state) return 0 /* WEBSOCKET */;
|
|
166
166
|
else if (1 /* SSE */ in state) return 1 /* SSE */;
|
|
167
167
|
else if (2 /* HTTP */ in state) return 2 /* HTTP */;
|
|
168
|
-
else
|
|
168
|
+
else _chunkLXAVET4Acjs.assertUnreachable.call(void 0, state);
|
|
169
169
|
}
|
|
170
170
|
|
|
171
171
|
// src/actor/conn.ts
|
|
@@ -173,7 +173,7 @@ function generateConnId() {
|
|
|
173
173
|
return crypto.randomUUID();
|
|
174
174
|
}
|
|
175
175
|
function generateConnToken() {
|
|
176
|
-
return
|
|
176
|
+
return _chunkNDCVQZBScjs.generateSecureToken.call(void 0, 32);
|
|
177
177
|
}
|
|
178
178
|
function generateConnSocketId() {
|
|
179
179
|
return crypto.randomUUID();
|
|
@@ -316,17 +316,17 @@ var Conn = (_class = class {
|
|
|
316
316
|
connId: this.id
|
|
317
317
|
});
|
|
318
318
|
this._sendMessage(
|
|
319
|
-
new (0,
|
|
319
|
+
new (0, _chunkNDCVQZBScjs.CachedSerializer)(
|
|
320
320
|
{
|
|
321
321
|
body: {
|
|
322
322
|
tag: "Event",
|
|
323
323
|
val: {
|
|
324
324
|
name: eventName,
|
|
325
|
-
args:
|
|
325
|
+
args: _chunkLXAVET4Acjs.bufferToArrayBuffer.call(void 0, cbor.encode(args))
|
|
326
326
|
}
|
|
327
327
|
}
|
|
328
328
|
},
|
|
329
|
-
|
|
329
|
+
_chunk7OOBMCQIcjs.TO_CLIENT_VERSIONED
|
|
330
330
|
)
|
|
331
331
|
);
|
|
332
332
|
}
|
|
@@ -393,7 +393,7 @@ function createActorInspectorRouter() {
|
|
|
393
393
|
"/state",
|
|
394
394
|
_standardvalidator.sValidator.call(void 0,
|
|
395
395
|
"json",
|
|
396
|
-
_v42.default.object({ patch:
|
|
396
|
+
_v42.default.object({ patch: _chunkOSK2VSJFcjs.PatchSchema }).or(_v42.default.object({ replace: _v42.default.any() }))
|
|
397
397
|
),
|
|
398
398
|
async (c) => {
|
|
399
399
|
if (!await c.var.inspector.accessors.isStateEnabled()) {
|
|
@@ -437,7 +437,7 @@ function createActorInspectorRouter() {
|
|
|
437
437
|
id: String(id++)
|
|
438
438
|
});
|
|
439
439
|
});
|
|
440
|
-
const { promise } =
|
|
440
|
+
const { promise } = _chunkLXAVET4Acjs.promiseWithResolvers.call(void 0, );
|
|
441
441
|
return promise;
|
|
442
442
|
},
|
|
443
443
|
async () => {
|
|
@@ -462,7 +462,7 @@ function createActorInspectorRouter() {
|
|
|
462
462
|
id: String(id++)
|
|
463
463
|
});
|
|
464
464
|
});
|
|
465
|
-
const { promise } =
|
|
465
|
+
const { promise } = _chunkLXAVET4Acjs.promiseWithResolvers.call(void 0, );
|
|
466
466
|
return promise;
|
|
467
467
|
},
|
|
468
468
|
async () => {
|
|
@@ -488,7 +488,7 @@ function createActorInspectorRouter() {
|
|
|
488
488
|
id: String(id++)
|
|
489
489
|
});
|
|
490
490
|
});
|
|
491
|
-
const { promise } =
|
|
491
|
+
const { promise } = _chunkLXAVET4Acjs.promiseWithResolvers.call(void 0, );
|
|
492
492
|
return promise;
|
|
493
493
|
},
|
|
494
494
|
async () => {
|
|
@@ -504,20 +504,20 @@ function createActorInspectorRouter() {
|
|
|
504
504
|
}
|
|
505
505
|
const db = await c.var.inspector.accessors.getDb();
|
|
506
506
|
const rows = await db.execute(`PRAGMA table_list`);
|
|
507
|
-
const tables =
|
|
507
|
+
const tables = _chunkOSK2VSJFcjs.TablesSchema.parse(rows).filter(
|
|
508
508
|
(table) => table.schema !== "temp" && !table.name.startsWith("sqlite_")
|
|
509
509
|
);
|
|
510
510
|
const tablesInfo = await Promise.all(
|
|
511
511
|
tables.map((table) => db.execute(`PRAGMA table_info(${table.name})`))
|
|
512
512
|
);
|
|
513
|
-
const columns = tablesInfo.map((def) =>
|
|
513
|
+
const columns = tablesInfo.map((def) => _chunkOSK2VSJFcjs.ColumnsSchema.parse(def));
|
|
514
514
|
const foreignKeysList = await Promise.all(
|
|
515
515
|
tables.map(
|
|
516
516
|
(table) => db.execute(`PRAGMA foreign_key_list(${table.name})`)
|
|
517
517
|
)
|
|
518
518
|
);
|
|
519
519
|
const foreignKeys = foreignKeysList.map(
|
|
520
|
-
(def) =>
|
|
520
|
+
(def) => _chunkOSK2VSJFcjs.ForeignKeysSchema.parse(def)
|
|
521
521
|
);
|
|
522
522
|
const countInfo = await Promise.all(
|
|
523
523
|
tables.map(
|
|
@@ -797,8 +797,8 @@ var ActorInstance = class {
|
|
|
797
797
|
#persist;
|
|
798
798
|
/** Raw state without the proxy wrapper */
|
|
799
799
|
#persistRaw;
|
|
800
|
-
#persistWriteQueue = new (0,
|
|
801
|
-
#alarmWriteQueue = new (0,
|
|
800
|
+
#persistWriteQueue = new (0, _chunkLXAVET4Acjs.SinglePromiseQueue)();
|
|
801
|
+
#alarmWriteQueue = new (0, _chunkLXAVET4Acjs.SinglePromiseQueue)();
|
|
802
802
|
#lastSaveTime = 0;
|
|
803
803
|
#pendingSaveTimeout;
|
|
804
804
|
#vars;
|
|
@@ -884,12 +884,12 @@ var ActorInstance = class {
|
|
|
884
884
|
key: serializeActorKey(key),
|
|
885
885
|
actorId
|
|
886
886
|
};
|
|
887
|
-
this.#log =
|
|
888
|
-
Object.assign(
|
|
887
|
+
this.#log = _chunkETDWYT2Pcjs.getBaseLogger.call(void 0, ).child(
|
|
888
|
+
Object.assign(_chunkETDWYT2Pcjs.getIncludeTarget.call(void 0, ) ? { target: "actor" } : {}, logParams)
|
|
889
889
|
);
|
|
890
|
-
this.#rLog =
|
|
890
|
+
this.#rLog = _chunkETDWYT2Pcjs.getBaseLogger.call(void 0, ).child(
|
|
891
891
|
Object.assign(
|
|
892
|
-
|
|
892
|
+
_chunkETDWYT2Pcjs.getIncludeTarget.call(void 0, ) ? { target: "actor-runtime" } : {},
|
|
893
893
|
logParams
|
|
894
894
|
)
|
|
895
895
|
);
|
|
@@ -909,7 +909,7 @@ var ActorInstance = class {
|
|
|
909
909
|
this.#actorDriver.getContext(this.#actorId)
|
|
910
910
|
);
|
|
911
911
|
if (dataOrPromise instanceof Promise) {
|
|
912
|
-
vars = await
|
|
912
|
+
vars = await _chunkNDCVQZBScjs.deadline.call(void 0,
|
|
913
913
|
dataOrPromise,
|
|
914
914
|
this.#config.options.createVarsTimeout
|
|
915
915
|
);
|
|
@@ -1036,7 +1036,7 @@ var ActorInstance = class {
|
|
|
1036
1036
|
} catch (error) {
|
|
1037
1037
|
this.actorContext.log.error({
|
|
1038
1038
|
msg: "error while running event",
|
|
1039
|
-
error:
|
|
1039
|
+
error: _chunkLXAVET4Acjs.stringifyError.call(void 0, error),
|
|
1040
1040
|
event: event.eventId,
|
|
1041
1041
|
timestamp: event.timestamp,
|
|
1042
1042
|
action: event.kind.generic.actionName
|
|
@@ -1045,7 +1045,7 @@ var ActorInstance = class {
|
|
|
1045
1045
|
} catch (error) {
|
|
1046
1046
|
this.actorContext.log.error({
|
|
1047
1047
|
msg: "internal error while running event",
|
|
1048
|
-
error:
|
|
1048
|
+
error: _chunkLXAVET4Acjs.stringifyError.call(void 0, error),
|
|
1049
1049
|
...event
|
|
1050
1050
|
});
|
|
1051
1051
|
}
|
|
@@ -1058,7 +1058,7 @@ var ActorInstance = class {
|
|
|
1058
1058
|
kind: {
|
|
1059
1059
|
generic: {
|
|
1060
1060
|
actionName: action,
|
|
1061
|
-
args:
|
|
1061
|
+
args: _chunkLXAVET4Acjs.bufferToArrayBuffer.call(void 0, cbor2.encode(args))
|
|
1062
1062
|
}
|
|
1063
1063
|
}
|
|
1064
1064
|
});
|
|
@@ -1112,7 +1112,7 @@ var ActorInstance = class {
|
|
|
1112
1112
|
const bareData = this.#convertToBarePersisted(this.#persistRaw);
|
|
1113
1113
|
await this.#actorDriver.writePersistedData(
|
|
1114
1114
|
this.#actorId,
|
|
1115
|
-
|
|
1115
|
+
_chunk7OOBMCQIcjs.PERSISTED_ACTOR_VERSIONED.serializeWithEmbeddedVersion(bareData)
|
|
1116
1116
|
);
|
|
1117
1117
|
this.#rLog.debug({ msg: "persist saved" });
|
|
1118
1118
|
});
|
|
@@ -1136,7 +1136,7 @@ var ActorInstance = class {
|
|
|
1136
1136
|
this.#persistRaw = target;
|
|
1137
1137
|
if (target === null || typeof target !== "object") {
|
|
1138
1138
|
let invalidPath = "";
|
|
1139
|
-
if (!
|
|
1139
|
+
if (!_chunkLXAVET4Acjs.isCborSerializable.call(void 0,
|
|
1140
1140
|
target,
|
|
1141
1141
|
(path) => {
|
|
1142
1142
|
invalidPath = path;
|
|
@@ -1158,7 +1158,7 @@ var ActorInstance = class {
|
|
|
1158
1158
|
return;
|
|
1159
1159
|
}
|
|
1160
1160
|
let invalidPath = "";
|
|
1161
|
-
if (!
|
|
1161
|
+
if (!_chunkLXAVET4Acjs.isCborSerializable.call(void 0,
|
|
1162
1162
|
value,
|
|
1163
1163
|
(invalidPathPart) => {
|
|
1164
1164
|
invalidPath = invalidPathPart;
|
|
@@ -1181,7 +1181,7 @@ var ActorInstance = class {
|
|
|
1181
1181
|
} catch (error) {
|
|
1182
1182
|
this.#rLog.error({
|
|
1183
1183
|
msg: "error in `_onStateChange`",
|
|
1184
|
-
error:
|
|
1184
|
+
error: _chunkLXAVET4Acjs.stringifyError.call(void 0, error)
|
|
1185
1185
|
});
|
|
1186
1186
|
} finally {
|
|
1187
1187
|
this.#isInOnStateChange = false;
|
|
@@ -1199,7 +1199,7 @@ var ActorInstance = class {
|
|
|
1199
1199
|
persistDataBuffer !== void 0,
|
|
1200
1200
|
"persist data has not been set, it should be set when initialized"
|
|
1201
1201
|
);
|
|
1202
|
-
const bareData =
|
|
1202
|
+
const bareData = _chunk7OOBMCQIcjs.PERSISTED_ACTOR_VERSIONED.deserializeWithEmbeddedVersion(
|
|
1203
1203
|
persistDataBuffer
|
|
1204
1204
|
);
|
|
1205
1205
|
const persistData = this.#convertFromBarePersisted(bareData);
|
|
@@ -1241,7 +1241,7 @@ var ActorInstance = class {
|
|
|
1241
1241
|
const bareData2 = this.#convertToBarePersisted(persistData);
|
|
1242
1242
|
await this.#actorDriver.writePersistedData(
|
|
1243
1243
|
this.#actorId,
|
|
1244
|
-
|
|
1244
|
+
_chunk7OOBMCQIcjs.PERSISTED_ACTOR_VERSIONED.serializeWithEmbeddedVersion(bareData2)
|
|
1245
1245
|
);
|
|
1246
1246
|
this.#setPersist(persistData);
|
|
1247
1247
|
if (this.#config.onCreate) {
|
|
@@ -1307,14 +1307,14 @@ var ActorInstance = class {
|
|
|
1307
1307
|
result.catch((error) => {
|
|
1308
1308
|
this.#rLog.error({
|
|
1309
1309
|
msg: "error in `onDisconnect`",
|
|
1310
|
-
error:
|
|
1310
|
+
error: _chunkLXAVET4Acjs.stringifyError.call(void 0, error)
|
|
1311
1311
|
});
|
|
1312
1312
|
});
|
|
1313
1313
|
}
|
|
1314
1314
|
} catch (error) {
|
|
1315
1315
|
this.#rLog.error({
|
|
1316
1316
|
msg: "error in `onDisconnect`",
|
|
1317
|
-
error:
|
|
1317
|
+
error: _chunkLXAVET4Acjs.stringifyError.call(void 0, error)
|
|
1318
1318
|
});
|
|
1319
1319
|
}
|
|
1320
1320
|
}
|
|
@@ -1355,7 +1355,7 @@ var ActorInstance = class {
|
|
|
1355
1355
|
this.#resetSleepTimer();
|
|
1356
1356
|
this.inspector.emitter.emit("connectionUpdated");
|
|
1357
1357
|
existingConn._sendMessage(
|
|
1358
|
-
new (0,
|
|
1358
|
+
new (0, _chunkNDCVQZBScjs.CachedSerializer)(
|
|
1359
1359
|
{
|
|
1360
1360
|
body: {
|
|
1361
1361
|
tag: "Init",
|
|
@@ -1366,7 +1366,7 @@ var ActorInstance = class {
|
|
|
1366
1366
|
}
|
|
1367
1367
|
}
|
|
1368
1368
|
},
|
|
1369
|
-
|
|
1369
|
+
_chunk7OOBMCQIcjs.TO_CLIENT_VERSIONED
|
|
1370
1370
|
)
|
|
1371
1371
|
);
|
|
1372
1372
|
return existingConn;
|
|
@@ -1400,7 +1400,7 @@ var ActorInstance = class {
|
|
|
1400
1400
|
params
|
|
1401
1401
|
);
|
|
1402
1402
|
if (dataOrPromise instanceof Promise) {
|
|
1403
|
-
connState = await
|
|
1403
|
+
connState = await _chunkNDCVQZBScjs.deadline.call(void 0,
|
|
1404
1404
|
dataOrPromise,
|
|
1405
1405
|
this.#config.options.createConnStateTimeout
|
|
1406
1406
|
);
|
|
@@ -1433,7 +1433,7 @@ var ActorInstance = class {
|
|
|
1433
1433
|
try {
|
|
1434
1434
|
const result = this.#config.onConnect(this.actorContext, conn);
|
|
1435
1435
|
if (result instanceof Promise) {
|
|
1436
|
-
|
|
1436
|
+
_chunkNDCVQZBScjs.deadline.call(void 0, result, this.#config.options.onConnectTimeout).catch(
|
|
1437
1437
|
(error) => {
|
|
1438
1438
|
this.#rLog.error({
|
|
1439
1439
|
msg: "error in `onConnect`, closing socket",
|
|
@@ -1446,14 +1446,14 @@ var ActorInstance = class {
|
|
|
1446
1446
|
} catch (error) {
|
|
1447
1447
|
this.#rLog.error({
|
|
1448
1448
|
msg: "error in `onConnect`",
|
|
1449
|
-
error:
|
|
1449
|
+
error: _chunkLXAVET4Acjs.stringifyError.call(void 0, error)
|
|
1450
1450
|
});
|
|
1451
1451
|
conn == null ? void 0 : conn.disconnect("`onConnect` failed");
|
|
1452
1452
|
}
|
|
1453
1453
|
}
|
|
1454
1454
|
this.inspector.emitter.emit("connectionUpdated");
|
|
1455
1455
|
conn._sendMessage(
|
|
1456
|
-
new (0,
|
|
1456
|
+
new (0, _chunkNDCVQZBScjs.CachedSerializer)(
|
|
1457
1457
|
{
|
|
1458
1458
|
body: {
|
|
1459
1459
|
tag: "Init",
|
|
@@ -1464,14 +1464,14 @@ var ActorInstance = class {
|
|
|
1464
1464
|
}
|
|
1465
1465
|
}
|
|
1466
1466
|
},
|
|
1467
|
-
|
|
1467
|
+
_chunk7OOBMCQIcjs.TO_CLIENT_VERSIONED
|
|
1468
1468
|
)
|
|
1469
1469
|
);
|
|
1470
1470
|
return conn;
|
|
1471
1471
|
}
|
|
1472
1472
|
// MARK: Messages
|
|
1473
1473
|
async processMessage(message, conn) {
|
|
1474
|
-
await
|
|
1474
|
+
await _chunk7OOBMCQIcjs.processMessage.call(void 0, message, this, conn, {
|
|
1475
1475
|
onExecuteAction: async (ctx, name, args) => {
|
|
1476
1476
|
this.inspector.emitter.emit("eventFired", {
|
|
1477
1477
|
type: "action",
|
|
@@ -1640,7 +1640,7 @@ var ActorInstance = class {
|
|
|
1640
1640
|
msg: "awaiting async action",
|
|
1641
1641
|
actionName
|
|
1642
1642
|
});
|
|
1643
|
-
output = await
|
|
1643
|
+
output = await _chunkNDCVQZBScjs.deadline.call(void 0,
|
|
1644
1644
|
outputOrPromise,
|
|
1645
1645
|
this.#config.options.actionTimeout
|
|
1646
1646
|
);
|
|
@@ -1675,7 +1675,7 @@ var ActorInstance = class {
|
|
|
1675
1675
|
} catch (error) {
|
|
1676
1676
|
this.#rLog.error({
|
|
1677
1677
|
msg: "error in `onBeforeActionResponse`",
|
|
1678
|
-
error:
|
|
1678
|
+
error: _chunkLXAVET4Acjs.stringifyError.call(void 0, error)
|
|
1679
1679
|
});
|
|
1680
1680
|
}
|
|
1681
1681
|
}
|
|
@@ -1687,13 +1687,13 @@ var ActorInstance = class {
|
|
|
1687
1687
|
});
|
|
1688
1688
|
return output;
|
|
1689
1689
|
} catch (error) {
|
|
1690
|
-
if (error instanceof
|
|
1690
|
+
if (error instanceof _chunkNDCVQZBScjs.DeadlineError) {
|
|
1691
1691
|
throw new (0, _chunk5QGQK44Lcjs.ActionTimedOut)();
|
|
1692
1692
|
}
|
|
1693
1693
|
this.#rLog.error({
|
|
1694
1694
|
msg: "action error",
|
|
1695
1695
|
actionName,
|
|
1696
|
-
error:
|
|
1696
|
+
error: _chunkLXAVET4Acjs.stringifyError.call(void 0, error)
|
|
1697
1697
|
});
|
|
1698
1698
|
throw error;
|
|
1699
1699
|
} finally {
|
|
@@ -1727,7 +1727,7 @@ var ActorInstance = class {
|
|
|
1727
1727
|
}
|
|
1728
1728
|
return response;
|
|
1729
1729
|
} catch (error) {
|
|
1730
|
-
this.#rLog.error({ msg: "onFetch error", error:
|
|
1730
|
+
this.#rLog.error({ msg: "onFetch error", error: _chunkLXAVET4Acjs.stringifyError.call(void 0, error) });
|
|
1731
1731
|
throw error;
|
|
1732
1732
|
} finally {
|
|
1733
1733
|
this.#activeRawFetchCount = Math.max(0, this.#activeRawFetchCount - 1);
|
|
@@ -1768,7 +1768,7 @@ var ActorInstance = class {
|
|
|
1768
1768
|
} catch (error) {
|
|
1769
1769
|
this.#rLog.error({
|
|
1770
1770
|
msg: "onWebSocket error",
|
|
1771
|
-
error:
|
|
1771
|
+
error: _chunkLXAVET4Acjs.stringifyError.call(void 0, error)
|
|
1772
1772
|
});
|
|
1773
1773
|
throw error;
|
|
1774
1774
|
} finally {
|
|
@@ -1863,17 +1863,17 @@ var ActorInstance = class {
|
|
|
1863
1863
|
});
|
|
1864
1864
|
const subscriptions = this.#subscriptionIndex.get(name);
|
|
1865
1865
|
if (!subscriptions) return;
|
|
1866
|
-
const toClientSerializer = new (0,
|
|
1866
|
+
const toClientSerializer = new (0, _chunkNDCVQZBScjs.CachedSerializer)(
|
|
1867
1867
|
{
|
|
1868
1868
|
body: {
|
|
1869
1869
|
tag: "Event",
|
|
1870
1870
|
val: {
|
|
1871
1871
|
name,
|
|
1872
|
-
args:
|
|
1872
|
+
args: _chunkLXAVET4Acjs.bufferToArrayBuffer.call(void 0, cbor2.encode(args))
|
|
1873
1873
|
}
|
|
1874
1874
|
}
|
|
1875
1875
|
},
|
|
1876
|
-
|
|
1876
|
+
_chunk7OOBMCQIcjs.TO_CLIENT_VERSIONED
|
|
1877
1877
|
);
|
|
1878
1878
|
for (const connection of subscriptions) {
|
|
1879
1879
|
connection._sendMessage(toClientSerializer);
|
|
@@ -1894,7 +1894,7 @@ var ActorInstance = class {
|
|
|
1894
1894
|
}).catch((error) => {
|
|
1895
1895
|
this.#rLog.error({
|
|
1896
1896
|
msg: "wait until promise failed",
|
|
1897
|
-
error:
|
|
1897
|
+
error: _chunkLXAVET4Acjs.stringifyError.call(void 0, error)
|
|
1898
1898
|
});
|
|
1899
1899
|
});
|
|
1900
1900
|
this.#backgroundPromises.push(nonfailablePromise);
|
|
@@ -1914,7 +1914,7 @@ var ActorInstance = class {
|
|
|
1914
1914
|
await this.#savePersistInner();
|
|
1915
1915
|
} else {
|
|
1916
1916
|
if (!this.#onPersistSavedPromise) {
|
|
1917
|
-
this.#onPersistSavedPromise =
|
|
1917
|
+
this.#onPersistSavedPromise = _chunkLXAVET4Acjs.promiseWithResolvers.call(void 0, );
|
|
1918
1918
|
}
|
|
1919
1919
|
this.#savePersistThrottled();
|
|
1920
1920
|
await this.#onPersistSavedPromise.promise;
|
|
@@ -1950,7 +1950,7 @@ var ActorInstance = class {
|
|
|
1950
1950
|
this._sleep().catch((error) => {
|
|
1951
1951
|
this.#rLog.error({
|
|
1952
1952
|
msg: "error during sleep",
|
|
1953
|
-
error:
|
|
1953
|
+
error: _chunkLXAVET4Acjs.stringifyError.call(void 0, error)
|
|
1954
1954
|
});
|
|
1955
1955
|
});
|
|
1956
1956
|
}, this.#config.options.sleepTimeout);
|
|
@@ -2002,16 +2002,16 @@ var ActorInstance = class {
|
|
|
2002
2002
|
this.#rLog.debug({ msg: "calling onStop" });
|
|
2003
2003
|
const result = this.#config.onStop(this.actorContext);
|
|
2004
2004
|
if (result instanceof Promise) {
|
|
2005
|
-
await
|
|
2005
|
+
await _chunkNDCVQZBScjs.deadline.call(void 0, result, this.#config.options.onStopTimeout);
|
|
2006
2006
|
}
|
|
2007
2007
|
this.#rLog.debug({ msg: "onStop completed" });
|
|
2008
2008
|
} catch (error) {
|
|
2009
|
-
if (error instanceof
|
|
2009
|
+
if (error instanceof _chunkNDCVQZBScjs.DeadlineError) {
|
|
2010
2010
|
this.#rLog.error({ msg: "onStop timed out" });
|
|
2011
2011
|
} else {
|
|
2012
2012
|
this.#rLog.error({
|
|
2013
2013
|
msg: "error in onStop",
|
|
2014
|
-
error:
|
|
2014
|
+
error: _chunkLXAVET4Acjs.stringifyError.call(void 0, error)
|
|
2015
2015
|
});
|
|
2016
2016
|
}
|
|
2017
2017
|
}
|
|
@@ -2072,14 +2072,14 @@ var ActorInstance = class {
|
|
|
2072
2072
|
// MARK: BARE Conversion Helpers
|
|
2073
2073
|
#convertToBarePersisted(persist) {
|
|
2074
2074
|
return {
|
|
2075
|
-
input: persist.input !== void 0 ?
|
|
2075
|
+
input: persist.input !== void 0 ? _chunkLXAVET4Acjs.bufferToArrayBuffer.call(void 0, cbor2.encode(persist.input)) : null,
|
|
2076
2076
|
hasInitialized: persist.hasInitiated,
|
|
2077
|
-
state:
|
|
2077
|
+
state: _chunkLXAVET4Acjs.bufferToArrayBuffer.call(void 0, cbor2.encode(persist.state)),
|
|
2078
2078
|
connections: persist.connections.map((conn) => ({
|
|
2079
2079
|
id: conn.connId,
|
|
2080
2080
|
token: conn.token,
|
|
2081
|
-
parameters:
|
|
2082
|
-
state:
|
|
2081
|
+
parameters: _chunkLXAVET4Acjs.bufferToArrayBuffer.call(void 0, cbor2.encode(conn.params || {})),
|
|
2082
|
+
state: _chunkLXAVET4Acjs.bufferToArrayBuffer.call(void 0, cbor2.encode(conn.state || {})),
|
|
2083
2083
|
subscriptions: conn.subscriptions.map((sub) => ({
|
|
2084
2084
|
eventName: sub.eventName
|
|
2085
2085
|
})),
|
|
@@ -2197,7 +2197,7 @@ async function importEventSource() {
|
|
|
2197
2197
|
try {
|
|
2198
2198
|
const es = await Promise.resolve().then(() => _interopRequireWildcard(require("eventsource")));
|
|
2199
2199
|
_EventSource = es.EventSource;
|
|
2200
|
-
|
|
2200
|
+
_chunkVAF63BEIcjs.logger.call(void 0, ).debug("using eventsource from npm");
|
|
2201
2201
|
} catch (err) {
|
|
2202
2202
|
_EventSource = class MockEventSource {
|
|
2203
2203
|
constructor() {
|
|
@@ -2206,7 +2206,7 @@ async function importEventSource() {
|
|
|
2206
2206
|
);
|
|
2207
2207
|
}
|
|
2208
2208
|
};
|
|
2209
|
-
|
|
2209
|
+
_chunkVAF63BEIcjs.logger.call(void 0, ).debug("using mock eventsource");
|
|
2210
2210
|
}
|
|
2211
2211
|
return _EventSource;
|
|
2212
2212
|
})();
|
|
@@ -2215,7 +2215,7 @@ async function importEventSource() {
|
|
|
2215
2215
|
|
|
2216
2216
|
// src/client/actor-query.ts
|
|
2217
2217
|
async function queryActor(c, query, managerDriver) {
|
|
2218
|
-
|
|
2218
|
+
_chunkVAF63BEIcjs.logger.call(void 0, ).debug({ msg: "querying actor", query: JSON.stringify(query) });
|
|
2219
2219
|
let actorOutput;
|
|
2220
2220
|
if ("getForId" in query) {
|
|
2221
2221
|
const output = await managerDriver.getForId({
|
|
@@ -2262,7 +2262,7 @@ async function queryActor(c, query, managerDriver) {
|
|
|
2262
2262
|
} else {
|
|
2263
2263
|
throw new (0, _chunk5QGQK44Lcjs.InvalidRequest)("Invalid query format");
|
|
2264
2264
|
}
|
|
2265
|
-
|
|
2265
|
+
_chunkVAF63BEIcjs.logger.call(void 0, ).debug({ msg: "actor query result", actorId: actorOutput.actorId });
|
|
2266
2266
|
return { actorId: actorOutput.actorId };
|
|
2267
2267
|
}
|
|
2268
2268
|
|
|
@@ -2312,13 +2312,13 @@ async function rawHttpFetch(driver, actorQuery, params, input, init) {
|
|
|
2312
2312
|
}
|
|
2313
2313
|
try {
|
|
2314
2314
|
const { actorId } = await queryActor(void 0, actorQuery, driver);
|
|
2315
|
-
|
|
2315
|
+
_chunkVAF63BEIcjs.logger.call(void 0, ).debug({ msg: "found actor for raw http", actorId });
|
|
2316
2316
|
_invariant2.default.call(void 0, actorId, "Missing actor ID");
|
|
2317
2317
|
const normalizedPath = path.startsWith("/") ? path.slice(1) : path;
|
|
2318
2318
|
const url = new URL(`http://actor/raw/http/${normalizedPath}`);
|
|
2319
2319
|
const proxyRequestHeaders = new Headers(mergedInit.headers);
|
|
2320
2320
|
if (params) {
|
|
2321
|
-
proxyRequestHeaders.set(
|
|
2321
|
+
proxyRequestHeaders.set(_chunkNDCVQZBScjs.HEADER_CONN_PARAMS, JSON.stringify(params));
|
|
2322
2322
|
}
|
|
2323
2323
|
const proxyRequest = new Request(url, {
|
|
2324
2324
|
...mergedInit,
|
|
@@ -2326,9 +2326,9 @@ async function rawHttpFetch(driver, actorQuery, params, input, init) {
|
|
|
2326
2326
|
});
|
|
2327
2327
|
return driver.sendRequest(actorId, proxyRequest);
|
|
2328
2328
|
} catch (err) {
|
|
2329
|
-
const { group, code, message, metadata } =
|
|
2329
|
+
const { group, code, message, metadata } = _chunkLXAVET4Acjs.deconstructError.call(void 0,
|
|
2330
2330
|
err,
|
|
2331
|
-
|
|
2331
|
+
_chunkVAF63BEIcjs.logger.call(void 0, ),
|
|
2332
2332
|
{},
|
|
2333
2333
|
true
|
|
2334
2334
|
);
|
|
@@ -2338,7 +2338,7 @@ async function rawHttpFetch(driver, actorQuery, params, input, init) {
|
|
|
2338
2338
|
async function rawWebSocket(driver, actorQuery, params, path, protocols) {
|
|
2339
2339
|
const encoding = "bare";
|
|
2340
2340
|
const { actorId } = await queryActor(void 0, actorQuery, driver);
|
|
2341
|
-
|
|
2341
|
+
_chunkVAF63BEIcjs.logger.call(void 0, ).debug({ msg: "found actor for action", actorId });
|
|
2342
2342
|
_invariant2.default.call(void 0, actorId, "Missing actor ID");
|
|
2343
2343
|
let pathPortion = "";
|
|
2344
2344
|
let queryPortion = "";
|
|
@@ -2354,8 +2354,8 @@ async function rawWebSocket(driver, actorQuery, params, path, protocols) {
|
|
|
2354
2354
|
pathPortion = pathPortion.slice(1);
|
|
2355
2355
|
}
|
|
2356
2356
|
}
|
|
2357
|
-
const fullPath = `${
|
|
2358
|
-
|
|
2357
|
+
const fullPath = `${_chunkNDCVQZBScjs.PATH_RAW_WEBSOCKET_PREFIX}${pathPortion}${queryPortion}`;
|
|
2358
|
+
_chunkVAF63BEIcjs.logger.call(void 0, ).debug({
|
|
2359
2359
|
msg: "opening websocket",
|
|
2360
2360
|
actorId,
|
|
2361
2361
|
encoding,
|
|
@@ -2381,10 +2381,10 @@ function messageLength(message) {
|
|
|
2381
2381
|
if (typeof message === "string") {
|
|
2382
2382
|
return message.length;
|
|
2383
2383
|
}
|
|
2384
|
-
|
|
2384
|
+
_chunkLXAVET4Acjs.assertUnreachable.call(void 0, message);
|
|
2385
2385
|
}
|
|
2386
2386
|
async function sendHttpRequest(opts) {
|
|
2387
|
-
|
|
2387
|
+
_chunkVAF63BEIcjs.logger.call(void 0, ).debug({
|
|
2388
2388
|
msg: "sending http request",
|
|
2389
2389
|
url: opts.url,
|
|
2390
2390
|
encoding: opts.encoding
|
|
@@ -2393,8 +2393,8 @@ async function sendHttpRequest(opts) {
|
|
|
2393
2393
|
let bodyData;
|
|
2394
2394
|
if (opts.method === "POST" || opts.method === "PUT") {
|
|
2395
2395
|
_invariant2.default.call(void 0, opts.body !== void 0, "missing body");
|
|
2396
|
-
contentType =
|
|
2397
|
-
bodyData =
|
|
2396
|
+
contentType = _chunkNDCVQZBScjs.contentTypeForEncoding.call(void 0, opts.encoding);
|
|
2397
|
+
bodyData = _chunkNDCVQZBScjs.serializeWithEncoding.call(void 0,
|
|
2398
2398
|
opts.encoding,
|
|
2399
2399
|
opts.body,
|
|
2400
2400
|
opts.requestVersionedDataHandler
|
|
@@ -2410,7 +2410,7 @@ async function sendHttpRequest(opts) {
|
|
|
2410
2410
|
...contentType ? {
|
|
2411
2411
|
"Content-Type": contentType
|
|
2412
2412
|
} : {},
|
|
2413
|
-
"User-Agent":
|
|
2413
|
+
"User-Agent": _chunkLXAVET4Acjs.httpUserAgent.call(void 0, )
|
|
2414
2414
|
},
|
|
2415
2415
|
body: bodyData,
|
|
2416
2416
|
credentials: "include",
|
|
@@ -2426,10 +2426,10 @@ async function sendHttpRequest(opts) {
|
|
|
2426
2426
|
const bufferResponse = await response.arrayBuffer();
|
|
2427
2427
|
let responseData;
|
|
2428
2428
|
try {
|
|
2429
|
-
responseData =
|
|
2429
|
+
responseData = _chunkNDCVQZBScjs.deserializeWithEncoding.call(void 0,
|
|
2430
2430
|
opts.encoding,
|
|
2431
2431
|
new Uint8Array(bufferResponse),
|
|
2432
|
-
|
|
2432
|
+
_chunk7OOBMCQIcjs.HTTP_RESPONSE_ERROR_VERSIONED
|
|
2433
2433
|
);
|
|
2434
2434
|
} catch (error) {
|
|
2435
2435
|
const textResponse = new TextDecoder("utf-8", { fatal: false }).decode(
|
|
@@ -2452,7 +2452,7 @@ ${textResponse}`
|
|
|
2452
2452
|
}
|
|
2453
2453
|
try {
|
|
2454
2454
|
const buffer = new Uint8Array(await response.arrayBuffer());
|
|
2455
|
-
return
|
|
2455
|
+
return _chunkNDCVQZBScjs.deserializeWithEncoding.call(void 0,
|
|
2456
2456
|
opts.encoding,
|
|
2457
2457
|
buffer,
|
|
2458
2458
|
opts.responseVersionedDataHandler
|
|
@@ -2499,9 +2499,9 @@ var ActorHandleRaw = class {
|
|
|
2499
2499
|
this.#actorQuery,
|
|
2500
2500
|
this.#driver
|
|
2501
2501
|
);
|
|
2502
|
-
|
|
2502
|
+
_chunkVAF63BEIcjs.logger.call(void 0, ).debug({ msg: "found actor for action", actorId });
|
|
2503
2503
|
_invariant2.default.call(void 0, actorId, "Missing actor ID");
|
|
2504
|
-
|
|
2504
|
+
_chunkVAF63BEIcjs.logger.call(void 0, ).debug({
|
|
2505
2505
|
msg: "handling action",
|
|
2506
2506
|
name: opts.name,
|
|
2507
2507
|
encoding: this.#encoding
|
|
@@ -2510,23 +2510,23 @@ var ActorHandleRaw = class {
|
|
|
2510
2510
|
url: `http://actor/action/${encodeURIComponent(opts.name)}`,
|
|
2511
2511
|
method: "POST",
|
|
2512
2512
|
headers: {
|
|
2513
|
-
[
|
|
2514
|
-
...this.#params !== void 0 ? { [
|
|
2513
|
+
[_chunkNDCVQZBScjs.HEADER_ENCODING]: this.#encoding,
|
|
2514
|
+
...this.#params !== void 0 ? { [_chunkNDCVQZBScjs.HEADER_CONN_PARAMS]: JSON.stringify(this.#params) } : {}
|
|
2515
2515
|
},
|
|
2516
2516
|
body: {
|
|
2517
|
-
args:
|
|
2517
|
+
args: _chunkLXAVET4Acjs.bufferToArrayBuffer.call(void 0, cbor4.encode(opts.args))
|
|
2518
2518
|
},
|
|
2519
2519
|
encoding: this.#encoding,
|
|
2520
2520
|
customFetch: this.#driver.sendRequest.bind(this.#driver, actorId),
|
|
2521
2521
|
signal: opts == null ? void 0 : opts.signal,
|
|
2522
|
-
requestVersionedDataHandler:
|
|
2523
|
-
responseVersionedDataHandler:
|
|
2522
|
+
requestVersionedDataHandler: _chunk7OOBMCQIcjs.HTTP_ACTION_REQUEST_VERSIONED,
|
|
2523
|
+
responseVersionedDataHandler: _chunk7OOBMCQIcjs.HTTP_ACTION_RESPONSE_VERSIONED
|
|
2524
2524
|
});
|
|
2525
2525
|
return cbor4.decode(new Uint8Array(responseData.output));
|
|
2526
2526
|
} catch (err) {
|
|
2527
|
-
const { group, code, message, metadata } =
|
|
2527
|
+
const { group, code, message, metadata } = _chunkLXAVET4Acjs.deconstructError.call(void 0,
|
|
2528
2528
|
err,
|
|
2529
|
-
|
|
2529
|
+
_chunkVAF63BEIcjs.logger.call(void 0, ),
|
|
2530
2530
|
{},
|
|
2531
2531
|
true
|
|
2532
2532
|
);
|
|
@@ -2540,7 +2540,7 @@ var ActorHandleRaw = class {
|
|
|
2540
2540
|
* @returns {ActorConn<AD>} A connection to the actor.
|
|
2541
2541
|
*/
|
|
2542
2542
|
connect() {
|
|
2543
|
-
|
|
2543
|
+
_chunkVAF63BEIcjs.logger.call(void 0, ).debug({
|
|
2544
2544
|
msg: "establishing connection from handle",
|
|
2545
2545
|
query: this.#actorQuery
|
|
2546
2546
|
});
|
|
@@ -2600,7 +2600,7 @@ var ActorHandleRaw = class {
|
|
|
2600
2600
|
} else if ("getOrCreateForKey" in this.#actorQuery) {
|
|
2601
2601
|
name = this.#actorQuery.getOrCreateForKey.name;
|
|
2602
2602
|
} else {
|
|
2603
|
-
|
|
2603
|
+
_chunkNDCVQZBScjs.assertUnreachable.call(void 0, this.#actorQuery);
|
|
2604
2604
|
}
|
|
2605
2605
|
const { actorId } = await queryActor(
|
|
2606
2606
|
void 0,
|
|
@@ -2614,7 +2614,7 @@ var ActorHandleRaw = class {
|
|
|
2614
2614
|
} else if ("create" in this.#actorQuery) {
|
|
2615
2615
|
_invariant2.default.call(void 0, false, "actorQuery cannot be create");
|
|
2616
2616
|
} else {
|
|
2617
|
-
|
|
2617
|
+
_chunkNDCVQZBScjs.assertUnreachable.call(void 0, this.#actorQuery);
|
|
2618
2618
|
}
|
|
2619
2619
|
}
|
|
2620
2620
|
};
|
|
@@ -2651,7 +2651,7 @@ var ClientRaw = (_class4 = class {
|
|
|
2651
2651
|
* @returns {ActorHandle<AD>} - A handle to the actor.
|
|
2652
2652
|
*/
|
|
2653
2653
|
getForId(name, actorId, opts) {
|
|
2654
|
-
|
|
2654
|
+
_chunkVAF63BEIcjs.logger.call(void 0, ).debug({
|
|
2655
2655
|
msg: "get handle to actor with id",
|
|
2656
2656
|
name,
|
|
2657
2657
|
actorId,
|
|
@@ -2677,7 +2677,7 @@ var ClientRaw = (_class4 = class {
|
|
|
2677
2677
|
*/
|
|
2678
2678
|
get(name, key, opts) {
|
|
2679
2679
|
const keyArray = typeof key === "string" ? [key] : key || [];
|
|
2680
|
-
|
|
2680
|
+
_chunkVAF63BEIcjs.logger.call(void 0, ).debug({
|
|
2681
2681
|
msg: "get handle to actor",
|
|
2682
2682
|
name,
|
|
2683
2683
|
key: keyArray,
|
|
@@ -2703,7 +2703,7 @@ var ClientRaw = (_class4 = class {
|
|
|
2703
2703
|
*/
|
|
2704
2704
|
getOrCreate(name, key, opts) {
|
|
2705
2705
|
const keyArray = typeof key === "string" ? [key] : key || [];
|
|
2706
|
-
|
|
2706
|
+
_chunkVAF63BEIcjs.logger.call(void 0, ).debug({
|
|
2707
2707
|
msg: "get or create handle to actor",
|
|
2708
2708
|
name,
|
|
2709
2709
|
key: keyArray,
|
|
@@ -2741,7 +2741,7 @@ var ClientRaw = (_class4 = class {
|
|
|
2741
2741
|
key: keyArray
|
|
2742
2742
|
}
|
|
2743
2743
|
};
|
|
2744
|
-
|
|
2744
|
+
_chunkVAF63BEIcjs.logger.call(void 0, ).debug({
|
|
2745
2745
|
msg: "create actor handle",
|
|
2746
2746
|
name,
|
|
2747
2747
|
key: keyArray,
|
|
@@ -2749,7 +2749,7 @@ var ClientRaw = (_class4 = class {
|
|
|
2749
2749
|
create: createQuery.create
|
|
2750
2750
|
});
|
|
2751
2751
|
const { actorId } = await queryActor(void 0, createQuery, this.#driver);
|
|
2752
|
-
|
|
2752
|
+
_chunkVAF63BEIcjs.logger.call(void 0, ).debug({
|
|
2753
2753
|
msg: "created actor with ID",
|
|
2754
2754
|
name,
|
|
2755
2755
|
key: keyArray,
|
|
@@ -2786,11 +2786,11 @@ var ClientRaw = (_class4 = class {
|
|
|
2786
2786
|
*/
|
|
2787
2787
|
async dispose() {
|
|
2788
2788
|
if (this.#disposed) {
|
|
2789
|
-
|
|
2789
|
+
_chunkVAF63BEIcjs.logger.call(void 0, ).warn({ msg: "client already disconnected" });
|
|
2790
2790
|
return;
|
|
2791
2791
|
}
|
|
2792
2792
|
this.#disposed = true;
|
|
2793
|
-
|
|
2793
|
+
_chunkVAF63BEIcjs.logger.call(void 0, ).debug({ msg: "disposing client" });
|
|
2794
2794
|
const disposePromises = [];
|
|
2795
2795
|
for (const conn of this[ACTOR_CONNS_SYMBOL].values()) {
|
|
2796
2796
|
disposePromises.push(conn.dispose());
|
|
@@ -2955,10 +2955,10 @@ var ActorConnRaw = class {
|
|
|
2955
2955
|
* @returns {Promise<Response>} - A promise that resolves to the response of the action function.
|
|
2956
2956
|
*/
|
|
2957
2957
|
async action(opts) {
|
|
2958
|
-
|
|
2958
|
+
_chunkVAF63BEIcjs.logger.call(void 0, ).debug({ msg: "action", name: opts.name, args: opts.args });
|
|
2959
2959
|
const actionId = this.#actionIdCounter;
|
|
2960
2960
|
this.#actionIdCounter += 1;
|
|
2961
|
-
const { promise, resolve, reject } =
|
|
2961
|
+
const { promise, resolve, reject } = _chunkLXAVET4Acjs.promiseWithResolvers.call(void 0, );
|
|
2962
2962
|
this.#actionsInFlight.set(actionId, { name: opts.name, resolve, reject });
|
|
2963
2963
|
this.#sendMessage({
|
|
2964
2964
|
body: {
|
|
@@ -2966,7 +2966,7 @@ var ActorConnRaw = class {
|
|
|
2966
2966
|
val: {
|
|
2967
2967
|
id: BigInt(actionId),
|
|
2968
2968
|
name: opts.name,
|
|
2969
|
-
args:
|
|
2969
|
+
args: _chunkLXAVET4Acjs.bufferToArrayBuffer.call(void 0, cbor5.encode(opts.args))
|
|
2970
2970
|
}
|
|
2971
2971
|
}
|
|
2972
2972
|
});
|
|
@@ -2995,10 +2995,10 @@ var ActorConnRaw = class {
|
|
|
2995
2995
|
minTimeout: 250,
|
|
2996
2996
|
maxTimeout: 3e4,
|
|
2997
2997
|
onFailedAttempt: (error) => {
|
|
2998
|
-
|
|
2998
|
+
_chunkVAF63BEIcjs.logger.call(void 0, ).warn({
|
|
2999
2999
|
msg: "failed to reconnect",
|
|
3000
3000
|
attempt: error.attemptNumber,
|
|
3001
|
-
error:
|
|
3001
|
+
error: _chunkLXAVET4Acjs.stringifyError.call(void 0, error)
|
|
3002
3002
|
});
|
|
3003
3003
|
},
|
|
3004
3004
|
// Cancel retry if aborted
|
|
@@ -3006,7 +3006,7 @@ var ActorConnRaw = class {
|
|
|
3006
3006
|
});
|
|
3007
3007
|
} catch (err) {
|
|
3008
3008
|
if (err.name === "AbortError") {
|
|
3009
|
-
|
|
3009
|
+
_chunkVAF63BEIcjs.logger.call(void 0, ).info({ msg: "connection retry aborted" });
|
|
3010
3010
|
return;
|
|
3011
3011
|
} else {
|
|
3012
3012
|
throw err;
|
|
@@ -3018,13 +3018,13 @@ var ActorConnRaw = class {
|
|
|
3018
3018
|
try {
|
|
3019
3019
|
if (this.#onOpenPromise)
|
|
3020
3020
|
throw new Error("#onOpenPromise already defined");
|
|
3021
|
-
this.#onOpenPromise =
|
|
3021
|
+
this.#onOpenPromise = _chunkLXAVET4Acjs.promiseWithResolvers.call(void 0, );
|
|
3022
3022
|
if (this.#client[TRANSPORT_SYMBOL] === "websocket") {
|
|
3023
3023
|
await this.#connectWebSocket();
|
|
3024
3024
|
} else if (this.#client[TRANSPORT_SYMBOL] === "sse") {
|
|
3025
3025
|
await this.#connectSse();
|
|
3026
3026
|
} else {
|
|
3027
|
-
|
|
3027
|
+
_chunkLXAVET4Acjs.assertUnreachable.call(void 0, this.#client[TRANSPORT_SYMBOL]);
|
|
3028
3028
|
}
|
|
3029
3029
|
await this.#onOpenPromise.promise;
|
|
3030
3030
|
} finally {
|
|
@@ -3039,13 +3039,13 @@ var ActorConnRaw = class {
|
|
|
3039
3039
|
);
|
|
3040
3040
|
const isReconnection = this.#connectionId && this.#connectionToken;
|
|
3041
3041
|
if (isReconnection) {
|
|
3042
|
-
|
|
3042
|
+
_chunkVAF63BEIcjs.logger.call(void 0, ).debug({
|
|
3043
3043
|
msg: "attempting websocket reconnection",
|
|
3044
3044
|
connectionId: this.#connectionId
|
|
3045
3045
|
});
|
|
3046
3046
|
}
|
|
3047
3047
|
const ws = await this.#driver.openWebSocket(
|
|
3048
|
-
|
|
3048
|
+
_chunkNDCVQZBScjs.PATH_CONNECT_WEBSOCKET,
|
|
3049
3049
|
actorId,
|
|
3050
3050
|
this.#encoding,
|
|
3051
3051
|
this.#params,
|
|
@@ -3053,7 +3053,7 @@ var ActorConnRaw = class {
|
|
|
3053
3053
|
isReconnection ? this.#connectionId : void 0,
|
|
3054
3054
|
isReconnection ? this.#connectionToken : void 0
|
|
3055
3055
|
);
|
|
3056
|
-
|
|
3056
|
+
_chunkVAF63BEIcjs.logger.call(void 0, ).debug({
|
|
3057
3057
|
msg: "transport set to new websocket",
|
|
3058
3058
|
connectionId: this.#connectionId,
|
|
3059
3059
|
readyState: ws.readyState,
|
|
@@ -3061,7 +3061,7 @@ var ActorConnRaw = class {
|
|
|
3061
3061
|
});
|
|
3062
3062
|
this.#transport = { websocket: ws };
|
|
3063
3063
|
ws.addEventListener("open", () => {
|
|
3064
|
-
|
|
3064
|
+
_chunkVAF63BEIcjs.logger.call(void 0, ).debug({
|
|
3065
3065
|
msg: "client websocket open",
|
|
3066
3066
|
connectionId: this.#connectionId
|
|
3067
3067
|
});
|
|
@@ -3083,9 +3083,9 @@ var ActorConnRaw = class {
|
|
|
3083
3083
|
this.#actorQuery,
|
|
3084
3084
|
this.#driver
|
|
3085
3085
|
);
|
|
3086
|
-
|
|
3086
|
+
_chunkVAF63BEIcjs.logger.call(void 0, ).debug({ msg: "found actor for sse connection", actorId });
|
|
3087
3087
|
_invariant2.default.call(void 0, actorId, "Missing actor ID");
|
|
3088
|
-
|
|
3088
|
+
_chunkVAF63BEIcjs.logger.call(void 0, ).debug({
|
|
3089
3089
|
msg: "opening sse connection",
|
|
3090
3090
|
actorId,
|
|
3091
3091
|
encoding: this.#encoding
|
|
@@ -3099,12 +3099,12 @@ var ActorConnRaw = class {
|
|
|
3099
3099
|
...init,
|
|
3100
3100
|
headers: {
|
|
3101
3101
|
...init == null ? void 0 : init.headers,
|
|
3102
|
-
"User-Agent":
|
|
3103
|
-
[
|
|
3104
|
-
...this.#params !== void 0 ? { [
|
|
3102
|
+
"User-Agent": _chunkLXAVET4Acjs.httpUserAgent.call(void 0, ),
|
|
3103
|
+
[_chunkNDCVQZBScjs.HEADER_ENCODING]: this.#encoding,
|
|
3104
|
+
...this.#params !== void 0 ? { [_chunkNDCVQZBScjs.HEADER_CONN_PARAMS]: JSON.stringify(this.#params) } : {},
|
|
3105
3105
|
...isReconnection ? {
|
|
3106
|
-
[
|
|
3107
|
-
[
|
|
3106
|
+
[_chunkNDCVQZBScjs.HEADER_CONN_ID]: this.#connectionId,
|
|
3107
|
+
[_chunkNDCVQZBScjs.HEADER_CONN_TOKEN]: this.#connectionToken
|
|
3108
3108
|
} : {}
|
|
3109
3109
|
}
|
|
3110
3110
|
})
|
|
@@ -3122,7 +3122,7 @@ var ActorConnRaw = class {
|
|
|
3122
3122
|
}
|
|
3123
3123
|
/** Called by the onopen event from drivers. */
|
|
3124
3124
|
#handleOnOpen() {
|
|
3125
|
-
|
|
3125
|
+
_chunkVAF63BEIcjs.logger.call(void 0, ).debug({
|
|
3126
3126
|
msg: "socket open",
|
|
3127
3127
|
messageQueueLength: this.#messageQueue.length,
|
|
3128
3128
|
connectionId: this.#connectionId
|
|
@@ -3130,14 +3130,14 @@ var ActorConnRaw = class {
|
|
|
3130
3130
|
if (this.#onOpenPromise) {
|
|
3131
3131
|
this.#onOpenPromise.resolve(void 0);
|
|
3132
3132
|
} else {
|
|
3133
|
-
|
|
3133
|
+
_chunkVAF63BEIcjs.logger.call(void 0, ).warn({ msg: "#onOpenPromise is undefined" });
|
|
3134
3134
|
}
|
|
3135
3135
|
for (const eventName of this.#eventSubscriptions.keys()) {
|
|
3136
3136
|
this.#sendSubscription(eventName, true);
|
|
3137
3137
|
}
|
|
3138
3138
|
const queue = this.#messageQueue;
|
|
3139
3139
|
this.#messageQueue = [];
|
|
3140
|
-
|
|
3140
|
+
_chunkVAF63BEIcjs.logger.call(void 0, ).debug({
|
|
3141
3141
|
msg: "flushing message queue",
|
|
3142
3142
|
queueLength: queue.length
|
|
3143
3143
|
});
|
|
@@ -3147,24 +3147,24 @@ var ActorConnRaw = class {
|
|
|
3147
3147
|
}
|
|
3148
3148
|
/** Called by the onmessage event from drivers. */
|
|
3149
3149
|
async #handleOnMessage(data) {
|
|
3150
|
-
|
|
3150
|
+
_chunkVAF63BEIcjs.logger.call(void 0, ).trace({
|
|
3151
3151
|
msg: "received message",
|
|
3152
3152
|
dataType: typeof data,
|
|
3153
3153
|
isBlob: data instanceof Blob,
|
|
3154
3154
|
isArrayBuffer: data instanceof ArrayBuffer
|
|
3155
3155
|
});
|
|
3156
3156
|
const response = await this.#parseMessage(data);
|
|
3157
|
-
|
|
3158
|
-
|
|
3157
|
+
_chunkVAF63BEIcjs.logger.call(void 0, ).trace(
|
|
3158
|
+
_chunkLXAVET4Acjs.getEnvUniversal.call(void 0, "_RIVETKIT_LOG_MESSAGE") ? {
|
|
3159
3159
|
msg: "parsed message",
|
|
3160
|
-
message:
|
|
3160
|
+
message: _chunkNDCVQZBScjs.jsonStringifyCompat.call(void 0, response).substring(0, 100) + "..."
|
|
3161
3161
|
} : { msg: "parsed message" }
|
|
3162
3162
|
);
|
|
3163
3163
|
if (response.body.tag === "Init") {
|
|
3164
3164
|
this.#actorId = response.body.val.actorId;
|
|
3165
3165
|
this.#connectionId = response.body.val.connectionId;
|
|
3166
3166
|
this.#connectionToken = response.body.val.connectionToken;
|
|
3167
|
-
|
|
3167
|
+
_chunkVAF63BEIcjs.logger.call(void 0, ).trace({
|
|
3168
3168
|
msg: "received init message",
|
|
3169
3169
|
actorId: this.#actorId,
|
|
3170
3170
|
connectionId: this.#connectionId
|
|
@@ -3174,7 +3174,7 @@ var ActorConnRaw = class {
|
|
|
3174
3174
|
const { group, code, message, metadata, actionId } = response.body.val;
|
|
3175
3175
|
if (actionId) {
|
|
3176
3176
|
const inFlight = this.#takeActionInFlight(Number(actionId));
|
|
3177
|
-
|
|
3177
|
+
_chunkVAF63BEIcjs.logger.call(void 0, ).warn({
|
|
3178
3178
|
msg: "action error",
|
|
3179
3179
|
actionId,
|
|
3180
3180
|
actionName: inFlight == null ? void 0 : inFlight.name,
|
|
@@ -3185,7 +3185,7 @@ var ActorConnRaw = class {
|
|
|
3185
3185
|
});
|
|
3186
3186
|
inFlight.reject(new ActorError(group, code, message, metadata));
|
|
3187
3187
|
} else {
|
|
3188
|
-
|
|
3188
|
+
_chunkVAF63BEIcjs.logger.call(void 0, ).warn({
|
|
3189
3189
|
msg: "connection error",
|
|
3190
3190
|
group,
|
|
3191
3191
|
code,
|
|
@@ -3209,22 +3209,22 @@ var ActorConnRaw = class {
|
|
|
3209
3209
|
}
|
|
3210
3210
|
} else if (response.body.tag === "ActionResponse") {
|
|
3211
3211
|
const { id: actionId } = response.body.val;
|
|
3212
|
-
|
|
3212
|
+
_chunkVAF63BEIcjs.logger.call(void 0, ).trace({
|
|
3213
3213
|
msg: "received action response",
|
|
3214
3214
|
actionId
|
|
3215
3215
|
});
|
|
3216
3216
|
const inFlight = this.#takeActionInFlight(Number(actionId));
|
|
3217
|
-
|
|
3217
|
+
_chunkVAF63BEIcjs.logger.call(void 0, ).trace({
|
|
3218
3218
|
msg: "resolving action promise",
|
|
3219
3219
|
actionId,
|
|
3220
3220
|
actionName: inFlight == null ? void 0 : inFlight.name
|
|
3221
3221
|
});
|
|
3222
3222
|
inFlight.resolve(response.body.val);
|
|
3223
3223
|
} else if (response.body.tag === "Event") {
|
|
3224
|
-
|
|
3224
|
+
_chunkVAF63BEIcjs.logger.call(void 0, ).trace({ msg: "received event", name: response.body.val.name });
|
|
3225
3225
|
this.#dispatchEvent(response.body.val);
|
|
3226
3226
|
} else {
|
|
3227
|
-
|
|
3227
|
+
_chunkLXAVET4Acjs.assertUnreachable.call(void 0, response.body);
|
|
3228
3228
|
}
|
|
3229
3229
|
}
|
|
3230
3230
|
/** Called by the onclose event from drivers. */
|
|
@@ -3234,7 +3234,7 @@ var ActorConnRaw = class {
|
|
|
3234
3234
|
}
|
|
3235
3235
|
const closeEvent = event;
|
|
3236
3236
|
const wasClean = closeEvent.wasClean;
|
|
3237
|
-
|
|
3237
|
+
_chunkVAF63BEIcjs.logger.call(void 0, ).info({
|
|
3238
3238
|
msg: "socket closed",
|
|
3239
3239
|
code: closeEvent.code,
|
|
3240
3240
|
reason: closeEvent.reason,
|
|
@@ -3244,7 +3244,7 @@ var ActorConnRaw = class {
|
|
|
3244
3244
|
actionsInFlight: this.#actionsInFlight.size
|
|
3245
3245
|
});
|
|
3246
3246
|
if (this.#actionsInFlight.size > 0) {
|
|
3247
|
-
|
|
3247
|
+
_chunkVAF63BEIcjs.logger.call(void 0, ).debug({
|
|
3248
3248
|
msg: "rejecting in-flight actions after disconnect",
|
|
3249
3249
|
count: this.#actionsInFlight.size,
|
|
3250
3250
|
connectionId: this.#connectionId,
|
|
@@ -3260,7 +3260,7 @@ var ActorConnRaw = class {
|
|
|
3260
3260
|
}
|
|
3261
3261
|
this.#transport = void 0;
|
|
3262
3262
|
if (!this.#disposed && !this.#connecting) {
|
|
3263
|
-
|
|
3263
|
+
_chunkVAF63BEIcjs.logger.call(void 0, ).debug({
|
|
3264
3264
|
msg: "triggering reconnect",
|
|
3265
3265
|
connectionId: this.#connectionId,
|
|
3266
3266
|
messageQueueLength: this.#messageQueue.length
|
|
@@ -3271,7 +3271,7 @@ var ActorConnRaw = class {
|
|
|
3271
3271
|
/** Called by the onerror event from drivers. */
|
|
3272
3272
|
#handleOnError() {
|
|
3273
3273
|
if (this.#disposed) return;
|
|
3274
|
-
|
|
3274
|
+
_chunkVAF63BEIcjs.logger.call(void 0, ).warn("socket error");
|
|
3275
3275
|
}
|
|
3276
3276
|
#takeActionInFlight(id) {
|
|
3277
3277
|
const inFlight = this.#actionsInFlight.get(id);
|
|
@@ -3301,9 +3301,9 @@ var ActorConnRaw = class {
|
|
|
3301
3301
|
try {
|
|
3302
3302
|
handler(error);
|
|
3303
3303
|
} catch (err) {
|
|
3304
|
-
|
|
3304
|
+
_chunkVAF63BEIcjs.logger.call(void 0, ).error({
|
|
3305
3305
|
msg: "error in connection error handler",
|
|
3306
|
-
error:
|
|
3306
|
+
error: _chunkLXAVET4Acjs.stringifyError.call(void 0, err)
|
|
3307
3307
|
});
|
|
3308
3308
|
}
|
|
3309
3309
|
}
|
|
@@ -3374,11 +3374,11 @@ var ActorConnRaw = class {
|
|
|
3374
3374
|
}
|
|
3375
3375
|
let queueMessage = false;
|
|
3376
3376
|
if (!this.#transport) {
|
|
3377
|
-
|
|
3377
|
+
_chunkVAF63BEIcjs.logger.call(void 0, ).debug({ msg: "no transport, queueing message" });
|
|
3378
3378
|
queueMessage = true;
|
|
3379
3379
|
} else if ("websocket" in this.#transport) {
|
|
3380
3380
|
const readyState = this.#transport.websocket.readyState;
|
|
3381
|
-
|
|
3381
|
+
_chunkVAF63BEIcjs.logger.call(void 0, ).debug({
|
|
3382
3382
|
msg: "websocket send attempt",
|
|
3383
3383
|
readyState,
|
|
3384
3384
|
readyStateString: readyState === 0 ? "CONNECTING" : readyState === 1 ? "OPEN" : readyState === 2 ? "CLOSING" : "CLOSED",
|
|
@@ -3388,18 +3388,18 @@ var ActorConnRaw = class {
|
|
|
3388
3388
|
});
|
|
3389
3389
|
if (readyState === 1) {
|
|
3390
3390
|
try {
|
|
3391
|
-
const messageSerialized =
|
|
3391
|
+
const messageSerialized = _chunkNDCVQZBScjs.serializeWithEncoding.call(void 0,
|
|
3392
3392
|
this.#encoding,
|
|
3393
3393
|
message,
|
|
3394
|
-
|
|
3394
|
+
_chunk7OOBMCQIcjs.TO_SERVER_VERSIONED
|
|
3395
3395
|
);
|
|
3396
3396
|
this.#transport.websocket.send(messageSerialized);
|
|
3397
|
-
|
|
3397
|
+
_chunkVAF63BEIcjs.logger.call(void 0, ).trace({
|
|
3398
3398
|
msg: "sent websocket message",
|
|
3399
3399
|
len: messageLength(messageSerialized)
|
|
3400
3400
|
});
|
|
3401
3401
|
} catch (error) {
|
|
3402
|
-
|
|
3402
|
+
_chunkVAF63BEIcjs.logger.call(void 0, ).warn({
|
|
3403
3403
|
msg: "failed to send message, added to queue",
|
|
3404
3404
|
error,
|
|
3405
3405
|
connectionId: this.#connectionId
|
|
@@ -3407,7 +3407,7 @@ var ActorConnRaw = class {
|
|
|
3407
3407
|
queueMessage = true;
|
|
3408
3408
|
}
|
|
3409
3409
|
} else {
|
|
3410
|
-
|
|
3410
|
+
_chunkVAF63BEIcjs.logger.call(void 0, ).debug({
|
|
3411
3411
|
msg: "websocket not open, queueing message",
|
|
3412
3412
|
readyState
|
|
3413
3413
|
});
|
|
@@ -3420,11 +3420,11 @@ var ActorConnRaw = class {
|
|
|
3420
3420
|
queueMessage = true;
|
|
3421
3421
|
}
|
|
3422
3422
|
} else {
|
|
3423
|
-
|
|
3423
|
+
_chunkLXAVET4Acjs.assertUnreachable.call(void 0, this.#transport);
|
|
3424
3424
|
}
|
|
3425
3425
|
if (!(opts == null ? void 0 : opts.ephemeral) && queueMessage) {
|
|
3426
3426
|
this.#messageQueue.push(message);
|
|
3427
|
-
|
|
3427
|
+
_chunkVAF63BEIcjs.logger.call(void 0, ).debug({
|
|
3428
3428
|
msg: "queued connection message",
|
|
3429
3429
|
queueLength: this.#messageQueue.length,
|
|
3430
3430
|
connectionId: this.#connectionId,
|
|
@@ -3437,13 +3437,13 @@ var ActorConnRaw = class {
|
|
|
3437
3437
|
try {
|
|
3438
3438
|
if (!this.#actorId || !this.#connectionId || !this.#connectionToken)
|
|
3439
3439
|
throw new InternalError2("Missing connection ID or token.");
|
|
3440
|
-
|
|
3441
|
-
|
|
3440
|
+
_chunkVAF63BEIcjs.logger.call(void 0, ).trace(
|
|
3441
|
+
_chunkLXAVET4Acjs.getEnvUniversal.call(void 0, "_RIVETKIT_LOG_MESSAGE") ? {
|
|
3442
3442
|
msg: "sent http message",
|
|
3443
|
-
message: `${
|
|
3443
|
+
message: `${_chunkNDCVQZBScjs.jsonStringifyCompat.call(void 0, message).substring(0, 100)}...`
|
|
3444
3444
|
} : { msg: "sent http message" }
|
|
3445
3445
|
);
|
|
3446
|
-
|
|
3446
|
+
_chunkVAF63BEIcjs.logger.call(void 0, ).debug({
|
|
3447
3447
|
msg: "sending http message",
|
|
3448
3448
|
actorId: this.#actorId,
|
|
3449
3449
|
connectionId: this.#connectionId
|
|
@@ -3452,19 +3452,19 @@ var ActorConnRaw = class {
|
|
|
3452
3452
|
url: "http://actor/connections/message",
|
|
3453
3453
|
method: "POST",
|
|
3454
3454
|
headers: {
|
|
3455
|
-
[
|
|
3456
|
-
[
|
|
3457
|
-
[
|
|
3455
|
+
[_chunkNDCVQZBScjs.HEADER_ENCODING]: this.#encoding,
|
|
3456
|
+
[_chunkNDCVQZBScjs.HEADER_CONN_ID]: this.#connectionId,
|
|
3457
|
+
[_chunkNDCVQZBScjs.HEADER_CONN_TOKEN]: this.#connectionToken
|
|
3458
3458
|
},
|
|
3459
3459
|
body: message,
|
|
3460
3460
|
encoding: this.#encoding,
|
|
3461
3461
|
skipParseResponse: true,
|
|
3462
3462
|
customFetch: this.#driver.sendRequest.bind(this.#driver, this.#actorId),
|
|
3463
|
-
requestVersionedDataHandler:
|
|
3464
|
-
responseVersionedDataHandler:
|
|
3463
|
+
requestVersionedDataHandler: _chunk7OOBMCQIcjs.TO_SERVER_VERSIONED,
|
|
3464
|
+
responseVersionedDataHandler: _chunk7OOBMCQIcjs.TO_CLIENT_VERSIONED
|
|
3465
3465
|
});
|
|
3466
3466
|
} catch (error) {
|
|
3467
|
-
|
|
3467
|
+
_chunkVAF63BEIcjs.logger.call(void 0, ).warn({ msg: "failed to send message, added to queue", error });
|
|
3468
3468
|
if (!(opts == null ? void 0 : opts.ephemeral)) {
|
|
3469
3469
|
this.#messageQueue.unshift(message);
|
|
3470
3470
|
}
|
|
@@ -3472,7 +3472,7 @@ var ActorConnRaw = class {
|
|
|
3472
3472
|
}
|
|
3473
3473
|
async #parseMessage(data) {
|
|
3474
3474
|
_invariant2.default.call(void 0, this.#transport, "transport must be defined");
|
|
3475
|
-
if (
|
|
3475
|
+
if (_chunkNDCVQZBScjs.encodingIsBinary.call(void 0, this.#encoding) && "sse" in this.#transport) {
|
|
3476
3476
|
if (typeof data === "string") {
|
|
3477
3477
|
const binaryString = atob(data);
|
|
3478
3478
|
data = new Uint8Array(
|
|
@@ -3484,8 +3484,8 @@ var ActorConnRaw = class {
|
|
|
3484
3484
|
);
|
|
3485
3485
|
}
|
|
3486
3486
|
}
|
|
3487
|
-
const buffer = await
|
|
3488
|
-
return
|
|
3487
|
+
const buffer = await _chunk7OOBMCQIcjs.inputDataToBuffer.call(void 0, data);
|
|
3488
|
+
return _chunkNDCVQZBScjs.deserializeWithEncoding.call(void 0, this.#encoding, buffer, _chunk7OOBMCQIcjs.TO_CLIENT_VERSIONED);
|
|
3489
3489
|
}
|
|
3490
3490
|
/**
|
|
3491
3491
|
* Get the actor ID (for testing purposes).
|
|
@@ -3508,11 +3508,11 @@ var ActorConnRaw = class {
|
|
|
3508
3508
|
*/
|
|
3509
3509
|
async dispose() {
|
|
3510
3510
|
if (this.#disposed) {
|
|
3511
|
-
|
|
3511
|
+
_chunkVAF63BEIcjs.logger.call(void 0, ).warn({ msg: "connection already disconnected" });
|
|
3512
3512
|
return;
|
|
3513
3513
|
}
|
|
3514
3514
|
this.#disposed = true;
|
|
3515
|
-
|
|
3515
|
+
_chunkVAF63BEIcjs.logger.call(void 0, ).debug({ msg: "disposing actor conn" });
|
|
3516
3516
|
clearInterval(this.#keepNodeAliveInterval);
|
|
3517
3517
|
this.#abortController.abort();
|
|
3518
3518
|
this.#client[ACTOR_CONNS_SYMBOL].delete(this);
|
|
@@ -3520,11 +3520,11 @@ var ActorConnRaw = class {
|
|
|
3520
3520
|
} else if ("websocket" in this.#transport) {
|
|
3521
3521
|
const ws = this.#transport.websocket;
|
|
3522
3522
|
if (ws.readyState === 2 || ws.readyState === 3) {
|
|
3523
|
-
|
|
3523
|
+
_chunkVAF63BEIcjs.logger.call(void 0, ).debug({ msg: "ws already closed or closing" });
|
|
3524
3524
|
} else {
|
|
3525
|
-
const { promise, resolve } =
|
|
3525
|
+
const { promise, resolve } = _chunkLXAVET4Acjs.promiseWithResolvers.call(void 0, );
|
|
3526
3526
|
ws.addEventListener("close", () => {
|
|
3527
|
-
|
|
3527
|
+
_chunkVAF63BEIcjs.logger.call(void 0, ).debug({ msg: "ws closed" });
|
|
3528
3528
|
resolve(void 0);
|
|
3529
3529
|
});
|
|
3530
3530
|
ws.close();
|
|
@@ -3537,8 +3537,8 @@ var ActorConnRaw = class {
|
|
|
3537
3537
|
url: "http://actor/connections/close",
|
|
3538
3538
|
method: "POST",
|
|
3539
3539
|
headers: {
|
|
3540
|
-
[
|
|
3541
|
-
[
|
|
3540
|
+
[_chunkNDCVQZBScjs.HEADER_CONN_ID]: this.#connectionId,
|
|
3541
|
+
[_chunkNDCVQZBScjs.HEADER_CONN_TOKEN]: this.#connectionToken
|
|
3542
3542
|
},
|
|
3543
3543
|
encoding: this.#encoding,
|
|
3544
3544
|
skipParseResponse: true,
|
|
@@ -3546,16 +3546,16 @@ var ActorConnRaw = class {
|
|
|
3546
3546
|
this.#driver,
|
|
3547
3547
|
this.#actorId
|
|
3548
3548
|
),
|
|
3549
|
-
requestVersionedDataHandler:
|
|
3550
|
-
responseVersionedDataHandler:
|
|
3549
|
+
requestVersionedDataHandler: _chunk7OOBMCQIcjs.TO_SERVER_VERSIONED,
|
|
3550
|
+
responseVersionedDataHandler: _chunk7OOBMCQIcjs.TO_CLIENT_VERSIONED
|
|
3551
3551
|
});
|
|
3552
3552
|
} catch (error) {
|
|
3553
|
-
|
|
3553
|
+
_chunkVAF63BEIcjs.logger.call(void 0, ).warn({ msg: "failed to send close request", error });
|
|
3554
3554
|
}
|
|
3555
3555
|
}
|
|
3556
3556
|
this.#transport.sse.close();
|
|
3557
3557
|
} else {
|
|
3558
|
-
|
|
3558
|
+
_chunkLXAVET4Acjs.assertUnreachable.call(void 0, this.#transport);
|
|
3559
3559
|
}
|
|
3560
3560
|
this.#transport = void 0;
|
|
3561
3561
|
}
|
|
@@ -3581,7 +3581,7 @@ var ActorConnRaw = class {
|
|
|
3581
3581
|
|
|
3582
3582
|
// src/remote-manager-driver/log.ts
|
|
3583
3583
|
function logger2() {
|
|
3584
|
-
return
|
|
3584
|
+
return _chunkETDWYT2Pcjs.getLogger.call(void 0, "remote-manager-driver");
|
|
3585
3585
|
}
|
|
3586
3586
|
|
|
3587
3587
|
// src/remote-manager-driver/api-utils.ts
|
|
@@ -3598,7 +3598,7 @@ function getEndpoint(config) {
|
|
|
3598
3598
|
}
|
|
3599
3599
|
async function apiCall(config, method, path, body) {
|
|
3600
3600
|
const endpoint = getEndpoint(config);
|
|
3601
|
-
const url =
|
|
3601
|
+
const url = _chunkLXAVET4Acjs.combineUrlPath.call(void 0, endpoint, path, {
|
|
3602
3602
|
namespace: config.namespace
|
|
3603
3603
|
});
|
|
3604
3604
|
logger2().debug({ msg: "making api call", method, url });
|
|
@@ -3624,7 +3624,7 @@ async function apiCall(config, method, path, body) {
|
|
|
3624
3624
|
async function sendHttpRequestToActor(runConfig, actorId, actorRequest) {
|
|
3625
3625
|
const url = new URL(actorRequest.url);
|
|
3626
3626
|
const endpoint = getEndpoint(runConfig);
|
|
3627
|
-
const guardUrl =
|
|
3627
|
+
const guardUrl = _chunkLXAVET4Acjs.combineUrlPath.call(void 0, endpoint, url.pathname + url.search);
|
|
3628
3628
|
let bodyToSend = null;
|
|
3629
3629
|
const guardHeaders = buildGuardHeadersForHttp(
|
|
3630
3630
|
runConfig,
|
|
@@ -3661,19 +3661,19 @@ function buildGuardHeadersForHttp(runConfig, actorRequest, actorId) {
|
|
|
3661
3661
|
for (const [key, value] of Object.entries(runConfig.headers)) {
|
|
3662
3662
|
headers.set(key, value);
|
|
3663
3663
|
}
|
|
3664
|
-
headers.set(
|
|
3665
|
-
headers.set(
|
|
3664
|
+
headers.set(_chunkNDCVQZBScjs.HEADER_RIVET_TARGET, "actor");
|
|
3665
|
+
headers.set(_chunkNDCVQZBScjs.HEADER_RIVET_ACTOR, actorId);
|
|
3666
3666
|
if (runConfig.token) {
|
|
3667
|
-
headers.set(
|
|
3667
|
+
headers.set(_chunkNDCVQZBScjs.HEADER_RIVET_TOKEN, runConfig.token);
|
|
3668
3668
|
}
|
|
3669
3669
|
return headers;
|
|
3670
3670
|
}
|
|
3671
3671
|
|
|
3672
3672
|
// src/remote-manager-driver/actor-websocket-client.ts
|
|
3673
3673
|
async function openWebSocketToActor(runConfig, path, actorId, encoding, params, connId, connToken) {
|
|
3674
|
-
const WebSocket2 = await
|
|
3674
|
+
const WebSocket2 = await _chunkVAF63BEIcjs.importWebSocket.call(void 0, );
|
|
3675
3675
|
const endpoint = getEndpoint(runConfig);
|
|
3676
|
-
const guardUrl =
|
|
3676
|
+
const guardUrl = _chunkLXAVET4Acjs.combineUrlPath.call(void 0, endpoint, path);
|
|
3677
3677
|
logger2().debug({
|
|
3678
3678
|
msg: "opening websocket to actor via guard",
|
|
3679
3679
|
actorId,
|
|
@@ -3697,23 +3697,23 @@ async function openWebSocketToActor(runConfig, path, actorId, encoding, params,
|
|
|
3697
3697
|
}
|
|
3698
3698
|
function buildWebSocketProtocols(runConfig, actorId, encoding, params, connId, connToken) {
|
|
3699
3699
|
const protocols = [];
|
|
3700
|
-
protocols.push(
|
|
3701
|
-
protocols.push(`${
|
|
3702
|
-
protocols.push(`${
|
|
3703
|
-
protocols.push(`${
|
|
3700
|
+
protocols.push(_chunkNDCVQZBScjs.WS_PROTOCOL_STANDARD);
|
|
3701
|
+
protocols.push(`${_chunkNDCVQZBScjs.WS_PROTOCOL_TARGET}actor`);
|
|
3702
|
+
protocols.push(`${_chunkNDCVQZBScjs.WS_PROTOCOL_ACTOR}${actorId}`);
|
|
3703
|
+
protocols.push(`${_chunkNDCVQZBScjs.WS_PROTOCOL_ENCODING}${encoding}`);
|
|
3704
3704
|
if (runConfig.token) {
|
|
3705
|
-
protocols.push(`${
|
|
3705
|
+
protocols.push(`${_chunkNDCVQZBScjs.WS_PROTOCOL_TOKEN}${runConfig.token}`);
|
|
3706
3706
|
}
|
|
3707
3707
|
if (params) {
|
|
3708
3708
|
protocols.push(
|
|
3709
|
-
`${
|
|
3709
|
+
`${_chunkNDCVQZBScjs.WS_PROTOCOL_CONN_PARAMS}${encodeURIComponent(JSON.stringify(params))}`
|
|
3710
3710
|
);
|
|
3711
3711
|
}
|
|
3712
3712
|
if (connId) {
|
|
3713
|
-
protocols.push(`${
|
|
3713
|
+
protocols.push(`${_chunkNDCVQZBScjs.WS_PROTOCOL_CONN_ID}${connId}`);
|
|
3714
3714
|
}
|
|
3715
3715
|
if (connToken) {
|
|
3716
|
-
protocols.push(`${
|
|
3716
|
+
protocols.push(`${_chunkNDCVQZBScjs.WS_PROTOCOL_CONN_TOKEN}${connToken}`);
|
|
3717
3717
|
}
|
|
3718
3718
|
return protocols;
|
|
3719
3719
|
}
|
|
@@ -3760,7 +3760,7 @@ async function destroyActor(config, actorId) {
|
|
|
3760
3760
|
|
|
3761
3761
|
// src/remote-manager-driver/ws-proxy.ts
|
|
3762
3762
|
async function createWebSocketProxy(c, targetUrl, protocols) {
|
|
3763
|
-
const WebSocket2 = await
|
|
3763
|
+
const WebSocket2 = await _chunkVAF63BEIcjs.importWebSocket.call(void 0, );
|
|
3764
3764
|
const state = {};
|
|
3765
3765
|
return {
|
|
3766
3766
|
onOpen: async (event, clientWs) => {
|
|
@@ -3820,7 +3820,7 @@ async function createWebSocketProxy(c, targetUrl, protocols) {
|
|
|
3820
3820
|
logger2().error({
|
|
3821
3821
|
msg: "target websocket error",
|
|
3822
3822
|
targetUrl,
|
|
3823
|
-
error:
|
|
3823
|
+
error: _chunkLXAVET4Acjs.stringifyError.call(void 0, error)
|
|
3824
3824
|
});
|
|
3825
3825
|
closeWebSocketIfOpen(clientWs, 1011, "Target WebSocket error");
|
|
3826
3826
|
});
|
|
@@ -4022,7 +4022,7 @@ var RemoteManagerDriver = class {
|
|
|
4022
4022
|
const upgradeWebSocket = (_b = (_a = this.#config).getUpgradeWebSocket) == null ? void 0 : _b.call(_a);
|
|
4023
4023
|
_invariant2.default.call(void 0, upgradeWebSocket, "missing getUpgradeWebSocket");
|
|
4024
4024
|
const endpoint = getEndpoint(this.#config);
|
|
4025
|
-
const guardUrl =
|
|
4025
|
+
const guardUrl = _chunkLXAVET4Acjs.combineUrlPath.call(void 0, endpoint, path);
|
|
4026
4026
|
const wsGuardUrl = guardUrl.replace("http://", "ws://");
|
|
4027
4027
|
logger2().debug({
|
|
4028
4028
|
msg: "forwarding websocket to actor via guard",
|
|
@@ -4039,13 +4039,13 @@ var RemoteManagerDriver = class {
|
|
|
4039
4039
|
connToken
|
|
4040
4040
|
);
|
|
4041
4041
|
const args = await createWebSocketProxy(c, wsGuardUrl, protocols);
|
|
4042
|
-
return await upgradeWebSocket(() => args)(c,
|
|
4042
|
+
return await upgradeWebSocket(() => args)(c, _chunkLXAVET4Acjs.noopNext.call(void 0, ));
|
|
4043
4043
|
}
|
|
4044
4044
|
displayInformation() {
|
|
4045
4045
|
return { name: "Remote", properties: {} };
|
|
4046
4046
|
}
|
|
4047
4047
|
getOrCreateInspectorAccessToken() {
|
|
4048
|
-
return
|
|
4048
|
+
return _chunkNDCVQZBScjs.generateRandomString.call(void 0, );
|
|
4049
4049
|
}
|
|
4050
4050
|
};
|
|
4051
4051
|
|
|
@@ -4068,4 +4068,4 @@ var RemoteManagerDriver = class {
|
|
|
4068
4068
|
|
|
4069
4069
|
|
|
4070
4070
|
exports.generateConnId = generateConnId; exports.generateConnToken = generateConnToken; exports.generateConnSocketId = generateConnSocketId; exports.createActorInspectorRouter = createActorInspectorRouter; exports.serializeActorKey = serializeActorKey; exports.deserializeActorKey = deserializeActorKey; exports.ActorDefinition = ActorDefinition; exports.lookupInRegistry = lookupInRegistry; exports.ActorClientError = ActorClientError; exports.InternalError = InternalError2; exports.ManagerError = ManagerError; exports.MalformedResponseMessage = MalformedResponseMessage; exports.ActorError = ActorError; exports.ActorConnRaw = ActorConnRaw; exports.ActorHandleRaw = ActorHandleRaw; exports.createClientWithDriver = createClientWithDriver; exports.RemoteManagerDriver = RemoteManagerDriver;
|
|
4071
|
-
//# sourceMappingURL=chunk-
|
|
4071
|
+
//# sourceMappingURL=chunk-NUA6LOOJ.cjs.map
|