@piedata/pieui 2.0.4 → 2.0.6
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/cli.js +223 -97
- package/dist/code/commands/init.d.ts.map +1 -1
- package/dist/code/templates/index.d.ts +2 -1
- package/dist/code/templates/index.d.ts.map +1 -1
- package/dist/code/templates/nextConfig.d.ts +3 -0
- package/dist/code/templates/nextConfig.d.ts.map +1 -0
- package/dist/components/Common/CloudStorageCard/index.d.ts +3 -0
- package/dist/components/Common/CloudStorageCard/index.d.ts.map +1 -0
- package/dist/components/Common/CloudStorageCard/types/index.d.ts +13 -0
- package/dist/components/Common/CloudStorageCard/types/index.d.ts.map +1 -0
- package/dist/components/Common/CloudStorageCard/ui/CloudStorageCard.d.ts +4 -0
- package/dist/components/Common/CloudStorageCard/ui/CloudStorageCard.d.ts.map +1 -0
- package/dist/components/Common/DeviceStorageCard/index.d.ts +3 -0
- package/dist/components/Common/DeviceStorageCard/index.d.ts.map +1 -0
- package/dist/components/Common/DeviceStorageCard/types/index.d.ts +13 -0
- package/dist/components/Common/DeviceStorageCard/types/index.d.ts.map +1 -0
- package/dist/components/Common/DeviceStorageCard/ui/DeviceStorageCard.d.ts +4 -0
- package/dist/components/Common/DeviceStorageCard/ui/DeviceStorageCard.d.ts.map +1 -0
- package/dist/components/Common/SecureStorageCard/index.d.ts +3 -0
- package/dist/components/Common/SecureStorageCard/index.d.ts.map +1 -0
- package/dist/components/Common/SecureStorageCard/types/index.d.ts +13 -0
- package/dist/components/Common/SecureStorageCard/types/index.d.ts.map +1 -0
- package/dist/components/Common/SecureStorageCard/ui/SecureStorageCard.d.ts +4 -0
- package/dist/components/Common/SecureStorageCard/ui/SecureStorageCard.d.ts.map +1 -0
- package/dist/components/Common/SessionStorageCard/index.d.ts +3 -0
- package/dist/components/Common/SessionStorageCard/index.d.ts.map +1 -0
- package/dist/components/Common/SessionStorageCard/types/index.d.ts +13 -0
- package/dist/components/Common/SessionStorageCard/types/index.d.ts.map +1 -0
- package/dist/components/Common/SessionStorageCard/ui/SessionStorageCard.d.ts +4 -0
- package/dist/components/Common/SessionStorageCard/ui/SessionStorageCard.d.ts.map +1 -0
- 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.d.ts +4 -0
- package/dist/components/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 +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +2 -2
- package/dist/index.js +2 -2
- package/dist/pieui.components.json +144 -0
- package/dist/tests/mittAgentTools.test.d.ts +2 -0
- package/dist/tests/mittAgentTools.test.d.ts.map +1 -0
- package/dist/util/ajaxCommonUtils.d.ts +69 -3
- 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/mittAgentTools.d.ts +89 -0
- package/dist/util/mittAgentTools.d.ts.map +1 -0
- 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
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { tool } from '@openai/agents';
|
|
2
|
+
import type { Emitter } from 'mitt';
|
|
3
|
+
import { type MittEvents } from './mitt';
|
|
4
|
+
/**
|
|
5
|
+
* Descriptor passed to the customization callbacks on
|
|
6
|
+
* {@link MittAgentToolsOptions}.
|
|
7
|
+
*/
|
|
8
|
+
export type MittAgentToolDescriptor = {
|
|
9
|
+
/** Method key originally registered on the `PieCard.methods` map. */
|
|
10
|
+
methodName: string;
|
|
11
|
+
/** Value of `data.name` on the target `PieCard`. */
|
|
12
|
+
cardName: string;
|
|
13
|
+
/** Raw mitt event name (`pie{methodName}_{cardName}`). */
|
|
14
|
+
eventName: string;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Options accepted by {@link getMittAgentTools} and
|
|
18
|
+
* {@link usePieMittAgentTools}.
|
|
19
|
+
*/
|
|
20
|
+
export type MittAgentToolsOptions = {
|
|
21
|
+
/**
|
|
22
|
+
* Optional predicate invoked for each discovered PieCard method. Return
|
|
23
|
+
* `false` to omit the event from the generated tool list. Defaults to
|
|
24
|
+
* accepting everything.
|
|
25
|
+
*/
|
|
26
|
+
filter?: (descriptor: MittAgentToolDescriptor) => boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Optional override for the tool description surfaced to the model.
|
|
29
|
+
* Defaults to a generic string mentioning the card and method.
|
|
30
|
+
*/
|
|
31
|
+
describe?: (descriptor: MittAgentToolDescriptor) => string;
|
|
32
|
+
/**
|
|
33
|
+
* Optional override for the public tool name. Defaults to
|
|
34
|
+
* `{cardName}_{methodName}`. The returned value must be unique within the
|
|
35
|
+
* final tool set.
|
|
36
|
+
*/
|
|
37
|
+
nameFor?: (descriptor: MittAgentToolDescriptor) => string;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Return type of {@link getMittAgentTools}. We intentionally keep this loose
|
|
41
|
+
* rather than importing the deeply-parameterized `FunctionTool` generic from
|
|
42
|
+
* `@openai/agents-core` — callers typically feed the result directly into
|
|
43
|
+
* `new Agent({ tools: [...] })` which accepts any tool-shaped value.
|
|
44
|
+
*/
|
|
45
|
+
export type MittAgentTool = ReturnType<typeof tool>;
|
|
46
|
+
/**
|
|
47
|
+
* Scans a mitt emitter for all currently-registered PieCard methods (events
|
|
48
|
+
* matching `pie{methodName}_{cardName}`) and wraps each one as an
|
|
49
|
+
* `@openai/agents` function tool.
|
|
50
|
+
*
|
|
51
|
+
* Calling a returned tool re-emits the matching mitt event with the
|
|
52
|
+
* `payload` argument supplied by the model. Because mitt listeners run
|
|
53
|
+
* synchronously in-process, the tool executes entirely locally with no
|
|
54
|
+
* network hop.
|
|
55
|
+
*
|
|
56
|
+
* This takes a *snapshot* of the emitter at the moment it is called — cards
|
|
57
|
+
* that mount afterwards will not be represented until the function is called
|
|
58
|
+
* again. Prefer {@link usePieMittAgentTools} from inside React components so
|
|
59
|
+
* the snapshot refreshes whenever the surrounding tree re-renders.
|
|
60
|
+
*
|
|
61
|
+
* @param emitter The mitt emitter to scan. Defaults to the global PieUI
|
|
62
|
+
* singleton returned by {@link getEmitter}.
|
|
63
|
+
* @param options See {@link MittAgentToolsOptions}.
|
|
64
|
+
* @returns An array of `@openai/agents` function tools, one per discovered
|
|
65
|
+
* PieCard method.
|
|
66
|
+
*/
|
|
67
|
+
export declare function getMittAgentTools(emitter?: Emitter<MittEvents>, options?: MittAgentToolsOptions): MittAgentTool[];
|
|
68
|
+
/**
|
|
69
|
+
* React hook wrapper around {@link getMittAgentTools}. Reads the emitter from
|
|
70
|
+
* {@link MittContext} — falling back to the global singleton returned by
|
|
71
|
+
* {@link getEmitter} when used outside of a PieRoot — and memoizes the
|
|
72
|
+
* resulting tool array by a sorted snapshot of registered event names so the
|
|
73
|
+
* returned reference is stable across renders that don't add or remove
|
|
74
|
+
* PieCard methods.
|
|
75
|
+
*
|
|
76
|
+
* Because mitt does not emit a "handler-added" notification, the hook only
|
|
77
|
+
* refreshes its snapshot when the calling component re-renders. If you need
|
|
78
|
+
* to react to cards mounting at arbitrary times, trigger a re-render from the
|
|
79
|
+
* consumer or call {@link getMittAgentTools} imperatively right before you
|
|
80
|
+
* build the `Agent`.
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```tsx
|
|
84
|
+
* const tools = usePieMittAgentTools()
|
|
85
|
+
* const agent = useMemo(() => new Agent({ name: 'UI', tools }), [tools])
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
export declare function usePieMittAgentTools(options?: MittAgentToolsOptions): MittAgentTool[];
|
|
89
|
+
//# sourceMappingURL=mittAgentTools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mittAgentTools.d.ts","sourceRoot":"","sources":["../../src/util/mittAgentTools.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAA;AAErC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AACnC,OAAoB,EAAc,KAAK,UAAU,EAAE,MAAM,QAAQ,CAAA;AAWjE;;;GAGG;AACH,MAAM,MAAM,uBAAuB,GAAG;IAClC,qEAAqE;IACrE,UAAU,EAAE,MAAM,CAAA;IAClB,oDAAoD;IACpD,QAAQ,EAAE,MAAM,CAAA;IAChB,0DAA0D;IAC1D,SAAS,EAAE,MAAM,CAAA;CACpB,CAAA;AAED;;;GAGG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAChC;;;;OAIG;IACH,MAAM,CAAC,EAAE,CAAC,UAAU,EAAE,uBAAuB,KAAK,OAAO,CAAA;IACzD;;;OAGG;IACH,QAAQ,CAAC,EAAE,CAAC,UAAU,EAAE,uBAAuB,KAAK,MAAM,CAAA;IAC1D;;;;OAIG;IACH,OAAO,CAAC,EAAE,CAAC,UAAU,EAAE,uBAAuB,KAAK,MAAM,CAAA;CAC5D,CAAA;AAED;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC,OAAO,IAAI,CAAC,CAAA;AAEnD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,iBAAiB,CAC7B,OAAO,GAAE,OAAO,CAAC,UAAU,CAAgB,EAC3C,OAAO,GAAE,qBAA0B,GACpC,aAAa,EAAE,CAqDjB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,oBAAoB,CAChC,OAAO,GAAE,qBAA0B,GACpC,aAAa,EAAE,CAsBjB"}
|
package/dist/util/navigate.d.ts
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Signature of the navigation callback supplied to a PieRoot via its
|
|
3
|
+
* `onNavigate` prop. Implementations typically forward the url to the host
|
|
4
|
+
* router (Next.js, React Router, Telegram Mini App navigation, …).
|
|
5
|
+
*/
|
|
1
6
|
export type NavigateFunction = (_: string) => void;
|
|
7
|
+
/**
|
|
8
|
+
* React context that exposes the host application's navigation function to
|
|
9
|
+
* any PieUI component that needs to change routes (e.g. `AutoRedirectCard`,
|
|
10
|
+
* anchor components). `undefined` means no handler was provided — consumers
|
|
11
|
+
* should fall back to a native `window.location` assignment in that case.
|
|
12
|
+
*/
|
|
2
13
|
declare const NavigateContext: import("react").Context<NavigateFunction | undefined>;
|
|
3
14
|
export default NavigateContext;
|
|
4
15
|
//# sourceMappingURL=navigate.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"navigate.d.ts","sourceRoot":"","sources":["../../src/util/navigate.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;AAElD,QAAA,MAAM,eAAe,uDAAyD,CAAA;AAE9E,eAAe,eAAe,CAAA"}
|
|
1
|
+
{"version":3,"file":"navigate.d.ts","sourceRoot":"","sources":["../../src/util/navigate.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;AAElD;;;;;GAKG;AACH,QAAA,MAAM,eAAe,uDAAyD,CAAA;AAE9E,eAAe,eAAe,CAAA"}
|
package/dist/util/pieConfig.d.ts
CHANGED
|
@@ -1,17 +1,52 @@
|
|
|
1
1
|
import { PieConfig } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* React context that carries the {@link PieConfig} object supplied to a
|
|
4
|
+
* PieRoot. All runtime configuration (API server URL, Centrifuge URL,
|
|
5
|
+
* logging flag, page processor mode) flows through this context so that
|
|
6
|
+
* utilities can be plain hooks instead of reading from `process.env`.
|
|
7
|
+
*/
|
|
2
8
|
export declare const PieConfigContext: import("react").Context<PieConfig | null>;
|
|
9
|
+
/**
|
|
10
|
+
* Returns the current {@link PieConfig} from {@link PieConfigContext}.
|
|
11
|
+
*
|
|
12
|
+
* @throws Error When called outside of a PieRoot — the context will be
|
|
13
|
+
* `null` and no sensible default exists.
|
|
14
|
+
* @returns The config object provided to the enclosing PieRoot.
|
|
15
|
+
*/
|
|
3
16
|
export declare const usePieConfig: () => PieConfig;
|
|
17
|
+
/**
|
|
18
|
+
* Convenience hook returning the `apiServer` field from the current
|
|
19
|
+
* {@link PieConfig}. Must be called inside a PieRoot.
|
|
20
|
+
*/
|
|
4
21
|
export declare const useApiServer: () => string;
|
|
5
22
|
/** @deprecated Use useApiServer() instead */
|
|
6
23
|
export declare const getApiServer: () => string;
|
|
24
|
+
/**
|
|
25
|
+
* Convenience hook returning the `centrifugeServer` field from the current
|
|
26
|
+
* {@link PieConfig}. Returns `undefined` when Centrifuge is not configured.
|
|
27
|
+
*/
|
|
7
28
|
export declare const useCentrifugeServer: () => string | undefined;
|
|
8
29
|
/** @deprecated Use useCentrifugeServer() instead */
|
|
9
30
|
export declare const getCentrifugeServer: () => string | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* Convenience hook returning the `enableRenderingLog` flag from the current
|
|
33
|
+
* {@link PieConfig}. Used by internal components to gate verbose logging.
|
|
34
|
+
*/
|
|
10
35
|
export declare const useIsRenderingLogEnabled: () => boolean | undefined;
|
|
11
36
|
/** @deprecated Use useIsRenderingLogEnabled() instead */
|
|
12
37
|
export declare const isRenderingLogEnabled: () => boolean | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Convenience hook returning the `pageProcessor` field from the current
|
|
40
|
+
* {@link PieConfig}. Used by root components to decide how the page should
|
|
41
|
+
* be initialized (for example, whether to auto-expand Telegram WebApp).
|
|
42
|
+
*/
|
|
13
43
|
export declare const usePageProcessor: () => string | undefined;
|
|
14
44
|
/** @deprecated Use usePageProcessor() instead */
|
|
15
45
|
export declare const getPageProcessor: () => string | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* Separator token used by {@link pieName} to build nested component names
|
|
48
|
+
* of the form `parent{PIEBREAK}child`. Keeping it in one place ensures the
|
|
49
|
+
* UI configuration generator and the runtime agree on the delimiter.
|
|
50
|
+
*/
|
|
16
51
|
export declare const PIEBREAK = "__piedemo__";
|
|
17
52
|
//# sourceMappingURL=pieConfig.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pieConfig.d.ts","sourceRoot":"","sources":["../../src/util/pieConfig.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAEpC,eAAO,MAAM,gBAAgB,2CAAwC,CAAA;AAErE,eAAO,MAAM,YAAY,iBAMxB,CAAA;AAED,eAAO,MAAM,YAAY,cAGxB,CAAA;AAED,6CAA6C;AAC7C,eAAO,MAAM,YAAY,cAAe,CAAA;AAExC,eAAO,MAAM,mBAAmB,0BAG/B,CAAA;AAED,oDAAoD;AACpD,eAAO,MAAM,mBAAmB,0BAAsB,CAAA;AAEtD,eAAO,MAAM,wBAAwB,2BAGpC,CAAA;AAED,yDAAyD;AACzD,eAAO,MAAM,qBAAqB,2BAA2B,CAAA;AAE7D,eAAO,MAAM,gBAAgB,0BAG5B,CAAA;AAED,iDAAiD;AACjD,eAAO,MAAM,gBAAgB,0BAAmB,CAAA;AAEhD,eAAO,MAAM,QAAQ,gBAAgB,CAAA"}
|
|
1
|
+
{"version":3,"file":"pieConfig.d.ts","sourceRoot":"","sources":["../../src/util/pieConfig.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAEpC;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,2CAAwC,CAAA;AAErE;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,iBAMxB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,YAAY,cAGxB,CAAA;AAED,6CAA6C;AAC7C,eAAO,MAAM,YAAY,cAAe,CAAA;AAExC;;;GAGG;AACH,eAAO,MAAM,mBAAmB,0BAG/B,CAAA;AAED,oDAAoD;AACpD,eAAO,MAAM,mBAAmB,0BAAsB,CAAA;AAEtD;;;GAGG;AACH,eAAO,MAAM,wBAAwB,2BAGpC,CAAA;AAED,yDAAyD;AACzD,eAAO,MAAM,qBAAqB,2BAA2B,CAAA;AAE7D;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,0BAG5B,CAAA;AAED,iDAAiD;AACjD,eAAO,MAAM,gBAAgB,0BAAmB,CAAA;AAEhD;;;;GAIG;AACH,eAAO,MAAM,QAAQ,gBAAgB,CAAA"}
|
package/dist/util/pieName.d.ts
CHANGED
|
@@ -1,2 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Composes a nested PieUI component name of the form `parent{PIEBREAK}child`.
|
|
3
|
+
*
|
|
4
|
+
* PieUI uses this convention to identify inputs/cards that belong to a
|
|
5
|
+
* structured parent (for example, a single field inside a composite form).
|
|
6
|
+
* The separator is defined by {@link PIEBREAK} so that runtime and UI config
|
|
7
|
+
* generators cannot drift apart.
|
|
8
|
+
*
|
|
9
|
+
* @param name Name of the enclosing component.
|
|
10
|
+
* @param child Name of the nested child/field.
|
|
11
|
+
* @returns The joined name string.
|
|
12
|
+
*/
|
|
1
13
|
export declare const pieName: (name: string, child: string) => string;
|
|
2
14
|
//# sourceMappingURL=pieName.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pieName.d.ts","sourceRoot":"","sources":["../../src/util/pieName.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,OAAO,GAAI,MAAM,MAAM,EAAE,OAAO,MAAM,WACnB,CAAA"}
|
|
1
|
+
{"version":3,"file":"pieName.d.ts","sourceRoot":"","sources":["../../src/util/pieName.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,OAAO,GAAI,MAAM,MAAM,EAAE,OAAO,MAAM,WACnB,CAAA"}
|
package/dist/util/piecache.d.ts
CHANGED
|
@@ -1,4 +1,19 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { UIConfigType } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Picks the appropriate "loading" view for a PieRoot based on the provided
|
|
5
|
+
* `piecache`.
|
|
6
|
+
*
|
|
7
|
+
* If a cached `UIConfigType` exists for the current pathname (the leading
|
|
8
|
+
* slash is stripped before lookup), the helper returns a `<UILoading>`
|
|
9
|
+
* component rendering that cached configuration — this lets users see the
|
|
10
|
+
* last known shell of a page instantly on navigation. When no cache entry
|
|
11
|
+
* matches, the caller's own `fallback` node is returned instead.
|
|
12
|
+
*
|
|
13
|
+
* @param pathname Current route pathname (with or without a leading `/`).
|
|
14
|
+
* @param piecache Optional map of `pathname → cached UIConfig`.
|
|
15
|
+
* @param fallback Caller-provided fallback node used when the cache misses.
|
|
16
|
+
* @returns The cached loading UI, the original fallback, or `undefined`.
|
|
17
|
+
*/
|
|
3
18
|
export declare function resolvePieCacheFallback(pathname: string, piecache: Record<string, UIConfigType> | undefined, fallback: ReactNode | undefined): ReactNode | undefined;
|
|
4
19
|
//# sourceMappingURL=piecache.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"piecache.d.ts","sourceRoot":"","sources":["../../src/util/piecache.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAGvC,wBAAgB,uBAAuB,CACnC,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,GAAG,SAAS,EAClD,QAAQ,EAAE,SAAS,GAAG,SAAS,GAChC,SAAS,GAAG,SAAS,CAQvB"}
|
|
1
|
+
{"version":3,"file":"piecache.d.ts","sourceRoot":"","sources":["../../src/util/piecache.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAGvC;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,uBAAuB,CACnC,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,GAAG,SAAS,EAClD,QAAQ,EAAE,SAAS,GAAG,SAAS,GAChC,SAAS,GAAG,SAAS,CAQvB"}
|
package/dist/util/registry.d.ts
CHANGED
|
@@ -1,12 +1,61 @@
|
|
|
1
1
|
import { ComponentMetadata, ComponentRegistration } from '../types';
|
|
2
2
|
import { ComponentType } from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* Central in-memory registry of PieUI components keyed by their name. Every
|
|
5
|
+
* call to {@link registerPieComponent} writes into this `Map`, and the
|
|
6
|
+
* dynamic UI renderer reads from it at render time to resolve a `card` name
|
|
7
|
+
* to a concrete React component.
|
|
8
|
+
*/
|
|
3
9
|
export declare const registry: Map<string, ComponentRegistration<any>>;
|
|
10
|
+
/**
|
|
11
|
+
* Registers a PieUI component so it can be rendered by name from a dynamic
|
|
12
|
+
* UI configuration.
|
|
13
|
+
*
|
|
14
|
+
* The registration must provide at least a `name` and either a `component`
|
|
15
|
+
* or a `loader` (for code-split modules). When only `loader` is given, the
|
|
16
|
+
* helper wraps it in {@link trackLazy} automatically and the resulting
|
|
17
|
+
* `React.lazy` component is what gets stored.
|
|
18
|
+
*
|
|
19
|
+
* @param registration Shape describing the component, its metadata, and how
|
|
20
|
+
* to load it.
|
|
21
|
+
* @returns The concrete (possibly lazy) component that was stored.
|
|
22
|
+
* @throws Error When `name` is missing or neither `component` nor `loader`
|
|
23
|
+
* was supplied.
|
|
24
|
+
*/
|
|
4
25
|
export declare function registerPieComponent<TProps>(registration: ComponentRegistration<TProps>): ComponentType<TProps> | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Convenience wrapper that calls {@link registerPieComponent} for each item
|
|
28
|
+
* in the provided array. Useful when a package exports a catalogue of cards
|
|
29
|
+
* that should all be registered at once.
|
|
30
|
+
*/
|
|
5
31
|
export declare const registerMultipleComponents: (components: ComponentRegistration<any>[]) => void;
|
|
32
|
+
/**
|
|
33
|
+
* Removes a previously registered component from the registry. Subsequent
|
|
34
|
+
* renders of that name will fall back to the default "unknown component"
|
|
35
|
+
* behaviour of the dynamic renderer.
|
|
36
|
+
*/
|
|
6
37
|
export declare const unregisterComponent: (name: string) => void;
|
|
38
|
+
/**
|
|
39
|
+
* Returns `true` when a component with the given name has been registered.
|
|
40
|
+
*/
|
|
7
41
|
export declare const hasComponent: (name: string) => boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Returns the `metadata` object supplied at registration time, or
|
|
44
|
+
* `undefined` when the component was not registered or had no metadata.
|
|
45
|
+
*/
|
|
8
46
|
export declare const getComponentMeta: (name: string) => ComponentMetadata | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* Returns the full {@link ComponentRegistration} entry for the given name,
|
|
49
|
+
* including any `fallback` node and the normalized component reference.
|
|
50
|
+
*/
|
|
9
51
|
export declare const getRegistryEntry: (name: string) => ComponentRegistration<any> | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* Returns the list of names of every currently-registered PieUI component.
|
|
54
|
+
* Handy for debugging and for the `pieui postbuild` CLI manifest generator.
|
|
55
|
+
*/
|
|
10
56
|
export declare const getAllRegisteredComponents: () => string[];
|
|
57
|
+
/**
|
|
58
|
+
* Returns the number of components currently in the registry.
|
|
59
|
+
*/
|
|
11
60
|
export declare const getRegistrySize: () => number;
|
|
12
61
|
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/util/registry.ts"],"names":[],"mappings":"AAAA,OAAO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;AAED;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAAI,MAAM,MAAM,SAE/C,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,YAAY,GAAI,MAAM,MAAM,YAExC,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,gBAAgB,GACzB,MAAM,MAAM,KACb,iBAAiB,GAAG,SAEtB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,gBAAgB,GACzB,MAAM,MAAM,KACb,qBAAqB,CAAC,GAAG,CAAC,GAAG,SAE/B,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,0BAA0B,QAAO,MAAM,EAEnD,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,eAAe,QAAO,MAElC,CAAA"}
|
package/dist/util/socket.d.ts
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
import { Socket } from 'socket.io-client';
|
|
2
|
+
/**
|
|
3
|
+
* Returns a cached Socket.IO client for the given PieUI API server, creating
|
|
4
|
+
* one on first access.
|
|
5
|
+
*
|
|
6
|
+
* The client is configured with `autoConnect: false` so that the enclosing
|
|
7
|
+
* `SocketIOInitProvider` is in charge of connecting after any necessary
|
|
8
|
+
* handshake (e.g. token fetch, `window.sid` assignment). Only the
|
|
9
|
+
* `websocket` transport is enabled — long-polling is explicitly disabled to
|
|
10
|
+
* keep connection semantics predictable across hosts.
|
|
11
|
+
*
|
|
12
|
+
* Calling the function repeatedly with the same `apiServer` always returns
|
|
13
|
+
* the same instance, which is important because PieCard subscriptions rely
|
|
14
|
+
* on a shared socket.
|
|
15
|
+
*
|
|
16
|
+
* @param apiServer Base URL of the PieUI API server.
|
|
17
|
+
* @returns A shared `Socket` instance for that server.
|
|
18
|
+
*/
|
|
2
19
|
export declare const getSocket: (apiServer: string) => Socket;
|
|
20
|
+
/**
|
|
21
|
+
* React context that exposes the active Socket.IO client to components
|
|
22
|
+
* rendered inside a PieRoot. `PieCard` reads it to register `pie*` event
|
|
23
|
+
* listeners corresponding to its `methods` map.
|
|
24
|
+
*/
|
|
3
25
|
declare const SocketIOContext: import("react").Context<Socket<import("@socket.io/component-emitter").DefaultEventsMap, import("@socket.io/component-emitter").DefaultEventsMap> | null>;
|
|
4
26
|
export default SocketIOContext;
|
|
5
27
|
//# sourceMappingURL=socket.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"socket.d.ts","sourceRoot":"","sources":["../../src/util/socket.ts"],"names":[],"mappings":"AAEA,OAAO,EAAM,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAK7C,eAAO,MAAM,SAAS,GAAI,WAAW,MAAM,KAAG,MAU7C,CAAA;AAED,QAAA,MAAM,eAAe,0JAAqC,CAAA;AAE1D,eAAe,eAAe,CAAA"}
|
|
1
|
+
{"version":3,"file":"socket.d.ts","sourceRoot":"","sources":["../../src/util/socket.ts"],"names":[],"mappings":"AAEA,OAAO,EAAM,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAK7C;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,SAAS,GAAI,WAAW,MAAM,KAAG,MAU7C,CAAA;AAED;;;;GAIG;AACH,QAAA,MAAM,eAAe,0JAAqC,CAAA;AAE1D,eAAe,eAAe,CAAA"}
|
|
@@ -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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AM,KAAK,IAAI,CAAA;CAC1C,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,WA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