skybridge 0.0.0-dev.f5a2ffe → 0.0.0-dev.f76ccdc
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/src/web/hooks/index.d.ts +9 -3
- package/dist/src/web/hooks/index.js +9 -3
- package/dist/src/web/hooks/index.js.map +1 -1
- package/dist/src/web/hooks/use-locale.d.ts +1 -0
- package/dist/src/web/hooks/use-locale.js +5 -0
- package/dist/src/web/hooks/use-locale.js.map +1 -0
- package/dist/src/web/hooks/use-locale.test.d.ts +1 -0
- package/dist/src/web/hooks/use-locale.test.js +21 -0
- package/dist/src/web/hooks/use-locale.test.js.map +1 -0
- package/dist/src/web/hooks/use-open-external.d.ts +1 -0
- package/dist/src/web/hooks/use-open-external.js +6 -0
- package/dist/src/web/hooks/use-open-external.js.map +1 -0
- package/dist/src/web/hooks/use-open-external.test.d.ts +1 -0
- package/dist/src/web/hooks/use-open-external.test.js +24 -0
- package/dist/src/web/hooks/use-open-external.test.js.map +1 -0
- package/dist/src/web/hooks/use-request-modal.d.ts +5 -0
- package/dist/src/web/hooks/use-request-modal.js +9 -0
- package/dist/src/web/hooks/use-request-modal.js.map +1 -0
- package/dist/src/web/hooks/use-request-modal.test.d.ts +1 -0
- package/dist/src/web/hooks/use-request-modal.test.js +24 -0
- package/dist/src/web/hooks/use-request-modal.test.js.map +1 -0
- package/dist/src/web/hooks/use-send-follow-up-message.d.ts +1 -0
- package/dist/src/web/hooks/use-send-follow-up-message.js +11 -0
- package/dist/src/web/hooks/use-send-follow-up-message.js.map +1 -0
- package/dist/src/web/hooks/use-theme.d.ts +1 -0
- package/dist/src/web/hooks/use-theme.js +5 -0
- package/dist/src/web/hooks/use-theme.js.map +1 -0
- package/dist/src/web/hooks/use-theme.test.d.ts +1 -0
- package/dist/src/web/hooks/use-theme.test.js +26 -0
- package/dist/src/web/hooks/use-theme.test.js.map +1 -0
- package/dist/src/web/hooks/use-user-agent.d.ts +1 -0
- package/dist/src/web/hooks/use-user-agent.js +5 -0
- package/dist/src/web/hooks/use-user-agent.js.map +1 -0
- package/dist/src/web/hooks/use-user-agent.test.d.ts +1 -0
- package/dist/src/web/hooks/use-user-agent.test.js +31 -0
- package/dist/src/web/hooks/use-user-agent.test.js.map +1 -0
- package/dist/src/web/types.d.ts +5 -0
- package/dist/src/web/types.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,13 @@
|
|
|
1
|
+
export { useCallTool } from "./use-call-tool.js";
|
|
2
|
+
export { useDisplayMode } from "./use-display-mode.js";
|
|
3
|
+
export { useLocale } from "./use-locale.js";
|
|
4
|
+
export { useOpenExternal } from "./use-open-external.js";
|
|
1
5
|
export { useOpenAiGlobal } from "./use-openai-global.js";
|
|
6
|
+
export { useRequestModal } from "./use-request-modal.js";
|
|
7
|
+
export { useSendFollowUpMessage } from "./use-send-follow-up-message.js";
|
|
8
|
+
export { useTheme } from "./use-theme.js";
|
|
9
|
+
export { useToolInfo } from "./use-tool-info.js";
|
|
2
10
|
export { useToolOutput } from "./use-tool-output.js";
|
|
3
11
|
export { useToolResponseMetadata } from "./use-tool-response-metadata.js";
|
|
4
|
-
export {
|
|
12
|
+
export { useUserAgent } from "./use-user-agent.js";
|
|
5
13
|
export { useWidgetState } from "./use-widget-state.js";
|
|
6
|
-
export { useToolInfo } from "./use-tool-info.js";
|
|
7
|
-
export { useDisplayMode } from "./use-display-mode.js";
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
+
export { useCallTool } from "./use-call-tool.js";
|
|
2
|
+
export { useDisplayMode } from "./use-display-mode.js";
|
|
3
|
+
export { useLocale } from "./use-locale.js";
|
|
4
|
+
export { useOpenExternal } from "./use-open-external.js";
|
|
1
5
|
export { useOpenAiGlobal } from "./use-openai-global.js";
|
|
6
|
+
export { useRequestModal } from "./use-request-modal.js";
|
|
7
|
+
export { useSendFollowUpMessage } from "./use-send-follow-up-message.js";
|
|
8
|
+
export { useTheme } from "./use-theme.js";
|
|
9
|
+
export { useToolInfo } from "./use-tool-info.js";
|
|
2
10
|
export { useToolOutput } from "./use-tool-output.js";
|
|
3
11
|
export { useToolResponseMetadata } from "./use-tool-response-metadata.js";
|
|
4
|
-
export {
|
|
12
|
+
export { useUserAgent } from "./use-user-agent.js";
|
|
5
13
|
export { useWidgetState } from "./use-widget-state.js";
|
|
6
|
-
export { useToolInfo } from "./use-tool-info.js";
|
|
7
|
-
export { useDisplayMode } from "./use-display-mode.js";
|
|
8
14
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/web/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/web/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useLocale(): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-locale.js","sourceRoot":"","sources":["../../../../src/web/hooks/use-locale.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,MAAM,UAAU,SAAS;IACvB,OAAO,eAAe,CAAC,QAAQ,CAAE,CAAC;AACpC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { useLocale } from "./use-locale.js";
|
|
2
|
+
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
|
|
3
|
+
import { renderHook } from "@testing-library/react";
|
|
4
|
+
describe("useLocale", () => {
|
|
5
|
+
let OpenaiMock;
|
|
6
|
+
beforeEach(() => {
|
|
7
|
+
OpenaiMock = {
|
|
8
|
+
locale: "en-US",
|
|
9
|
+
};
|
|
10
|
+
vi.stubGlobal("openai", OpenaiMock);
|
|
11
|
+
});
|
|
12
|
+
afterEach(() => {
|
|
13
|
+
vi.unstubAllGlobals();
|
|
14
|
+
vi.resetAllMocks();
|
|
15
|
+
});
|
|
16
|
+
it("should return the current locale from window.openai.locale", () => {
|
|
17
|
+
const { result } = renderHook(() => useLocale());
|
|
18
|
+
expect(result.current).toBe("en-US");
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
//# sourceMappingURL=use-locale.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-locale.test.js","sourceRoot":"","sources":["../../../../src/web/hooks/use-locale.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;IACzB,IAAI,UAEH,CAAC;IAEF,UAAU,CAAC,GAAG,EAAE;QACd,UAAU,GAAG;YACX,MAAM,EAAE,OAAO;SAChB,CAAC;QACF,EAAE,CAAC,UAAU,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;IACtC,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACb,EAAE,CAAC,gBAAgB,EAAE,CAAC;QACtB,EAAE,CAAC,aAAa,EAAE,CAAC;IACrB,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,4DAA4D,EAAE,GAAG,EAAE;QACpE,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,SAAS,EAAE,CAAC,CAAC;QAEjD,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useOpenExternal(): (href: string) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-open-external.js","sourceRoot":"","sources":["../../../../src/web/hooks/use-open-external.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,eAAe;IAC7B,OAAO,CAAC,IAAY,EAAE,EAAE;QACtB,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;IACvC,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { useOpenExternal } from "./use-open-external.js";
|
|
2
|
+
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
|
|
3
|
+
import { renderHook } from "@testing-library/react";
|
|
4
|
+
describe("useOpenExternal", () => {
|
|
5
|
+
let openExternalMock;
|
|
6
|
+
beforeEach(() => {
|
|
7
|
+
openExternalMock = vi.fn();
|
|
8
|
+
vi.stubGlobal("openai", {
|
|
9
|
+
openExternal: openExternalMock,
|
|
10
|
+
});
|
|
11
|
+
});
|
|
12
|
+
afterEach(() => {
|
|
13
|
+
vi.unstubAllGlobals();
|
|
14
|
+
vi.resetAllMocks();
|
|
15
|
+
});
|
|
16
|
+
it("should return a function that calls window.openai.openExternal with the href", () => {
|
|
17
|
+
const { result } = renderHook(() => useOpenExternal());
|
|
18
|
+
const href = "https://example.com";
|
|
19
|
+
result.current(href);
|
|
20
|
+
expect(openExternalMock).toHaveBeenCalledTimes(1);
|
|
21
|
+
expect(openExternalMock).toHaveBeenCalledWith({ href });
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
//# sourceMappingURL=use-open-external.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-open-external.test.js","sourceRoot":"","sources":["../../../../src/web/hooks/use-open-external.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC/B,IAAI,gBAA0C,CAAC;IAE/C,UAAU,CAAC,GAAG,EAAE;QACd,gBAAgB,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC;QAC3B,EAAE,CAAC,UAAU,CAAC,QAAQ,EAAE;YACtB,YAAY,EAAE,gBAAgB;SAC/B,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACb,EAAE,CAAC,gBAAgB,EAAE,CAAC;QACtB,EAAE,CAAC,aAAa,EAAE,CAAC;IACrB,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,8EAA8E,EAAE,GAAG,EAAE;QACtF,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,eAAe,EAAE,CAAC,CAAC;QAEvD,MAAM,IAAI,GAAG,qBAAqB,CAAC;QACnC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAErB,MAAM,CAAC,gBAAgB,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;QAClD,MAAM,CAAC,gBAAgB,CAAC,CAAC,oBAAoB,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;IAC1D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-request-modal.js","sourceRoot":"","sources":["../../../../src/web/hooks/use-request-modal.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,UAAU,eAAe;IAC7B,OAAO,CAAC,OAA4B,EAAE,EAAE;QACtC,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { useRequestModal } from "./use-request-modal.js";
|
|
2
|
+
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
|
|
3
|
+
import { renderHook } from "@testing-library/react";
|
|
4
|
+
describe("useRequestModal", () => {
|
|
5
|
+
let requestModalMock;
|
|
6
|
+
beforeEach(() => {
|
|
7
|
+
requestModalMock = vi.fn();
|
|
8
|
+
vi.stubGlobal("openai", {
|
|
9
|
+
requestModal: requestModalMock,
|
|
10
|
+
});
|
|
11
|
+
});
|
|
12
|
+
afterEach(() => {
|
|
13
|
+
vi.unstubAllGlobals();
|
|
14
|
+
vi.resetAllMocks();
|
|
15
|
+
});
|
|
16
|
+
it("should return a function that calls window.openai.requestModal with the options", () => {
|
|
17
|
+
const { result } = renderHook(() => useRequestModal());
|
|
18
|
+
const options = { title: "Test Modal" };
|
|
19
|
+
result.current(options);
|
|
20
|
+
expect(requestModalMock).toHaveBeenCalledTimes(1);
|
|
21
|
+
expect(requestModalMock).toHaveBeenCalledWith(options);
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
//# sourceMappingURL=use-request-modal.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-request-modal.test.js","sourceRoot":"","sources":["../../../../src/web/hooks/use-request-modal.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC/B,IAAI,gBAA0C,CAAC;IAE/C,UAAU,CAAC,GAAG,EAAE;QACd,gBAAgB,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC;QAC3B,EAAE,CAAC,UAAU,CAAC,QAAQ,EAAE;YACtB,YAAY,EAAE,gBAAgB;SAC/B,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACb,EAAE,CAAC,gBAAgB,EAAE,CAAC;QACtB,EAAE,CAAC,aAAa,EAAE,CAAC;IACrB,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,iFAAiF,EAAE,GAAG,EAAE;QACzF,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,eAAe,EAAE,CAAC,CAAC;QAEvD,MAAM,OAAO,GAAG,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC;QACxC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAExB,MAAM,CAAC,gBAAgB,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;QAClD,MAAM,CAAC,gBAAgB,CAAC,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;IACzD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useSendFollowUpMessage(): (prompt: string) => Promise<void>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useCallback } from "react";
|
|
2
|
+
export function useSendFollowUpMessage() {
|
|
3
|
+
const sendFollowUpMessage = useCallback(async (prompt) => {
|
|
4
|
+
if (!window.openai?.sendFollowUpMessage) {
|
|
5
|
+
throw new Error("window.openai.sendFollowUpMessage is not available");
|
|
6
|
+
}
|
|
7
|
+
return window.openai.sendFollowUpMessage({ prompt });
|
|
8
|
+
}, []);
|
|
9
|
+
return sendFollowUpMessage;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=use-send-follow-up-message.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-send-follow-up-message.js","sourceRoot":"","sources":["../../../../src/web/hooks/use-send-follow-up-message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAEpC,MAAM,UAAU,sBAAsB;IACpC,MAAM,mBAAmB,GAAG,WAAW,CACrC,KAAK,EAAE,MAAc,EAAiB,EAAE;QACtC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,mBAAmB,EAAE,CAAC;YACxC,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;QACxE,CAAC;QACD,OAAO,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;IACvD,CAAC,EACD,EAAE,CACH,CAAC;IAEF,OAAO,mBAAmB,CAAC;AAC7B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useTheme(): import("../types.js").Theme;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-theme.js","sourceRoot":"","sources":["../../../../src/web/hooks/use-theme.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,MAAM,UAAU,QAAQ;IACtB,OAAO,eAAe,CAAC,OAAO,CAAE,CAAC;AACnC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { useTheme } from "./use-theme.js";
|
|
2
|
+
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
|
|
3
|
+
import { renderHook } from "@testing-library/react";
|
|
4
|
+
describe("useTheme", () => {
|
|
5
|
+
let OpenaiMock;
|
|
6
|
+
beforeEach(() => {
|
|
7
|
+
OpenaiMock = {
|
|
8
|
+
theme: "light",
|
|
9
|
+
};
|
|
10
|
+
vi.stubGlobal("openai", OpenaiMock);
|
|
11
|
+
});
|
|
12
|
+
afterEach(() => {
|
|
13
|
+
vi.unstubAllGlobals();
|
|
14
|
+
vi.resetAllMocks();
|
|
15
|
+
});
|
|
16
|
+
it("should return the current theme from window.openai.theme", () => {
|
|
17
|
+
const { result } = renderHook(() => useTheme());
|
|
18
|
+
expect(result.current).toBe("light");
|
|
19
|
+
});
|
|
20
|
+
it("should return dark theme when set to dark", () => {
|
|
21
|
+
OpenaiMock.theme = "dark";
|
|
22
|
+
const { result } = renderHook(() => useTheme());
|
|
23
|
+
expect(result.current).toBe("dark");
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
//# sourceMappingURL=use-theme.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-theme.test.js","sourceRoot":"","sources":["../../../../src/web/hooks/use-theme.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD,QAAQ,CAAC,UAAU,EAAE,GAAG,EAAE;IACxB,IAAI,UAEH,CAAC;IAEF,UAAU,CAAC,GAAG,EAAE;QACd,UAAU,GAAG;YACX,KAAK,EAAE,OAAO;SACf,CAAC;QACF,EAAE,CAAC,UAAU,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;IACtC,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACb,EAAE,CAAC,gBAAgB,EAAE,CAAC;QACtB,EAAE,CAAC,aAAa,EAAE,CAAC;IACrB,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,0DAA0D,EAAE,GAAG,EAAE;QAClE,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC;QAEhD,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,2CAA2C,EAAE,GAAG,EAAE;QACnD,UAAU,CAAC,KAAK,GAAG,MAAM,CAAC;QAC1B,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC;QAEhD,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACtC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useUserAgent(): import("../types.js").UserAgent;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-user-agent.js","sourceRoot":"","sources":["../../../../src/web/hooks/use-user-agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,MAAM,UAAU,YAAY;IAC1B,OAAO,eAAe,CAAC,WAAW,CAAE,CAAC;AACvC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { useUserAgent } from "./use-user-agent.js";
|
|
2
|
+
import { describe, it, expect, vi, beforeEach, afterEach, } from "vitest";
|
|
3
|
+
import { renderHook } from "@testing-library/react";
|
|
4
|
+
describe("useUserAgent", () => {
|
|
5
|
+
let OpenaiMock;
|
|
6
|
+
beforeEach(() => {
|
|
7
|
+
OpenaiMock = {
|
|
8
|
+
userAgent: {
|
|
9
|
+
device: { type: "mobile" },
|
|
10
|
+
capabilities: { hover: false, touch: true },
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
vi.stubGlobal("openai", OpenaiMock);
|
|
14
|
+
});
|
|
15
|
+
afterEach(() => {
|
|
16
|
+
vi.unstubAllGlobals();
|
|
17
|
+
vi.resetAllMocks();
|
|
18
|
+
});
|
|
19
|
+
it("should return the current user agent from window.openai.userAgent", () => {
|
|
20
|
+
OpenaiMock.userAgent = {
|
|
21
|
+
device: { type: "mobile" },
|
|
22
|
+
capabilities: { hover: false, touch: true },
|
|
23
|
+
};
|
|
24
|
+
const { result } = renderHook(() => useUserAgent());
|
|
25
|
+
expect(result.current).toEqual({
|
|
26
|
+
device: { type: "mobile" },
|
|
27
|
+
capabilities: { hover: false, touch: true },
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
//# sourceMappingURL=use-user-agent.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-user-agent.test.js","sourceRoot":"","sources":["../../../../src/web/hooks/use-user-agent.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EACL,QAAQ,EACR,EAAE,EACF,MAAM,EACN,EAAE,EACF,UAAU,EACV,SAAS,GAEV,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAGpD,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC5B,IAAI,UAEH,CAAC;IAEF,UAAU,CAAC,GAAG,EAAE;QACd,UAAU,GAAG;YACX,SAAS,EAAE;gBACT,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBAC1B,YAAY,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE;aAC5C;SACF,CAAC;QACF,EAAE,CAAC,UAAU,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;IACtC,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACb,EAAE,CAAC,gBAAgB,EAAE,CAAC;QACtB,EAAE,CAAC,aAAa,EAAE,CAAC;IACrB,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,mEAAmE,EAAE,GAAG,EAAE;QAC3E,UAAU,CAAC,SAAS,GAAG;YACrB,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YAC1B,YAAY,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE;SAC5C,CAAC;QACF,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,YAAY,EAAE,CAAC,CAAC;QAEpD,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC;YAC7B,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YAC1B,YAAY,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE;SAC5C,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/src/web/types.d.ts
CHANGED
|
@@ -9,6 +9,10 @@ export type RequestDisplayMode = (args: {
|
|
|
9
9
|
}) => Promise<{
|
|
10
10
|
mode: DisplayMode;
|
|
11
11
|
}>;
|
|
12
|
+
export type RequestModal = (options: RequestModalOptions) => Promise<void>;
|
|
13
|
+
export type RequestModalOptions = {
|
|
14
|
+
title: string;
|
|
15
|
+
};
|
|
12
16
|
export declare const TOOL_RESPONSE_EVENT_TYPE = "openai:tool_response";
|
|
13
17
|
export declare class ToolResponseEvent extends CustomEvent<{
|
|
14
18
|
tool: {
|
|
@@ -38,6 +42,7 @@ export type OpenAiGlobals<ToolInput extends UnknownObject = UnknownObject, ToolO
|
|
|
38
42
|
toolResponseMetadata: ToolResponseMetadata | null;
|
|
39
43
|
widgetState: WidgetState | null;
|
|
40
44
|
requestDisplayMode: RequestDisplayMode;
|
|
45
|
+
requestModal: RequestModal;
|
|
41
46
|
};
|
|
42
47
|
export type CallToolArgs = Record<string, unknown> | null;
|
|
43
48
|
export type CallToolResponse = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/web/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/web/types.ts"],"names":[],"mappings":"AAkBA,MAAM,CAAC,MAAM,wBAAwB,GAAG,sBAAsB,CAAC;AAC/D,MAAM,OAAO,iBAAkB,SAAQ,WAErC;IACkB,IAAI,GAAG,wBAAwB,CAAC;CACnD;AA6ED,sDAAsD;AACtD,MAAM,CAAC,MAAM,sBAAsB,GAAG,oBAAoB,CAAC;AAC3D,MAAM,OAAO,eAAgB,SAAQ,WAEnC;IACkB,IAAI,GAAG,sBAAsB,CAAC;CACjD"}
|