castle-web-sdk 0.4.38 → 0.4.39
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/multiplayer.d.ts +21 -0
- package/dist/server/wrapper.js +41 -3
- package/package.json +1 -1
package/dist/multiplayer.d.ts
CHANGED
|
@@ -90,6 +90,21 @@ export type MultiplayerWorldCharacterQuery = {
|
|
|
90
90
|
limit?: number;
|
|
91
91
|
cursor?: string;
|
|
92
92
|
};
|
|
93
|
+
/** Authenticated, participant-scoped projection of a shared character world. */
|
|
94
|
+
export interface MultiplayerWorldCharacterInspectResult<Gameplay = unknown, SharedState = unknown, PrivateState = unknown, Source = unknown> {
|
|
95
|
+
/** Durable identity used by gameplay holders and promise debtors. */
|
|
96
|
+
participantId: string;
|
|
97
|
+
worldRevision: string;
|
|
98
|
+
gameplay: Gameplay;
|
|
99
|
+
characters: Array<{
|
|
100
|
+
characterId: string;
|
|
101
|
+
npcRevision: string;
|
|
102
|
+
sharedState: SharedState;
|
|
103
|
+
privateState: PrivateState;
|
|
104
|
+
privateRevision: string;
|
|
105
|
+
}>;
|
|
106
|
+
sources: Source[];
|
|
107
|
+
}
|
|
93
108
|
export interface MultiplayerWorldCharacterCommandResult {
|
|
94
109
|
operationId: string;
|
|
95
110
|
status: "applied" | "ineligible";
|
|
@@ -118,6 +133,12 @@ export interface MultiplayerConnection {
|
|
|
118
133
|
operationId: string;
|
|
119
134
|
command: MultiplayerWorldCharacterCommand;
|
|
120
135
|
}): Promise<MultiplayerWorldCharacterCommandResult>;
|
|
136
|
+
readCharacters(request: {
|
|
137
|
+
requestId: string;
|
|
138
|
+
query: {
|
|
139
|
+
type: "inspect";
|
|
140
|
+
};
|
|
141
|
+
}): Promise<MultiplayerWorldCharacterInspectResult>;
|
|
121
142
|
readCharacters<T = unknown>(request: {
|
|
122
143
|
requestId: string;
|
|
123
144
|
query: MultiplayerWorldCharacterQuery;
|
package/dist/server/wrapper.js
CHANGED
|
@@ -49,6 +49,7 @@ async function bootSession(platformHandle, callbacks) {
|
|
|
49
49
|
platformHandle.on("worldCharacterTurn", async (raw) => {
|
|
50
50
|
const request = assertPlatformWorldCharacterTurn(raw);
|
|
51
51
|
let settled = false;
|
|
52
|
+
const brokerFailure = { rejection: null };
|
|
52
53
|
const turn = Object.freeze({
|
|
53
54
|
requestId: request.requestId,
|
|
54
55
|
operationId: request.operationId,
|
|
@@ -64,7 +65,14 @@ async function bootSession(platformHandle, callbacks) {
|
|
|
64
65
|
if (settled)
|
|
65
66
|
throw new TypeError("This shared character request is already settled.");
|
|
66
67
|
settled = true;
|
|
67
|
-
|
|
68
|
+
let rawReceipt;
|
|
69
|
+
try {
|
|
70
|
+
rawReceipt = await platformHandle.worldCharacterSend(request.grantId);
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
brokerFailure.rejection = { error };
|
|
74
|
+
throw error;
|
|
75
|
+
}
|
|
68
76
|
return parseWorldCharacterAdmission(rawReceipt, request.operationId);
|
|
69
77
|
},
|
|
70
78
|
reject(code) {
|
|
@@ -77,6 +85,10 @@ async function bootSession(platformHandle, callbacks) {
|
|
|
77
85
|
try {
|
|
78
86
|
await callbacks.onWorldCharacterTurn(session, turn);
|
|
79
87
|
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
if (brokerFailure.rejection === null || brokerFailure.rejection.error !== error)
|
|
90
|
+
throw error;
|
|
91
|
+
}
|
|
80
92
|
finally {
|
|
81
93
|
if (!settled)
|
|
82
94
|
turn.reject();
|
|
@@ -88,6 +100,7 @@ async function bootSession(platformHandle, callbacks) {
|
|
|
88
100
|
platformHandle.on("worldCharacterCommand", async (raw) => {
|
|
89
101
|
const request = assertPlatformWorldCharacterCommand(raw);
|
|
90
102
|
let settled = false;
|
|
103
|
+
const brokerFailure = { rejection: null };
|
|
91
104
|
const command = Object.freeze({
|
|
92
105
|
requestId: request.requestId,
|
|
93
106
|
operationId: request.operationId,
|
|
@@ -97,7 +110,15 @@ async function bootSession(platformHandle, callbacks) {
|
|
|
97
110
|
if (settled)
|
|
98
111
|
throw new TypeError("This shared character command is already settled.");
|
|
99
112
|
settled = true;
|
|
100
|
-
|
|
113
|
+
let rawResult;
|
|
114
|
+
try {
|
|
115
|
+
rawResult = await platformHandle.worldCharacterCommand(request.grantId);
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
brokerFailure.rejection = { error };
|
|
119
|
+
throw error;
|
|
120
|
+
}
|
|
121
|
+
return parseSharedCharacterJson(rawResult);
|
|
101
122
|
},
|
|
102
123
|
reject(code) {
|
|
103
124
|
if (settled)
|
|
@@ -109,6 +130,10 @@ async function bootSession(platformHandle, callbacks) {
|
|
|
109
130
|
try {
|
|
110
131
|
await callbacks.onWorldCharacterCommand(session, command);
|
|
111
132
|
}
|
|
133
|
+
catch (error) {
|
|
134
|
+
if (brokerFailure.rejection === null || brokerFailure.rejection.error !== error)
|
|
135
|
+
throw error;
|
|
136
|
+
}
|
|
112
137
|
finally {
|
|
113
138
|
if (!settled)
|
|
114
139
|
command.reject();
|
|
@@ -120,6 +145,7 @@ async function bootSession(platformHandle, callbacks) {
|
|
|
120
145
|
platformHandle.on("worldCharacterRead", async (raw) => {
|
|
121
146
|
const request = assertPlatformWorldCharacterRead(raw);
|
|
122
147
|
let settled = false;
|
|
148
|
+
const brokerFailure = { rejection: null };
|
|
123
149
|
const read = Object.freeze({
|
|
124
150
|
requestId: request.requestId,
|
|
125
151
|
speaker: Object.freeze({ ...request.speaker }),
|
|
@@ -128,7 +154,15 @@ async function bootSession(platformHandle, callbacks) {
|
|
|
128
154
|
if (settled)
|
|
129
155
|
throw new TypeError("This shared character read is already settled.");
|
|
130
156
|
settled = true;
|
|
131
|
-
|
|
157
|
+
let rawResult;
|
|
158
|
+
try {
|
|
159
|
+
rawResult = await platformHandle.worldCharacterRead(request.grantId);
|
|
160
|
+
}
|
|
161
|
+
catch (error) {
|
|
162
|
+
brokerFailure.rejection = { error };
|
|
163
|
+
throw error;
|
|
164
|
+
}
|
|
165
|
+
return parseSharedCharacterJson(rawResult);
|
|
132
166
|
},
|
|
133
167
|
reject(code) {
|
|
134
168
|
if (settled)
|
|
@@ -140,6 +174,10 @@ async function bootSession(platformHandle, callbacks) {
|
|
|
140
174
|
try {
|
|
141
175
|
await callbacks.onWorldCharacterRead(session, read);
|
|
142
176
|
}
|
|
177
|
+
catch (error) {
|
|
178
|
+
if (brokerFailure.rejection === null || brokerFailure.rejection.error !== error)
|
|
179
|
+
throw error;
|
|
180
|
+
}
|
|
143
181
|
finally {
|
|
144
182
|
if (!settled)
|
|
145
183
|
read.reject();
|