@absolutejs/voice 0.0.22-beta.444 → 0.0.22-beta.445

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
@@ -11781,6 +11781,8 @@ var getSessionsFromStore = async (store) => {
11781
11781
  };
11782
11782
  var createVoiceReconnectProofRoutes = (options = {}) => {
11783
11783
  const path = options.path ?? "/api/voice/reconnect-proof";
11784
+ const collectedSnapshots = [];
11785
+ const maxCollectedSnapshots = options.maxCollectedSnapshots ?? 500;
11784
11786
  const buildReport = async () => buildVoiceReconnectProofReport({
11785
11787
  completedSessionCount: options.getCompletedSessionCount ? await options.getCompletedSessionCount() : undefined,
11786
11788
  maxAttempts: options.maxAttempts,
@@ -11788,7 +11790,10 @@ var createVoiceReconnectProofRoutes = (options = {}) => {
11788
11790
  requireReplayProtection: options.requireReplayProtection,
11789
11791
  requireResumeAfterReconnect: options.requireResumeAfterReconnect,
11790
11792
  sessions: options.getSessions ? await options.getSessions() : options.store ? await getSessionsFromStore(options.store) : undefined,
11791
- snapshots: options.getSnapshots ? await options.getSnapshots() : undefined
11793
+ snapshots: [
11794
+ ...collectedSnapshots,
11795
+ ...options.getSnapshots ? await options.getSnapshots() : []
11796
+ ]
11792
11797
  });
11793
11798
  const respond = async () => new Response(JSON.stringify(await buildReport()), {
11794
11799
  headers: {
@@ -11796,9 +11801,25 @@ var createVoiceReconnectProofRoutes = (options = {}) => {
11796
11801
  ...options.headers
11797
11802
  }
11798
11803
  });
11804
+ const collectSnapshot = (body) => {
11805
+ if (!isReconnectPayload(body)) {
11806
+ return;
11807
+ }
11808
+ collectedSnapshots.push({
11809
+ at: body.at,
11810
+ reconnect: body.reconnect,
11811
+ turnIds: Array.isArray(body.turnIds) ? body.turnIds.filter((turnId) => typeof turnId === "string") : undefined
11812
+ });
11813
+ if (collectedSnapshots.length > maxCollectedSnapshots) {
11814
+ collectedSnapshots.splice(0, collectedSnapshots.length - maxCollectedSnapshots);
11815
+ }
11816
+ };
11799
11817
  return new Elysia9({
11800
11818
  name: options.name ?? "absolutejs-voice-reconnect-proof"
11801
- }).get(path, respond).post(path, respond);
11819
+ }).get(path, respond).post(path, async ({ body }) => {
11820
+ collectSnapshot(body);
11821
+ return respond();
11822
+ });
11802
11823
  };
11803
11824
  var renderVoiceReconnectContractHTML = (report) => {
11804
11825
  const issues = report.issues.map((issue) => `<li class="${escapeHtml12(issue.severity)}"><strong>${escapeHtml12(issue.code)}</strong>: ${escapeHtml12(issue.message)}</li>`).join("");
@@ -60,6 +60,7 @@ export type VoiceReconnectProofRoutesOptions = Omit<VoiceReconnectProofOptions,
60
60
  getSessions?: () => readonly VoiceSessionRecord[] | Promise<readonly VoiceSessionRecord[]>;
61
61
  getSnapshots?: () => readonly VoiceReconnectContractSnapshot[] | Promise<readonly VoiceReconnectContractSnapshot[]>;
62
62
  headers?: HeadersInit;
63
+ maxCollectedSnapshots?: number;
63
64
  name?: string;
64
65
  path?: string;
65
66
  store?: VoiceSessionStore;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@absolutejs/voice",
3
- "version": "0.0.22-beta.444",
3
+ "version": "0.0.22-beta.445",
4
4
  "description": "Voice primitives and Elysia plugin for AbsoluteJS",
5
5
  "repository": {
6
6
  "type": "git",