@speeq/react 0.2.0 → 0.4.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.cjs CHANGED
@@ -209,7 +209,11 @@ function SpeeqProvider(props) {
209
209
  const client = props.client ?? initial.client;
210
210
  const owned = initial.owned && client === initial.client && props.client === void 0;
211
211
  (0, import_react2.useEffect)(() => {
212
- if (owned) return () => client.cancel();
212
+ if (owned)
213
+ return () => {
214
+ client.endCall();
215
+ client.cancel();
216
+ };
213
217
  }, [owned, client]);
214
218
  const value = (0, import_react2.useMemo)(() => {
215
219
  const snapshot = initialServerSnapshot(client);
@@ -235,6 +239,8 @@ function useSpeeq() {
235
239
  sendText: client.sendText.bind(client),
236
240
  startListening: client.startListening.bind(client),
237
241
  stopListening: client.stopListening.bind(client),
242
+ startCall: client.startCall.bind(client),
243
+ endCall: client.endCall.bind(client),
238
244
  cancel: client.cancel.bind(client),
239
245
  setLanguage: client.setLanguage.bind(client),
240
246
  confirm: client.confirm.bind(client),
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/audit-hooks.ts","../src/hooks.ts","../src/provider.tsx","../src/context-registry.ts"],"sourcesContent":["\"use client\";\nexport type {\n AuditClient,\n AuditClientOptions,\n AuditListParams,\n ChatMessage,\n ConversationEvent,\n NavigateAction,\n PendingConfirmation,\n SessionSummary,\n SpeeqClient,\n SpeeqClientEvents,\n SpeeqClientOptions,\n SpeeqSnapshot,\n SpeeqState,\n} from \"@speeq/client\";\nexport { isSpeeqError, SpeeqError } from \"@speeq/client\";\nexport type {\n UseAuditSessionResult,\n UseAuditSessionsOptions,\n UseAuditSessionsResult,\n} from \"./audit-hooks.js\";\nexport { useAuditSession, useAuditSessions, useSpeeqAudit } from \"./audit-hooks.js\";\nexport type { UseSpeeqResult } from \"./hooks.js\";\nexport { useSpeeq, useSpeeqContext, useSpeeqEvent } from \"./hooks.js\";\nexport type { SpeeqProviderProps } from \"./provider.js\";\nexport { SpeeqProvider } from \"./provider.js\";\n","import {\n type AuditClient,\n type AuditClientOptions,\n type AuditListParams,\n type ConversationEvent,\n createAuditClient,\n isSpeeqError,\n type SessionSummary,\n SpeeqError,\n} from \"@speeq/client\";\nimport { useEffect, useMemo, useRef, useState } from \"react\";\n\n/** Creates an audit client for the endpoint and credential mode. */\nexport function useSpeeqAudit(options: AuditClientOptions): AuditClient {\n const latest = useRef(options);\n latest.current = options;\n const { endpoint, credentials } = options;\n return useMemo(\n () => createAuditClient({ ...latest.current, endpoint, credentials }),\n [endpoint, credentials],\n );\n}\n\n/** Audit connection and optional session list filter. */\nexport interface UseAuditSessionsOptions extends AuditClientOptions {\n filter?: Omit<AuditListParams, \"cursor\">;\n}\n\n/** Current session list with pagination and refresh controls. */\nexport interface UseAuditSessionsResult {\n sessions: SessionSummary[];\n loading: boolean;\n error: SpeeqError | null;\n hasMore: boolean;\n loadMore(): void;\n refresh(): void;\n}\n\ninterface RequestState<T> {\n data: T;\n loading: boolean;\n error: SpeeqError | null;\n}\n\nfunction requestError(error: unknown) {\n return isSpeeqError(error) ? error : new SpeeqError(\"INTERNAL\");\n}\n\nconst emptyPage = { sessions: [] as SessionSummary[], nextCursor: null as string | null };\n\n/** Loads session summaries and appends additional pages on demand. */\nexport function useAuditSessions(options: UseAuditSessionsOptions): UseAuditSessionsResult {\n const client = useSpeeqAudit(options);\n const { userId, from, to, limit } = options.filter ?? {};\n const [version, setVersion] = useState(0);\n const key = JSON.stringify({ userId, from, to, limit, version });\n const [state, setState] = useState<RequestState<typeof emptyPage>>({\n data: emptyPage,\n loading: true,\n error: null,\n });\n const load = useRef<(cursor?: string) => void>(() => {});\n useEffect(() => {\n const filter = JSON.parse(key) as AuditListParams;\n let pending: AbortController | undefined;\n let active = true;\n load.current = (cursor) => {\n if (!active || pending) return;\n const controller = new AbortController();\n pending = controller;\n setState((current) => ({\n data: cursor ? current.data : emptyPage,\n loading: true,\n error: null,\n }));\n void client\n .listSessions({ ...filter, cursor }, controller.signal)\n .then(\n (page) => {\n if (active)\n setState((current) => ({\n data: cursor\n ? { ...page, sessions: [...current.data.sessions, ...page.sessions] }\n : page,\n loading: false,\n error: null,\n }));\n },\n (error) => {\n if (active)\n setState((current) => ({ ...current, loading: false, error: requestError(error) }));\n },\n )\n .finally(() => {\n pending = undefined;\n });\n };\n load.current();\n return () => {\n active = false;\n pending?.abort();\n };\n }, [client, key]);\n return {\n sessions: state.data.sessions,\n loading: state.loading,\n error: state.error,\n hasMore: !!state.data.nextCursor,\n loadMore() {\n if (!state.loading && state.data.nextCursor) load.current(state.data.nextCursor);\n },\n refresh() {\n setVersion((current) => current + 1);\n },\n };\n}\n\n/** Current session, its ordered events and a reload control. */\nexport interface UseAuditSessionResult {\n session: SessionSummary | null;\n events: ConversationEvent[];\n loading: boolean;\n error: SpeeqError | null;\n refresh(): void;\n}\n\nconst emptyDetail = { session: null, events: [] as ConversationEvent[] };\n\n/** Loads and refreshes the event history for a selected session. */\nexport function useAuditSession(\n sessionId: string | null,\n options: AuditClientOptions,\n): UseAuditSessionResult {\n const client = useSpeeqAudit(options);\n const [version, setVersion] = useState(0);\n const [state, setState] = useState<\n RequestState<Pick<UseAuditSessionResult, \"session\" | \"events\">>\n >({\n data: emptyDetail,\n loading: sessionId !== null,\n error: null,\n });\n // biome-ignore lint/correctness/useExhaustiveDependencies: Refresh reloads the same selected session.\n useEffect(() => {\n if (sessionId === null) {\n setState({ data: emptyDetail, loading: false, error: null });\n return;\n }\n const controller = new AbortController();\n setState({ data: emptyDetail, loading: true, error: null });\n void client.getSession(sessionId, controller.signal).then(\n (data) => {\n if (!controller.signal.aborted) setState({ data, loading: false, error: null });\n },\n (error) => {\n if (!controller.signal.aborted)\n setState({ data: emptyDetail, loading: false, error: requestError(error) });\n },\n );\n return () => controller.abort();\n }, [client, sessionId, version]);\n return {\n ...(sessionId === null ? emptyDetail : state.data),\n loading: sessionId !== null && state.loading,\n error: sessionId === null ? null : state.error,\n refresh() {\n setVersion((current) => current + 1);\n },\n };\n}\n","import type { SpeeqClient, SpeeqClientEvents, SpeeqSnapshot } from \"@speeq/client\";\nimport { useEffect, useMemo, useRef, useSyncExternalStore } from \"react\";\nimport { useProvider } from \"./provider.js\";\n\n/** Live client snapshot and stable client actions. */\nexport interface UseSpeeqResult extends SpeeqSnapshot {\n client: SpeeqClient;\n sendText: SpeeqClient[\"sendText\"];\n startListening: SpeeqClient[\"startListening\"];\n stopListening: SpeeqClient[\"stopListening\"];\n cancel: SpeeqClient[\"cancel\"];\n setLanguage: SpeeqClient[\"setLanguage\"];\n confirm: SpeeqClient[\"confirm\"];\n speak: SpeeqClient[\"speak\"];\n}\n\n/** Reads the current snapshot and actions of the provider's client. */\nexport function useSpeeq(): UseSpeeqResult {\n const { client, getServerSnapshot } = useProvider(\"useSpeeq\");\n const store = useMemo(\n () => ({\n subscribe: client.subscribe.bind(client),\n getSnapshot: client.getSnapshot.bind(client),\n actions: {\n client,\n sendText: client.sendText.bind(client),\n startListening: client.startListening.bind(client),\n stopListening: client.stopListening.bind(client),\n cancel: client.cancel.bind(client),\n setLanguage: client.setLanguage.bind(client),\n confirm: client.confirm.bind(client),\n speak: client.speak.bind(client),\n },\n }),\n [client],\n );\n const snapshot = useSyncExternalStore(store.subscribe, store.getSnapshot, getServerSnapshot);\n return { ...snapshot, ...store.actions };\n}\n\n/** Registers data from the current page for subsequent conversation requests. */\nexport function useSpeeqContext(data: Record<string, unknown>): void {\n const { registry } = useProvider(\"useSpeeqContext\");\n const current = useRef(data);\n current.current = data;\n useEffect(() => registry.register(() => current.current), [registry]);\n}\n\n/** Subscribes to a client event and calls the latest handler. */\nexport function useSpeeqEvent<K extends keyof SpeeqClientEvents>(\n event: K,\n handler: (payload: SpeeqClientEvents[K]) => void,\n): void {\n const { client } = useProvider(\"useSpeeqEvent\");\n const current = useRef(handler);\n current.current = handler;\n useEffect(() => client.on(event, (payload) => current.current(payload)), [client, event]);\n}\n","import {\n createSpeeqClient,\n type SpeeqClient,\n type SpeeqClientOptions,\n type SpeeqSnapshot,\n} from \"@speeq/client\";\nimport {\n createContext,\n type JSX,\n type ReactNode,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { createContextRegistry } from \"./context-registry.js\";\n\n/** Configuration for a provider-owned client or an existing client. */\nexport interface SpeeqProviderProps extends SpeeqClientOptions {\n children: ReactNode;\n /** Use an existing client instead of creating one. The other options are then ignored. */\n client?: SpeeqClient;\n}\n\nconst ProviderContext = createContext<{\n client: SpeeqClient;\n getServerSnapshot: () => SpeeqSnapshot;\n registry: ReturnType<typeof createContextRegistry>;\n} | null>(null);\n\nconst serverSnapshots = new WeakMap<SpeeqClient, SpeeqSnapshot>();\n\nfunction initialServerSnapshot(client: SpeeqClient) {\n let snapshot = serverSnapshots.get(client);\n if (!snapshot) {\n snapshot = {\n ...client.getSnapshot(),\n support: { speechInput: false, speechOutput: false, voiceForLanguage: null },\n };\n serverSnapshots.set(client, snapshot);\n }\n return snapshot;\n}\n\n/** Makes a speeq client available to descendant hooks. */\nexport function SpeeqProvider(props: SpeeqProviderProps): JSX.Element {\n const navigate = useRef(props.onNavigate);\n const context = useRef(props.getContext);\n navigate.current = props.onNavigate;\n context.current = props.getContext;\n const [registry] = useState(() => createContextRegistry(() => context.current?.()));\n const [initial] = useState(() => ({\n client:\n props.client ??\n createSpeeqClient({\n ...props,\n onNavigate: (action) => navigate.current?.(action),\n getContext: registry.getContext,\n }),\n owned: props.client === undefined,\n }));\n const client = props.client ?? initial.client;\n const owned = initial.owned && client === initial.client && props.client === undefined;\n useEffect(() => {\n if (owned) return () => client.cancel();\n }, [owned, client]);\n const value = useMemo(() => {\n const snapshot = initialServerSnapshot(client);\n return { client, getServerSnapshot: () => snapshot, registry };\n }, [client, registry]);\n return <ProviderContext.Provider value={value}>{props.children}</ProviderContext.Provider>;\n}\n\n/** Reads the provider store for a named hook. */\nexport function useProvider(hook: string) {\n const value = useContext(ProviderContext);\n if (!value) throw new Error(`${hook} must be used inside <SpeeqProvider>`);\n return value;\n}\n","import type { SpeeqClientOptions } from \"@speeq/client\";\n\ntype GetContext = NonNullable<SpeeqClientOptions[\"getContext\"]>;\n\n/** Collects committed context hooks in registration order. */\nexport function createContextRegistry(base: GetContext) {\n const entries = new Set<() => Record<string, unknown>>();\n return {\n register(read: () => Record<string, unknown>) {\n entries.add(read);\n return () => {\n entries.delete(read);\n };\n },\n getContext() {\n const context = base();\n if (!entries.size) return context;\n return {\n ...context,\n data: Object.assign({}, context?.data, ...Array.from(entries, (read) => read())),\n };\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBA,IAAAA,iBAAyC;;;AChBzC,oBASO;AACP,mBAAqD;AAG9C,SAAS,cAAc,SAA0C;AACtE,QAAM,aAAS,qBAAO,OAAO;AAC7B,SAAO,UAAU;AACjB,QAAM,EAAE,UAAU,YAAY,IAAI;AAClC,aAAO;AAAA,IACL,UAAM,iCAAkB,EAAE,GAAG,OAAO,SAAS,UAAU,YAAY,CAAC;AAAA,IACpE,CAAC,UAAU,WAAW;AAAA,EACxB;AACF;AAuBA,SAAS,aAAa,OAAgB;AACpC,aAAO,4BAAa,KAAK,IAAI,QAAQ,IAAI,yBAAW,UAAU;AAChE;AAEA,IAAM,YAAY,EAAE,UAAU,CAAC,GAAuB,YAAY,KAAsB;AAGjF,SAAS,iBAAiB,SAA0D;AACzF,QAAM,SAAS,cAAc,OAAO;AACpC,QAAM,EAAE,QAAQ,MAAM,IAAI,MAAM,IAAI,QAAQ,UAAU,CAAC;AACvD,QAAM,CAAC,SAAS,UAAU,QAAI,uBAAS,CAAC;AACxC,QAAM,MAAM,KAAK,UAAU,EAAE,QAAQ,MAAM,IAAI,OAAO,QAAQ,CAAC;AAC/D,QAAM,CAAC,OAAO,QAAQ,QAAI,uBAAyC;AAAA,IACjE,MAAM;AAAA,IACN,SAAS;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oCAAqB,MAAM,WAAW,MAAM,aAAa,iBAAiB;AAC3F,SAAO,EAAE,GAAG,UAAU,GAAG,MAAM,QAAQ;AACzC;AAGO,SAAS,gBAAgB,MAAqC;AACnE,QAAM,EAAE,SAAS,IAAI,YAAY,iBAAiB;AAClD,QAAM,cAAU,sBAAO,IAAI;AAC3B,UAAQ,UAAU;AAClB,+BAAU,MAAM,SAAS,SAAS,MAAM,QAAQ,OAAO,GAAG,CAAC,QAAQ,CAAC;AACtE;AAGO,SAAS,cACd,OACA,SACM;AACN,QAAM,EAAE,OAAO,IAAI,YAAY,eAAe;AAC9C,QAAM,cAAU,sBAAO,OAAO;AAC9B,UAAQ,UAAU;AAClB,+BAAU,MAAM,OAAO,GAAG,OAAO,CAAC,YAAY,QAAQ,QAAQ,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,CAAC;AAC1F;","names":["import_client","import_react","import_client","import_react"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/audit-hooks.ts","../src/hooks.ts","../src/provider.tsx","../src/context-registry.ts"],"sourcesContent":["\"use client\";\nexport type {\n AuditClient,\n AuditClientOptions,\n AuditListParams,\n ChatMessage,\n ConversationEvent,\n NavigateAction,\n PendingConfirmation,\n SessionSummary,\n SpeeqClient,\n SpeeqClientEvents,\n SpeeqClientOptions,\n SpeeqSnapshot,\n SpeeqState,\n} from \"@speeq/client\";\nexport { isSpeeqError, SpeeqError } from \"@speeq/client\";\nexport type {\n UseAuditSessionResult,\n UseAuditSessionsOptions,\n UseAuditSessionsResult,\n} from \"./audit-hooks.js\";\nexport { useAuditSession, useAuditSessions, useSpeeqAudit } from \"./audit-hooks.js\";\nexport type { UseSpeeqResult } from \"./hooks.js\";\nexport { useSpeeq, useSpeeqContext, useSpeeqEvent } from \"./hooks.js\";\nexport type { SpeeqProviderProps } from \"./provider.js\";\nexport { SpeeqProvider } from \"./provider.js\";\n","import {\n type AuditClient,\n type AuditClientOptions,\n type AuditListParams,\n type ConversationEvent,\n createAuditClient,\n isSpeeqError,\n type SessionSummary,\n SpeeqError,\n} from \"@speeq/client\";\nimport { useEffect, useMemo, useRef, useState } from \"react\";\n\n/** Creates an audit client for the endpoint and credential mode. */\nexport function useSpeeqAudit(options: AuditClientOptions): AuditClient {\n const latest = useRef(options);\n latest.current = options;\n const { endpoint, credentials } = options;\n return useMemo(\n () => createAuditClient({ ...latest.current, endpoint, credentials }),\n [endpoint, credentials],\n );\n}\n\n/** Audit connection and optional session list filter. */\nexport interface UseAuditSessionsOptions extends AuditClientOptions {\n filter?: Omit<AuditListParams, \"cursor\">;\n}\n\n/** Current session list with pagination and refresh controls. */\nexport interface UseAuditSessionsResult {\n sessions: SessionSummary[];\n loading: boolean;\n error: SpeeqError | null;\n hasMore: boolean;\n loadMore(): void;\n refresh(): void;\n}\n\ninterface RequestState<T> {\n data: T;\n loading: boolean;\n error: SpeeqError | null;\n}\n\nfunction requestError(error: unknown) {\n return isSpeeqError(error) ? error : new SpeeqError(\"INTERNAL\");\n}\n\nconst emptyPage = { sessions: [] as SessionSummary[], nextCursor: null as string | null };\n\n/** Loads session summaries and appends additional pages on demand. */\nexport function useAuditSessions(options: UseAuditSessionsOptions): UseAuditSessionsResult {\n const client = useSpeeqAudit(options);\n const { userId, from, to, limit } = options.filter ?? {};\n const [version, setVersion] = useState(0);\n const key = JSON.stringify({ userId, from, to, limit, version });\n const [state, setState] = useState<RequestState<typeof emptyPage>>({\n data: emptyPage,\n loading: true,\n error: null,\n });\n const load = useRef<(cursor?: string) => void>(() => {});\n useEffect(() => {\n const filter = JSON.parse(key) as AuditListParams;\n let pending: AbortController | undefined;\n let active = true;\n load.current = (cursor) => {\n if (!active || pending) return;\n const controller = new AbortController();\n pending = controller;\n setState((current) => ({\n data: cursor ? current.data : emptyPage,\n loading: true,\n error: null,\n }));\n void client\n .listSessions({ ...filter, cursor }, controller.signal)\n .then(\n (page) => {\n if (active)\n setState((current) => ({\n data: cursor\n ? { ...page, sessions: [...current.data.sessions, ...page.sessions] }\n : page,\n loading: false,\n error: null,\n }));\n },\n (error) => {\n if (active)\n setState((current) => ({ ...current, loading: false, error: requestError(error) }));\n },\n )\n .finally(() => {\n pending = undefined;\n });\n };\n load.current();\n return () => {\n active = false;\n pending?.abort();\n };\n }, [client, key]);\n return {\n sessions: state.data.sessions,\n loading: state.loading,\n error: state.error,\n hasMore: !!state.data.nextCursor,\n loadMore() {\n if (!state.loading && state.data.nextCursor) load.current(state.data.nextCursor);\n },\n refresh() {\n setVersion((current) => current + 1);\n },\n };\n}\n\n/** Current session, its ordered events and a reload control. */\nexport interface UseAuditSessionResult {\n session: SessionSummary | null;\n events: ConversationEvent[];\n loading: boolean;\n error: SpeeqError | null;\n refresh(): void;\n}\n\nconst emptyDetail = { session: null, events: [] as ConversationEvent[] };\n\n/** Loads and refreshes the event history for a selected session. */\nexport function useAuditSession(\n sessionId: string | null,\n options: AuditClientOptions,\n): UseAuditSessionResult {\n const client = useSpeeqAudit(options);\n const [version, setVersion] = useState(0);\n const [state, setState] = useState<\n RequestState<Pick<UseAuditSessionResult, \"session\" | \"events\">>\n >({\n data: emptyDetail,\n loading: sessionId !== null,\n error: null,\n });\n // biome-ignore lint/correctness/useExhaustiveDependencies: Refresh reloads the same selected session.\n useEffect(() => {\n if (sessionId === null) {\n setState({ data: emptyDetail, loading: false, error: null });\n return;\n }\n const controller = new AbortController();\n setState({ data: emptyDetail, loading: true, error: null });\n void client.getSession(sessionId, controller.signal).then(\n (data) => {\n if (!controller.signal.aborted) setState({ data, loading: false, error: null });\n },\n (error) => {\n if (!controller.signal.aborted)\n setState({ data: emptyDetail, loading: false, error: requestError(error) });\n },\n );\n return () => controller.abort();\n }, [client, sessionId, version]);\n return {\n ...(sessionId === null ? emptyDetail : state.data),\n loading: sessionId !== null && state.loading,\n error: sessionId === null ? null : state.error,\n refresh() {\n setVersion((current) => current + 1);\n },\n };\n}\n","import type { SpeeqClient, SpeeqClientEvents, SpeeqSnapshot } from \"@speeq/client\";\nimport { useEffect, useMemo, useRef, useSyncExternalStore } from \"react\";\nimport { useProvider } from \"./provider.js\";\n\n/** Live client snapshot and stable client actions. */\nexport interface UseSpeeqResult extends SpeeqSnapshot {\n client: SpeeqClient;\n sendText: SpeeqClient[\"sendText\"];\n startListening: SpeeqClient[\"startListening\"];\n stopListening: SpeeqClient[\"stopListening\"];\n startCall: SpeeqClient[\"startCall\"];\n endCall: SpeeqClient[\"endCall\"];\n cancel: SpeeqClient[\"cancel\"];\n setLanguage: SpeeqClient[\"setLanguage\"];\n confirm: SpeeqClient[\"confirm\"];\n speak: SpeeqClient[\"speak\"];\n}\n\n/** Reads the current snapshot and actions of the provider's client. */\nexport function useSpeeq(): UseSpeeqResult {\n const { client, getServerSnapshot } = useProvider(\"useSpeeq\");\n const store = useMemo(\n () => ({\n subscribe: client.subscribe.bind(client),\n getSnapshot: client.getSnapshot.bind(client),\n actions: {\n client,\n sendText: client.sendText.bind(client),\n startListening: client.startListening.bind(client),\n stopListening: client.stopListening.bind(client),\n startCall: client.startCall.bind(client),\n endCall: client.endCall.bind(client),\n cancel: client.cancel.bind(client),\n setLanguage: client.setLanguage.bind(client),\n confirm: client.confirm.bind(client),\n speak: client.speak.bind(client),\n },\n }),\n [client],\n );\n const snapshot = useSyncExternalStore(store.subscribe, store.getSnapshot, getServerSnapshot);\n return { ...snapshot, ...store.actions };\n}\n\n/** Registers data from the current page for subsequent conversation requests. */\nexport function useSpeeqContext(data: Record<string, unknown>): void {\n const { registry } = useProvider(\"useSpeeqContext\");\n const current = useRef(data);\n current.current = data;\n useEffect(() => registry.register(() => current.current), [registry]);\n}\n\n/** Subscribes to a client event and calls the latest handler. */\nexport function useSpeeqEvent<K extends keyof SpeeqClientEvents>(\n event: K,\n handler: (payload: SpeeqClientEvents[K]) => void,\n): void {\n const { client } = useProvider(\"useSpeeqEvent\");\n const current = useRef(handler);\n current.current = handler;\n useEffect(() => client.on(event, (payload) => current.current(payload)), [client, event]);\n}\n","import {\n createSpeeqClient,\n type SpeeqClient,\n type SpeeqClientOptions,\n type SpeeqSnapshot,\n} from \"@speeq/client\";\nimport {\n createContext,\n type JSX,\n type ReactNode,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { createContextRegistry } from \"./context-registry.js\";\n\n/** Configuration for a provider-owned client or an existing client. */\nexport interface SpeeqProviderProps extends SpeeqClientOptions {\n children: ReactNode;\n /** Use an existing client instead of creating one. The other options are then ignored. */\n client?: SpeeqClient;\n}\n\nconst ProviderContext = createContext<{\n client: SpeeqClient;\n getServerSnapshot: () => SpeeqSnapshot;\n registry: ReturnType<typeof createContextRegistry>;\n} | null>(null);\n\nconst serverSnapshots = new WeakMap<SpeeqClient, SpeeqSnapshot>();\n\nfunction initialServerSnapshot(client: SpeeqClient) {\n let snapshot = serverSnapshots.get(client);\n if (!snapshot) {\n snapshot = {\n ...client.getSnapshot(),\n support: { speechInput: false, speechOutput: false, voiceForLanguage: null },\n };\n serverSnapshots.set(client, snapshot);\n }\n return snapshot;\n}\n\n/** Makes a speeq client available to descendant hooks. */\nexport function SpeeqProvider(props: SpeeqProviderProps): JSX.Element {\n const navigate = useRef(props.onNavigate);\n const context = useRef(props.getContext);\n navigate.current = props.onNavigate;\n context.current = props.getContext;\n const [registry] = useState(() => createContextRegistry(() => context.current?.()));\n const [initial] = useState(() => ({\n client:\n props.client ??\n createSpeeqClient({\n ...props,\n onNavigate: (action) => navigate.current?.(action),\n getContext: registry.getContext,\n }),\n owned: props.client === undefined,\n }));\n const client = props.client ?? initial.client;\n const owned = initial.owned && client === initial.client && props.client === undefined;\n useEffect(() => {\n if (owned)\n return () => {\n client.endCall(); // never leave the microphone on after the provider is gone\n client.cancel();\n };\n }, [owned, client]);\n const value = useMemo(() => {\n const snapshot = initialServerSnapshot(client);\n return { client, getServerSnapshot: () => snapshot, registry };\n }, [client, registry]);\n return <ProviderContext.Provider value={value}>{props.children}</ProviderContext.Provider>;\n}\n\n/** Reads the provider store for a named hook. */\nexport function useProvider(hook: string) {\n const value = useContext(ProviderContext);\n if (!value) throw new Error(`${hook} must be used inside <SpeeqProvider>`);\n return value;\n}\n","import type { SpeeqClientOptions } from \"@speeq/client\";\n\ntype GetContext = NonNullable<SpeeqClientOptions[\"getContext\"]>;\n\n/** Collects committed context hooks in registration order. */\nexport function createContextRegistry(base: GetContext) {\n const entries = new Set<() => Record<string, unknown>>();\n return {\n register(read: () => Record<string, unknown>) {\n entries.add(read);\n return () => {\n entries.delete(read);\n };\n },\n getContext() {\n const context = base();\n if (!entries.size) return context;\n return {\n ...context,\n data: Object.assign({}, context?.data, ...Array.from(entries, (read) => read())),\n };\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBA,IAAAA,iBAAyC;;;AChBzC,oBASO;AACP,mBAAqD;AAG9C,SAAS,cAAc,SAA0C;AACtE,QAAM,aAAS,qBAAO,OAAO;AAC7B,SAAO,UAAU;AACjB,QAAM,EAAE,UAAU,YAAY,IAAI;AAClC,aAAO;AAAA,IACL,UAAM,iCAAkB,EAAE,GAAG,OAAO,SAAS,UAAU,YAAY,CAAC;AAAA,IACpE,CAAC,UAAU,WAAW;AAAA,EACxB;AACF;AAuBA,SAAS,aAAa,OAAgB;AACpC,aAAO,4BAAa,KAAK,IAAI,QAAQ,IAAI,yBAAW,UAAU;AAChE;AAEA,IAAM,YAAY,EAAE,UAAU,CAAC,GAAuB,YAAY,KAAsB;AAGjF,SAAS,iBAAiB,SAA0D;AACzF,QAAM,SAAS,cAAc,OAAO;AACpC,QAAM,EAAE,QAAQ,MAAM,IAAI,MAAM,IAAI,QAAQ,UAAU,CAAC;AACvD,QAAM,CAAC,SAAS,UAAU,QAAI,uBAAS,CAAC;AACxC,QAAM,MAAM,KAAK,UAAU,EAAE,QAAQ,MAAM,IAAI,OAAO,QAAQ,CAAC;AAC/D,QAAM,CAAC,OAAO,QAAQ,QAAI,uBAA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AA,QAC3C,SAAS,OAAO,QAAQ,KAAK,MAAM;AAAA,QACnC,OAAO,OAAO,MAAM,KAAK,MAAM;AAAA,MACjC;AAAA,IACF;AAAA,IACA,CAAC,MAAM;AAAA,EACT;AACA,QAAM,eAAW,oCAAqB,MAAM,WAAW,MAAM,aAAa,iBAAiB;AAC3F,SAAO,EAAE,GAAG,UAAU,GAAG,MAAM,QAAQ;AACzC;AAGO,SAAS,gBAAgB,MAAqC;AACnE,QAAM,EAAE,SAAS,IAAI,YAAY,iBAAiB;AAClD,QAAM,cAAU,sBAAO,IAAI;AAC3B,UAAQ,UAAU;AAClB,+BAAU,MAAM,SAAS,SAAS,MAAM,QAAQ,OAAO,GAAG,CAAC,QAAQ,CAAC;AACtE;AAGO,SAAS,cACd,OACA,SACM;AACN,QAAM,EAAE,OAAO,IAAI,YAAY,eAAe;AAC9C,QAAM,cAAU,sBAAO,OAAO;AAC9B,UAAQ,UAAU;AAClB,+BAAU,MAAM,OAAO,GAAG,OAAO,CAAC,YAAY,QAAQ,QAAQ,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,CAAC;AAC1F;","names":["import_client","import_react","import_client","import_react"]}
package/dist/index.d.cts CHANGED
@@ -36,6 +36,8 @@ interface UseSpeeqResult extends SpeeqSnapshot {
36
36
  sendText: SpeeqClient["sendText"];
37
37
  startListening: SpeeqClient["startListening"];
38
38
  stopListening: SpeeqClient["stopListening"];
39
+ startCall: SpeeqClient["startCall"];
40
+ endCall: SpeeqClient["endCall"];
39
41
  cancel: SpeeqClient["cancel"];
40
42
  setLanguage: SpeeqClient["setLanguage"];
41
43
  confirm: SpeeqClient["confirm"];
package/dist/index.d.ts CHANGED
@@ -36,6 +36,8 @@ interface UseSpeeqResult extends SpeeqSnapshot {
36
36
  sendText: SpeeqClient["sendText"];
37
37
  startListening: SpeeqClient["startListening"];
38
38
  stopListening: SpeeqClient["stopListening"];
39
+ startCall: SpeeqClient["startCall"];
40
+ endCall: SpeeqClient["endCall"];
39
41
  cancel: SpeeqClient["cancel"];
40
42
  setLanguage: SpeeqClient["setLanguage"];
41
43
  confirm: SpeeqClient["confirm"];
package/dist/index.js CHANGED
@@ -191,7 +191,11 @@ function SpeeqProvider(props) {
191
191
  const client = props.client ?? initial.client;
192
192
  const owned = initial.owned && client === initial.client && props.client === void 0;
193
193
  useEffect2(() => {
194
- if (owned) return () => client.cancel();
194
+ if (owned)
195
+ return () => {
196
+ client.endCall();
197
+ client.cancel();
198
+ };
195
199
  }, [owned, client]);
196
200
  const value = useMemo2(() => {
197
201
  const snapshot = initialServerSnapshot(client);
@@ -217,6 +221,8 @@ function useSpeeq() {
217
221
  sendText: client.sendText.bind(client),
218
222
  startListening: client.startListening.bind(client),
219
223
  stopListening: client.stopListening.bind(client),
224
+ startCall: client.startCall.bind(client),
225
+ endCall: client.endCall.bind(client),
220
226
  cancel: client.cancel.bind(client),
221
227
  setLanguage: client.setLanguage.bind(client),
222
228
  confirm: client.confirm.bind(client),
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/audit-hooks.ts","../src/hooks.ts","../src/provider.tsx","../src/context-registry.ts"],"sourcesContent":["\"use client\";\nexport type {\n AuditClient,\n AuditClientOptions,\n AuditListParams,\n ChatMessage,\n ConversationEvent,\n NavigateAction,\n PendingConfirmation,\n SessionSummary,\n SpeeqClient,\n SpeeqClientEvents,\n SpeeqClientOptions,\n SpeeqSnapshot,\n SpeeqState,\n} from \"@speeq/client\";\nexport { isSpeeqError, SpeeqError } from \"@speeq/client\";\nexport type {\n UseAuditSessionResult,\n UseAuditSessionsOptions,\n UseAuditSessionsResult,\n} from \"./audit-hooks.js\";\nexport { useAuditSession, useAuditSessions, useSpeeqAudit } from \"./audit-hooks.js\";\nexport type { UseSpeeqResult } from \"./hooks.js\";\nexport { useSpeeq, useSpeeqContext, useSpeeqEvent } from \"./hooks.js\";\nexport type { SpeeqProviderProps } from \"./provider.js\";\nexport { SpeeqProvider } from \"./provider.js\";\n","import {\n type AuditClient,\n type AuditClientOptions,\n type AuditListParams,\n type ConversationEvent,\n createAuditClient,\n isSpeeqError,\n type SessionSummary,\n SpeeqError,\n} from \"@speeq/client\";\nimport { useEffect, useMemo, useRef, useState } from \"react\";\n\n/** Creates an audit client for the endpoint and credential mode. */\nexport function useSpeeqAudit(options: AuditClientOptions): AuditClient {\n const latest = useRef(options);\n latest.current = options;\n const { endpoint, credentials } = options;\n return useMemo(\n () => createAuditClient({ ...latest.current, endpoint, credentials }),\n [endpoint, credentials],\n );\n}\n\n/** Audit connection and optional session list filter. */\nexport interface UseAuditSessionsOptions extends AuditClientOptions {\n filter?: Omit<AuditListParams, \"cursor\">;\n}\n\n/** Current session list with pagination and refresh controls. */\nexport interface UseAuditSessionsResult {\n sessions: SessionSummary[];\n loading: boolean;\n error: SpeeqError | null;\n hasMore: boolean;\n loadMore(): void;\n refresh(): void;\n}\n\ninterface RequestState<T> {\n data: T;\n loading: boolean;\n error: SpeeqError | null;\n}\n\nfunction requestError(error: unknown) {\n return isSpeeqError(error) ? error : new SpeeqError(\"INTERNAL\");\n}\n\nconst emptyPage = { sessions: [] as SessionSummary[], nextCursor: null as string | null };\n\n/** Loads session summaries and appends additional pages on demand. */\nexport function useAuditSessions(options: UseAuditSessionsOptions): UseAuditSessionsResult {\n const client = useSpeeqAudit(options);\n const { userId, from, to, limit } = options.filter ?? {};\n const [version, setVersion] = useState(0);\n const key = JSON.stringify({ userId, from, to, limit, version });\n const [state, setState] = useState<RequestState<typeof emptyPage>>({\n data: emptyPage,\n loading: true,\n error: null,\n });\n const load = useRef<(cursor?: string) => void>(() => {});\n useEffect(() => {\n const filter = JSON.parse(key) as AuditListParams;\n let pending: AbortController | undefined;\n let active = true;\n load.current = (cursor) => {\n if (!active || pending) return;\n const controller = new AbortController();\n pending = controller;\n setState((current) => ({\n data: cursor ? current.data : emptyPage,\n loading: true,\n error: null,\n }));\n void client\n .listSessions({ ...filter, cursor }, controller.signal)\n .then(\n (page) => {\n if (active)\n setState((current) => ({\n data: cursor\n ? { ...page, sessions: [...current.data.sessions, ...page.sessions] }\n : page,\n loading: false,\n error: null,\n }));\n },\n (error) => {\n if (active)\n setState((current) => ({ ...current, loading: false, error: requestError(error) }));\n },\n )\n .finally(() => {\n pending = undefined;\n });\n };\n load.current();\n return () => {\n active = false;\n pending?.abort();\n };\n }, [client, key]);\n return {\n sessions: state.data.sessions,\n loading: state.loading,\n error: state.error,\n hasMore: !!state.data.nextCursor,\n loadMore() {\n if (!state.loading && state.data.nextCursor) load.current(state.data.nextCursor);\n },\n refresh() {\n setVersion((current) => current + 1);\n },\n };\n}\n\n/** Current session, its ordered events and a reload control. */\nexport interface UseAuditSessionResult {\n session: SessionSummary | null;\n events: ConversationEvent[];\n loading: boolean;\n error: SpeeqError | null;\n refresh(): void;\n}\n\nconst emptyDetail = { session: null, events: [] as ConversationEvent[] };\n\n/** Loads and refreshes the event history for a selected session. */\nexport function useAuditSession(\n sessionId: string | null,\n options: AuditClientOptions,\n): UseAuditSessionResult {\n const client = useSpeeqAudit(options);\n const [version, setVersion] = useState(0);\n const [state, setState] = useState<\n RequestState<Pick<UseAuditSessionResult, \"session\" | \"events\">>\n >({\n data: emptyDetail,\n loading: sessionId !== null,\n error: null,\n });\n // biome-ignore lint/correctness/useExhaustiveDependencies: Refresh reloads the same selected session.\n useEffect(() => {\n if (sessionId === null) {\n setState({ data: emptyDetail, loading: false, error: null });\n return;\n }\n const controller = new AbortController();\n setState({ data: emptyDetail, loading: true, error: null });\n void client.getSession(sessionId, controller.signal).then(\n (data) => {\n if (!controller.signal.aborted) setState({ data, loading: false, error: null });\n },\n (error) => {\n if (!controller.signal.aborted)\n setState({ data: emptyDetail, loading: false, error: requestError(error) });\n },\n );\n return () => controller.abort();\n }, [client, sessionId, version]);\n return {\n ...(sessionId === null ? emptyDetail : state.data),\n loading: sessionId !== null && state.loading,\n error: sessionId === null ? null : state.error,\n refresh() {\n setVersion((current) => current + 1);\n },\n };\n}\n","import type { SpeeqClient, SpeeqClientEvents, SpeeqSnapshot } from \"@speeq/client\";\nimport { useEffect, useMemo, useRef, useSyncExternalStore } from \"react\";\nimport { useProvider } from \"./provider.js\";\n\n/** Live client snapshot and stable client actions. */\nexport interface UseSpeeqResult extends SpeeqSnapshot {\n client: SpeeqClient;\n sendText: SpeeqClient[\"sendText\"];\n startListening: SpeeqClient[\"startListening\"];\n stopListening: SpeeqClient[\"stopListening\"];\n cancel: SpeeqClient[\"cancel\"];\n setLanguage: SpeeqClient[\"setLanguage\"];\n confirm: SpeeqClient[\"confirm\"];\n speak: SpeeqClient[\"speak\"];\n}\n\n/** Reads the current snapshot and actions of the provider's client. */\nexport function useSpeeq(): UseSpeeqResult {\n const { client, getServerSnapshot } = useProvider(\"useSpeeq\");\n const store = useMemo(\n () => ({\n subscribe: client.subscribe.bind(client),\n getSnapshot: client.getSnapshot.bind(client),\n actions: {\n client,\n sendText: client.sendText.bind(client),\n startListening: client.startListening.bind(client),\n stopListening: client.stopListening.bind(client),\n cancel: client.cancel.bind(client),\n setLanguage: client.setLanguage.bind(client),\n confirm: client.confirm.bind(client),\n speak: client.speak.bind(client),\n },\n }),\n [client],\n );\n const snapshot = useSyncExternalStore(store.subscribe, store.getSnapshot, getServerSnapshot);\n return { ...snapshot, ...store.actions };\n}\n\n/** Registers data from the current page for subsequent conversation requests. */\nexport function useSpeeqContext(data: Record<string, unknown>): void {\n const { registry } = useProvider(\"useSpeeqContext\");\n const current = useRef(data);\n current.current = data;\n useEffect(() => registry.register(() => current.current), [registry]);\n}\n\n/** Subscribes to a client event and calls the latest handler. */\nexport function useSpeeqEvent<K extends keyof SpeeqClientEvents>(\n event: K,\n handler: (payload: SpeeqClientEvents[K]) => void,\n): void {\n const { client } = useProvider(\"useSpeeqEvent\");\n const current = useRef(handler);\n current.current = handler;\n useEffect(() => client.on(event, (payload) => current.current(payload)), [client, event]);\n}\n","import {\n createSpeeqClient,\n type SpeeqClient,\n type SpeeqClientOptions,\n type SpeeqSnapshot,\n} from \"@speeq/client\";\nimport {\n createContext,\n type JSX,\n type ReactNode,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { createContextRegistry } from \"./context-registry.js\";\n\n/** Configuration for a provider-owned client or an existing client. */\nexport interface SpeeqProviderProps extends SpeeqClientOptions {\n children: ReactNode;\n /** Use an existing client instead of creating one. The other options are then ignored. */\n client?: SpeeqClient;\n}\n\nconst ProviderContext = createContext<{\n client: SpeeqClient;\n getServerSnapshot: () => SpeeqSnapshot;\n registry: ReturnType<typeof createContextRegistry>;\n} | null>(null);\n\nconst serverSnapshots = new WeakMap<SpeeqClient, SpeeqSnapshot>();\n\nfunction initialServerSnapshot(client: SpeeqClient) {\n let snapshot = serverSnapshots.get(client);\n if (!snapshot) {\n snapshot = {\n ...client.getSnapshot(),\n support: { speechInput: false, speechOutput: false, voiceForLanguage: null },\n };\n serverSnapshots.set(client, snapshot);\n }\n return snapshot;\n}\n\n/** Makes a speeq client available to descendant hooks. */\nexport function SpeeqProvider(props: SpeeqProviderProps): JSX.Element {\n const navigate = useRef(props.onNavigate);\n const context = useRef(props.getContext);\n navigate.current = props.onNavigate;\n context.current = props.getContext;\n const [registry] = useState(() => createContextRegistry(() => context.current?.()));\n const [initial] = useState(() => ({\n client:\n props.client ??\n createSpeeqClient({\n ...props,\n onNavigate: (action) => navigate.current?.(action),\n getContext: registry.getContext,\n }),\n owned: props.client === undefined,\n }));\n const client = props.client ?? initial.client;\n const owned = initial.owned && client === initial.client && props.client === undefined;\n useEffect(() => {\n if (owned) return () => client.cancel();\n }, [owned, client]);\n const value = useMemo(() => {\n const snapshot = initialServerSnapshot(client);\n return { client, getServerSnapshot: () => snapshot, registry };\n }, [client, registry]);\n return <ProviderContext.Provider value={value}>{props.children}</ProviderContext.Provider>;\n}\n\n/** Reads the provider store for a named hook. */\nexport function useProvider(hook: string) {\n const value = useContext(ProviderContext);\n if (!value) throw new Error(`${hook} must be used inside <SpeeqProvider>`);\n return value;\n}\n","import type { SpeeqClientOptions } from \"@speeq/client\";\n\ntype GetContext = NonNullable<SpeeqClientOptions[\"getContext\"]>;\n\n/** Collects committed context hooks in registration order. */\nexport function createContextRegistry(base: GetContext) {\n const entries = new Set<() => Record<string, unknown>>();\n return {\n register(read: () => Record<string, unknown>) {\n entries.add(read);\n return () => {\n entries.delete(read);\n };\n },\n getContext() {\n const context = base();\n if (!entries.size) return context;\n return {\n ...context,\n data: Object.assign({}, context?.data, ...Array.from(entries, (read) => read())),\n };\n },\n };\n}\n"],"mappings":";;;;AAgBA,SAAS,gBAAAA,eAAc,cAAAC,mBAAkB;;;AChBzC;AAAA,EAKE;AAAA,EACA;AAAA,EAEA;AAAA,OACK;AACP,SAAS,WAAW,SAAS,QAAQ,gBAAgB;AAG9C,SAAS,cAAc,SAA0C;AACtE,QAAM,SAAS,OAAO,OAAO;AAC7B,SAAO,UAAU;AACjB,QAAM,EAAE,UAAU,YAAY,IAAI;AAClC,SAAO;AAAA,IACL,MAAM,kBAAkB,EAAE,GAAG,OAAO,SAAS,UAAU,YAAY,CAAC;AAAA,IACpE,CAAC,UAAU,WAAW;AAAA,EACxB;AACF;AAuBA,SAAS,aAAa,OAAgB;AACpC,SAAO,aAAa,KAAK,IAAI,QAAQ,IAAI,WAAW,UAAU;AAChE;AAEA,IAAM,YAAY,EAAE,UAAU,CAAC,GAAuB,YAAY,KAAsB;AAGjF,SAAS,iBAAiB,SAA0D;AACzF,QAAM,SAAS,cAAc,OAAO;AACpC,QAAM,EAAE,QAAQ,MAAM,IAAI,MAAM,IAAI,QAAQ,UAAU,CAAC;AACvD,QAAM,CAAC,SAAS,UAAU,IAAI,SAAS,CAAC;AACxC,QAAM,MAAM,KAAK,UAAU,EAAE,QAAQ,MAAM,IAAI,OAAO,QAAQ,CAAC;AAC/D,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAyC;AAAA,IACjE,MAAM;AAAA,IACN,SAAS;AAAA,IACT,OAAO;AAAA,EACT,CAAC;AACD,QAAM,OAA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AM,KAAK,MAAM;AAAA,MACjC;AAAA,IACF;AAAA,IACA,CAAC,MAAM;AAAA,EACT;AACA,QAAM,WAAW,qBAAqB,MAAM,WAAW,MAAM,aAAa,iBAAiB;AAC3F,SAAO,EAAE,GAAG,UAAU,GAAG,MAAM,QAAQ;AACzC;AAGO,SAAS,gBAAgB,MAAqC;AACnE,QAAM,EAAE,SAAS,IAAI,YAAY,iBAAiB;AAClD,QAAM,UAAUC,QAAO,IAAI;AAC3B,UAAQ,UAAU;AAClB,EAAAC,WAAU,MAAM,SAAS,SAAS,MAAM,QAAQ,OAAO,GAAG,CAAC,QAAQ,CAAC;AACtE;AAGO,SAAS,cACd,OACA,SACM;AACN,QAAM,EAAE,OAAO,IAAI,YAAY,eAAe;AAC9C,QAAM,UAAUD,QAAO,OAAO;AAC9B,UAAQ,UAAU;AAClB,EAAAC,WAAU,MAAM,OAAO,GAAG,OAAO,CAAC,YAAY,QAAQ,QAAQ,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,CAAC;AAC1F;","names":["isSpeeqError","SpeeqError","useEffect","useMemo","useRef","useEffect","useMemo","useRef","useState","useRef","useState","useEffect","useMemo","useMemo","useRef","useEffect"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/audit-hooks.ts","../src/hooks.ts","../src/provider.tsx","../src/context-registry.ts"],"sourcesContent":["\"use client\";\nexport type {\n AuditClient,\n AuditClientOptions,\n AuditListParams,\n ChatMessage,\n ConversationEvent,\n NavigateAction,\n PendingConfirmation,\n SessionSummary,\n SpeeqClient,\n SpeeqClientEvents,\n SpeeqClientOptions,\n SpeeqSnapshot,\n SpeeqState,\n} from \"@speeq/client\";\nexport { isSpeeqError, SpeeqError } from \"@speeq/client\";\nexport type {\n UseAuditSessionResult,\n UseAuditSessionsOptions,\n UseAuditSessionsResult,\n} from \"./audit-hooks.js\";\nexport { useAuditSession, useAuditSessions, useSpeeqAudit } from \"./audit-hooks.js\";\nexport type { UseSpeeqResult } from \"./hooks.js\";\nexport { useSpeeq, useSpeeqContext, useSpeeqEvent } from \"./hooks.js\";\nexport type { SpeeqProviderProps } from \"./provider.js\";\nexport { SpeeqProvider } from \"./provider.js\";\n","import {\n type AuditClient,\n type AuditClientOptions,\n type AuditListParams,\n type ConversationEvent,\n createAuditClient,\n isSpeeqError,\n type SessionSummary,\n SpeeqError,\n} from \"@speeq/client\";\nimport { useEffect, useMemo, useRef, useState } from \"react\";\n\n/** Creates an audit client for the endpoint and credential mode. */\nexport function useSpeeqAudit(options: AuditClientOptions): AuditClient {\n const latest = useRef(options);\n latest.current = options;\n const { endpoint, credentials } = options;\n return useMemo(\n () => createAuditClient({ ...latest.current, endpoint, credentials }),\n [endpoint, credentials],\n );\n}\n\n/** Audit connection and optional session list filter. */\nexport interface UseAuditSessionsOptions extends AuditClientOptions {\n filter?: Omit<AuditListParams, \"cursor\">;\n}\n\n/** Current session list with pagination and refresh controls. */\nexport interface UseAuditSessionsResult {\n sessions: SessionSummary[];\n loading: boolean;\n error: SpeeqError | null;\n hasMore: boolean;\n loadMore(): void;\n refresh(): void;\n}\n\ninterface RequestState<T> {\n data: T;\n loading: boolean;\n error: SpeeqError | null;\n}\n\nfunction requestError(error: unknown) {\n return isSpeeqError(error) ? error : new SpeeqError(\"INTERNAL\");\n}\n\nconst emptyPage = { sessions: [] as SessionSummary[], nextCursor: null as string | null };\n\n/** Loads session summaries and appends additional pages on demand. */\nexport function useAuditSessions(options: UseAuditSessionsOptions): UseAuditSessionsResult {\n const client = useSpeeqAudit(options);\n const { userId, from, to, limit } = options.filter ?? {};\n const [version, setVersion] = useState(0);\n const key = JSON.stringify({ userId, from, to, limit, version });\n const [state, setState] = useState<RequestState<typeof emptyPage>>({\n data: emptyPage,\n loading: true,\n error: null,\n });\n const load = useRef<(cursor?: string) => void>(() => {});\n useEffect(() => {\n const filter = JSON.parse(key) as AuditListParams;\n let pending: AbortController | undefined;\n let active = true;\n load.current = (cursor) => {\n if (!active || pending) return;\n const controller = new AbortController();\n pending = controller;\n setState((current) => ({\n data: cursor ? current.data : emptyPage,\n loading: true,\n error: null,\n }));\n void client\n .listSessions({ ...filter, cursor }, controller.signal)\n .then(\n (page) => {\n if (active)\n setState((current) => ({\n data: cursor\n ? { ...page, sessions: [...current.data.sessions, ...page.sessions] }\n : page,\n loading: false,\n error: null,\n }));\n },\n (error) => {\n if (active)\n setState((current) => ({ ...current, loading: false, error: requestError(error) }));\n },\n )\n .finally(() => {\n pending = undefined;\n });\n };\n load.current();\n return () => {\n active = false;\n pending?.abort();\n };\n }, [client, key]);\n return {\n sessions: state.data.sessions,\n loading: state.loading,\n error: state.error,\n hasMore: !!state.data.nextCursor,\n loadMore() {\n if (!state.loading && state.data.nextCursor) load.current(state.data.nextCursor);\n },\n refresh() {\n setVersion((current) => current + 1);\n },\n };\n}\n\n/** Current session, its ordered events and a reload control. */\nexport interface UseAuditSessionResult {\n session: SessionSummary | null;\n events: ConversationEvent[];\n loading: boolean;\n error: SpeeqError | null;\n refresh(): void;\n}\n\nconst emptyDetail = { session: null, events: [] as ConversationEvent[] };\n\n/** Loads and refreshes the event history for a selected session. */\nexport function useAuditSession(\n sessionId: string | null,\n options: AuditClientOptions,\n): UseAuditSessionResult {\n const client = useSpeeqAudit(options);\n const [version, setVersion] = useState(0);\n const [state, setState] = useState<\n RequestState<Pick<UseAuditSessionResult, \"session\" | \"events\">>\n >({\n data: emptyDetail,\n loading: sessionId !== null,\n error: null,\n });\n // biome-ignore lint/correctness/useExhaustiveDependencies: Refresh reloads the same selected session.\n useEffect(() => {\n if (sessionId === null) {\n setState({ data: emptyDetail, loading: false, error: null });\n return;\n }\n const controller = new AbortController();\n setState({ data: emptyDetail, loading: true, error: null });\n void client.getSession(sessionId, controller.signal).then(\n (data) => {\n if (!controller.signal.aborted) setState({ data, loading: false, error: null });\n },\n (error) => {\n if (!controller.signal.aborted)\n setState({ data: emptyDetail, loading: false, error: requestError(error) });\n },\n );\n return () => controller.abort();\n }, [client, sessionId, version]);\n return {\n ...(sessionId === null ? emptyDetail : state.data),\n loading: sessionId !== null && state.loading,\n error: sessionId === null ? null : state.error,\n refresh() {\n setVersion((current) => current + 1);\n },\n };\n}\n","import type { SpeeqClient, SpeeqClientEvents, SpeeqSnapshot } from \"@speeq/client\";\nimport { useEffect, useMemo, useRef, useSyncExternalStore } from \"react\";\nimport { useProvider } from \"./provider.js\";\n\n/** Live client snapshot and stable client actions. */\nexport interface UseSpeeqResult extends SpeeqSnapshot {\n client: SpeeqClient;\n sendText: SpeeqClient[\"sendText\"];\n startListening: SpeeqClient[\"startListening\"];\n stopListening: SpeeqClient[\"stopListening\"];\n startCall: SpeeqClient[\"startCall\"];\n endCall: SpeeqClient[\"endCall\"];\n cancel: SpeeqClient[\"cancel\"];\n setLanguage: SpeeqClient[\"setLanguage\"];\n confirm: SpeeqClient[\"confirm\"];\n speak: SpeeqClient[\"speak\"];\n}\n\n/** Reads the current snapshot and actions of the provider's client. */\nexport function useSpeeq(): UseSpeeqResult {\n const { client, getServerSnapshot } = useProvider(\"useSpeeq\");\n const store = useMemo(\n () => ({\n subscribe: client.subscribe.bind(client),\n getSnapshot: client.getSnapshot.bind(client),\n actions: {\n client,\n sendText: client.sendText.bind(client),\n startListening: client.startListening.bind(client),\n stopListening: client.stopListening.bind(client),\n startCall: client.startCall.bind(client),\n endCall: client.endCall.bind(client),\n cancel: client.cancel.bind(client),\n setLanguage: client.setLanguage.bind(client),\n confirm: client.confirm.bind(client),\n speak: client.speak.bind(client),\n },\n }),\n [client],\n );\n const snapshot = useSyncExternalStore(store.subscribe, store.getSnapshot, getServerSnapshot);\n return { ...snapshot, ...store.actions };\n}\n\n/** Registers data from the current page for subsequent conversation requests. */\nexport function useSpeeqContext(data: Record<string, unknown>): void {\n const { registry } = useProvider(\"useSpeeqContext\");\n const current = useRef(data);\n current.current = data;\n useEffect(() => registry.register(() => current.current), [registry]);\n}\n\n/** Subscribes to a client event and calls the latest handler. */\nexport function useSpeeqEvent<K extends keyof SpeeqClientEvents>(\n event: K,\n handler: (payload: SpeeqClientEvents[K]) => void,\n): void {\n const { client } = useProvider(\"useSpeeqEvent\");\n const current = useRef(handler);\n current.current = handler;\n useEffect(() => client.on(event, (payload) => current.current(payload)), [client, event]);\n}\n","import {\n createSpeeqClient,\n type SpeeqClient,\n type SpeeqClientOptions,\n type SpeeqSnapshot,\n} from \"@speeq/client\";\nimport {\n createContext,\n type JSX,\n type ReactNode,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { createContextRegistry } from \"./context-registry.js\";\n\n/** Configuration for a provider-owned client or an existing client. */\nexport interface SpeeqProviderProps extends SpeeqClientOptions {\n children: ReactNode;\n /** Use an existing client instead of creating one. The other options are then ignored. */\n client?: SpeeqClient;\n}\n\nconst ProviderContext = createContext<{\n client: SpeeqClient;\n getServerSnapshot: () => SpeeqSnapshot;\n registry: ReturnType<typeof createContextRegistry>;\n} | null>(null);\n\nconst serverSnapshots = new WeakMap<SpeeqClient, SpeeqSnapshot>();\n\nfunction initialServerSnapshot(client: SpeeqClient) {\n let snapshot = serverSnapshots.get(client);\n if (!snapshot) {\n snapshot = {\n ...client.getSnapshot(),\n support: { speechInput: false, speechOutput: false, voiceForLanguage: null },\n };\n serverSnapshots.set(client, snapshot);\n }\n return snapshot;\n}\n\n/** Makes a speeq client available to descendant hooks. */\nexport function SpeeqProvider(props: SpeeqProviderProps): JSX.Element {\n const navigate = useRef(props.onNavigate);\n const context = useRef(props.getContext);\n navigate.current = props.onNavigate;\n context.current = props.getContext;\n const [registry] = useState(() => createContextRegistry(() => context.current?.()));\n const [initial] = useState(() => ({\n client:\n props.client ??\n createSpeeqClient({\n ...props,\n onNavigate: (action) => navigate.current?.(action),\n getContext: registry.getContext,\n }),\n owned: props.client === undefined,\n }));\n const client = props.client ?? initial.client;\n const owned = initial.owned && client === initial.client && props.client === undefined;\n useEffect(() => {\n if (owned)\n return () => {\n client.endCall(); // never leave the microphone on after the provider is gone\n client.cancel();\n };\n }, [owned, client]);\n const value = useMemo(() => {\n const snapshot = initialServerSnapshot(client);\n return { client, getServerSnapshot: () => snapshot, registry };\n }, [client, registry]);\n return <ProviderContext.Provider value={value}>{props.children}</ProviderContext.Provider>;\n}\n\n/** Reads the provider store for a named hook. */\nexport function useProvider(hook: string) {\n const value = useContext(ProviderContext);\n if (!value) throw new Error(`${hook} must be used inside <SpeeqProvider>`);\n return value;\n}\n","import type { SpeeqClientOptions } from \"@speeq/client\";\n\ntype GetContext = NonNullable<SpeeqClientOptions[\"getContext\"]>;\n\n/** Collects committed context hooks in registration order. */\nexport function createContextRegistry(base: GetContext) {\n const entries = new Set<() => Record<string, unknown>>();\n return {\n register(read: () => Record<string, unknown>) {\n entries.add(read);\n return () => {\n entries.delete(read);\n };\n },\n getContext() {\n const context = base();\n if (!entries.size) return context;\n return {\n ...context,\n data: Object.assign({}, context?.data, ...Array.from(entries, (read) => read())),\n };\n },\n };\n}\n"],"mappings":";;;;AAgBA,SAAS,gBAAAA,eAAc,cAAAC,mBAAkB;;;AChBzC;AAAA,EAKE;AAAA,EACA;AAAA,EAEA;AAAA,OACK;AACP,SAAS,WAAW,SAAS,QAAQ,gBAAgB;AAG9C,SAAS,cAAc,SAA0C;AACtE,QAAM,SAAS,OAAO,OAAO;AAC7B,SAAO,UAAU;AACjB,QAAM,EAAE,UAAU,YAAY,IAAI;AAClC,SAAO;AAAA,IACL,MAAM,kBAAkB,EAAE,GAAG,OAAO,SAAS,UAAU,YAAY,CAAC;AAAA,IACpE,CAAC,UAAU,WAAW;AAAA,EACxB;AACF;AAuBA,SAAS,aAAa,OAAgB;AACpC,SAAO,aAAa,KAAK,IAAI,QAAQ,IAAI,WAAW,UAAU;AAChE;AAEA,IAAM,YAAY,EAAE,UAAU,CAAC,GAAuB,YAAY,KAAsB;AAGjF,SAAS,iBAAiB,SAA0D;AACzF,QAAM,SAAS,cAAc,OAAO;AACpC,QAAM,EAAE,QAAQ,MAAM,IAAI,MAAM,IAAI,QAAQ,UAAU,CAAC;AACvD,QAAM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UAAU,OAAO,SAAS,KAAK,MAAM;AAAA,QACrC,gBAAgB,OAAO,eAAe,KAAK,MAAM;AAAA,QACjD,eAAe,OAAO,cAAc,KAAK,MAAM;AAAA,QAC/C,WAAW,OAAO,UAAU,KAAK,MAAM;AAAA,QACvC,SAAS,OAAO,QAAQ,KAAK,MAAM;AAAA,QACnC,QAAQ,OAAO,OAAO,KAAK,MAAM;AAAA,QACjC,aAAa,OAAO,YAAY,KAAK,MAAM;AAAA,QAC3C,SAAS,OAAO,QAAQ,KAAK,MAAM;AAAA,QACnC,OAAO,OAAO,MAAM,KAAK,MAAM;AAAA,MACjC;AAAA,IACF;AAAA,IACA,CAAC,MAAM;AAAA,EACT;AACA,QAAM,WAAW,qBAAqB,MAAM,WAAW,MAAM,aAAa,iBAAiB;AAC3F,SAAO,EAAE,GAAG,UAAU,GAAG,MAAM,QAAQ;AACzC;AAGO,SAAS,gBAAgB,MAAqC;AACnE,QAAM,EAAE,SAAS,IAAI,YAAY,iBAAiB;AAClD,QAAM,UAAUC,QAAO,IAAI;AAC3B,UAAQ,UAAU;AAClB,EAAAC,WAAU,MAAM,SAAS,SAAS,MAAM,QAAQ,OAAO,GAAG,CAAC,QAAQ,CAAC;AACtE;AAGO,SAAS,cACd,OACA,SACM;AACN,QAAM,EAAE,OAAO,IAAI,YAAY,eAAe;AAC9C,QAAM,UAAUD,QAAO,OAAO;AAC9B,UAAQ,UAAU;AAClB,EAAAC,WAAU,MAAM,OAAO,GAAG,OAAO,CAAC,YAAY,QAAQ,QAAQ,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,CAAC;AAC1F;","names":["isSpeeqError","SpeeqError","useEffect","useMemo","useRef","useEffect","useMemo","useRef","useState","useRef","useState","useEffect","useMemo","useMemo","useRef","useEffect"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@speeq/react",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "description": "Headless React bindings for speeq",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -45,7 +45,7 @@
45
45
  "access": "public"
46
46
  },
47
47
  "dependencies": {
48
- "@speeq/client": "0.2.0"
48
+ "@speeq/client": "0.4.0"
49
49
  },
50
50
  "peerDependencies": {
51
51
  "react": "^18.2.0 || ^19.0.0"