deepspace 0.16.0 → 0.17.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/index.js CHANGED
@@ -570,15 +570,6 @@ var MSG = {
570
570
  ACK: "records.ack",
571
571
  LIST_SCHEMAS: "records.list_schemas",
572
572
  RESUBSCRIBE: "records.resubscribe",
573
- // ---- GameRoom --------------------------------------------------------
574
- GAME_STATE: "game.state",
575
- GAME_INPUT: "game.input",
576
- GAME_PLAYER_JOIN: "game.player_join",
577
- GAME_PLAYER_LEAVE: "game.player_leave",
578
- GAME_PLAYER_READY: "game.player_ready",
579
- GAME_START: "game.start",
580
- GAME_END: "game.end",
581
- GAME_TICK: "game.tick",
582
573
  // ---- CanvasRoom ------------------------------------------------------
583
574
  CANVAS_SHAPES: "canvas.shapes",
584
575
  CANVAS_ADD: "canvas.add",
@@ -641,11 +632,6 @@ var clientBuild = {
641
632
  // Yjs
642
633
  yjsJoin: (collection, recordId, fieldName) => ({ type: MSG.YJS_JOIN, payload: { collection, recordId, fieldName } }),
643
634
  yjsLeave: (collection, recordId, fieldName) => ({ type: MSG.YJS_LEAVE, payload: { collection, recordId, fieldName } }),
644
- // Game
645
- gameInput: (action, data = {}) => ({ type: MSG.GAME_INPUT, payload: { action, data } }),
646
- gamePlayerReady: () => ({ type: MSG.GAME_PLAYER_READY, payload: EMPTY }),
647
- gameStart: () => ({ type: MSG.GAME_START, payload: EMPTY }),
648
- gameEnd: () => ({ type: MSG.GAME_END, payload: EMPTY }),
649
635
  // Canvas — `CANVAS_ADD` / `CANVAS_VIEWPORT` payloads are flat (the shape
650
636
  // or viewport object is the whole payload).
651
637
  canvasAdd: (shape) => ({ type: MSG.CANVAS_ADD, payload: shape }),
@@ -697,14 +683,6 @@ var serverBuild = {
697
683
  type: MSG.YJS_JOIN,
698
684
  payload: { collection, recordId, fieldName, canWrite }
699
685
  }),
700
- // Game
701
- gameState: (state, tick, players, running) => ({ type: MSG.GAME_STATE, payload: { state, tick, players, running } }),
702
- gameTick: (state, tick) => ({ type: MSG.GAME_TICK, payload: { state, tick } }),
703
- gameStart: (state, tick) => ({ type: MSG.GAME_START, payload: { state, tick } }),
704
- gameEnd: (state, tick) => ({ type: MSG.GAME_END, payload: { state, tick } }),
705
- gamePlayerJoin: (player) => ({ type: MSG.GAME_PLAYER_JOIN, payload: { player } }),
706
- gamePlayerLeave: (userId) => ({ type: MSG.GAME_PLAYER_LEAVE, payload: { userId } }),
707
- gamePlayerReady: (userId) => ({ type: MSG.GAME_PLAYER_READY, payload: { userId } }),
708
686
  // Canvas
709
687
  canvasShapes: (shapes, viewports) => ({ type: MSG.CANVAS_SHAPES, payload: { shapes, viewports } }),
710
688
  canvasAdd: (shape) => ({ type: MSG.CANVAS_ADD, payload: { shape } }),
@@ -770,7 +748,6 @@ function encode(message) {
770
748
  // src/shared/protocol/app-migrations.ts
771
749
  var APP_MIGRATION_ID_RE = /^[a-z0-9][a-z0-9._-]{0,127}$/;
772
750
  var MAX_APP_MIGRATION_IDS = 256;
773
- var CANONICAL_APP_IDENTITY_MIGRATION_ID = "2026-08-canonical-app-identity-wire";
774
751
  var WORKER_OWNED_NOT_FOUND_MIGRATION_ID = "2026-08-worker-owned-not-found";
775
752
  function validateAppMigrationIds(value) {
776
753
  if (!Array.isArray(value)) {
@@ -2973,123 +2950,15 @@ function useYjsRoom(docId, fieldName) {
2973
2950
  return { doc, awareness, text, setText, synced, canWrite, writeAuthResolved };
2974
2951
  }
2975
2952
 
2976
- // src/client/storage/hooks/useGameRoom.ts
2953
+ // src/client/storage/hooks/useCanvas.ts
2977
2954
  import { useState as useState8, useEffect as useEffect11, useCallback as useCallback10, useRef as useRef9 } from "react";
2978
- function useGameRoom(roomId) {
2979
- const [gameState, setGameState] = useState8({});
2980
- const [tick, setTick] = useState8(0);
2981
- const [players, setPlayers] = useState8([]);
2982
- const [running, setRunning] = useState8(false);
2955
+ function useCanvas(roomId) {
2956
+ const [shapes, setShapes] = useState8([]);
2957
+ const [viewports, setViewports] = useState8([]);
2983
2958
  const [connected, setConnected] = useState8(false);
2984
2959
  const [canWrite, setCanWrite] = useState8(false);
2985
2960
  const wsRef = useRef9(null);
2986
2961
  useEffect11(() => {
2987
- let ws = null;
2988
- let reconnectTimer = null;
2989
- let alive = true;
2990
- const connect = async () => {
2991
- if (!alive) return;
2992
- const token = await getAuthToken();
2993
- const protocol = window.location.protocol === "https:" ? "wss:" : "ws:";
2994
- const baseUrl = `${protocol}//${window.location.host}`;
2995
- const url = new URL(`/ws/game/${encodeURIComponent(roomId)}`, baseUrl);
2996
- if (token) url.searchParams.set("token", token);
2997
- wsLog("connecting", `game:${roomId}`);
2998
- ws = new WebSocket(url.toString());
2999
- wsRef.current = ws;
3000
- ws.onopen = () => {
3001
- wsLog("connected", `game:${roomId}`);
3002
- setConnected(true);
3003
- };
3004
- ws.onmessage = (event) => {
3005
- dispatch(event.data, {
3006
- [MSG.AUTH]: (p) => {
3007
- setCanWrite(p.canWrite);
3008
- },
3009
- [MSG.GAME_STATE]: (p) => {
3010
- setGameState(p.state);
3011
- setTick(p.tick);
3012
- setPlayers(p.players);
3013
- setRunning(p.running);
3014
- },
3015
- [MSG.GAME_TICK]: (p) => {
3016
- setGameState(p.state);
3017
- setTick(p.tick);
3018
- },
3019
- [MSG.GAME_PLAYER_JOIN]: (p) => {
3020
- const player = p.player;
3021
- setPlayers((prev) => [...prev.filter((x) => x.userId !== player.userId), player]);
3022
- },
3023
- [MSG.GAME_PLAYER_LEAVE]: (p) => {
3024
- setPlayers((prev) => prev.filter((x) => x.userId !== p.userId));
3025
- },
3026
- [MSG.GAME_PLAYER_READY]: (p) => {
3027
- setPlayers(
3028
- (prev) => prev.map((x) => x.userId === p.userId ? { ...x, ready: true } : x)
3029
- );
3030
- },
3031
- [MSG.GAME_START]: (p) => {
3032
- setRunning(true);
3033
- setGameState(p.state);
3034
- setTick(p.tick);
3035
- },
3036
- [MSG.GAME_END]: (p) => {
3037
- setRunning(false);
3038
- setGameState(p.state);
3039
- }
3040
- });
3041
- };
3042
- ws.onclose = () => {
3043
- wsLog("disconnected", `game:${roomId}`);
3044
- wsRef.current = null;
3045
- setConnected(false);
3046
- setCanWrite(false);
3047
- if (alive) reconnectTimer = setTimeout(connect, 1e3);
3048
- };
3049
- ws.onerror = () => ws?.close();
3050
- };
3051
- connect();
3052
- return () => {
3053
- wsLog("closing", `game:${roomId}`);
3054
- alive = false;
3055
- if (reconnectTimer) clearTimeout(reconnectTimer);
3056
- if (ws) {
3057
- ws.onclose = null;
3058
- ws.onmessage = null;
3059
- ws.onerror = null;
3060
- ws.close();
3061
- }
3062
- wsRef.current = null;
3063
- };
3064
- }, [roomId]);
3065
- const send = useCallback10(
3066
- (message) => {
3067
- if (!canWrite) return;
3068
- const ws = wsRef.current;
3069
- if (!ws || ws.readyState !== WebSocket.OPEN) return;
3070
- ws.send(encode(message));
3071
- },
3072
- [canWrite]
3073
- );
3074
- const sendInput = useCallback10(
3075
- (action, data = {}) => send(clientBuild.gameInput(action, data)),
3076
- [send]
3077
- );
3078
- const setReady = useCallback10(() => send(clientBuild.gamePlayerReady()), [send]);
3079
- const startGame = useCallback10(() => send(clientBuild.gameStart()), [send]);
3080
- const endGame = useCallback10(() => send(clientBuild.gameEnd()), [send]);
3081
- return { state: gameState, tick, players, running, connected, canWrite, sendInput, setReady, startGame, endGame };
3082
- }
3083
-
3084
- // src/client/storage/hooks/useCanvas.ts
3085
- import { useState as useState9, useEffect as useEffect12, useCallback as useCallback11, useRef as useRef10 } from "react";
3086
- function useCanvas(roomId) {
3087
- const [shapes, setShapes] = useState9([]);
3088
- const [viewports, setViewports] = useState9([]);
3089
- const [connected, setConnected] = useState9(false);
3090
- const [canWrite, setCanWrite] = useState9(false);
3091
- const wsRef = useRef10(null);
3092
- useEffect12(() => {
3093
2962
  let ws = null;
3094
2963
  let reconnectTimer = null;
3095
2964
  let alive = true;
@@ -3183,7 +3052,7 @@ function useCanvas(roomId) {
3183
3052
  wsRef.current = null;
3184
3053
  };
3185
3054
  }, [roomId]);
3186
- const sendBuilt = useCallback11(
3055
+ const sendBuilt = useCallback10(
3187
3056
  (message) => {
3188
3057
  const ws = wsRef.current;
3189
3058
  if (!ws || ws.readyState !== WebSocket.OPEN) return;
@@ -3191,51 +3060,51 @@ function useCanvas(roomId) {
3191
3060
  },
3192
3061
  []
3193
3062
  );
3194
- const sendWrite = useCallback11(
3063
+ const sendWrite = useCallback10(
3195
3064
  (message) => {
3196
3065
  if (!canWrite) return;
3197
3066
  sendBuilt(message);
3198
3067
  },
3199
3068
  [sendBuilt, canWrite]
3200
3069
  );
3201
- const addShape = useCallback11(
3070
+ const addShape = useCallback10(
3202
3071
  (shape) => sendWrite(clientBuild.canvasAdd(shape)),
3203
3072
  [sendWrite]
3204
3073
  );
3205
- const moveShape = useCallback11(
3074
+ const moveShape = useCallback10(
3206
3075
  (shapeId, x, y) => sendWrite(clientBuild.canvasMove(shapeId, x, y)),
3207
3076
  [sendWrite]
3208
3077
  );
3209
- const resizeShape = useCallback11(
3078
+ const resizeShape = useCallback10(
3210
3079
  (shapeId, width, height, x, y) => sendWrite(clientBuild.canvasResize(shapeId, width, height, x, y)),
3211
3080
  [sendWrite]
3212
3081
  );
3213
- const deleteShape = useCallback11(
3082
+ const deleteShape = useCallback10(
3214
3083
  (shapeId) => sendWrite(clientBuild.canvasDelete(shapeId)),
3215
3084
  [sendWrite]
3216
3085
  );
3217
- const updateShape = useCallback11(
3086
+ const updateShape = useCallback10(
3218
3087
  (shapeId, props) => sendWrite(clientBuild.canvasUpdate(shapeId, props)),
3219
3088
  [sendWrite]
3220
3089
  );
3221
- const setViewport = useCallback11(
3090
+ const setViewport = useCallback10(
3222
3091
  (viewport) => sendBuilt(clientBuild.canvasViewport(viewport)),
3223
3092
  [sendBuilt]
3224
3093
  );
3225
- const undo = useCallback11(() => sendWrite(clientBuild.canvasUndo()), [sendWrite]);
3226
- const redo = useCallback11(() => sendWrite(clientBuild.canvasRedo()), [sendWrite]);
3094
+ const undo = useCallback10(() => sendWrite(clientBuild.canvasUndo()), [sendWrite]);
3095
+ const redo = useCallback10(() => sendWrite(clientBuild.canvasRedo()), [sendWrite]);
3227
3096
  return { shapes, viewports, connected, canWrite, addShape, moveShape, resizeShape, deleteShape, updateShape, setViewport, undo, redo };
3228
3097
  }
3229
3098
 
3230
3099
  // src/client/storage/hooks/useCronMonitor.ts
3231
- import { useState as useState10, useEffect as useEffect13, useCallback as useCallback12, useRef as useRef11 } from "react";
3100
+ import { useState as useState9, useEffect as useEffect12, useCallback as useCallback11, useRef as useRef10 } from "react";
3232
3101
  function useCronMonitor(roomId) {
3233
- const [tasks, setTasks] = useState10([]);
3234
- const [history, setHistory] = useState10([]);
3235
- const [connected, setConnected] = useState10(false);
3236
- const [canWrite, setCanWrite] = useState10(false);
3237
- const wsRef = useRef11(null);
3238
- useEffect13(() => {
3102
+ const [tasks, setTasks] = useState9([]);
3103
+ const [history, setHistory] = useState9([]);
3104
+ const [connected, setConnected] = useState9(false);
3105
+ const [canWrite, setCanWrite] = useState9(false);
3106
+ const wsRef = useRef10(null);
3107
+ useEffect12(() => {
3239
3108
  let ws = null;
3240
3109
  let reconnectTimer = null;
3241
3110
  let alive = true;
@@ -3282,7 +3151,7 @@ function useCronMonitor(roomId) {
3282
3151
  wsRef.current = null;
3283
3152
  };
3284
3153
  }, [roomId]);
3285
- const sendWrite = useCallback12(
3154
+ const sendWrite = useCallback11(
3286
3155
  (message) => {
3287
3156
  if (!canWrite) return;
3288
3157
  const ws = wsRef.current;
@@ -3291,15 +3160,15 @@ function useCronMonitor(roomId) {
3291
3160
  },
3292
3161
  [canWrite]
3293
3162
  );
3294
- const trigger = useCallback12(
3163
+ const trigger = useCallback11(
3295
3164
  (taskName) => sendWrite(clientBuild.cronTrigger(taskName)),
3296
3165
  [sendWrite]
3297
3166
  );
3298
- const pause = useCallback12(
3167
+ const pause = useCallback11(
3299
3168
  (taskName) => sendWrite(clientBuild.cronPause(taskName)),
3300
3169
  [sendWrite]
3301
3170
  );
3302
- const resume = useCallback12(
3171
+ const resume = useCallback11(
3303
3172
  (taskName) => sendWrite(clientBuild.cronResume(taskName)),
3304
3173
  [sendWrite]
3305
3174
  );
@@ -3307,14 +3176,14 @@ function useCronMonitor(roomId) {
3307
3176
  }
3308
3177
 
3309
3178
  // src/client/storage/hooks/useJobs.ts
3310
- import { useState as useState11, useEffect as useEffect14, useCallback as useCallback13, useRef as useRef12 } from "react";
3179
+ import { useState as useState10, useEffect as useEffect13, useCallback as useCallback12, useRef as useRef11 } from "react";
3311
3180
  var ENQUEUE_TIMEOUT_MS = 1e4;
3312
3181
  function useJobs(roomId) {
3313
- const [jobs, setJobs] = useState11([]);
3314
- const [connected, setConnected] = useState11(false);
3315
- const wsRef = useRef12(null);
3316
- const pendingEnqueueRef = useRef12(/* @__PURE__ */ new Map());
3317
- useEffect14(() => {
3182
+ const [jobs, setJobs] = useState10([]);
3183
+ const [connected, setConnected] = useState10(false);
3184
+ const wsRef = useRef11(null);
3185
+ const pendingEnqueueRef = useRef11(/* @__PURE__ */ new Map());
3186
+ useEffect13(() => {
3318
3187
  let ws = null;
3319
3188
  let reconnectTimer = null;
3320
3189
  let alive = true;
@@ -3382,7 +3251,7 @@ function useJobs(roomId) {
3382
3251
  wsRef.current = null;
3383
3252
  };
3384
3253
  }, [roomId]);
3385
- const enqueue = useCallback13(
3254
+ const enqueue = useCallback12(
3386
3255
  (type, payload, options) => {
3387
3256
  return new Promise((resolve, reject) => {
3388
3257
  const ws = wsRef.current;
@@ -3413,7 +3282,7 @@ function useJobs(roomId) {
3413
3282
  },
3414
3283
  []
3415
3284
  );
3416
- const sendBuilt = useCallback13(
3285
+ const sendBuilt = useCallback12(
3417
3286
  (message) => {
3418
3287
  const ws = wsRef.current;
3419
3288
  if (!ws || ws.readyState !== WebSocket.OPEN) return;
@@ -3421,15 +3290,15 @@ function useJobs(roomId) {
3421
3290
  },
3422
3291
  []
3423
3292
  );
3424
- const getJob = useCallback13(
3293
+ const getJob = useCallback12(
3425
3294
  (jobId) => jobs.find((j) => j.id === jobId),
3426
3295
  [jobs]
3427
3296
  );
3428
- const cancel = useCallback13(
3297
+ const cancel = useCallback12(
3429
3298
  (jobId) => sendBuilt(clientBuild.jobCancel(jobId)),
3430
3299
  [sendBuilt]
3431
3300
  );
3432
- const retry = useCallback13(
3301
+ const retry = useCallback12(
3433
3302
  (jobId) => sendBuilt(clientBuild.jobRetry(jobId)),
3434
3303
  [sendBuilt]
3435
3304
  );
@@ -3437,12 +3306,12 @@ function useJobs(roomId) {
3437
3306
  }
3438
3307
 
3439
3308
  // src/client/storage/hooks/usePresenceRoom.ts
3440
- import { useState as useState12, useEffect as useEffect15, useCallback as useCallback14, useRef as useRef13 } from "react";
3309
+ import { useState as useState11, useEffect as useEffect14, useCallback as useCallback13, useRef as useRef12 } from "react";
3441
3310
  function usePresenceRoom(scopeId) {
3442
- const [peers, setPeers] = useState12([]);
3443
- const [connected, setConnected] = useState12(false);
3444
- const wsRef = useRef13(null);
3445
- useEffect15(() => {
3311
+ const [peers, setPeers] = useState11([]);
3312
+ const [connected, setConnected] = useState11(false);
3313
+ const wsRef = useRef12(null);
3314
+ useEffect14(() => {
3446
3315
  let ws = null;
3447
3316
  let reconnectTimer = null;
3448
3317
  let alive = true;
@@ -3503,7 +3372,7 @@ function usePresenceRoom(scopeId) {
3503
3372
  wsRef.current = null;
3504
3373
  };
3505
3374
  }, [scopeId]);
3506
- const updateState = useCallback14((state) => {
3375
+ const updateState = useCallback13((state) => {
3507
3376
  const ws = wsRef.current;
3508
3377
  if (!ws || ws.readyState !== WebSocket.OPEN) return;
3509
3378
  ws.send(encode(clientBuild.presenceUpdate(state)));
@@ -3519,7 +3388,7 @@ function toConnectionStatus(queryStatus) {
3519
3388
  }
3520
3389
 
3521
3390
  // src/client/storage/useR2Files.ts
3522
- import { useCallback as useCallback15, useState as useState13, useMemo as useMemo11 } from "react";
3391
+ import { useCallback as useCallback14, useState as useState12, useMemo as useMemo11 } from "react";
3523
3392
 
3524
3393
  // src/shared/app-files.ts
3525
3394
  var MAX_APP_FILE_BYTES = 1024 * 1024 * 1024;
@@ -3659,21 +3528,21 @@ async function uploadInParts(file, name, scopeParams, authHeaders, onProgress) {
3659
3528
  }
3660
3529
  }
3661
3530
  function useR2Files(options) {
3662
- const [isUploading, setIsUploading] = useState13(false);
3531
+ const [isUploading, setIsUploading] = useState12(false);
3663
3532
  const scope = options?.scope ?? "self";
3664
3533
  const scopeParams = useMemo11(() => {
3665
3534
  const params = new URLSearchParams();
3666
3535
  params.set("scope", scope);
3667
3536
  return params.toString();
3668
3537
  }, [scope]);
3669
- const authHeaders = useCallback15(async () => {
3538
+ const authHeaders = useCallback14(async () => {
3670
3539
  const token = await getAuthToken();
3671
3540
  if (token) {
3672
3541
  return { Authorization: `Bearer ${token}` };
3673
3542
  }
3674
3543
  return {};
3675
3544
  }, []);
3676
- const upload = useCallback15(
3545
+ const upload = useCallback14(
3677
3546
  async (file, name, options2) => {
3678
3547
  setIsUploading(true);
3679
3548
  try {
@@ -3702,7 +3571,7 @@ function useR2Files(options) {
3702
3571
  },
3703
3572
  [scopeParams, authHeaders]
3704
3573
  );
3705
- const uploadBase64 = useCallback15(
3574
+ const uploadBase64 = useCallback14(
3706
3575
  async (base64Data, name, mimeType) => {
3707
3576
  setIsUploading(true);
3708
3577
  try {
@@ -3726,7 +3595,7 @@ function useR2Files(options) {
3726
3595
  },
3727
3596
  [scopeParams, authHeaders]
3728
3597
  );
3729
- const deleteFile = useCallback15(
3598
+ const deleteFile = useCallback14(
3730
3599
  async (fileOrKey) => {
3731
3600
  const { key } = resolveFile(fileOrKey);
3732
3601
  try {
@@ -3742,7 +3611,7 @@ function useR2Files(options) {
3742
3611
  },
3743
3612
  [scopeParams, authHeaders]
3744
3613
  );
3745
- const list = useCallback15(
3614
+ const list = useCallback14(
3746
3615
  async (prefix) => {
3747
3616
  try {
3748
3617
  const headers = await authHeaders();
@@ -3757,7 +3626,7 @@ function useR2Files(options) {
3757
3626
  },
3758
3627
  [scopeParams, authHeaders]
3759
3628
  );
3760
- const downloadFile = useCallback15(
3629
+ const downloadFile = useCallback14(
3761
3630
  async (fileOrKey, fileName) => {
3762
3631
  const { key, name: infoName } = resolveFile(fileOrKey);
3763
3632
  try {
@@ -3787,7 +3656,7 @@ function useR2Files(options) {
3787
3656
  },
3788
3657
  [scopeParams, authHeaders]
3789
3658
  );
3790
- const readFile = useCallback15(
3659
+ const readFile = useCallback14(
3791
3660
  async (fileOrKey) => {
3792
3661
  const { key } = resolveFile(fileOrKey);
3793
3662
  const headers = await authHeaders();
@@ -3800,7 +3669,7 @@ function useR2Files(options) {
3800
3669
  },
3801
3670
  [scopeParams, authHeaders]
3802
3671
  );
3803
- const getUrl = useCallback15(
3672
+ const getUrl = useCallback14(
3804
3673
  (fileOrKey) => {
3805
3674
  const { key } = resolveFile(fileOrKey);
3806
3675
  return `/api/files/${encodeKeyPath(key)}?${scopeParams}`;
@@ -3846,7 +3715,7 @@ function getUserColor(userId, palette = DEFAULT_USER_COLORS) {
3846
3715
  }
3847
3716
 
3848
3717
  // src/client/messaging/useMessages.ts
3849
- import { useCallback as useCallback16, useMemo as useMemo12 } from "react";
3718
+ import { useCallback as useCallback15, useMemo as useMemo12 } from "react";
3850
3719
  function useMessages(channelId, options) {
3851
3720
  const where = useMemo12(() => {
3852
3721
  if (!channelId) return { channelId: "__none__" };
@@ -3863,7 +3732,7 @@ function useMessages(channelId, options) {
3863
3732
  orderDir: "asc"
3864
3733
  });
3865
3734
  const { create, put, remove: removeMutation } = useMutations("messages");
3866
- const send = useCallback16(
3735
+ const send = useCallback15(
3867
3736
  (content, parentMessageId) => {
3868
3737
  if (!channelId || !user) return;
3869
3738
  const data = { channelId, content, authorId: user.id, edited: false };
@@ -3872,19 +3741,19 @@ function useMessages(channelId, options) {
3872
3741
  },
3873
3742
  [channelId, user, create]
3874
3743
  );
3875
- const edit = useCallback16(
3744
+ const edit = useCallback15(
3876
3745
  (messageId, newContent) => {
3877
3746
  put(messageId, { content: newContent, edited: true });
3878
3747
  },
3879
3748
  [put]
3880
3749
  );
3881
- const remove = useCallback16(
3750
+ const remove = useCallback15(
3882
3751
  (messageId) => {
3883
3752
  removeMutation(messageId);
3884
3753
  },
3885
3754
  [removeMutation]
3886
3755
  );
3887
- const softDelete = useCallback16(
3756
+ const softDelete = useCallback15(
3888
3757
  (messageId) => {
3889
3758
  put(messageId, { deleted: true });
3890
3759
  },
@@ -3902,7 +3771,7 @@ function useMessages(channelId, options) {
3902
3771
  }
3903
3772
 
3904
3773
  // src/client/messaging/useChannels.ts
3905
- import { useCallback as useCallback17 } from "react";
3774
+ import { useCallback as useCallback16 } from "react";
3906
3775
  function useChannels() {
3907
3776
  const { user } = useUser();
3908
3777
  const { records, status, error } = useQuery("channels", {
@@ -3910,7 +3779,7 @@ function useChannels() {
3910
3779
  orderDir: "asc"
3911
3780
  });
3912
3781
  const { create: createMutation, put, remove } = useMutations("channels");
3913
- const create = useCallback17(
3782
+ const create = useCallback16(
3914
3783
  (data) => {
3915
3784
  return createMutation({
3916
3785
  name: data.name,
@@ -3922,13 +3791,13 @@ function useChannels() {
3922
3791
  },
3923
3792
  [user, createMutation]
3924
3793
  );
3925
- const archive = useCallback17(
3794
+ const archive = useCallback16(
3926
3795
  (channelId) => {
3927
3796
  put(channelId, { archived: true });
3928
3797
  },
3929
3798
  [put]
3930
3799
  );
3931
- const update = useCallback17(
3800
+ const update = useCallback16(
3932
3801
  (channelId, data) => {
3933
3802
  put(channelId, data);
3934
3803
  },
@@ -3946,14 +3815,14 @@ function useChannels() {
3946
3815
  }
3947
3816
 
3948
3817
  // src/client/messaging/useReactions.ts
3949
- import { useCallback as useCallback18 } from "react";
3818
+ import { useCallback as useCallback17 } from "react";
3950
3819
  function useReactions(channelId) {
3951
3820
  const { user } = useUser();
3952
3821
  const { records, status, error } = useQuery("reactions", {
3953
3822
  where: channelId ? { channelId } : { channelId: "__none__" }
3954
3823
  });
3955
3824
  const { create, remove: removeMutation } = useMutations("reactions");
3956
- const getReactionsForMessage = useCallback18(
3825
+ const getReactionsForMessage = useCallback17(
3957
3826
  (messageId) => {
3958
3827
  const messageReactions = records.filter((r) => r.data.messageId === messageId);
3959
3828
  const grouped = /* @__PURE__ */ new Map();
@@ -3970,7 +3839,7 @@ function useReactions(channelId) {
3970
3839
  },
3971
3840
  [records, user]
3972
3841
  );
3973
- const toggle = useCallback18(
3842
+ const toggle = useCallback17(
3974
3843
  (messageId, emoji) => {
3975
3844
  if (!channelId || !user) return;
3976
3845
  const existing = records.find(
@@ -3988,20 +3857,20 @@ function useReactions(channelId) {
3988
3857
  }
3989
3858
 
3990
3859
  // src/client/messaging/useChannelMembers.ts
3991
- import { useCallback as useCallback19 } from "react";
3860
+ import { useCallback as useCallback18 } from "react";
3992
3861
  function useChannelMembers(channelId) {
3993
3862
  const { user } = useUser();
3994
3863
  const { records, status, error } = useQuery("channel-members", {
3995
3864
  where: channelId ? { channelId } : { channelId: "__none__" }
3996
3865
  });
3997
3866
  const { create, remove: removeMutation } = useMutations("channel-members");
3998
- const join = useCallback19(() => {
3867
+ const join = useCallback18(() => {
3999
3868
  if (!channelId || !user) return;
4000
3869
  const existing = records.find((r) => r.data.userId === user.id);
4001
3870
  if (existing) return;
4002
3871
  create({ channelId, userId: user.id, joinedAt: (/* @__PURE__ */ new Date()).toISOString() });
4003
3872
  }, [channelId, user, records, create]);
4004
- const leave = useCallback19(() => {
3873
+ const leave = useCallback18(() => {
4005
3874
  if (!channelId || !user) return;
4006
3875
  const membership = records.find((r) => r.data.userId === user.id);
4007
3876
  if (membership) removeMutation(membership.recordId);
@@ -4011,14 +3880,14 @@ function useChannelMembers(channelId) {
4011
3880
  }
4012
3881
 
4013
3882
  // src/client/messaging/useReadReceipts.ts
4014
- import { useCallback as useCallback20 } from "react";
3883
+ import { useCallback as useCallback19 } from "react";
4015
3884
  function useReadReceipts() {
4016
3885
  const { user } = useUser();
4017
3886
  const { records, status, error } = useQuery("read-receipts", {
4018
3887
  where: user ? { userId: user.id } : { userId: "__none__" }
4019
3888
  });
4020
3889
  const { create, put } = useMutations("read-receipts");
4021
- const markAsRead = useCallback20(
3890
+ const markAsRead = useCallback19(
4022
3891
  (channelId) => {
4023
3892
  if (!user) return;
4024
3893
  const existing = records.find((r) => r.data.channelId === channelId);
@@ -4031,7 +3900,7 @@ function useReadReceipts() {
4031
3900
  },
4032
3901
  [user, records, create, put]
4033
3902
  );
4034
- const getUnreadCount = useCallback20(
3903
+ const getUnreadCount = useCallback19(
4035
3904
  (channelId, messages) => {
4036
3905
  const receipt = records.find((r) => r.data.channelId === channelId);
4037
3906
  if (!receipt) return messages.length;
@@ -4044,7 +3913,7 @@ function useReadReceipts() {
4044
3913
  }
4045
3914
 
4046
3915
  // src/client/messaging/useConversation.ts
4047
- import { useCallback as useCallback21, useMemo as useMemo13 } from "react";
3916
+ import { useCallback as useCallback20, useMemo as useMemo13 } from "react";
4048
3917
  function useConversation(opts) {
4049
3918
  const { user } = useUser();
4050
3919
  const { ready } = useRecordContext();
@@ -4053,7 +3922,7 @@ function useConversation(opts) {
4053
3922
  const { records: members } = useQuery("conv_members");
4054
3923
  const messageMut = useMutations("conv_messages");
4055
3924
  const reactionMut = useMutations("conv_reactions");
4056
- const send = useCallback21(
3925
+ const send = useCallback20(
4057
3926
  (content, parentMessageId, messageType, metadata) => {
4058
3927
  messageMut.create({
4059
3928
  Content: content,
@@ -4068,7 +3937,7 @@ function useConversation(opts) {
4068
3937
  // eslint-disable-next-line react-hooks/exhaustive-deps -- depend on the precise opts?.onMessageSent callback, not the whole opts object, to avoid recreating send when unrelated opts fields change
4069
3938
  [messageMut, user?.id, opts?.onMessageSent]
4070
3939
  );
4071
- const edit = useCallback21(
3940
+ const edit = useCallback20(
4072
3941
  (recordId, content) => {
4073
3942
  const existing = allMessages.find((m) => m.recordId === recordId);
4074
3943
  if (!existing) return;
@@ -4076,7 +3945,7 @@ function useConversation(opts) {
4076
3945
  },
4077
3946
  [messageMut, allMessages]
4078
3947
  );
4079
- const remove = useCallback21(
3948
+ const remove = useCallback20(
4080
3949
  (recordId) => {
4081
3950
  const existing = allMessages.find((m) => m.recordId === recordId);
4082
3951
  if (!existing) return;
@@ -4089,7 +3958,7 @@ function useConversation(opts) {
4089
3958
  },
4090
3959
  [messageMut, allMessages]
4091
3960
  );
4092
- const toggleReaction = useCallback21(
3961
+ const toggleReaction = useCallback20(
4093
3962
  (messageId, emoji) => {
4094
3963
  const existing = allReactions.find(
4095
3964
  (r) => r.data.MessageId === messageId && r.data.Emoji === emoji && r.data.UserId === user?.id
@@ -4222,7 +4091,7 @@ function parseMessageMetadata(raw) {
4222
4091
  }
4223
4092
 
4224
4093
  // src/client/directory/useConversations.ts
4225
- import { useCallback as useCallback22, useMemo as useMemo14, useRef as useRef14 } from "react";
4094
+ import { useCallback as useCallback21, useMemo as useMemo14, useRef as useRef13 } from "react";
4226
4095
  var defaultConvFields = {
4227
4096
  Visibility: "public",
4228
4097
  Status: "active",
@@ -4237,7 +4106,7 @@ function useConversations() {
4237
4106
  const stateMut = useMutations("conversation_state");
4238
4107
  const { user } = useUser();
4239
4108
  const ready = status === "ready";
4240
- const recentCreationsRef = useRef14(/* @__PURE__ */ new Map());
4109
+ const recentCreationsRef = useRef13(/* @__PURE__ */ new Map());
4241
4110
  for (const [id] of recentCreationsRef.current) {
4242
4111
  if (conversations.find((c) => c.recordId === id)) {
4243
4112
  recentCreationsRef.current.delete(id);
@@ -4259,13 +4128,13 @@ function useConversations() {
4259
4128
  () => new Set(stateRecords.filter((r) => r.data.Archived).map((r) => r.data.ConversationId)),
4260
4129
  [stateRecords]
4261
4130
  );
4262
- const getConversationState = useCallback22(
4131
+ const getConversationState = useCallback21(
4263
4132
  (conversationId) => {
4264
4133
  return stateRecords.find((r) => r.data.ConversationId === conversationId)?.data;
4265
4134
  },
4266
4135
  [stateRecords]
4267
4136
  );
4268
- const createChannel = useCallback22(
4137
+ const createChannel = useCallback21(
4269
4138
  async (name, description) => {
4270
4139
  const existing = conversations.find((r) => r.data.Name === name && r.data.Type !== "dm");
4271
4140
  if (existing) return existing.recordId;
@@ -4285,7 +4154,7 @@ function useConversations() {
4285
4154
  },
4286
4155
  [create, user?.id, conversations]
4287
4156
  );
4288
- const createDM = useCallback22(
4157
+ const createDM = useCallback21(
4289
4158
  async (otherUserId) => {
4290
4159
  if (!user?.id) return null;
4291
4160
  const hash = [user.id, otherUserId].sort().join(":");
@@ -4313,7 +4182,7 @@ function useConversations() {
4313
4182
  },
4314
4183
  [create, user?.id, conversations]
4315
4184
  );
4316
- const createGroupDM = useCallback22(
4185
+ const createGroupDM = useCallback21(
4317
4186
  async (participantIds) => {
4318
4187
  if (!user?.id) return null;
4319
4188
  const allIds = [.../* @__PURE__ */ new Set([user.id, ...participantIds])];
@@ -4343,14 +4212,14 @@ function useConversations() {
4343
4212
  },
4344
4213
  [create, user?.id, conversations]
4345
4214
  );
4346
- const lookupByName = useCallback22(
4215
+ const lookupByName = useCallback21(
4347
4216
  (name) => {
4348
4217
  const found = conversations.find((r) => r.data.Name === name);
4349
4218
  return found?.recordId ?? null;
4350
4219
  },
4351
4220
  [conversations]
4352
4221
  );
4353
- const updateLastMessage = useCallback22(
4222
+ const updateLastMessage = useCallback21(
4354
4223
  (conversationId, preview, authorId) => {
4355
4224
  const conv = conversations.find((c) => c.recordId === conversationId);
4356
4225
  const baseData = conv?.data ?? recentCreationsRef.current.get(conversationId);
@@ -4369,7 +4238,7 @@ function useConversations() {
4369
4238
  },
4370
4239
  [put, conversations]
4371
4240
  );
4372
- const upsertState = useCallback22(
4241
+ const upsertState = useCallback21(
4373
4242
  (conversationId, partial) => {
4374
4243
  if (!user?.id) return;
4375
4244
  const existing = stateRecords.find(
@@ -4391,7 +4260,7 @@ function useConversations() {
4391
4260
  },
4392
4261
  [stateMut, stateRecords, user?.id]
4393
4262
  );
4394
- const markRead = useCallback22(
4263
+ const markRead = useCallback21(
4395
4264
  (conversationId) => {
4396
4265
  const conv = conversations.find((c) => c.recordId === conversationId);
4397
4266
  const msgCount = conv?.data.MessageCount ?? recentCreationsRef.current.get(conversationId)?.MessageCount ?? 0;
@@ -4402,32 +4271,32 @@ function useConversations() {
4402
4271
  },
4403
4272
  [upsertState, conversations]
4404
4273
  );
4405
- const toggleStar = useCallback22(
4274
+ const toggleStar = useCallback21(
4406
4275
  (conversationId) => {
4407
4276
  const isStarred = starredSet.has(conversationId);
4408
4277
  upsertState(conversationId, { Starred: isStarred ? 0 : 1 });
4409
4278
  },
4410
4279
  [upsertState, starredSet]
4411
4280
  );
4412
- const setArchived = useCallback22(
4281
+ const setArchived = useCallback21(
4413
4282
  (conversationId, archived) => {
4414
4283
  upsertState(conversationId, { Archived: archived ? 1 : 0 });
4415
4284
  },
4416
4285
  [upsertState]
4417
4286
  );
4418
- const setTrashed = useCallback22(
4287
+ const setTrashed = useCallback21(
4419
4288
  (conversationId, trashed) => {
4420
4289
  upsertState(conversationId, { Trashed: trashed ? 1 : 0 });
4421
4290
  },
4422
4291
  [upsertState]
4423
4292
  );
4424
- const setLabels = useCallback22(
4293
+ const setLabels = useCallback21(
4425
4294
  (conversationId, labels) => {
4426
4295
  upsertState(conversationId, { Labels: JSON.stringify(labels) });
4427
4296
  },
4428
4297
  [upsertState]
4429
4298
  );
4430
- const setFolder = useCallback22(
4299
+ const setFolder = useCallback21(
4431
4300
  (conversationId, folder) => {
4432
4301
  upsertState(conversationId, { Folder: folder });
4433
4302
  },
@@ -4457,7 +4326,7 @@ function useConversations() {
4457
4326
  }
4458
4327
 
4459
4328
  // src/client/directory/useCommunities.ts
4460
- import { useCallback as useCallback23, useMemo as useMemo15 } from "react";
4329
+ import { useCallback as useCallback22, useMemo as useMemo15 } from "react";
4461
4330
  function useCommunities() {
4462
4331
  const { records: communities, status } = useQuery("communities");
4463
4332
  const communityMut = useMutations("communities");
@@ -4480,7 +4349,7 @@ function useCommunities() {
4480
4349
  ),
4481
4350
  [memberships, user?.id]
4482
4351
  );
4483
- const createCommunity = useCallback23(
4352
+ const createCommunity = useCallback22(
4484
4353
  async (name, opts) => {
4485
4354
  const existing = communities.find((c) => c.data.Name === name);
4486
4355
  if (existing) return existing.recordId;
@@ -4499,7 +4368,7 @@ function useCommunities() {
4499
4368
  },
4500
4369
  [communityMut, user?.id, communities]
4501
4370
  );
4502
- const updateCommunity = useCallback23(
4371
+ const updateCommunity = useCallback22(
4503
4372
  (communityId, updates) => {
4504
4373
  const existing = communities.find((c) => c.recordId === communityId);
4505
4374
  if (!existing) return;
@@ -4507,7 +4376,7 @@ function useCommunities() {
4507
4376
  },
4508
4377
  [communityMut, communities]
4509
4378
  );
4510
- const joinCommunity = useCallback23(
4379
+ const joinCommunity = useCallback22(
4511
4380
  async (communityId, userName) => {
4512
4381
  if (!user?.id) return null;
4513
4382
  const existing = memberships.find(
@@ -4525,7 +4394,7 @@ function useCommunities() {
4525
4394
  },
4526
4395
  [membershipMut, memberships, user?.id]
4527
4396
  );
4528
- const leaveCommunity = useCallback23(
4397
+ const leaveCommunity = useCallback22(
4529
4398
  (communityId) => {
4530
4399
  if (!user?.id) return;
4531
4400
  const membership = memberships.find(
@@ -4537,13 +4406,13 @@ function useCommunities() {
4537
4406
  },
4538
4407
  [membershipMut, memberships, user?.id]
4539
4408
  );
4540
- const getMembersOf = useCallback23(
4409
+ const getMembersOf = useCallback22(
4541
4410
  (communityId) => {
4542
4411
  return membershipMap.get(communityId) ?? [];
4543
4412
  },
4544
4413
  [membershipMap]
4545
4414
  );
4546
- const lookupByName = useCallback23(
4415
+ const lookupByName = useCallback22(
4547
4416
  (name) => {
4548
4417
  const found = communities.find((c) => c.data.Name === name);
4549
4418
  return found?.recordId ?? null;
@@ -4565,14 +4434,14 @@ function useCommunities() {
4565
4434
  }
4566
4435
 
4567
4436
  // src/client/directory/usePosts.ts
4568
- import { useCallback as useCallback24 } from "react";
4437
+ import { useCallback as useCallback23 } from "react";
4569
4438
  function usePosts(opts) {
4570
4439
  const { records: allPosts, status } = useQuery("posts");
4571
4440
  const postMut = useMutations("posts");
4572
4441
  const { user } = useUser();
4573
4442
  const ready = status === "ready";
4574
4443
  const posts = opts?.communityId ? allPosts.filter((p) => p.data.CommunityId === opts.communityId) : allPosts;
4575
- const createPost = useCallback24(
4444
+ const createPost = useCallback23(
4576
4445
  async (data) => {
4577
4446
  const recordId = await postMut.create({
4578
4447
  Title: data.title,
@@ -4590,7 +4459,7 @@ function usePosts(opts) {
4590
4459
  },
4591
4460
  [postMut, user?.id]
4592
4461
  );
4593
- const updatePost = useCallback24(
4462
+ const updatePost = useCallback23(
4594
4463
  (postId, updates) => {
4595
4464
  const existing = allPosts.find((p) => p.recordId === postId);
4596
4465
  if (!existing) return;
@@ -4598,13 +4467,13 @@ function usePosts(opts) {
4598
4467
  },
4599
4468
  [postMut, allPosts]
4600
4469
  );
4601
- const deletePost = useCallback24(
4470
+ const deletePost = useCallback23(
4602
4471
  (postId) => {
4603
4472
  postMut.remove(postId);
4604
4473
  },
4605
4474
  [postMut]
4606
4475
  );
4607
- const setConversationId = useCallback24(
4476
+ const setConversationId = useCallback23(
4608
4477
  (postId, conversationId) => {
4609
4478
  updatePost(postId, { ConversationId: conversationId });
4610
4479
  },
@@ -4621,7 +4490,7 @@ function usePosts(opts) {
4621
4490
  }
4622
4491
 
4623
4492
  // src/client/theme/DeepSpaceThemeProvider.tsx
4624
- import { useEffect as useEffect16 } from "react";
4493
+ import { useEffect as useEffect15 } from "react";
4625
4494
 
4626
4495
  // src/client/theme/applyTheme.ts
4627
4496
  function mix(color, pct, base = "transparent") {
@@ -4934,7 +4803,7 @@ function DeepSpaceThemeProvider({
4934
4803
  children,
4935
4804
  theme
4936
4805
  }) {
4937
- useEffect16(() => {
4806
+ useEffect15(() => {
4938
4807
  const root = document.documentElement;
4939
4808
  const config = theme ?? readThemeFromDOM(root);
4940
4809
  applyDeepSpaceTheme(config, root);
@@ -4943,12 +4812,12 @@ function DeepSpaceThemeProvider({
4943
4812
  }
4944
4813
 
4945
4814
  // src/client/theme/useIsDarkTheme.ts
4946
- import { useState as useState14, useEffect as useEffect17 } from "react";
4815
+ import { useState as useState13, useEffect as useEffect16 } from "react";
4947
4816
  function useIsDarkTheme() {
4948
- const [isDark, setIsDark] = useState14(
4817
+ const [isDark, setIsDark] = useState13(
4949
4818
  () => typeof document === "undefined" || document.documentElement.dataset.uiTheme !== "light"
4950
4819
  );
4951
- useEffect17(() => {
4820
+ useEffect16(() => {
4952
4821
  const update = () => {
4953
4822
  setIsDark(document.documentElement.dataset.uiTheme !== "light");
4954
4823
  };
@@ -4960,7 +4829,7 @@ function useIsDarkTheme() {
4960
4829
  }
4961
4830
 
4962
4831
  // src/client/platform/PlatformProvider.tsx
4963
- import { createContext as createContext3, useContext as useContext5, useState as useState15, useEffect as useEffect18, useRef as useRef15, useCallback as useCallback25 } from "react";
4832
+ import { createContext as createContext3, useContext as useContext5, useState as useState14, useEffect as useEffect17, useRef as useRef14, useCallback as useCallback24 } from "react";
4964
4833
  import { jsx as jsx9 } from "react/jsx-runtime";
4965
4834
  var PlatformContext = createContext3(null);
4966
4835
  function usePlatform() {
@@ -4970,14 +4839,14 @@ function usePlatform() {
4970
4839
  }
4971
4840
  function useInbox() {
4972
4841
  const { inbox, subscribeInbox } = usePlatform();
4973
- useEffect18(() => subscribeInbox(), [subscribeInbox]);
4842
+ useEffect17(() => subscribeInbox(), [subscribeInbox]);
4974
4843
  return inbox;
4975
4844
  }
4976
4845
  function PlatformProvider({ children }) {
4977
- const [inbox, setInbox] = useState15([]);
4978
- const inboxSubscribers = useRef15(0);
4979
- const [inboxActive, setInboxActive] = useState15(false);
4980
- const subscribeInbox = useCallback25(() => {
4846
+ const [inbox, setInbox] = useState14([]);
4847
+ const inboxSubscribers = useRef14(0);
4848
+ const [inboxActive, setInboxActive] = useState14(false);
4849
+ const subscribeInbox = useCallback24(() => {
4981
4850
  inboxSubscribers.current++;
4982
4851
  if (inboxSubscribers.current === 1) setInboxActive(true);
4983
4852
  return () => {
@@ -4985,7 +4854,7 @@ function PlatformProvider({ children }) {
4985
4854
  if (inboxSubscribers.current === 0) setInboxActive(false);
4986
4855
  };
4987
4856
  }, []);
4988
- useEffect18(() => {
4857
+ useEffect17(() => {
4989
4858
  if (!inboxActive) return;
4990
4859
  let mounted = true;
4991
4860
  let ws = null;
@@ -5046,7 +4915,7 @@ function PlatformProvider({ children }) {
5046
4915
  setInbox([]);
5047
4916
  };
5048
4917
  }, [inboxActive]);
5049
- const platformFetch = useCallback25(async (path, init) => {
4918
+ const platformFetch = useCallback24(async (path, init) => {
5050
4919
  const token = await getAuthToken();
5051
4920
  const headers = new Headers(init?.headers);
5052
4921
  if (token) headers.set("Authorization", `Bearer ${token}`);
@@ -5057,28 +4926,28 @@ function PlatformProvider({ children }) {
5057
4926
  }
5058
4927
 
5059
4928
  // src/client/platform/usePlatformWS.ts
5060
- import { useState as useState16, useEffect as useEffect19, useRef as useRef16 } from "react";
4929
+ import { useState as useState15, useEffect as useEffect18, useRef as useRef15 } from "react";
5061
4930
  var MAX_RECONNECT_DELAY = 1e4;
5062
4931
  var BASE_RECONNECT_DELAY = 500;
5063
4932
  function usePlatformWS(options) {
5064
4933
  const { path, scopeId, initialState, onMessage } = options;
5065
- const wsRef = useRef16(null);
5066
- const pingIntervalRef = useRef16(null);
5067
- const [state, setState] = useState16(initialState);
5068
- const reconnectAttemptRef = useRef16(0);
5069
- const reconnectTimerRef = useRef16(null);
5070
- const mountedRef = useRef16(true);
5071
- const onMessageRef = useRef16(onMessage);
4934
+ const wsRef = useRef15(null);
4935
+ const pingIntervalRef = useRef15(null);
4936
+ const [state, setState] = useState15(initialState);
4937
+ const reconnectAttemptRef = useRef15(0);
4938
+ const reconnectTimerRef = useRef15(null);
4939
+ const mountedRef = useRef15(true);
4940
+ const onMessageRef = useRef15(onMessage);
5072
4941
  onMessageRef.current = onMessage;
5073
- const initialStateRef = useRef16(initialState);
4942
+ const initialStateRef = useRef15(initialState);
5074
4943
  initialStateRef.current = initialState;
5075
- useEffect19(() => {
4944
+ useEffect18(() => {
5076
4945
  mountedRef.current = true;
5077
4946
  return () => {
5078
4947
  mountedRef.current = false;
5079
4948
  };
5080
4949
  }, []);
5081
- useEffect19(() => {
4950
+ useEffect18(() => {
5082
4951
  if (!scopeId) return;
5083
4952
  setState(initialStateRef.current);
5084
4953
  reconnectAttemptRef.current = 0;
@@ -5137,7 +5006,7 @@ function usePlatformWS(options) {
5137
5006
  wsRef.current = null;
5138
5007
  };
5139
5008
  }, [scopeId, path]);
5140
- const send = useRef16((msg) => {
5009
+ const send = useRef15((msg) => {
5141
5010
  wsRef.current?.send(JSON.stringify(msg));
5142
5011
  }).current;
5143
5012
  return { state, send };
@@ -5248,27 +5117,27 @@ var integration = {
5248
5117
  };
5249
5118
 
5250
5119
  // src/client/voice/useVoiceAgent.ts
5251
- import { useCallback as useCallback26, useEffect as useEffect20, useRef as useRef17, useState as useState17 } from "react";
5120
+ import { useCallback as useCallback25, useEffect as useEffect19, useRef as useRef16, useState as useState16 } from "react";
5252
5121
  var OPENAI_REALTIME_BASE = "https://api.openai.com/v1";
5253
5122
  var ZERO_USAGE = { inputAudioTokens: 0, outputAudioTokens: 0, inputTextTokens: 0, outputTextTokens: 0 };
5254
5123
  function useVoiceAgent(options = {}) {
5255
- const [status, setStatus] = useState17("idle");
5256
- const [isMuted, setIsMuted] = useState17(false);
5257
- const [isAgentSpeaking, setIsAgentSpeaking] = useState17(false);
5258
- const [transcript, setTranscript] = useState17([]);
5259
- const [error, setError] = useState17(null);
5260
- const pcRef = useRef17(null);
5261
- const dcRef = useRef17(null);
5262
- const streamRef = useRef17(null);
5263
- const audioRef = useRef17(null);
5264
- const timerRef = useRef17(null);
5265
- const sessionIdRef = useRef17(null);
5266
- const liveStartRef = useRef17(null);
5267
- const settledRef = useRef17(false);
5268
- const usageRef = useRef17({ ...ZERO_USAGE });
5269
- const optsRef = useRef17(options);
5124
+ const [status, setStatus] = useState16("idle");
5125
+ const [isMuted, setIsMuted] = useState16(false);
5126
+ const [isAgentSpeaking, setIsAgentSpeaking] = useState16(false);
5127
+ const [transcript, setTranscript] = useState16([]);
5128
+ const [error, setError] = useState16(null);
5129
+ const pcRef = useRef16(null);
5130
+ const dcRef = useRef16(null);
5131
+ const streamRef = useRef16(null);
5132
+ const audioRef = useRef16(null);
5133
+ const timerRef = useRef16(null);
5134
+ const sessionIdRef = useRef16(null);
5135
+ const liveStartRef = useRef16(null);
5136
+ const settledRef = useRef16(false);
5137
+ const usageRef = useRef16({ ...ZERO_USAGE });
5138
+ const optsRef = useRef16(options);
5270
5139
  optsRef.current = options;
5271
- const settle = useCallback26(async () => {
5140
+ const settle = useCallback25(async () => {
5272
5141
  const sessionId = sessionIdRef.current;
5273
5142
  if (!sessionId || settledRef.current) return;
5274
5143
  settledRef.current = true;
@@ -5282,7 +5151,7 @@ function useVoiceAgent(options = {}) {
5282
5151
  } catch {
5283
5152
  }
5284
5153
  }, []);
5285
- const cleanup = useCallback26(() => {
5154
+ const cleanup = useCallback25(() => {
5286
5155
  if (timerRef.current) {
5287
5156
  clearTimeout(timerRef.current);
5288
5157
  timerRef.current = null;
@@ -5306,13 +5175,13 @@ function useVoiceAgent(options = {}) {
5306
5175
  streamRef.current = null;
5307
5176
  audioRef.current = null;
5308
5177
  }, []);
5309
- const stop = useCallback26(async () => {
5178
+ const stop = useCallback25(async () => {
5310
5179
  cleanup();
5311
5180
  await settle();
5312
5181
  setIsAgentSpeaking(false);
5313
5182
  setStatus((s) => s === "error" ? s : "ended");
5314
5183
  }, [cleanup, settle]);
5315
- const appendTranscript = useCallback26((role, delta) => {
5184
+ const appendTranscript = useCallback25((role, delta) => {
5316
5185
  if (!delta) return;
5317
5186
  setTranscript((prev) => {
5318
5187
  const last = prev[prev.length - 1];
@@ -5320,7 +5189,7 @@ function useVoiceAgent(options = {}) {
5320
5189
  return [...prev, { role, content: delta }];
5321
5190
  });
5322
5191
  }, []);
5323
- const handleToolCall = useCallback26(async (item) => {
5192
+ const handleToolCall = useCallback25(async (item) => {
5324
5193
  const onToolCall = optsRef.current.onToolCall;
5325
5194
  let output = null;
5326
5195
  if (onToolCall && item.name) {
@@ -5346,7 +5215,7 @@ function useVoiceAgent(options = {}) {
5346
5215
  );
5347
5216
  dc.send(JSON.stringify({ type: "response.create" }));
5348
5217
  }, []);
5349
- const handleEvent = useCallback26(
5218
+ const handleEvent = useCallback25(
5350
5219
  (raw) => {
5351
5220
  if (typeof raw !== "string") return;
5352
5221
  let ev;
@@ -5386,7 +5255,7 @@ function useVoiceAgent(options = {}) {
5386
5255
  },
5387
5256
  [appendTranscript, handleToolCall]
5388
5257
  );
5389
- const start = useCallback26(
5258
+ const start = useCallback25(
5390
5259
  async (overrides = {}) => {
5391
5260
  if (sessionIdRef.current) {
5392
5261
  cleanup();
@@ -5448,7 +5317,7 @@ function useVoiceAgent(options = {}) {
5448
5317
  },
5449
5318
  [cleanup, settle, stop, handleEvent]
5450
5319
  );
5451
- const toggleMute = useCallback26(() => {
5320
+ const toggleMute = useCallback25(() => {
5452
5321
  const stream = streamRef.current;
5453
5322
  if (!stream) return;
5454
5323
  setIsMuted((muted) => {
@@ -5457,7 +5326,7 @@ function useVoiceAgent(options = {}) {
5457
5326
  return next;
5458
5327
  });
5459
5328
  }, []);
5460
- useEffect20(() => {
5329
+ useEffect19(() => {
5461
5330
  return () => {
5462
5331
  cleanup();
5463
5332
  void settle();
@@ -5545,7 +5414,7 @@ function decodeAiStreamChunk(chunk) {
5545
5414
  }
5546
5415
 
5547
5416
  // src/client/status.ts
5548
- import { useCallback as useCallback27, useEffect as useEffect21, useMemo as useMemo16, useRef as useRef18, useState as useState18 } from "react";
5417
+ import { useCallback as useCallback26, useEffect as useEffect20, useMemo as useMemo16, useRef as useRef17, useState as useState17 } from "react";
5549
5418
 
5550
5419
  // src/client/status-core.ts
5551
5420
  var ASYNC_RESOURCE_DEFAULTS = {
@@ -5629,7 +5498,7 @@ function useAsyncResource(fetcher, deps, options = {}) {
5629
5498
  const retry = options.retry ?? ASYNC_RESOURCE_DEFAULTS.retry;
5630
5499
  const retryDelayMs = options.retryDelayMs ?? ASYNC_RESOURCE_DEFAULTS.retryDelayMs;
5631
5500
  const slowAfterMs = options.slowAfterMs ?? ASYNC_RESOURCE_DEFAULTS.slowAfterMs;
5632
- const [state, setState] = useState18(() => ({
5501
+ const [state, setState] = useState17(() => ({
5633
5502
  status: enabled ? "loading" : "idle",
5634
5503
  data: options.initialData ?? null,
5635
5504
  error: null,
@@ -5637,12 +5506,12 @@ function useAsyncResource(fetcher, deps, options = {}) {
5637
5506
  isSlow: false,
5638
5507
  retryCount: 0
5639
5508
  }));
5640
- const requestIdRef = useRef18(0);
5641
- const [reloadTick, setReloadTick] = useState18(0);
5642
- const reload = useCallback27(() => {
5509
+ const requestIdRef = useRef17(0);
5510
+ const [reloadTick, setReloadTick] = useState17(0);
5511
+ const reload = useCallback26(() => {
5643
5512
  setReloadTick((tick) => tick + 1);
5644
5513
  }, []);
5645
- useEffect21(() => {
5514
+ useEffect20(() => {
5646
5515
  if (!enabled) {
5647
5516
  setState((prev) => ({ ...prev, status: "idle", isRefreshing: false, isSlow: false, retryCount: 0 }));
5648
5517
  return;
@@ -5731,7 +5600,7 @@ function usePagedResource(fetchPage, deps, options = {}) {
5731
5600
  const retryDelayMs = options.retryDelayMs ?? ASYNC_RESOURCE_DEFAULTS.retryDelayMs;
5732
5601
  const maxRetryDelayMs = options.maxRetryDelayMs ?? 3e4;
5733
5602
  const hasInitialItems = initialItems.length > 0;
5734
- const [state, setState] = useState18(() => ({
5603
+ const [state, setState] = useState17(() => ({
5735
5604
  status: enabled ? hasInitialItems ? "ready" : "loading" : "idle",
5736
5605
  items: initialItems,
5737
5606
  error: null,
@@ -5741,25 +5610,25 @@ function usePagedResource(fetchPage, deps, options = {}) {
5741
5610
  isLoadingMore: false,
5742
5611
  isRefreshing: false
5743
5612
  }));
5744
- const requestIdRef = useRef18(0);
5745
- const controllerRef = useRef18(null);
5746
- const loadingRef = useRef18(false);
5747
- const nextPageRef = useRef18(hasInitialItems ? 2 : 1);
5748
- const failedPageRef = useRef18(null);
5749
- const failureCountRef = useRef18(0);
5750
- const cooldownUntilRef = useRef18(0);
5751
- const autoRetryTimerRef = useRef18(null);
5752
- const clearAutoRetryTimer = useCallback27(() => {
5613
+ const requestIdRef = useRef17(0);
5614
+ const controllerRef = useRef17(null);
5615
+ const loadingRef = useRef17(false);
5616
+ const nextPageRef = useRef17(hasInitialItems ? 2 : 1);
5617
+ const failedPageRef = useRef17(null);
5618
+ const failureCountRef = useRef17(0);
5619
+ const cooldownUntilRef = useRef17(0);
5620
+ const autoRetryTimerRef = useRef17(null);
5621
+ const clearAutoRetryTimer = useCallback26(() => {
5753
5622
  if (autoRetryTimerRef.current) {
5754
5623
  clearTimeout(autoRetryTimerRef.current);
5755
5624
  autoRetryTimerRef.current = null;
5756
5625
  }
5757
5626
  }, []);
5758
- const resetCooldown = useCallback27(() => {
5627
+ const resetCooldown = useCallback26(() => {
5759
5628
  failureCountRef.current = 0;
5760
5629
  cooldownUntilRef.current = 0;
5761
5630
  }, []);
5762
- const setFailureCooldown = useCallback27(() => {
5631
+ const setFailureCooldown = useCallback26(() => {
5763
5632
  failureCountRef.current += 1;
5764
5633
  const delay = getPagedResourceCooldownMs({
5765
5634
  failureCount: failureCountRef.current,
@@ -5769,7 +5638,7 @@ function usePagedResource(fetchPage, deps, options = {}) {
5769
5638
  cooldownUntilRef.current = Date.now() + delay;
5770
5639
  return delay;
5771
5640
  }, [maxRetryDelayMs, retryDelayMs]);
5772
- const startLoad = useCallback27(async (page, mode) => {
5641
+ const startLoad = useCallback26(async (page, mode) => {
5773
5642
  if (!enabled || loadingRef.current) return;
5774
5643
  if (mode === "auto" && !canAutoLoadPagedResource({
5775
5644
  hasMore: true,
@@ -5849,21 +5718,21 @@ function usePagedResource(fetchPage, deps, options = {}) {
5849
5718
  }
5850
5719
  }
5851
5720
  }, [autoRetryOnError, clearAutoRetryTimer, enabled, fetchPage, keepPreviousData, maxItemsPerPage, pageSize, resetCooldown, setFailureCooldown]);
5852
- const loadMore = useCallback27(() => {
5721
+ const loadMore = useCallback26(() => {
5853
5722
  if (!state.hasMore || state.isLoadingInitial || state.isLoadingMore || state.isRefreshing) return;
5854
5723
  void startLoad(nextPageRef.current, "auto");
5855
5724
  }, [startLoad, state.hasMore, state.isLoadingInitial, state.isLoadingMore, state.isRefreshing]);
5856
- const retry = useCallback27(() => {
5725
+ const retry = useCallback26(() => {
5857
5726
  const page = failedPageRef.current ?? nextPageRef.current;
5858
5727
  void startLoad(page, "manual");
5859
5728
  }, [startLoad]);
5860
- const refresh = useCallback27(() => {
5729
+ const refresh = useCallback26(() => {
5861
5730
  failedPageRef.current = null;
5862
5731
  resetCooldown();
5863
5732
  nextPageRef.current = 1;
5864
5733
  void startLoad(1, "refresh");
5865
5734
  }, [resetCooldown, startLoad]);
5866
- useEffect21(() => {
5735
+ useEffect20(() => {
5867
5736
  requestIdRef.current += 1;
5868
5737
  controllerRef.current?.abort();
5869
5738
  clearAutoRetryTimer();
@@ -5900,7 +5769,7 @@ function usePagedResource(fetchPage, deps, options = {}) {
5900
5769
  }
5901
5770
 
5902
5771
  // src/client/subscriptions/useSubscription.ts
5903
- import { useCallback as useCallback28, useEffect as useEffect22, useState as useState19 } from "react";
5772
+ import { useCallback as useCallback27, useEffect as useEffect21, useState as useState18 } from "react";
5904
5773
 
5905
5774
  // src/shared/subscription.ts
5906
5775
  var ENTITLED_STATUSES = /* @__PURE__ */ new Set([
@@ -5931,7 +5800,7 @@ async function authedJson(path, init) {
5931
5800
  return data;
5932
5801
  }
5933
5802
  function useSubscription() {
5934
- const [state, setState] = useState19({
5803
+ const [state, setState] = useState18({
5935
5804
  tier: "free",
5936
5805
  status: "none",
5937
5806
  interval: null,
@@ -5940,9 +5809,9 @@ function useSubscription() {
5940
5809
  trialEndsAt: null,
5941
5810
  plans: []
5942
5811
  });
5943
- const [isLoading, setLoading] = useState19(true);
5944
- const [error, setError] = useState19(null);
5945
- const refresh = useCallback28(async () => {
5812
+ const [isLoading, setLoading] = useState18(true);
5813
+ const [error, setError] = useState18(null);
5814
+ const refresh = useCallback27(async () => {
5946
5815
  setLoading(true);
5947
5816
  try {
5948
5817
  const r = await authedJson("/_deepspace/subscriptions/me");
@@ -5962,15 +5831,15 @@ function useSubscription() {
5962
5831
  setLoading(false);
5963
5832
  }
5964
5833
  }, []);
5965
- useEffect22(() => {
5834
+ useEffect21(() => {
5966
5835
  refresh();
5967
5836
  }, [refresh]);
5968
5837
  const entitled = isEntitled(state.tier, state.status);
5969
- const hasTier = useCallback28(
5838
+ const hasTier = useCallback27(
5970
5839
  (slug) => state.tier === slug && isEntitled(state.tier, state.status),
5971
5840
  [state.tier, state.status]
5972
5841
  );
5973
- const isAtLeast = useCallback28(
5842
+ const isAtLeast = useCallback27(
5974
5843
  (slug) => {
5975
5844
  if (!isEntitled(state.tier, state.status)) return false;
5976
5845
  const targetRank = state.plans.find((p) => p.slug === slug)?.rank;
@@ -5980,7 +5849,7 @@ function useSubscription() {
5980
5849
  },
5981
5850
  [state.plans, state.tier, state.status]
5982
5851
  );
5983
- const subscribe = useCallback28(
5852
+ const subscribe = useCallback27(
5984
5853
  async (planSlug, opts) => {
5985
5854
  const result = await authedJson("/_deepspace/subscriptions/checkout", {
5986
5855
  method: "POST",
@@ -6000,7 +5869,7 @@ function useSubscription() {
6000
5869
  },
6001
5870
  [refresh]
6002
5871
  );
6003
- const openPortal = useCallback28(
5872
+ const openPortal = useCallback27(
6004
5873
  async (returnUrl) => {
6005
5874
  return authedJson("/_deepspace/subscriptions/portal", {
6006
5875
  method: "POST",
@@ -6069,7 +5938,7 @@ function PricingTable(props) {
6069
5938
  }
6070
5939
 
6071
5940
  // src/client/charges/useCheckout.ts
6072
- import { useCallback as useCallback29, useEffect as useEffect23, useMemo as useMemo17, useState as useState20 } from "react";
5941
+ import { useCallback as useCallback28, useEffect as useEffect22, useMemo as useMemo17, useState as useState19 } from "react";
6073
5942
  async function authedJson2(path, init) {
6074
5943
  const token = await getAuthToken();
6075
5944
  const res = await fetch(path, {
@@ -6088,10 +5957,10 @@ async function authedJson2(path, init) {
6088
5957
  return data;
6089
5958
  }
6090
5959
  function useCheckout(opts) {
6091
- const [purchases, setPurchases] = useState20([]);
6092
- const [isLoading, setLoading] = useState20(true);
6093
- const [error, setError] = useState20(null);
6094
- const refresh = useCallback29(async () => {
5960
+ const [purchases, setPurchases] = useState19([]);
5961
+ const [isLoading, setLoading] = useState19(true);
5962
+ const [error, setError] = useState19(null);
5963
+ const refresh = useCallback28(async () => {
6095
5964
  setLoading(true);
6096
5965
  try {
6097
5966
  const r = await authedJson2(
@@ -6105,10 +5974,10 @@ function useCheckout(opts) {
6105
5974
  setLoading(false);
6106
5975
  }
6107
5976
  }, []);
6108
- useEffect23(() => {
5977
+ useEffect22(() => {
6109
5978
  refresh();
6110
5979
  }, [refresh]);
6111
- const chargeOnce = useCallback29(
5980
+ const chargeOnce = useCallback28(
6112
5981
  async (chargeOpts) => {
6113
5982
  setError(null);
6114
5983
  const common = {
@@ -6142,7 +6011,7 @@ function useCheckout(opts) {
6142
6011
  },
6143
6012
  []
6144
6013
  );
6145
- const ownsProduct = useCallback29(
6014
+ const ownsProduct = useCallback28(
6146
6015
  (productId) => purchases.some((p) => p.productId === productId),
6147
6016
  [purchases]
6148
6017
  );
@@ -6311,7 +6180,6 @@ export {
6311
6180
  AuthGate,
6312
6181
  AuthOverlay,
6313
6182
  Awareness,
6314
- CANONICAL_APP_IDENTITY_MIGRATION_ID,
6315
6183
  DEEPSPACE_AGENT_PROFILES,
6316
6184
  DEEPSPACE_AI_DEFAULTS,
6317
6185
  DEEPSPACE_AI_MODELS,
@@ -6422,7 +6290,6 @@ export {
6422
6290
  useConversations,
6423
6291
  useCronMonitor,
6424
6292
  useDisplayName,
6425
- useGameRoom,
6426
6293
  useInbox,
6427
6294
  useIsDarkTheme,
6428
6295
  useJobs,