@piedata/pieui 2.0.4 → 2.0.5
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/components/PieBaseRoot/index.d.ts +11 -0
- package/dist/components/PieBaseRoot/index.d.ts.map +1 -1
- package/dist/components/PieBaseRoot/types/index.d.ts +6 -0
- package/dist/components/PieBaseRoot/types/index.d.ts.map +1 -1
- package/dist/components/PieCard/index.d.ts +18 -0
- package/dist/components/PieCard/index.d.ts.map +1 -1
- package/dist/components/PieCard/types/index.d.ts +36 -0
- package/dist/components/PieCard/types/index.d.ts.map +1 -1
- package/dist/components/PieMaxRoot/index.d.ts +12 -0
- package/dist/components/PieMaxRoot/index.d.ts.map +1 -1
- package/dist/components/PieRoot/index.d.ts +17 -0
- package/dist/components/PieRoot/index.d.ts.map +1 -1
- package/dist/components/PieRoot/types/index.d.ts +31 -0
- package/dist/components/PieRoot/types/index.d.ts.map +1 -1
- package/dist/components/PieTelegramRoot/index.d.ts +13 -0
- package/dist/components/PieTelegramRoot/index.d.ts.map +1 -1
- package/dist/components/index.esm.js +1 -1
- package/dist/components/index.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +2 -2
- package/dist/index.js +2 -2
- package/dist/util/ajaxCommonUtils.d.ts +48 -1
- package/dist/util/ajaxCommonUtils.d.ts.map +1 -1
- package/dist/util/centrifuge.d.ts +22 -0
- package/dist/util/centrifuge.d.ts.map +1 -1
- package/dist/util/fallback.d.ts +6 -0
- package/dist/util/fallback.d.ts.map +1 -1
- package/dist/util/globalForm.d.ts +8 -0
- package/dist/util/globalForm.d.ts.map +1 -1
- package/dist/util/lazy.d.ts +25 -0
- package/dist/util/lazy.d.ts.map +1 -1
- package/dist/util/mitt.d.ts +37 -0
- package/dist/util/mitt.d.ts.map +1 -1
- package/dist/util/navigate.d.ts +11 -0
- package/dist/util/navigate.d.ts.map +1 -1
- package/dist/util/pieConfig.d.ts +35 -0
- package/dist/util/pieConfig.d.ts.map +1 -1
- package/dist/util/pieName.d.ts +12 -0
- package/dist/util/pieName.d.ts.map +1 -1
- package/dist/util/piecache.d.ts +15 -0
- package/dist/util/piecache.d.ts.map +1 -1
- package/dist/util/registry.d.ts +49 -0
- package/dist/util/registry.d.ts.map +1 -1
- package/dist/util/socket.d.ts +22 -0
- package/dist/util/socket.d.ts.map +1 -1
- package/dist/util/tailwindCommonUtils.d.ts +14 -0
- package/dist/util/tailwindCommonUtils.d.ts.map +1 -1
- package/dist/util/uiRenderer.d.ts +14 -0
- package/dist/util/uiRenderer.d.ts.map +1 -1
- package/dist/util/useIsSupported.d.ts +18 -0
- package/dist/util/useIsSupported.d.ts.map +1 -1
- package/dist/util/useMaxWebApp.d.ts +27 -0
- package/dist/util/useMaxWebApp.d.ts.map +1 -1
- package/dist/util/useOpenAIWebRTC.d.ts +44 -0
- package/dist/util/useOpenAIWebRTC.d.ts.map +1 -1
- package/dist/util/useWebApp.d.ts +21 -0
- package/dist/util/useWebApp.d.ts.map +1 -1
- package/dist/util/webrtcClient.d.ts +61 -0
- package/dist/util/webrtcClient.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,3 +1,17 @@
|
|
|
1
1
|
import { type ClassValue } from 'clsx';
|
|
2
|
+
/**
|
|
3
|
+
* Merges a list of Tailwind CSS class name inputs into a single deduplicated
|
|
4
|
+
* class string.
|
|
5
|
+
*
|
|
6
|
+
* First runs `clsx` to flatten arrays, booleans and object shorthand into a
|
|
7
|
+
* flat list, then pipes the result through `tailwind-merge` so that later
|
|
8
|
+
* utilities override earlier ones on the same property (e.g. `px-2 px-4`
|
|
9
|
+
* collapses to `px-4`). This is the canonical PieUI helper for composing
|
|
10
|
+
* className props.
|
|
11
|
+
*
|
|
12
|
+
* @param inputs Any combination of strings, arrays, objects or falsy values
|
|
13
|
+
* accepted by `clsx`.
|
|
14
|
+
* @returns A merged, whitespace-separated class name string.
|
|
15
|
+
*/
|
|
2
16
|
export declare function cn(...inputs: ClassValue[]): string;
|
|
3
17
|
//# sourceMappingURL=tailwindCommonUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tailwindCommonUtils.d.ts","sourceRoot":"","sources":["../../src/util/tailwindCommonUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,UAAU,EAAE,MAAM,MAAM,CAAA;AAG5C,wBAAgB,EAAE,CAAC,GAAG,MAAM,EAAE,UAAU,EAAE,UAEzC"}
|
|
1
|
+
{"version":3,"file":"tailwindCommonUtils.d.ts","sourceRoot":"","sources":["../../src/util/tailwindCommonUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,UAAU,EAAE,MAAM,MAAM,CAAA;AAG5C;;;;;;;;;;;;;GAaG;AACH,wBAAgB,EAAE,CAAC,GAAG,MAAM,EAAE,UAAU,EAAE,UAEzC"}
|
|
@@ -1,9 +1,23 @@
|
|
|
1
1
|
import { ComponentType } from 'react';
|
|
2
2
|
import { SetUiAjaxConfigurationType, UIConfigType } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Props accepted by any component installed as the active UI renderer.
|
|
5
|
+
*
|
|
6
|
+
* @property uiConfig The declarative UI configuration to render.
|
|
7
|
+
* @property setUiAjaxConfiguration Optional setter forwarded by Ajax
|
|
8
|
+
* containers so nested cards can update the
|
|
9
|
+
* tree in response to AJAX calls.
|
|
10
|
+
*/
|
|
3
11
|
export type UIRendererProps = {
|
|
4
12
|
uiConfig: UIConfigType;
|
|
5
13
|
setUiAjaxConfiguration?: SetUiAjaxConfigurationType;
|
|
6
14
|
};
|
|
15
|
+
/**
|
|
16
|
+
* React context that exposes the active UI renderer component to nested
|
|
17
|
+
* cards. PieRoot variants populate this so that containers can render new
|
|
18
|
+
* `UIConfigType` subtrees (e.g. after an Ajax update) without importing the
|
|
19
|
+
* renderer module themselves, which would create a circular dependency.
|
|
20
|
+
*/
|
|
7
21
|
declare const UIRendererContext: import("react").Context<ComponentType<UIRendererProps> | null>;
|
|
8
22
|
export default UIRendererContext;
|
|
9
23
|
//# sourceMappingURL=uiRenderer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uiRenderer.d.ts","sourceRoot":"","sources":["../../src/util/uiRenderer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAiB,MAAM,OAAO,CAAA;AACpD,OAAO,EAAE,0BAA0B,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAEnE,MAAM,MAAM,eAAe,GAAG;IAC1B,QAAQ,EAAE,YAAY,CAAA;IACtB,sBAAsB,CAAC,EAAE,0BAA0B,CAAA;CACtD,CAAA;AAED,QAAA,MAAM,iBAAiB,gEAEtB,CAAA;AAED,eAAe,iBAAiB,CAAA"}
|
|
1
|
+
{"version":3,"file":"uiRenderer.d.ts","sourceRoot":"","sources":["../../src/util/uiRenderer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAiB,MAAM,OAAO,CAAA;AACpD,OAAO,EAAE,0BAA0B,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAEnE;;;;;;;GAOG;AACH,MAAM,MAAM,eAAe,GAAG;IAC1B,QAAQ,EAAE,YAAY,CAAA;IACtB,sBAAsB,CAAC,EAAE,0BAA0B,CAAA;CACtD,CAAA;AAED;;;;;GAKG;AACH,QAAA,MAAM,iBAAiB,gEAEtB,CAAA;AAED,eAAe,iBAAiB,CAAA"}
|
|
@@ -1,2 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React hook that asks the PieUI backend whether a named feature/component is
|
|
3
|
+
* supported for the current user, and returns the boolean answer.
|
|
4
|
+
*
|
|
5
|
+
* The hook maintains two module-level caches:
|
|
6
|
+
* - `resultCache` stores resolved answers for the rest of the session, so
|
|
7
|
+
* only the first caller actually hits the network;
|
|
8
|
+
* - `inflightCache` deduplicates concurrent requests for the same
|
|
9
|
+
* `(apiServer, name)` pair, so multiple components mounting in the same
|
|
10
|
+
* tick share one fetch.
|
|
11
|
+
*
|
|
12
|
+
* While the answer is being fetched the hook returns `null`, which callers
|
|
13
|
+
* can use to show a neutral/loading state.
|
|
14
|
+
*
|
|
15
|
+
* @param apiServer Base URL of the PieUI API server.
|
|
16
|
+
* @param name Feature/component identifier passed as `api/support/{name}`.
|
|
17
|
+
* @returns `true`/`false` once known, or `null` while loading.
|
|
18
|
+
*/
|
|
1
19
|
export declare function useIsSupported(apiServer: string, name: string): boolean | null;
|
|
2
20
|
//# sourceMappingURL=useIsSupported.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIsSupported.d.ts","sourceRoot":"","sources":["../../src/util/useIsSupported.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useIsSupported.d.ts","sourceRoot":"","sources":["../../src/util/useIsSupported.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,cAAc,CAC1B,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,GACb,OAAO,GAAG,IAAI,CAiDhB"}
|
|
@@ -1,6 +1,33 @@
|
|
|
1
1
|
import { MaxWebApp, MaxWebAppData } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* React hook that resolves the MAX (VK Messenger mini-app) WebApp object
|
|
4
|
+
* from `window.WebApp` and calls `ready()` on first access. Returns `null`
|
|
5
|
+
* on the server and when running outside of the MAX host, so callers can
|
|
6
|
+
* gracefully degrade.
|
|
7
|
+
*/
|
|
2
8
|
export declare const useMaxWebApp: () => MaxWebApp | null;
|
|
9
|
+
/**
|
|
10
|
+
* Convenience hook that returns `[initDataUnsafe, initData]` from the MAX
|
|
11
|
+
* WebApp. Both values are `undefined` until the mini-app is ready or when
|
|
12
|
+
* running outside of the MAX host.
|
|
13
|
+
*/
|
|
3
14
|
export declare const useMaxInitData: () => readonly [MaxWebAppData | undefined, string | undefined];
|
|
15
|
+
/**
|
|
16
|
+
* Wires up the MAX native BackButton.
|
|
17
|
+
*
|
|
18
|
+
* When `onBack` is provided, the back button is shown and will invoke the
|
|
19
|
+
* callback on press; the effect cleanly un-registers the listener and hides
|
|
20
|
+
* the button on unmount or when `onBack` changes. When the WebApp is not
|
|
21
|
+
* available (SSR or non-MAX host) the hook is a no-op and returns `null`.
|
|
22
|
+
*
|
|
23
|
+
* @param onBack Optional callback fired when the user taps the back button.
|
|
24
|
+
* @returns The native `BackButton` controller, or `null` when unavailable.
|
|
25
|
+
*/
|
|
4
26
|
export declare const useMaxBackButton: (onBack?: () => void) => MaxWebApp["BackButton"] | null;
|
|
27
|
+
/**
|
|
28
|
+
* Returns the MAX `HapticFeedback` controller, or `null` when the WebApp is
|
|
29
|
+
* not available. Use it to trigger vibration/impact feedback in response to
|
|
30
|
+
* user interactions inside a MAX mini-app.
|
|
31
|
+
*/
|
|
5
32
|
export declare const useMaxHapticFeedback: () => MaxWebApp["HapticFeedback"] | null;
|
|
6
33
|
//# sourceMappingURL=useMaxWebApp.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMaxWebApp.d.ts","sourceRoot":"","sources":["../../src/util/useMaxWebApp.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAEnD,eAAO,MAAM,YAAY,QAAO,SAAS,GAAG,IAc3C,CAAA;AAED,eAAO,MAAM,cAAc,QAAO,SAAS,CACvC,aAAa,GAAG,SAAS,EACzB,MAAM,GAAG,SAAS,CAKrB,CAAA;AAED,eAAO,MAAM,gBAAgB,GACzB,SAAS,MAAM,IAAI,KACpB,SAAS,CAAC,YAAY,CAAC,GAAG,IAgB5B,CAAA;AAED,eAAO,MAAM,oBAAoB,QAAO,SAAS,CAAC,gBAAgB,CAAC,GAAG,IAGrE,CAAA"}
|
|
1
|
+
{"version":3,"file":"useMaxWebApp.d.ts","sourceRoot":"","sources":["../../src/util/useMaxWebApp.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAEnD;;;;;GAKG;AACH,eAAO,MAAM,YAAY,QAAO,SAAS,GAAG,IAc3C,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,cAAc,QAAO,SAAS,CACvC,aAAa,GAAG,SAAS,EACzB,MAAM,GAAG,SAAS,CAKrB,CAAA;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,gBAAgB,GACzB,SAAS,MAAM,IAAI,KACpB,SAAS,CAAC,YAAY,CAAC,GAAG,IAgB5B,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,QAAO,SAAS,CAAC,gBAAgB,CAAC,GAAG,IAGrE,CAAA"}
|
|
@@ -1,14 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A single OpenAI Realtime event exchanged over the WebRTC data channel.
|
|
3
|
+
* `type` is always present; `event_id` and `timestamp` are auto-populated
|
|
4
|
+
* by the hook when missing. Any additional fields defined by the OpenAI
|
|
5
|
+
* Realtime API are passed through unchanged.
|
|
6
|
+
*/
|
|
1
7
|
export type OpenAIEvent = {
|
|
2
8
|
type: string;
|
|
3
9
|
event_id?: string;
|
|
4
10
|
timestamp?: string;
|
|
5
11
|
[key: string]: any;
|
|
6
12
|
};
|
|
13
|
+
/**
|
|
14
|
+
* Return type of {@link useOpenAIWebRTC}. Exposes the live session state
|
|
15
|
+
* and imperative controls for opening/closing a realtime voice session.
|
|
16
|
+
*
|
|
17
|
+
* @property isSessionActive Whether the peer connection is currently
|
|
18
|
+
* `connected` — updates in real time.
|
|
19
|
+
* @property startSession Opens a new peer connection to the OpenAI
|
|
20
|
+
* Realtime API and attaches the configured audio
|
|
21
|
+
* element. Resolves once the data channel is
|
|
22
|
+
* open and safe to send on.
|
|
23
|
+
* @property stopSession Stops microphone tracks, closes the peer
|
|
24
|
+
* connection, and releases all resources.
|
|
25
|
+
* @property sendTextMessage Queues a `conversation.item.create` + `response.create`
|
|
26
|
+
* pair on the data channel, waiting for the
|
|
27
|
+
* channel to open if necessary.
|
|
28
|
+
*/
|
|
7
29
|
export type UseOpenAIWebRTCReturn = {
|
|
8
30
|
isSessionActive: boolean;
|
|
9
31
|
startSession: (ephemeralKey: string, useMicrophone?: boolean) => Promise<void>;
|
|
10
32
|
stopSession: () => void;
|
|
11
33
|
sendTextMessage: (text: string) => void;
|
|
12
34
|
};
|
|
35
|
+
/**
|
|
36
|
+
* React hook that manages a realtime voice session with the OpenAI Realtime
|
|
37
|
+
* API over WebRTC.
|
|
38
|
+
*
|
|
39
|
+
* Usage flow:
|
|
40
|
+
* 1. Render an `<audio autoPlay />` element and pass its ref in as
|
|
41
|
+
* `audioElement` — remote audio will be routed there.
|
|
42
|
+
* 2. Fetch an ephemeral key from your backend.
|
|
43
|
+
* 3. Call `startSession(ephemeralKey, useMicrophone?)`. When `useMicrophone`
|
|
44
|
+
* is `false` the hook creates a silent local track so the peer connection
|
|
45
|
+
* is still valid (useful for text-only demos).
|
|
46
|
+
* 4. Use `sendTextMessage(text)` to inject user turns and receive replies
|
|
47
|
+
* via the `onEvent` callback.
|
|
48
|
+
* 5. Call `stopSession()` when done.
|
|
49
|
+
*
|
|
50
|
+
* All handlers are stable and safe to pass to dependent effects/memos.
|
|
51
|
+
*
|
|
52
|
+
* @param audioElement Target `<audio>` element used to play back the model's
|
|
53
|
+
* response audio. `null` disables playback routing.
|
|
54
|
+
* @param onEvent Optional listener invoked for every incoming and
|
|
55
|
+
* outgoing realtime event (with `timestamp` populated).
|
|
56
|
+
*/
|
|
13
57
|
export default function useOpenAIWebRTC(audioElement?: HTMLAudioElement | null, onEvent?: (event: OpenAIEvent) => void): UseOpenAIWebRTCReturn;
|
|
14
58
|
//# sourceMappingURL=useOpenAIWebRTC.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useOpenAIWebRTC.d.ts","sourceRoot":"","sources":["../../src/util/useOpenAIWebRTC.ts"],"names":[],"mappings":"AAIA,M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C,CAAA;AAcD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,OAAO,UAAU,eAAe,CACnC,YAAY,GAAE,gBAAgB,GAAG,IAAW,EAC5C,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,GACvC,qBAAqB,CAkKvB"}
|
package/dist/util/useWebApp.d.ts
CHANGED
|
@@ -1,6 +1,27 @@
|
|
|
1
1
|
import { InitData, InitDataUnsafe, WebApp } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* React hook that resolves the Telegram `WebApp` object from
|
|
4
|
+
* `window.Telegram.WebApp`, calls `ready()`, and optionally expands the
|
|
5
|
+
* viewport on iOS/Android when the current `pageProcessor` is
|
|
6
|
+
* `'telegram_expanded'`.
|
|
7
|
+
*
|
|
8
|
+
* When Telegram is not present (SSR, regular browsers, embedded previews)
|
|
9
|
+
* the hook silently returns `null`. Any error thrown by `ready()` is
|
|
10
|
+
* swallowed and forwarded to the caller-provided `onError` callback so
|
|
11
|
+
* that a failed init does not crash the tree.
|
|
12
|
+
*
|
|
13
|
+
* Accepts a single options object with an optional `onError` handler that
|
|
14
|
+
* fires when `wApp.ready()` throws.
|
|
15
|
+
*
|
|
16
|
+
* @returns The Telegram WebApp instance, or `null` when unavailable.
|
|
17
|
+
*/
|
|
2
18
|
export declare const useWebApp: ({ onError, }?: {
|
|
3
19
|
onError?: () => void;
|
|
4
20
|
}) => WebApp | null;
|
|
21
|
+
/**
|
|
22
|
+
* Convenience hook returning the Telegram WebApp init payload as a tuple of
|
|
23
|
+
* `[initDataUnsafe, initData]`. Both values are `undefined` on the server
|
|
24
|
+
* and while Telegram is still initializing.
|
|
25
|
+
*/
|
|
5
26
|
export declare const useInitData: () => readonly [InitDataUnsafe | undefined, InitData | undefined];
|
|
6
27
|
//# sourceMappingURL=useWebApp.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useWebApp.d.ts","sourceRoot":"","sources":["../../src/util/useWebApp.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAE3D,eAAO,MAAM,SAAS,GAAI,eAEvB;IAAE,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;CAAO,KAAG,MAAM,GAAG,IA2B3C,CAAA;AAED,eAAO,MAAM,WAAW,QAAO,SAAS,CACpC,cAAc,GAAG,SAAS,EAC1B,QAAQ,GAAG,SAAS,CAKvB,CAAA"}
|
|
1
|
+
{"version":3,"file":"useWebApp.d.ts","sourceRoot":"","sources":["../../src/util/useWebApp.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAE3D;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,SAAS,GAAI,eAEvB;IAAE,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;CAAO,KAAG,MAAM,GAAG,IA2B3C,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,WAAW,QAAO,SAAS,CACpC,cAAc,GAAG,SAAS,EAC1B,QAAQ,GAAG,SAAS,CAKvB,CAAA"}
|
|
@@ -1,3 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options accepted by {@link WebRTCClient}.
|
|
3
|
+
*
|
|
4
|
+
* @property endpoint HTTP endpoint that exchanges SDP with the
|
|
5
|
+
* backend; must accept a POST of
|
|
6
|
+
* `{ sdp, type, webrtc_id }` and return the
|
|
7
|
+
* answer description.
|
|
8
|
+
* @property onConnected Fires after `setRemoteDescription` succeeds.
|
|
9
|
+
* @property onDisconnected Fires when `disconnect()` is invoked,
|
|
10
|
+
* regardless of whether a connection existed.
|
|
11
|
+
* @property onMessage Invoked for every JSON-parsed message
|
|
12
|
+
* received on the `text` data channel.
|
|
13
|
+
* @property onAudioStream Receives the remote `MediaStream` once
|
|
14
|
+
* negotiated so the caller can attach it to
|
|
15
|
+
* an audio element.
|
|
16
|
+
* @property onAudioLevel Throttled average microphone level in
|
|
17
|
+
* `[0, 1]`. Updates roughly every 100ms.
|
|
18
|
+
* @property audioInputDeviceId Optional `deviceId` constraint for
|
|
19
|
+
* `getUserMedia`.
|
|
20
|
+
* @property audioOutputDeviceId Output device id forwarded to the audio
|
|
21
|
+
* stream consumer via
|
|
22
|
+
* `options.audioOutputDeviceId`.
|
|
23
|
+
*/
|
|
1
24
|
interface WebRTCClientOptions {
|
|
2
25
|
endpoint: string;
|
|
3
26
|
onConnected?: () => void;
|
|
@@ -8,6 +31,15 @@ interface WebRTCClientOptions {
|
|
|
8
31
|
audioInputDeviceId?: string;
|
|
9
32
|
audioOutputDeviceId?: string;
|
|
10
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Browser-side WebRTC helper that opens an audio peer connection to a PieUI
|
|
36
|
+
* backend endpoint, exchanges SDP, and exposes lightweight hooks for
|
|
37
|
+
* messaging and microphone level analysis.
|
|
38
|
+
*
|
|
39
|
+
* The class is safe to instantiate in SSR environments — `connect()` and
|
|
40
|
+
* device setters guard on `typeof window !== 'undefined'` and no-op on the
|
|
41
|
+
* server. Calling any method twice cleanly re-establishes the connection.
|
|
42
|
+
*/
|
|
11
43
|
export declare class WebRTCClient {
|
|
12
44
|
private peerConnection;
|
|
13
45
|
private mediaStream;
|
|
@@ -20,12 +52,41 @@ export declare class WebRTCClient {
|
|
|
20
52
|
private currentInputDeviceId;
|
|
21
53
|
private currentOutputDeviceId;
|
|
22
54
|
constructor(options: WebRTCClientOptions);
|
|
55
|
+
/**
|
|
56
|
+
* Changes the active microphone device.
|
|
57
|
+
*
|
|
58
|
+
* If a peer connection is already open the client tears it down and
|
|
59
|
+
* re-connects with the new device, because WebRTC tracks cannot be
|
|
60
|
+
* swapped mid-session without renegotiation.
|
|
61
|
+
*/
|
|
23
62
|
setAudioInputDevice(deviceId: string): void;
|
|
63
|
+
/**
|
|
64
|
+
* Changes the preferred audio output device. Because the actual sink is
|
|
65
|
+
* attached to the `<audio>` element in the consumer code, the new
|
|
66
|
+
* `deviceId` is forwarded through `options.audioOutputDeviceId` so the
|
|
67
|
+
* `onAudioStream` callback can apply `HTMLAudioElement.setSinkId()`.
|
|
68
|
+
*/
|
|
24
69
|
setAudioOutputDevice(deviceId: string): void;
|
|
70
|
+
/**
|
|
71
|
+
* Opens a new peer connection: acquires the microphone, wires up audio
|
|
72
|
+
* analysis, creates a `text` data channel, exchanges SDP with the
|
|
73
|
+
* configured endpoint, and invokes `onConnected` on success.
|
|
74
|
+
*
|
|
75
|
+
* Throws user-friendly `Error`s for the two most common microphone
|
|
76
|
+
* failures (`NotAllowedError` → permission denied, `NotFoundError` →
|
|
77
|
+
* no device detected). Any other failure triggers `disconnect()` and
|
|
78
|
+
* the underlying error is re-thrown so the caller can react.
|
|
79
|
+
*/
|
|
25
80
|
connect(): Promise<void>;
|
|
26
81
|
private setupAudioAnalysis;
|
|
27
82
|
private startAnalysis;
|
|
28
83
|
private stopAnalysis;
|
|
84
|
+
/**
|
|
85
|
+
* Tears the session down: stops the microphone tracks, closes the peer
|
|
86
|
+
* connection and data channel, releases the `AudioContext` used for
|
|
87
|
+
* level analysis, and invokes `onDisconnected`. Safe to call multiple
|
|
88
|
+
* times and on the server (no-op).
|
|
89
|
+
*/
|
|
29
90
|
disconnect(): void;
|
|
30
91
|
}
|
|
31
92
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webrtcClient.d.ts","sourceRoot":"","sources":["../../src/util/webrtcClient.ts"],"names":[],"mappings":"AAAA,UAAU,mBAAmB;IACzB,QAAQ,EAAE,MAAM,CAAA;IAChB,WAAW,CAAC,EAAE,MAAM,IAAI,CAAA;IACxB,cAAc,CAAC,EAAE,MAAM,IAAI,CAAA;IAC3B,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,IAAI,CAAA;IAClC,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,CAAA;IAC7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