@littlepartytime/dev-kit 1.9.0 → 1.10.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.
|
@@ -41,7 +41,7 @@ export default function PhoneFrame({ children }: { children: React.ReactNode })
|
|
|
41
41
|
<div
|
|
42
42
|
ref={containerRef}
|
|
43
43
|
className="flex items-center justify-center h-full overflow-hidden"
|
|
44
|
-
style={{ minWidth: 0, minHeight: 0 }}
|
|
44
|
+
style={{ flex: 1, minWidth: 0, minHeight: 0 }}
|
|
45
45
|
>
|
|
46
46
|
{/* Wrapper sized to the scaled phone for correct layout flow */}
|
|
47
47
|
<div style={{ width: BODY_W * scale, height: BODY_H * scale, flexShrink: 0 }}>
|
|
@@ -180,8 +180,8 @@ export default function Preview() {
|
|
|
180
180
|
|
|
181
181
|
return (
|
|
182
182
|
<div className="flex gap-4 h-[calc(100vh-80px)]">
|
|
183
|
-
{/* Renderer —
|
|
184
|
-
<div className="
|
|
183
|
+
{/* Renderer — half the screen width */}
|
|
184
|
+
<div className="h-full" style={{ width: '50%' }}>
|
|
185
185
|
<PhoneFrame>
|
|
186
186
|
{GameRenderer && platform && viewState ? (
|
|
187
187
|
<GameRenderer platform={platform} state={viewState} />
|
|
@@ -218,10 +218,25 @@ export default function Preview() {
|
|
|
218
218
|
const isActive = i === playerIndex;
|
|
219
219
|
const hue = (i * 137) % 360; // deterministic color per player
|
|
220
220
|
const playerState = fullState?.players?.find((ps: any) => ps.id === p.id);
|
|
221
|
+
// Fallback chain: 1) PlayerState field 2) GameState.data mapping table
|
|
221
222
|
const ROLE_KEYS = ['role', 'character', 'team', 'class', 'job', 'faction', 'type'];
|
|
222
|
-
const
|
|
223
|
-
|
|
224
|
-
|
|
223
|
+
const DATA_MAP_KEYS = ['playerRoles', 'roles', 'playerCharacters', 'characters', 'playerTeams', 'teams'];
|
|
224
|
+
let roleLabel: string | undefined;
|
|
225
|
+
// Try PlayerState direct field
|
|
226
|
+
if (playerState) {
|
|
227
|
+
const entry = Object.entries(playerState).find(([k]) => ROLE_KEYS.includes(k.toLowerCase()));
|
|
228
|
+
if (entry) roleLabel = String(entry[1]);
|
|
229
|
+
}
|
|
230
|
+
// Try GameState.data lookup table
|
|
231
|
+
if (!roleLabel && fullState?.data) {
|
|
232
|
+
for (const mapKey of DATA_MAP_KEYS) {
|
|
233
|
+
const map = fullState.data[mapKey];
|
|
234
|
+
if (map && typeof map === 'object' && !Array.isArray(map)) {
|
|
235
|
+
const val = (map as Record<string, unknown>)[p.id];
|
|
236
|
+
if (val != null) { roleLabel = String(val); break; }
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
225
240
|
return (
|
|
226
241
|
<button
|
|
227
242
|
key={p.id}
|
|
@@ -246,9 +261,9 @@ export default function Preview() {
|
|
|
246
261
|
<span className="text-[10px] text-amber-400 shrink-0">HOST</span>
|
|
247
262
|
)}
|
|
248
263
|
</div>
|
|
249
|
-
{
|
|
264
|
+
{roleLabel && (
|
|
250
265
|
<div className="text-[10px] text-zinc-500 truncate">
|
|
251
|
-
{
|
|
266
|
+
{roleLabel}
|
|
252
267
|
</div>
|
|
253
268
|
)}
|
|
254
269
|
</div>
|