@opengeni/react-native 6.2.2-canary.41175921349001 → 6.2.2-canary.41207200451001
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/{chunk-SHR6OAIG.js → chunk-ANJ3XLQA.js} +7 -2
- package/dist/chunk-ANJ3XLQA.js.map +1 -0
- package/dist/meetings/index.js +2 -3
- package/dist/meetings/index.js.map +1 -1
- package/dist/recordings/index.js +1 -1
- package/package.json +5 -5
- package/src/meetings/meetings-list.tsx +2 -2
- package/src/recordings/native-recorder.ts +6 -0
- package/dist/chunk-SHR6OAIG.js.map +0 -1
|
@@ -228,6 +228,7 @@ function createNativeRecorder(options) {
|
|
|
228
228
|
isCaptureActive: async (id) => native.activeRecordingId() === id
|
|
229
229
|
});
|
|
230
230
|
let unsubscribe = null;
|
|
231
|
+
let titleIsGuess = true;
|
|
231
232
|
let subscriptions = [];
|
|
232
233
|
let ticker = null;
|
|
233
234
|
let live = null;
|
|
@@ -309,10 +310,12 @@ function createNativeRecorder(options) {
|
|
|
309
310
|
return;
|
|
310
311
|
}
|
|
311
312
|
const recordingId = options.randomUUID();
|
|
313
|
+
titleIsGuess = !options.title || options.titleSource === "app";
|
|
312
314
|
unsubscribe ??= uploader.subscribe((status) => {
|
|
313
315
|
if (status.recordingId !== snapshot.recordingId) return;
|
|
314
316
|
emit({
|
|
315
317
|
upload: status,
|
|
318
|
+
...status.serverTitle && titleIsGuess ? { title: status.serverTitle } : {},
|
|
316
319
|
...status.failed ? { error: { code: "upload_failed", message: status.failed.message } } : {}
|
|
317
320
|
});
|
|
318
321
|
});
|
|
@@ -325,6 +328,7 @@ function createNativeRecorder(options) {
|
|
|
325
328
|
recordingId,
|
|
326
329
|
...options.purpose ? { purpose: options.purpose } : {},
|
|
327
330
|
...options.title ? { title: options.title } : {},
|
|
331
|
+
...options.title && options.titleSource ? { titleSource: options.titleSource } : {},
|
|
328
332
|
...options.visibility ? { visibility: options.visibility } : {},
|
|
329
333
|
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
330
334
|
...options.externalRef ? { externalRef: options.externalRef } : {},
|
|
@@ -441,6 +445,7 @@ function createNativeRecorder(options) {
|
|
|
441
445
|
const recordingId = snapshot.recordingId;
|
|
442
446
|
if (!recordingId) throw new Error("Nothing is being recorded to rename.");
|
|
443
447
|
await uploader.rename(options.workspaceId, recordingId, title);
|
|
448
|
+
titleIsGuess = false;
|
|
444
449
|
if (snapshot.recordingId === recordingId) emit({ title });
|
|
445
450
|
},
|
|
446
451
|
levels() {
|
|
@@ -722,5 +727,5 @@ function useNativeRecorderPlatform(options = {}) {
|
|
|
722
727
|
}
|
|
723
728
|
|
|
724
729
|
export { NATIVE_RECORDING_MIME_TYPE, createFileRecordingChunkStore, createNativeRecorder, expoRecordingChunkStore, expoRecordingFileSystem, nativeAudioCapture, nativeRecorderPlatform, parseRecordingChunkFileName, readAdtsFrame, recordingChunkFileName, useNativeDictation, useNativeRecorderPlatform, wholeAdtsFrames };
|
|
725
|
-
//# sourceMappingURL=chunk-
|
|
726
|
-
//# sourceMappingURL=chunk-
|
|
730
|
+
//# sourceMappingURL=chunk-ANJ3XLQA.js.map
|
|
731
|
+
//# sourceMappingURL=chunk-ANJ3XLQA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/recordings/adts.ts","../src/recordings/file-store.ts","../src/recordings/native-recorder.ts","../src/recordings/dictation.ts","../src/recordings/index.ts"],"names":["digest","expoFetch","useOpenGeniText"],"mappings":";;;;;;;;;;;;;;;AAMA,IAAM,YAAA,GAAe;AAAA,EACnB,IAAA;AAAA,EAAQ,KAAA;AAAA,EAAQ,IAAA;AAAA,EAAQ,IAAA;AAAA,EAAQ,KAAA;AAAA,EAAQ,IAAA;AAAA,EAAQ,IAAA;AAAA,EAAQ,KAAA;AAAA,EAAQ,IAAA;AAAA,EAAQ,IAAA;AAAA,EAAQ,KAAA;AAAA,EAAQ,GAAA;AAAA,EACx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frame starts with\n * its own 7-byte header (9 with a CRC), so frames concatenate across chunk\n * files, and a file cut short by a crash is good up to its last whole frame.\n */\n\nconst SAMPLE_RATES = [\n 96_000, 88_200, 64_000, 48_000, 44_100, 32_000, 24_000, 22_050, 16_000, 12_000, 11_025, 8_000,\n 7_350,\n] as const;\n\nexport type AdtsFrame = { offset: number; length: number; samples: number; sampleRate: number };\n\n/** The ADTS frame header at `offset`, or null when there is no whole frame there. */\nexport function readAdtsFrame(bytes: Uint8Array, offset: number): AdtsFrame | null {\n if (offset + 7 > bytes.length) return null;\n if (bytes[offset] !== 0xff || (bytes[offset + 1]! & 0xf6) !== 0xf0) return null;\n const sampleRate = SAMPLE_RATES[(bytes[offset + 2]! >> 2) & 0x0f];\n if (!sampleRate) return null;\n const length =\n ((bytes[offset + 3]! & 0x03) << 11) | (bytes[offset + 4]! << 3) | (bytes[offset + 5]! >> 5);\n const headerLength = (bytes[offset + 1]! & 0x01) === 1 ? 7 : 9;\n if (length < headerLength || offset + length > bytes.length) return null;\n const samples = ((bytes[offset + 6]! & 0x03) + 1) * 1024;\n return { offset, length, samples, sampleRate };\n}\n\n/** How much of `bytes` is whole ADTS frames from the start, and how long they play. */\nexport function wholeAdtsFrames(bytes: Uint8Array): {\n byteLength: number;\n frames: number;\n durationMilliseconds: number;\n} {\n let offset = 0;\n let frames = 0;\n let milliseconds = 0;\n for (;;) {\n const frame = readAdtsFrame(bytes, offset);\n if (!frame) break;\n frames += 1;\n milliseconds += (frame.samples * 1_000) / frame.sampleRate;\n offset += frame.length;\n }\n return { byteLength: offset, frames, durationMilliseconds: Math.round(milliseconds) };\n}\n","import type {\n RecordingChunk,\n RecordingChunkStore,\n StoredRecording,\n StoredRecordingChunk,\n} from \"@opengeni/sdk/recordings\";\nimport { wholeAdtsFrames } from \"./adts\";\n\n/**\n * The few file operations the recording store needs. `@opengeni/react-native/recordings`\n * implements it on expo-file-system; paths are `${directory}/${name}`.\n */\nexport interface RecordingFileSystem {\n /** Entry names in a directory; empty when it does not exist. */\n list(directory: string): Promise<string[]>;\n readBytes(path: string): Promise<Uint8Array | null>;\n readText(path: string): Promise<string | null>;\n /** Replace the file in one step, so a crash leaves the old or the new content. */\n writeBytes(path: string, bytes: Uint8Array): Promise<void>;\n writeText(path: string, text: string): Promise<void>;\n rename(from: string, to: string): Promise<void>;\n /** Remove a file or a whole directory; nothing when it is gone already. */\n remove(path: string): Promise<void>;\n /** Create a directory and its parents; nothing when it exists. */\n makeDirectory(path: string): Promise<void>;\n}\n\n/**\n * Chunk files are named after what the uploader needs to know about them, so\n * listing a recording reads no file:\n * `t<track>-c<chunk>-s<start ms>-d<duration ms>-b<bytes>-<sha256>.chunk`.\n * A chunk the native recorder is still writing is `t<track>-c<chunk>-s<start ms>.part`.\n */\nconst CHUNK = /^t(\\d+)-c(\\d+)-s(\\d+)-d(\\d+)-b(\\d+)-([0-9a-f]{64})\\.chunk$/u;\nconst PART = /^t(\\d+)-c(\\d+)-s(\\d+)\\.part$/u;\nconst RECORDING_FILE = \"recording.json\";\n\nexport function recordingChunkFileName(chunk: Omit<StoredRecordingChunk, \"recordingId\">): string {\n return (\n `t${chunk.trackNumber}-c${String(chunk.chunkNumber).padStart(6, \"0\")}` +\n `-s${Math.max(0, Math.round(chunk.startMilliseconds))}` +\n `-d${Math.max(0, Math.round(chunk.durationMilliseconds))}` +\n `-b${chunk.byteLength}-${chunk.sha256}.chunk`\n );\n}\n\nexport function parseRecordingChunkFileName(\n recordingId: string,\n name: string,\n): StoredRecordingChunk | null {\n const match = CHUNK.exec(name);\n if (!match) return null;\n return {\n recordingId,\n trackNumber: Number(match[1]),\n chunkNumber: Number(match[2]),\n startMilliseconds: Number(match[3]),\n durationMilliseconds: Number(match[4]),\n byteLength: Number(match[5]),\n sha256: match[6]!,\n };\n}\n\nexport type FileRecordingChunkStore = RecordingChunkStore & {\n /** The directory one recording's files live in; the native recorder writes its chunks there. */\n directory(recordingId: string): string;\n /**\n * Save what a capture cut short left behind: chunks still being written\n * are kept up to their last whole AAC frame, and every recording's chunk\n * counts cover the chunk files it has. Recordings `skip` names are left alone.\n */\n recover(options?: { skip?: (recordingId: string) => boolean }): Promise<void>;\n};\n\n/** A durable chunk store in a directory of the app's files. */\nexport function createFileRecordingChunkStore(input: {\n fs: RecordingFileSystem;\n root: string;\n sha256: (bytes: Uint8Array) => Promise<string>;\n}): FileRecordingChunkStore {\n const { fs, root } = input;\n const directory = (recordingId: string) => `${root}/${recordingId}`;\n const key = (trackNumber: number, chunkNumber: number) => `${trackNumber}:${chunkNumber}`;\n // File names by track and chunk, per recording, from the latest listing.\n const names = new Map<string, Map<string, string>>();\n\n const listChunkFiles = async (recordingId: string) => {\n const chunks: Array<StoredRecordingChunk & { name: string }> = [];\n for (const name of await fs.list(directory(recordingId))) {\n const chunk = parseRecordingChunkFileName(recordingId, name);\n if (chunk) chunks.push({ ...chunk, name });\n }\n chunks.sort((a, b) => a.trackNumber - b.trackNumber || a.chunkNumber - b.chunkNumber);\n names.set(\n recordingId,\n new Map(chunks.map((chunk) => [key(chunk.trackNumber, chunk.chunkNumber), chunk.name])),\n );\n return chunks;\n };\n\n const fileName = async (recordingId: string, trackNumber: number, chunkNumber: number) => {\n const cached = names.get(recordingId)?.get(key(trackNumber, chunkNumber));\n if (cached) return cached;\n await listChunkFiles(recordingId);\n return names.get(recordingId)?.get(key(trackNumber, chunkNumber)) ?? null;\n };\n\n const getRecording = async (recordingId: string): Promise<StoredRecording | null> => {\n const text = await fs.readText(`${directory(recordingId)}/${RECORDING_FILE}`);\n if (!text) return null;\n try {\n return JSON.parse(text) as StoredRecording;\n } catch {\n return null;\n }\n };\n\n const putRecording = async (recording: StoredRecording) => {\n await fs.makeDirectory(directory(recording.recordingId));\n await fs.writeText(\n `${directory(recording.recordingId)}/${RECORDING_FILE}`,\n JSON.stringify(recording),\n );\n };\n\n return {\n directory,\n putRecording,\n getRecording,\n async listRecordings() {\n const recordings: StoredRecording[] = [];\n for (const name of await fs.list(root)) {\n const recording = await getRecording(name);\n if (recording) recordings.push(recording);\n }\n return recordings;\n },\n async deleteRecording(recordingId) {\n names.delete(recordingId);\n await fs.remove(directory(recordingId));\n },\n async putChunk(chunk: RecordingChunk) {\n const { bytes, ...details } = chunk;\n const name = recordingChunkFileName({ ...details, byteLength: bytes.byteLength });\n const existing = await fileName(chunk.recordingId, chunk.trackNumber, chunk.chunkNumber);\n // The native recorder already wrote this exact file into the recording's directory.\n if (existing === name) return;\n await fs.makeDirectory(directory(chunk.recordingId));\n await fs.writeBytes(`${directory(chunk.recordingId)}/${name}`, bytes);\n if (existing) await fs.remove(`${directory(chunk.recordingId)}/${existing}`);\n names.get(chunk.recordingId)?.set(key(chunk.trackNumber, chunk.chunkNumber), name);\n },\n async listChunks(recordingId) {\n return (await listChunkFiles(recordingId)).map(({ name: _name, ...chunk }) => chunk);\n },\n async readChunk(recordingId, trackNumber, chunkNumber) {\n const name = await fileName(recordingId, trackNumber, chunkNumber);\n if (!name) return null;\n return await fs.readBytes(`${directory(recordingId)}/${name}`);\n },\n async deleteChunks(recordingId, trackNumber, chunkNumbers) {\n for (const chunkNumber of chunkNumbers) {\n const name = await fileName(recordingId, trackNumber, chunkNumber);\n if (!name) continue;\n await fs.remove(`${directory(recordingId)}/${name}`);\n names.get(recordingId)?.delete(key(trackNumber, chunkNumber));\n }\n },\n async recover(options = {}) {\n for (const recordingId of await fs.list(root)) {\n if (options.skip?.(recordingId)) continue;\n const recording = await getRecording(recordingId);\n if (!recording) continue;\n const folder = directory(recordingId);\n for (const name of await fs.list(folder)) {\n const part = PART.exec(name);\n if (!part) continue;\n const bytes = (await fs.readBytes(`${folder}/${name}`)) ?? new Uint8Array();\n const whole = wholeAdtsFrames(bytes);\n if (whole.frames > 0) {\n const kept = bytes.slice(0, whole.byteLength);\n const chunkName = recordingChunkFileName({\n trackNumber: Number(part[1]),\n chunkNumber: Number(part[2]),\n startMilliseconds: Number(part[3]),\n durationMilliseconds: whole.durationMilliseconds,\n byteLength: kept.byteLength,\n sha256: await input.sha256(kept),\n });\n await fs.writeBytes(`${folder}/${chunkName}`, kept);\n }\n await fs.remove(`${folder}/${name}`);\n }\n const counts = { ...recording.chunkCounts };\n let changed = false;\n for (const chunk of await listChunkFiles(recordingId)) {\n if ((counts[chunk.trackNumber] ?? 0) <= chunk.chunkNumber) {\n counts[chunk.trackNumber] = chunk.chunkNumber + 1;\n changed = true;\n }\n }\n if (changed) {\n // updatedAt stays: resuming takes it as the time capture ended.\n await putRecording({ ...recording, chunkCounts: counts });\n }\n }\n },\n };\n}\n","import type {\n LiveTranscriber,\n LiveTranscriptTransport,\n Recorder,\n RecorderErrorCode,\n RecorderOptions,\n RecorderSnapshot,\n RecordingUploadStatus,\n} from \"@opengeni/sdk/recordings\";\nimport { createLiveTranscriber, RecordingUploader } from \"@opengeni/sdk/recordings\";\nimport type { FileRecordingChunkStore, RecordingFileSystem } from \"./file-store\";\nimport { errorMessage } from \"@opengeni/contracts/values\";\n\n/** A chunk file the native recorder finished, already in the recording's directory. */\nexport type NativeAudioChunkEvent = {\n recordingId: string;\n trackNumber: number;\n chunkNumber: number;\n startMilliseconds: number;\n durationMilliseconds: number;\n byteLength: number;\n sha256: string;\n fileName: string;\n};\n\nexport type NativeAudioStateEvent = {\n recordingId: string;\n /** `interrupted`: the system took the microphone (a call, another app); capture resumes by itself when it can. */\n state: \"recording\" | \"interrupted\" | \"stopped\";\n};\n\nexport type NativeAudioErrorEvent = { recordingId: string; code: string; message: string };\n\n/**\n * The live transcript's copy of the microphone while it is asked for: 16-bit\n * little-endian mono PCM, base64, starting `recordedMilliseconds` into the\n * recording (excluding pauses).\n */\nexport type NativeAudioPcmEvent = {\n recordingId: string;\n data: string;\n sampleRate: number;\n recordedMilliseconds: number;\n};\n\n/**\n * The native capture module (`OpenGeniAudioCapture`): the microphone encoded\n * as AAC in ADTS frames, cut into chunk files in the recording's directory,\n * named as the file store names them. It keeps recording in the background\n * (iOS audio background mode, an Android microphone foreground service).\n */\nexport interface NativeAudioCapture {\n start(options: {\n recordingId: string;\n directory: string;\n trackNumber: number;\n chunkMilliseconds: number;\n bitRate: number;\n notificationTitle: string;\n notificationText: string;\n }): Promise<{ sampleRate: number; inputName: string | null }>;\n pause(): void;\n resume(): Promise<void>;\n /**\n * Stop and finish the last chunk. Resolves with that chunk (also sent as an\n * event, which may arrive after this resolves), or null when none was left.\n */\n stop(): Promise<NativeAudioChunkEvent | null>;\n /** Stop and delete what is not finished. */\n cancel(): Promise<void>;\n /** Recorded time so far (excluding pauses and interruptions). */\n elapsedMilliseconds(): number;\n /** Input level from 0 to 1. */\n level(): number;\n /** The recording being captured now, also across a JavaScript reload. */\n activeRecordingId(): string | null;\n /** Start or stop sending the live transcript's copy of the audio as `onPcm`. Older builds lack it. */\n setLivePcm?(enabled: boolean): void;\n addListener(\n event: \"onChunk\",\n listener: (event: NativeAudioChunkEvent) => void,\n ): { remove(): void };\n addListener(\n event: \"onState\",\n listener: (event: NativeAudioStateEvent) => void,\n ): { remove(): void };\n addListener(\n event: \"onError\",\n listener: (event: NativeAudioErrorEvent) => void,\n ): { remove(): void };\n addListener(event: \"onPcm\", listener: (event: NativeAudioPcmEvent) => void): { remove(): void };\n}\n\nexport const NATIVE_RECORDING_MIME_TYPE = \"audio/aac\";\n\nexport type NativeRecorderOptions = RecorderOptions & {\n native: NativeAudioCapture;\n store: FileRecordingChunkStore;\n fs: RecordingFileSystem;\n randomUUID: () => string;\n /** Resolves false when the person declines microphone access. */\n requestPermission: () => Promise<boolean>;\n /** The ongoing notification Android shows while recording. */\n notification: { title: string; text: string };\n bitRate?: number;\n fetch?: typeof fetch;\n};\n\nconst message = (error: unknown) => errorMessage(error);\n\n/** Little-endian 16-bit samples from base64. */\nfunction decodePcm(data: string): Int16Array {\n const binary = atob(data);\n const samples = new Int16Array(binary.length >> 1);\n for (let index = 0; index < samples.length; index += 1) {\n const value = binary.charCodeAt(index * 2) | (binary.charCodeAt(index * 2 + 1) << 8);\n samples[index] = value >= 0x8000 ? value - 0x10000 : value;\n }\n return samples;\n}\n\n/** A {@link Recorder} on the phone's microphone, with the same lifecycle as the browser one. */\nexport function createNativeRecorder(options: NativeRecorderOptions): Recorder {\n const { native, store, fs } = options;\n let snapshot: RecorderSnapshot = {\n state: \"idle\",\n recordingId: null,\n elapsedMilliseconds: 0,\n tracks: [],\n upload: null,\n error: null,\n };\n const emit = (patch: Partial<RecorderSnapshot>) => {\n snapshot = { ...snapshot, ...patch };\n options.onChange?.(snapshot);\n };\n const fail = (code: RecorderErrorCode, text: string) =>\n emit({ state: \"failed\", error: { code, message: text } });\n const uploader =\n options.uploader ??\n new RecordingUploader({\n client: options.client,\n store,\n ...(options.fetch ? { fetch: options.fetch } : {}),\n isCaptureActive: async (id) => native.activeRecordingId() === id,\n });\n let unsubscribe: (() => void) | null = null;\n let titleIsGuess = true;\n let subscriptions: Array<{ remove(): void }> = [];\n let ticker: ReturnType<typeof setInterval> | null = null;\n let live: LiveTranscriber | null = null;\n let writes: Promise<void> = Promise.resolve();\n // Chunks already handed to the uploader, so the final one is saved once\n // whether its event or stop()'s result arrives first.\n const seen = new Set<number>();\n const record = (event: NativeAudioChunkEvent) => {\n if (seen.has(event.chunkNumber)) return;\n seen.add(event.chunkNumber);\n // Chain writes so a track's chunks are recorded in order.\n writes = writes\n .then(() => saveChunk(event))\n .catch((error: unknown) => fail(\"capture_failed\", message(error)));\n };\n\n const release = () => {\n native.setLivePcm?.(false);\n for (const subscription of subscriptions) subscription.remove();\n subscriptions = [];\n if (ticker) clearInterval(ticker);\n ticker = null;\n };\n\n /** Stream the microphone to the live transcript. Recording never waits on it. */\n const startLive = (recordingId: string) => {\n const client = options.client as Partial<LiveTranscriptTransport>;\n if (!options.liveTranscript || !native.setLivePcm) return;\n if (!client.createRecordingLiveSession || !client.appendRecordingLiveSegments) return;\n const transcriber = createLiveTranscriber({\n client: client as LiveTranscriptTransport,\n workspaceId: options.workspaceId,\n recordingId,\n trackNumber: 0,\n ...(options.liveWebSocket ? { WebSocket: options.liveWebSocket } : {}),\n // React Native's WebSocket takes headers, which OpenAI Realtime signs in with.\n webSocketHeaders: true,\n onChange: (track) => {\n if (live === transcriber) emit({ live: [track] });\n },\n });\n live = transcriber;\n emit({ live: [transcriber.snapshot] });\n subscriptions.push(\n native.addListener(\"onPcm\", (event) => {\n // Paused audio is not recorded, so it is not transcribed either.\n if (event.recordingId !== recordingId || snapshot.state !== \"recording\") return;\n transcriber.push(decodePcm(event.data), event.sampleRate, event.recordedMilliseconds);\n }),\n );\n native.setLivePcm(true);\n };\n\n const saveChunk = async (event: NativeAudioChunkEvent) => {\n const path = `${store.directory(event.recordingId)}/${event.fileName}`;\n const bytes = await fs.readBytes(path);\n if (!bytes) throw new Error(`Chunk ${event.chunkNumber} is missing on the device.`);\n // The file is already where the store keeps it; this records it and starts its upload.\n await uploader.addChunk({\n recordingId: event.recordingId,\n trackNumber: event.trackNumber,\n chunkNumber: event.chunkNumber,\n bytes,\n sha256: event.sha256,\n startMilliseconds: event.startMilliseconds,\n durationMilliseconds: event.durationMilliseconds,\n });\n };\n\n return {\n get snapshot() {\n return snapshot;\n },\n\n async start() {\n if (\n snapshot.state !== \"idle\" &&\n snapshot.state !== \"failed\" &&\n snapshot.state !== \"stopped\"\n ) {\n return;\n }\n if (options.microphone === false) {\n fail(\"unsupported\", \"Phones record the microphone; there is nothing else to record.\");\n return;\n }\n emit({ state: \"starting\", error: null, upload: null, elapsedMilliseconds: 0 });\n let granted = false;\n try {\n granted = await options.requestPermission();\n } catch {\n granted = false;\n }\n if (!granted) {\n fail(\"microphone_denied\", \"Microphone access was not allowed.\");\n return;\n }\n const recordingId = options.randomUUID();\n // Until someone names it, a name the server found replaces the guess shown.\n titleIsGuess = !options.title || options.titleSource === \"app\";\n unsubscribe ??= uploader.subscribe((status: RecordingUploadStatus) => {\n if (status.recordingId !== snapshot.recordingId) return;\n emit({\n upload: status,\n ...(status.serverTitle && titleIsGuess ? { title: status.serverTitle } : {}),\n ...(status.failed\n ? { error: { code: \"upload_failed\" as const, message: status.failed.message } }\n : {}),\n });\n });\n live = null;\n emit({ recordingId, title: options.title ?? null, live: null });\n await uploader.begin({\n workspaceId: options.workspaceId,\n recordingId,\n create: {\n recordingId,\n ...(options.purpose ? { purpose: options.purpose } : {}),\n ...(options.title ? { title: options.title } : {}),\n ...(options.title && options.titleSource ? { titleSource: options.titleSource } : {}),\n ...(options.visibility ? { visibility: options.visibility } : {}),\n startedAt: new Date().toISOString(),\n ...(options.externalRef ? { externalRef: options.externalRef } : {}),\n ...(options.metadata ? { metadata: options.metadata } : {}),\n ...(options.transcription ? { transcription: options.transcription } : {}),\n tracks: [{ trackNumber: 0, source: \"microphone\", mimeType: NATIVE_RECORDING_MIME_TYPE }],\n },\n });\n writes = Promise.resolve();\n seen.clear();\n subscriptions = [\n native.addListener(\"onChunk\", (event) => {\n if (event.recordingId !== recordingId) return;\n record(event);\n }),\n native.addListener(\"onState\", (event) => {\n if (event.recordingId !== recordingId) return;\n if (event.state === \"interrupted\" && snapshot.state === \"recording\") {\n emit({ state: \"paused\", pauseReason: \"interruption\" });\n } else if (\n event.state === \"recording\" &&\n snapshot.state === \"paused\" &&\n snapshot.pauseReason === \"interruption\"\n ) {\n emit({ state: \"recording\", pauseReason: null });\n }\n }),\n native.addListener(\"onError\", (event) => {\n if (event.recordingId !== recordingId) return;\n // Android could not keep recording in the background; it goes on while the app is open.\n if (event.code === \"background_unavailable\") return;\n fail(\"capture_failed\", event.message);\n }),\n ];\n let input: { inputName: string | null };\n try {\n input = await native.start({\n recordingId,\n directory: store.directory(recordingId),\n trackNumber: 0,\n chunkMilliseconds: options.timesliceMilliseconds ?? 5_000,\n bitRate: options.bitRate ?? 64_000,\n notificationTitle: options.notification.title,\n notificationText: options.notification.text,\n });\n } catch (error) {\n release();\n await uploader.discard(recordingId).catch(() => undefined);\n fail(\"microphone_unavailable\", message(error) || \"No microphone could be opened.\");\n return;\n }\n ticker = setInterval(() => emit({ elapsedMilliseconds: native.elapsedMilliseconds() }), 250);\n emit({\n state: \"recording\",\n pauseReason: null,\n tracks: [{ trackNumber: 0, source: \"microphone\", label: input.inputName || \"Microphone\" }],\n });\n startLive(recordingId);\n },\n\n pause() {\n if (snapshot.state !== \"recording\") return;\n native.pause();\n emit({\n state: \"paused\",\n pauseReason: \"person\",\n elapsedMilliseconds: native.elapsedMilliseconds(),\n });\n },\n\n resume() {\n if (snapshot.state !== \"paused\") return;\n void native.resume().then(\n () => emit({ state: \"recording\", pauseReason: null }),\n (error: unknown) => fail(\"capture_failed\", message(error)),\n );\n },\n\n async stop(stopOptions = {}) {\n const recordingId = snapshot.recordingId;\n if (!recordingId || (snapshot.state !== \"recording\" && snapshot.state !== \"paused\")) {\n return snapshot.upload;\n }\n emit({ state: \"stopping\", elapsedMilliseconds: native.elapsedMilliseconds() });\n try {\n const last = await native.stop();\n if (last && last.recordingId === recordingId) record(last);\n } catch {\n // What was written is kept; recovery saves a chunk the stop could not finish.\n }\n await writes;\n release();\n // The live transcript finishes its last words while the upload completes.\n const liveClosed = live?.close();\n const status = await uploader.finish(recordingId, { ...stopOptions, endedAt: new Date() });\n await liveClosed?.catch(() => undefined);\n emit({\n state: status.failed ? \"failed\" : \"stopped\",\n pauseReason: null,\n upload: status,\n ...(status.failed\n ? { error: { code: \"upload_failed\" as const, message: status.failed.message } }\n : {}),\n });\n return status;\n },\n\n async discard() {\n const recordingId = snapshot.recordingId;\n release();\n live?.abort();\n live = null;\n await native.cancel().catch(() => undefined);\n await writes;\n if (recordingId) await uploader.discard(recordingId);\n emit({\n state: \"idle\",\n recordingId: null,\n pauseReason: null,\n elapsedMilliseconds: 0,\n tracks: [],\n upload: null,\n live: null,\n });\n },\n\n async rename(title: string) {\n const recordingId = snapshot.recordingId;\n if (!recordingId) throw new Error(\"Nothing is being recorded to rename.\");\n await uploader.rename(options.workspaceId, recordingId, title);\n titleIsGuess = false;\n if (snapshot.recordingId === recordingId) emit({ title });\n },\n\n levels(): Record<number, number> {\n if (snapshot.state !== \"recording\") return {};\n return { 0: native.level() };\n },\n };\n}\n","import type { ClientVoiceInputConfig, OpenGeniClient } from \"@opengeni/sdk\";\nimport type { RecorderPlatform } from \"@opengeni/sdk/recordings\";\nimport { useOpenGeniText } from \"@opengeni/react/messages\";\nimport {\n useVoiceInput,\n type UseVoiceInputResult,\n type VoiceInputRecordingsClient,\n} from \"@opengeni/react/recordings\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\nimport type { NativeVoiceInput, NativeVoiceInputStatus } from \"../voice-input\";\n\nexport type UseNativeDictationOptions = {\n /** The SDK client; dictations are recorded through its recordings API. */\n client:\n | (Pick<OpenGeniClient, \"transcribeAudio\"> & Partial<Pick<OpenGeniClient, \"requestJson\">>)\n | null;\n workspaceId: string;\n /** The deployment's voice input, from the client config. */\n capability: ClientVoiceInputConfig | null;\n /** The phone's capture, from `useNativeRecorderPlatform`. */\n platform: RecorderPlatform;\n /** Whether this workspace allows voice input. */\n enabled?: boolean | undefined;\n value: string;\n setValue: (value: string) => void;\n /** The language spoken (\"nb\", \"en\"); omitted or null detects it. */\n language?: string | null | undefined;\n /** Asked before each new dictation takes the microphone (a consent prompt); false keeps it off. */\n beforeStart?: (() => boolean | Promise<boolean>) | undefined;\n /** Changing this (another session) ends a running capture; real speech is kept. */\n scope?: string | undefined;\n /** Host feedback (haptics) when recording starts and stops. */\n onFeedback?: ((event: \"start\" | \"stop\" | \"cancel\") => void) | undefined;\n /** A recordings client, such as a proxy. Built from `client` otherwise. */\n recordings?: Partial<VoiceInputRecordingsClient> | undefined;\n};\n\n/**\n * Dictation for a native composer, kept as a recording until its text is in\n * the draft: the phone records to its files, uploads as it goes and the\n * server transcribes it. A killed app, no signal or a failed transcription\n * loses nothing; the next composer in the workspace offers the text.\n *\n * The same dictation as the web composer's `useVoiceInput`, shaped for\n * the native composer.\n */\nexport function useNativeDictation(options: UseNativeDictationOptions): NativeVoiceInput {\n const t = useOpenGeniText();\n const voice = useVoiceInput({\n client: options.client,\n workspaceId: options.workspaceId,\n capability: options.capability,\n enabled: options.enabled ?? true,\n value: options.value,\n setValue: options.setValue,\n focusInput: () => undefined,\n language: options.language ?? null,\n ...(options.beforeStart ? { beforeStart: options.beforeStart } : {}),\n platform: options.platform,\n ...(options.recordings ? { recordings: options.recordings } : {}),\n });\n const feedback = useRef(options.onFeedback);\n feedback.current = options.onFeedback;\n\n // The meter and clock tick while recording.\n const [tick, setTick] = useState<{ level: number | null; seconds: number }>({\n level: null,\n seconds: 0,\n });\n const recording = voice.status === \"recording\";\n const startedAt = voice.recordingStartedAt;\n const readLevel = voice.level;\n useEffect(() => {\n if (!recording) {\n setTick({ level: null, seconds: 0 });\n return;\n }\n feedback.current?.(\"start\");\n const timer = setInterval(() => {\n setTick({\n level: readLevel(),\n seconds: startedAt === null ? 0 : Math.max(0, (Date.now() - startedAt) / 1_000),\n });\n }, 100);\n return () => clearInterval(timer);\n }, [readLevel, recording, startedAt]);\n\n const cancelVoice = voice.cancel;\n // Another session: end capture and keep real speech, to insert later.\n const setAside = voice.setAside;\n const scope = options.scope;\n const lastScope = useRef(scope);\n useEffect(() => {\n if (lastScope.current === scope) return;\n lastScope.current = scope;\n setAside();\n }, [setAside, scope]);\n\n const held = voice.hasRecoverableRecording;\n const status = nativeStatus(voice.status, held);\n const error = voice.error ? nativeError(voice.error, held, t) : null;\n const { start: startVoice, insertSavedTranscript, retry: retryVoice, discard } = voice;\n const savedTranscript = held ? voice.savedTranscript : null;\n\n const start = useCallback(() => {\n // A kept dictation comes first; a new one never replaces it.\n if (savedTranscript !== null) {\n void insertSavedTranscript();\n return;\n }\n if (held) {\n retryVoice();\n return;\n }\n void startVoice();\n }, [held, insertSavedTranscript, retryVoice, savedTranscript, startVoice]);\n\n const stop = useCallback(() => {\n if (voice.status !== \"recording\") return;\n feedback.current?.(\"stop\");\n voice.stop();\n }, [voice]);\n\n const cancel = useCallback(() => {\n if (voice.status === \"recording\") {\n feedback.current?.(\"cancel\");\n cancelVoice();\n return;\n }\n if (held || voice.status === \"error\") {\n void discard();\n return;\n }\n cancelVoice();\n }, [cancelVoice, discard, held, voice.status]);\n\n return {\n available: voice.available,\n status,\n error,\n durationSeconds: recording ? tick.seconds : voice.durationSeconds,\n level: recording ? tick.level : null,\n maxDurationSeconds: voice.maxRecordingSeconds,\n hasSavedRecording: held,\n savedTranscript,\n start,\n stop,\n cancel,\n retry: () => (savedTranscript !== null ? void insertSavedTranscript() : retryVoice()),\n insertSaved: () => void insertSavedTranscript(),\n clearError: () => {\n if (!held) void discard();\n },\n };\n}\n\nfunction nativeStatus(\n status: UseVoiceInputResult[\"status\"],\n held: boolean,\n): NativeVoiceInputStatus {\n switch (status) {\n case \"requesting-permission\":\n case \"recording\":\n return status;\n case \"saving\":\n case \"transcribing\":\n case \"retrying\":\n // A kept dictation the server is still hearing waits quietly, not as a spinner.\n return held ? \"error\" : \"transcribing\";\n case \"recovered\":\n case \"transcript-ready\":\n case \"error\":\n return held || status === \"error\" ? \"error\" : \"idle\";\n default:\n return \"idle\";\n }\n}\n\nfunction nativeError(code: string, held: boolean, t: ReturnType<typeof useOpenGeniText>): string {\n switch (code) {\n case \"permission_denied\":\n return t(\"native.voiceInput.allowMicrophoneAccessInSettings\");\n case \"not_supported\":\n return t(\"native.voiceInput.couldnTStartTheMicrophone\");\n case \"policy_blocked\":\n return t(\"composerTranscriptionControl.voiceInputIsnTAllowed\");\n case \"insufficient_credits\":\n return t(\"composerTranscriptionControl.voiceInputNeedsCreditsRecording\");\n case \"allowance_exhausted\":\n case \"monthly_model_cost_limit\":\n return t(\"composerTranscriptionControl.usageLimitReachedRecordingSaved\");\n case \"too_large\":\n return t(\"composerTranscriptionControl.recordingIsTooLargeTry\");\n case \"network\":\n case \"timeout\":\n case \"unavailable\":\n case \"provider\":\n return held\n ? t(\"native.voiceInput.couldnTReachTranscriptionYour\")\n : t(\"native.voiceInput.couldnTStartTheMicrophone\");\n default:\n return held\n ? t(\"native.voiceInput.couldNotTranscribe\")\n : t(\"native.voiceInput.couldnTStartTheMicrophone\");\n }\n}\n","// @opengeni/react-native/recordings: meeting and site-walk recording on phones.\n//\n// The microphone is recorded natively (AAC, cut into chunk files every few\n// seconds) into the app's files, and uploaded in the background straight to\n// storage. A crash, a killed app or a day without signal loses at most the\n// last few seconds; the next start finishes and uploads what was left.\n//\n// const platform = useNativeRecorderPlatform();\n// const recorder = useRecorder({ platform, title: \"Site walk\" });\n//\n// `useRecorder` and the reading hooks come from `@opengeni/react/recordings`.\nimport { useMemo } from \"react\";\nimport { PermissionsAndroid, Platform } from \"react-native\";\nimport { requireOptionalNativeModule } from \"expo-modules-core\";\nimport { Directory, File, Paths } from \"expo-file-system\";\nimport * as Crypto from \"expo-crypto\";\nimport { requestRecordingPermissionsAsync } from \"expo-audio\";\nimport { fetch as expoFetch } from \"expo/fetch\";\nimport { useOpenGeniText } from \"@opengeni/react/messages\";\nimport type { RecorderPlatform } from \"@opengeni/sdk/recordings\";\nimport {\n createFileRecordingChunkStore,\n type FileRecordingChunkStore,\n type RecordingFileSystem,\n} from \"./file-store\";\nimport { createNativeRecorder, type NativeAudioCapture } from \"./native-recorder\";\n\nexport { readAdtsFrame, wholeAdtsFrames } from \"./adts\";\nexport { useNativeDictation, type UseNativeDictationOptions } from \"./dictation\";\nexport {\n createFileRecordingChunkStore,\n parseRecordingChunkFileName,\n recordingChunkFileName,\n type FileRecordingChunkStore,\n type RecordingFileSystem,\n} from \"./file-store\";\nexport {\n createNativeRecorder,\n NATIVE_RECORDING_MIME_TYPE,\n type NativeAudioCapture,\n type NativeAudioChunkEvent,\n type NativeAudioErrorEvent,\n type NativeAudioPcmEvent,\n type NativeAudioStateEvent,\n type NativeRecorderOptions,\n} from \"./native-recorder\";\n\n/** The native capture module, or null in a build without it (Expo Go, web). */\nexport function nativeAudioCapture(): NativeAudioCapture | null {\n return requireOptionalNativeModule<NativeAudioCapture>(\"OpenGeniAudioCapture\");\n}\n\n/** {@link RecordingFileSystem} on expo-file-system. */\nexport const expoRecordingFileSystem: RecordingFileSystem = {\n async list(directory) {\n const folder = new Directory(directory);\n if (!folder.exists) return [];\n return folder.list().map((entry) => entry.name);\n },\n async readBytes(path) {\n const file = new File(path);\n return file.exists ? await file.bytes() : null;\n },\n async readText(path) {\n const file = new File(path);\n return file.exists ? await file.text() : null;\n },\n async writeBytes(path, bytes) {\n replaceFile(path, bytes);\n },\n async writeText(path, text) {\n replaceFile(path, text);\n },\n async rename(from, to) {\n new File(from).moveSync(new File(to), { overwrite: true });\n },\n async remove(path) {\n const file = new File(path);\n if (file.exists) {\n file.delete();\n return;\n }\n const folder = new Directory(path);\n if (folder.exists) folder.delete();\n },\n async makeDirectory(path) {\n const folder = new Directory(path);\n if (!folder.exists) folder.create({ intermediates: true });\n },\n};\n\n/** Write next to the target, then move it over, so a crash never leaves half a file. */\nfunction replaceFile(path: string, content: string | Uint8Array): void {\n const temporary = new File(`${path}.tmp`);\n if (temporary.exists) temporary.delete();\n temporary.create({ intermediates: true });\n temporary.write(content);\n temporary.moveSync(new File(path), { overwrite: true });\n}\n\nasync function sha256Hex(bytes: Uint8Array): Promise<string> {\n const digest = await Crypto.digest(Crypto.CryptoDigestAlgorithm.SHA256, bytes as never);\n return [...new Uint8Array(digest)].map((byte) => byte.toString(16).padStart(2, \"0\")).join(\"\");\n}\n\nconst stores = new Map<string, FileRecordingChunkStore>();\n\n/**\n * A recording store in the app's documents, kept until uploaded:\n * `opengeni-recordings`, or `opengeni-recordings/<scope>` with a scope.\n */\nexport function expoRecordingChunkStore(scope?: string): FileRecordingChunkStore {\n const key = scope ?? \"\";\n let store = stores.get(key);\n if (!store) {\n const base = new Directory(Paths.document, \"opengeni-recordings\");\n const directory = scope ? new Directory(base, safeScope(scope)) : base;\n store = createFileRecordingChunkStore({\n fs: expoRecordingFileSystem,\n root: directory.uri.replace(/\\/+$/u, \"\"),\n sha256: sha256Hex,\n });\n stores.set(key, store);\n }\n return store;\n}\n\nfunction safeScope(scope: string): string {\n return scope.replace(/[^A-Za-z0-9._-]/gu, \"_\");\n}\n\n/**\n * Android 13 and later hide a foreground service's notification until the app\n * may post notifications. Recording works either way, but the notification is\n * how people see that it is still on with the app closed, and how they get\n * back to it, so the recorder asks right after the microphone is allowed.\n * Android stops showing the question after it was turned down twice.\n */\nasync function requestRecordingNotificationPermission(): Promise<void> {\n if (Platform.OS !== \"android\" || typeof Platform.Version !== \"number\" || Platform.Version < 33) {\n return;\n }\n const permission = PermissionsAndroid.PERMISSIONS.POST_NOTIFICATIONS;\n try {\n if (!(await PermissionsAndroid.check(permission))) await PermissionsAndroid.request(permission);\n } catch {\n // Without it the recording still runs; only its notification is hidden.\n }\n}\n\nexport type NativeRecorderPlatformOptions = {\n /** The ongoing notification Android shows while recording. Defaults to a generic one. */\n notification?: { title: string; text: string };\n /** AAC bit rate. Default 64 kbps, about 29 MB an hour. */\n bitRate?: number;\n /**\n * Keeps unsent audio apart per signed-in account, for apps with several:\n * pass the account's id. Recordings are only ever uploaded with the client\n * of the store they were saved in.\n */\n storeScope?: string;\n};\n\n/** The phone's capture for `useRecorder`, or an unsupported platform without the native module. */\nexport function nativeRecorderPlatform(\n options: NativeRecorderPlatformOptions & { notification: { title: string; text: string } },\n): RecorderPlatform {\n const native = nativeAudioCapture();\n const store = expoRecordingChunkStore(options.storeScope);\n const fetchImpl = expoFetch as unknown as typeof fetch;\n return {\n supported: native !== null,\n systemAudioSupported: false,\n fetch: fetchImpl,\n createStore: () => store,\n createRecorder: (recorderOptions) => {\n if (!native) throw new Error(\"This build has no native audio capture module.\");\n return createNativeRecorder({\n ...recorderOptions,\n native,\n store,\n fs: expoRecordingFileSystem,\n randomUUID: () => Crypto.randomUUID(),\n requestPermission: async () => {\n const { granted } = await requestRecordingPermissionsAsync();\n if (granted) await requestRecordingNotificationPermission();\n return granted;\n },\n notification: options.notification,\n fetch: fetchImpl,\n ...(options.bitRate ? { bitRate: options.bitRate } : {}),\n });\n },\n isCaptureActive: async (recordingId) => native?.activeRecordingId() === recordingId,\n recover: async () => {\n const active = native?.activeRecordingId() ?? null;\n await store.recover({ skip: (recordingId) => recordingId === active });\n },\n };\n}\n\n/** {@link nativeRecorderPlatform} for a component, with the notification in the app's language. */\nexport function useNativeRecorderPlatform(\n options: NativeRecorderPlatformOptions = {},\n): RecorderPlatform {\n const t = useOpenGeniText();\n const title = options.notification?.title ?? t(\"native.recorder.notificationTitle\");\n const text = options.notification?.text ?? t(\"native.recorder.notificationText\");\n const bitRate = options.bitRate;\n const storeScope = options.storeScope;\n return useMemo(\n () =>\n nativeRecorderPlatform({\n notification: { title, text },\n ...(bitRate ? { bitRate } : {}),\n ...(storeScope ? { storeScope } : {}),\n }),\n [title, text, bitRate, storeScope],\n );\n}\n"]}
|
package/dist/meetings/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useNativeRecorderPlatform } from '../chunk-
|
|
1
|
+
import { useNativeRecorderPlatform } from '../chunk-ANJ3XLQA.js';
|
|
2
2
|
import { Button, BottomSheet } from '../chunk-L3PAKCJV.js';
|
|
3
3
|
import '../chunk-6D7LKJOZ.js';
|
|
4
4
|
import { withAlpha } from '../chunk-23Y3ABT4.js';
|
|
@@ -7,7 +7,7 @@ import '../chunk-6BMCWK7G.js';
|
|
|
7
7
|
import '../chunk-7ZDF5VGA.js';
|
|
8
8
|
import { useNativeTimelineTheme, fontStyle, Icon } from '../chunk-4IFOWV3O.js';
|
|
9
9
|
import '../chunk-V4OQ3NZ2.js';
|
|
10
|
-
import { useRecorder, useRecordings, useRecordingModels, meetingHereStatus, meetingStatusLabel, meetingPhase, formatDuration, meetingTitle, formatClock, groupLiveTurns, tidyPartialText, tidyLiveText, useRecording, useTranscript, groupTranscriptTurns, useRecordingPeople, transcribingText, transcriptErrorText, versionSummary, speakerDisplayName, speakerIsNamed
|
|
10
|
+
import { useRecorder, useRecordings, useRecordingModels, meetingHereStatus, meetingStatusLabel, meetingPhase, formatDuration, meetingTitle, formatClock, groupLiveTurns, tidyPartialText, tidyLiveText, useRecording, useTranscript, groupTranscriptTurns, useRecordingPeople, transcribingText, transcriptErrorText, versionSummary, speakerDisplayName, speakerIsNamed } from '@opengeni/react/recordings';
|
|
11
11
|
import { createContext, useMemo, useSyncExternalStore, useState, useRef, useLayoutEffect, useEffect, useContext, useCallback } from 'react';
|
|
12
12
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
13
13
|
import { useOpenGeniText } from '@opengeni/react/messages';
|
|
@@ -468,7 +468,6 @@ function RecorderCard({
|
|
|
468
468
|
const liveOn = liveTranscript ? liveChoice ?? liveTranscript.defaultOn : false;
|
|
469
469
|
const start = () => {
|
|
470
470
|
void recorder.start({
|
|
471
|
-
title: defaultMeetingTitle(/* @__PURE__ */ new Date(), msg),
|
|
472
471
|
...externalRef ? { externalRef } : {},
|
|
473
472
|
...liveOn ? { liveTranscript: true } : {}
|
|
474
473
|
});
|