skybridge 0.0.0-dev.b96ae66 → 0.0.0-dev.bc56028
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/server/templates/development.hbs +1 -1
- package/dist/src/server/templates/production.hbs +1 -1
- package/dist/src/web/bridges/apps-sdk-adapter.d.ts +3 -2
- package/dist/src/web/bridges/apps-sdk-adapter.js +4 -1
- package/dist/src/web/bridges/apps-sdk-adapter.js.map +1 -1
- package/dist/src/web/bridges/get-bridge-methods.d.ts +2 -2
- package/dist/src/web/bridges/get-bridge-methods.js +2 -2
- package/dist/src/web/bridges/get-bridge-methods.js.map +1 -1
- package/dist/src/web/bridges/hooks/types.d.ts +6 -0
- package/dist/src/web/bridges/hooks/types.js +2 -0
- package/dist/src/web/bridges/hooks/types.js.map +1 -0
- package/dist/src/web/bridges/hooks/use-bridge.d.ts +2 -2
- package/dist/src/web/bridges/hooks/use-bridge.js +6 -44
- package/dist/src/web/bridges/hooks/use-bridge.js.map +1 -1
- package/dist/src/web/bridges/hooks/use-mcp-app-bridge.js +1 -1
- package/dist/src/web/bridges/hooks/use-mcp-app-bridge.js.map +1 -1
- package/dist/src/web/bridges/index.d.ts +1 -0
- package/dist/src/web/bridges/index.js +1 -0
- package/dist/src/web/bridges/index.js.map +1 -1
- package/dist/src/web/bridges/mcp-app-adapter.d.ts +5 -2
- package/dist/src/web/bridges/mcp-app-adapter.js +46 -2
- package/dist/src/web/bridges/mcp-app-adapter.js.map +1 -1
- package/dist/src/web/bridges/mcp-app-bridge.d.ts +2 -1
- package/dist/src/web/bridges/mcp-app-bridge.js +14 -5
- package/dist/src/web/bridges/mcp-app-bridge.js.map +1 -1
- package/dist/src/web/bridges/types.d.ts +16 -5
- package/dist/src/web/hooks/use-display-mode.d.ts +2 -2
- package/dist/src/web/hooks/use-send-follow-up-message.js +2 -7
- package/dist/src/web/hooks/use-send-follow-up-message.js.map +1 -1
- package/dist/src/web/hooks/use-user.js +2 -2
- package/dist/src/web/hooks/use-user.js.map +1 -1
- package/package.json +5 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<base href="{{serverUrl}}" />
|
|
2
|
-
<script>
|
|
2
|
+
<script type="module">window.skybridge = { hostType: "{{hostType}}" };</script>
|
|
3
3
|
<script type="module">
|
|
4
4
|
import { injectIntoGlobalHook } from "{{serverUrl}}/@react-refresh";
|
|
5
5
|
injectIntoGlobalHook(window); window.$RefreshReg$ = () => {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<base href="{{serverUrl}}" />
|
|
2
|
-
<script>
|
|
2
|
+
<script type="module">window.skybridge = { hostType: "{{hostType}}" };</script>
|
|
3
3
|
<div id="root"></div>
|
|
4
4
|
<script type="module">
|
|
5
5
|
import('{{serverUrl}}/assets/{{widgetFile}}');
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const requestDisplayMode:
|
|
1
|
+
import type { Methods } from "./types.js";
|
|
2
|
+
export declare const requestDisplayMode: Methods["requestDisplayMode"];
|
|
3
|
+
export declare const sendFollowUpMessage: Methods["sendFollowUpMessage"];
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
export const requestDisplayMode = ({ mode
|
|
1
|
+
export const requestDisplayMode = ({ mode }) => {
|
|
2
2
|
return window.openai.requestDisplayMode({ mode });
|
|
3
3
|
};
|
|
4
|
+
export const sendFollowUpMessage = (prompt) => {
|
|
5
|
+
return window.openai.sendFollowUpMessage({ prompt });
|
|
6
|
+
};
|
|
4
7
|
//# sourceMappingURL=apps-sdk-adapter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apps-sdk-adapter.js","sourceRoot":"","sources":["../../../../src/web/bridges/apps-sdk-adapter.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,kBAAkB,
|
|
1
|
+
{"version":3,"file":"apps-sdk-adapter.js","sourceRoot":"","sources":["../../../../src/web/bridges/apps-sdk-adapter.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,kBAAkB,GAAkC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE;IAC5E,OAAO,MAAM,CAAC,MAAM,CAAC,kBAAkB,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;AACpD,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAmC,CAAC,MAAM,EAAE,EAAE;IAC5E,OAAO,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;AACvD,CAAC,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const getBridgeMethods: () =>
|
|
1
|
+
import type { Methods } from "./types.js";
|
|
2
|
+
export declare const getBridgeMethods: () => Methods;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as AppsSdkAdapter from "./apps-sdk-adapter";
|
|
2
|
-
import * as McpAppAdapter from "./mcp-app-adapter";
|
|
1
|
+
import * as AppsSdkAdapter from "./apps-sdk-adapter.js";
|
|
2
|
+
import * as McpAppAdapter from "./mcp-app-adapter.js";
|
|
3
3
|
export const getBridgeMethods = () => {
|
|
4
4
|
return window.skybridge.hostType === "apps-sdk"
|
|
5
5
|
? AppsSdkAdapter
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-bridge-methods.js","sourceRoot":"","sources":["../../../../src/web/bridges/get-bridge-methods.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,cAAc,MAAM,
|
|
1
|
+
{"version":3,"file":"get-bridge-methods.js","sourceRoot":"","sources":["../../../../src/web/bridges/get-bridge-methods.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,cAAc,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,aAAa,MAAM,sBAAsB,CAAC;AAGtD,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAY,EAAE;IAC5C,OAAO,MAAM,CAAC,SAAS,CAAC,QAAQ,KAAK,UAAU;QAC7C,CAAC,CAAC,cAAc;QAChB,CAAC,CAAC,aAAa,CAAC;AACpB,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/web/bridges/hooks/types.ts"],"names":[],"mappings":""}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { BridgeInterface } from "../types";
|
|
2
|
-
export declare const useBridge: <K extends keyof BridgeInterface>(key: K
|
|
1
|
+
import type { BridgeInterface } from "../types.js";
|
|
2
|
+
export declare const useBridge: <K extends keyof BridgeInterface>(key: K) => BridgeInterface[K];
|
|
@@ -1,21 +1,7 @@
|
|
|
1
1
|
import { useSyncExternalStore } from "react";
|
|
2
|
-
import { AppsSdkBridge } from "../apps-sdk-bridge";
|
|
3
|
-
import {
|
|
4
|
-
const
|
|
5
|
-
theme: "light",
|
|
6
|
-
locale: "en-US",
|
|
7
|
-
displayMode: "inline",
|
|
8
|
-
safeArea: {
|
|
9
|
-
insets: {
|
|
10
|
-
top: 0,
|
|
11
|
-
right: 0,
|
|
12
|
-
bottom: 0,
|
|
13
|
-
left: 0,
|
|
14
|
-
},
|
|
15
|
-
},
|
|
16
|
-
maxHeight: window.innerHeight,
|
|
17
|
-
};
|
|
18
|
-
const getExternalStore = (key, defaultValue = DEFAULT_VALUE_FOR_MCP_APP_BRIDGE[key]) => {
|
|
2
|
+
import { AppsSdkBridge } from "../apps-sdk-bridge.js";
|
|
3
|
+
import { getMcpAppAdapter } from "../mcp-app-adapter.js";
|
|
4
|
+
const getExternalStore = (key) => {
|
|
19
5
|
const hostType = window.skybridge.hostType;
|
|
20
6
|
if (hostType === "apps-sdk") {
|
|
21
7
|
const bridge = AppsSdkBridge.getInstance();
|
|
@@ -24,34 +10,10 @@ const getExternalStore = (key, defaultValue = DEFAULT_VALUE_FOR_MCP_APP_BRIDGE[k
|
|
|
24
10
|
getSnapshot: () => bridge.getSnapshot(key),
|
|
25
11
|
};
|
|
26
12
|
}
|
|
27
|
-
|
|
28
|
-
if (key === "safeArea") {
|
|
29
|
-
return {
|
|
30
|
-
subscribe: bridge.subscribe("safeAreaInsets"),
|
|
31
|
-
getSnapshot: () => {
|
|
32
|
-
const safeArea = bridge.getSnapshot("safeAreaInsets");
|
|
33
|
-
return safeArea
|
|
34
|
-
? { insets: safeArea }
|
|
35
|
-
: defaultValue;
|
|
36
|
-
},
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
if (key === "maxHeight") {
|
|
40
|
-
return {
|
|
41
|
-
subscribe: bridge.subscribe("viewport"),
|
|
42
|
-
getSnapshot: () => {
|
|
43
|
-
const viewport = bridge.getSnapshot("viewport");
|
|
44
|
-
return (viewport?.maxHeight ?? defaultValue);
|
|
45
|
-
},
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
return {
|
|
49
|
-
subscribe: bridge.subscribe(key),
|
|
50
|
-
getSnapshot: () => (bridge.getSnapshot(key) ?? defaultValue),
|
|
51
|
-
};
|
|
13
|
+
return getMcpAppAdapter()[key];
|
|
52
14
|
};
|
|
53
|
-
export const useBridge = (key
|
|
54
|
-
const externalStore = getExternalStore(key
|
|
15
|
+
export const useBridge = (key) => {
|
|
16
|
+
const externalStore = getExternalStore(key);
|
|
55
17
|
return useSyncExternalStore(externalStore.subscribe, externalStore.getSnapshot);
|
|
56
18
|
};
|
|
57
19
|
//# sourceMappingURL=use-bridge.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-bridge.js","sourceRoot":"","sources":["../../../../../src/web/bridges/hooks/use-bridge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"use-bridge.js","sourceRoot":"","sources":["../../../../../src/web/bridges/hooks/use-bridge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAIzD,MAAM,gBAAgB,GAAG,CACvB,GAAM,EACkB,EAAE;IAC1B,MAAM,QAAQ,GAAG,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC;IAC3C,IAAI,QAAQ,KAAK,UAAU,EAAE,CAAC;QAC5B,MAAM,MAAM,GAAG,aAAa,CAAC,WAAW,EAAE,CAAC;QAC3C,OAAO;YACL,SAAS,EAAE,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC;YAChC,WAAW,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC;SAC3C,CAAC;IACJ,CAAC;IAED,OAAO,gBAAgB,EAAE,CAAC,GAAG,CAAC,CAAC;AACjC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG,CACvB,GAAM,EACc,EAAE;IACtB,MAAM,aAAa,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC;IAE5C,OAAO,oBAAoB,CACzB,aAAa,CAAC,SAAS,EACvB,aAAa,CAAC,WAAW,CAC1B,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useSyncExternalStore } from "react";
|
|
2
|
-
import { McpAppBridge } from "../mcp-app-bridge";
|
|
2
|
+
import { McpAppBridge } from "../mcp-app-bridge.js";
|
|
3
3
|
export function useMcpAppBridge(key, options, requestTimeout) {
|
|
4
4
|
const bridge = McpAppBridge.getInstance(options, requestTimeout);
|
|
5
5
|
return useSyncExternalStore(bridge.subscribe(key), () => bridge.getSnapshot(key));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-mcp-app-bridge.js","sourceRoot":"","sources":["../../../../../src/web/bridges/hooks/use-mcp-app-bridge.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"use-mcp-app-bridge.js","sourceRoot":"","sources":["../../../../../src/web/bridges/hooks/use-mcp-app-bridge.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAOpD,MAAM,UAAU,eAAe,CAC7B,GAAM,EACN,OAA8C,EAC9C,cAAuB;IAEvB,MAAM,MAAM,GAAG,YAAY,CAAC,WAAW,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;IACjE,OAAO,oBAAoB,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,CACtD,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,CACxB,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/web/bridges/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/web/bridges/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC"}
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
1
|
+
import type { BridgeExternalStore } from "./hooks/types.js";
|
|
2
|
+
import type { BridgeInterface, Methods } from "./types.js";
|
|
3
|
+
export declare const requestDisplayMode: Methods["requestDisplayMode"];
|
|
4
|
+
export declare const sendFollowUpMessage: Methods["sendFollowUpMessage"];
|
|
5
|
+
export declare const getMcpAppAdapter: () => { [K in keyof BridgeInterface]: BridgeExternalStore<K>; };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { McpAppBridge } from "./mcp-app-bridge";
|
|
2
|
-
export const requestDisplayMode = ({ mode
|
|
1
|
+
import { McpAppBridge } from "./mcp-app-bridge.js";
|
|
2
|
+
export const requestDisplayMode = ({ mode }) => {
|
|
3
3
|
const bridge = McpAppBridge.getInstance();
|
|
4
4
|
if (mode !== "modal") {
|
|
5
5
|
return bridge.request({
|
|
@@ -9,4 +9,48 @@ export const requestDisplayMode = ({ mode, }) => {
|
|
|
9
9
|
}
|
|
10
10
|
throw new Error("Modal display mode is not accessible in MCP App.");
|
|
11
11
|
};
|
|
12
|
+
export const sendFollowUpMessage = async (prompt) => {
|
|
13
|
+
const bridge = McpAppBridge.getInstance();
|
|
14
|
+
await bridge.request({
|
|
15
|
+
method: "ui/message",
|
|
16
|
+
params: {
|
|
17
|
+
role: "user",
|
|
18
|
+
content: [
|
|
19
|
+
{
|
|
20
|
+
type: "text",
|
|
21
|
+
text: prompt,
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
const createExternalStore = (keys, getSnapshot) => {
|
|
28
|
+
const bridge = McpAppBridge.getInstance();
|
|
29
|
+
return {
|
|
30
|
+
subscribe: bridge.subscribe(keys),
|
|
31
|
+
getSnapshot: () => {
|
|
32
|
+
const context = Object.fromEntries(keys.map((k) => [k, bridge.getSnapshot(k)]));
|
|
33
|
+
return getSnapshot(context);
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
export const getMcpAppAdapter = () => ({
|
|
38
|
+
theme: createExternalStore(["theme"], ({ theme }) => theme ?? "light"),
|
|
39
|
+
locale: createExternalStore(["locale"], ({ locale }) => locale ?? "en-US"),
|
|
40
|
+
safeArea: createExternalStore(["safeAreaInsets"], ({ safeAreaInsets }) => ({
|
|
41
|
+
insets: safeAreaInsets ?? { top: 0, right: 0, bottom: 0, left: 0 },
|
|
42
|
+
})),
|
|
43
|
+
displayMode: createExternalStore(["displayMode"], ({ displayMode }) => displayMode ?? "inline"),
|
|
44
|
+
maxHeight: createExternalStore(["viewport"], ({ viewport }) => viewport?.maxHeight ?? window.innerHeight),
|
|
45
|
+
userAgent: createExternalStore(["platform", "deviceCapabilities"], ({ platform, deviceCapabilities }) => ({
|
|
46
|
+
device: {
|
|
47
|
+
type: platform === "web" ? "desktop" : (platform ?? "unknown"),
|
|
48
|
+
},
|
|
49
|
+
capabilities: {
|
|
50
|
+
hover: true,
|
|
51
|
+
touch: true,
|
|
52
|
+
...deviceCapabilities,
|
|
53
|
+
},
|
|
54
|
+
})),
|
|
55
|
+
});
|
|
12
56
|
//# sourceMappingURL=mcp-app-adapter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-app-adapter.js","sourceRoot":"","sources":["../../../../src/web/bridges/mcp-app-adapter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mcp-app-adapter.js","sourceRoot":"","sources":["../../../../src/web/bridges/mcp-app-adapter.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGnD,MAAM,CAAC,MAAM,kBAAkB,GAAkC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE;IAC5E,MAAM,MAAM,GAAG,YAAY,CAAC,WAAW,EAAE,CAAC;IAC1C,IAAI,IAAI,KAAK,OAAO,EAAE,CAAC;QACrB,OAAO,MAAM,CAAC,OAAO,CAGnB;YACA,MAAM,EAAE,yBAAyB;YACjC,MAAM,EAAE,EAAE,IAAI,EAAE;SACjB,CAAC,CAAC;IACL,CAAC;IAED,MAAM,IAAI,KAA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B,CAAC,EAAE,CAAC,EAAE,cAAc,EAAE,EAAE,EAAE,CAAC,CAAC;QACzE,MAAM,EAAE,cAAc,IAAI,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE;KACnE,CAAC,CAAC;IACH,WAAW,EAAE,mBAAmB,CAC9B,CAAC,aAAa,CAAC,EACf,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC,WAAW,IAAI,QAAQ,CAC7C;IACD,SAAS,EAAE,mBAAmB,CAC5B,CAAC,UAAU,CAAC,EACZ,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,QAAQ,EAAE,SAAS,IAAI,MAAM,CAAC,WAAW,CAC5D;IACD,SAAS,EAAE,mBAAmB,CAC5B,CAAC,UAAU,EAAE,oBAAoB,CAAC,EAClC,CAAC,EAAE,QAAQ,EAAE,kBAAkB,EAAE,EAAE,EAAE,CAAC,CAAC;QACrC,MAAM,EAAE;YACN,IAAI,EAAE,QAAQ,KAAK,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,QAAQ,IAAI,SAAS,CAAC;SAC/D;QACD,YAAY,EAAE;YACZ,KAAK,EAAE,IAAI;YACX,KAAK,EAAE,IAAI;YACX,GAAG,kBAAkB;SACtB;KACF,CAAC,CACH;CACF,CAAC,CAAC"}
|
|
@@ -11,7 +11,8 @@ export declare class McpAppBridge {
|
|
|
11
11
|
private requestTimeout;
|
|
12
12
|
constructor(options: McpAppInitializationOptions, requestTimeout?: number);
|
|
13
13
|
static getInstance(options?: Partial<McpAppInitializationOptions>, requestTimeout?: number): McpAppBridge;
|
|
14
|
-
subscribe
|
|
14
|
+
subscribe(key: keyof McpUiHostContext): (onChange: () => void) => () => void;
|
|
15
|
+
subscribe(keys: readonly (keyof McpUiHostContext)[]): (onChange: () => void) => () => void;
|
|
15
16
|
getSnapshot: <K extends keyof McpUiHostContext>(key: K) => McpUiHostContext[K] | undefined;
|
|
16
17
|
cleanup: () => void;
|
|
17
18
|
static resetInstance(): void;
|
|
@@ -32,11 +32,20 @@ export class McpAppBridge {
|
|
|
32
32
|
}
|
|
33
33
|
return McpAppBridge.instance;
|
|
34
34
|
}
|
|
35
|
-
subscribe
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
subscribe(keyOrKeys) {
|
|
36
|
+
const keys = Array.isArray(keyOrKeys) ? keyOrKeys : [keyOrKeys];
|
|
37
|
+
return (onChange) => {
|
|
38
|
+
for (const key of keys) {
|
|
39
|
+
this.listeners.set(key, new Set([...(this.listeners.get(key) || []), onChange]));
|
|
40
|
+
}
|
|
41
|
+
this.init();
|
|
42
|
+
return () => {
|
|
43
|
+
for (const key of keys) {
|
|
44
|
+
this.listeners.get(key)?.delete(onChange);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
}
|
|
40
49
|
getSnapshot = (key) => {
|
|
41
50
|
return this.context?.[key];
|
|
42
51
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-app-bridge.js","sourceRoot":"","sources":["../../../../src/web/bridges/mcp-app-bridge.ts"],"names":[],"mappings":"AAkBA,MAAM,uBAAuB,GAAG,YAAY,CAAC;AAE7C,MAAM,OAAO,YAAY;IACf,MAAM,CAAC,QAAQ,GAAwB,IAAI,CAAC;IAC7C,OAAO,GAA4B,IAAI,CAAC;IACvC,SAAS,GAAG,IAAI,GAAG,EAA2C,CAAC;IAC/D,eAAe,GAAG,IAAI,GAAG,EAAmC,CAAC;IAC7D,MAAM,GAAG,CAAC,CAAC;IACX,WAAW,CAAU;IACrB,wBAAwB,CAAmC;IAC3D,cAAc,CAAS;IAE/B,YACE,OAAoC,EACpC,iBAAyB,MAAM;QAE/B,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;QACzB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O,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACrB,CAAC;IACH,CAAC;IAEO,MAAM,CAAC,YAA0C;QACvD,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,YAAY,EAAE,EAAE,GAAG,CAAC,CAAC;IACtE,CAAC"}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
export type
|
|
1
|
+
export type Methods = {
|
|
2
2
|
requestDisplayMode({ mode }: {
|
|
3
|
-
mode:
|
|
3
|
+
mode: DisplayMode;
|
|
4
4
|
}): Promise<{
|
|
5
|
-
mode:
|
|
5
|
+
mode: DisplayMode;
|
|
6
6
|
}>;
|
|
7
|
+
sendFollowUpMessage(prompt: string): Promise<void>;
|
|
7
8
|
};
|
|
8
|
-
export type
|
|
9
|
+
export type DisplayMode = "pip" | "inline" | "fullscreen" | "modal";
|
|
10
|
+
export type DeviceType = "mobile" | "tablet" | "desktop" | "unknown";
|
|
9
11
|
export interface BridgeInterface {
|
|
10
12
|
theme: "light" | "dark";
|
|
11
13
|
locale: string;
|
|
12
|
-
displayMode:
|
|
14
|
+
displayMode: DisplayMode;
|
|
13
15
|
safeArea: {
|
|
14
16
|
insets: {
|
|
15
17
|
top: number;
|
|
@@ -19,4 +21,13 @@ export interface BridgeInterface {
|
|
|
19
21
|
};
|
|
20
22
|
};
|
|
21
23
|
maxHeight: number;
|
|
24
|
+
userAgent: {
|
|
25
|
+
device: {
|
|
26
|
+
type: DeviceType;
|
|
27
|
+
};
|
|
28
|
+
capabilities: {
|
|
29
|
+
hover: boolean;
|
|
30
|
+
touch: boolean;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
22
33
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { DisplayMode } from "../types.js";
|
|
2
|
-
export declare function useDisplayMode(): readonly [import("../bridges/types.js").
|
|
3
|
-
mode: import("../bridges/types.js").
|
|
2
|
+
export declare function useDisplayMode(): readonly [import("../bridges/types.js").DisplayMode, (mode: DisplayMode) => Promise<{
|
|
3
|
+
mode: import("../bridges/types.js").DisplayMode;
|
|
4
4
|
}>];
|
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getBridgeMethods } from "../bridges/index.js";
|
|
2
2
|
export function useSendFollowUpMessage() {
|
|
3
|
-
const sendFollowUpMessage =
|
|
4
|
-
if (!window.openai?.sendFollowUpMessage) {
|
|
5
|
-
throw new Error("window.openai.sendFollowUpMessage is not available");
|
|
6
|
-
}
|
|
7
|
-
return window.openai.sendFollowUpMessage({ prompt });
|
|
8
|
-
}, []);
|
|
3
|
+
const { sendFollowUpMessage } = getBridgeMethods();
|
|
9
4
|
return sendFollowUpMessage;
|
|
10
5
|
}
|
|
11
6
|
//# sourceMappingURL=use-send-follow-up-message.js.map
|
|
@@ -1 +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,
|
|
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,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD,MAAM,UAAU,sBAAsB;IACpC,MAAM,EAAE,mBAAmB,EAAE,GAAG,gBAAgB,EAAE,CAAC;IAEnD,OAAO,mBAAmB,CAAC;AAC7B,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useBridge } from "../bridges/index.js";
|
|
2
2
|
/**
|
|
3
3
|
* Hook for accessing session-stable user information.
|
|
4
4
|
* These values are set once at initialization and do not change during the session.
|
|
@@ -13,7 +13,7 @@ import { useAppsSdkBridge, useBridge } from "../bridges/index.js";
|
|
|
13
13
|
*/
|
|
14
14
|
export function useUser() {
|
|
15
15
|
const locale = useBridge("locale");
|
|
16
|
-
const userAgent =
|
|
16
|
+
const userAgent = useBridge("userAgent");
|
|
17
17
|
return { locale, userAgent };
|
|
18
18
|
}
|
|
19
19
|
//# sourceMappingURL=use-user.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-user.js","sourceRoot":"","sources":["../../../../src/web/hooks/use-user.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"use-user.js","sourceRoot":"","sources":["../../../../src/web/hooks/use-user.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAQhD;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,OAAO;IACrB,MAAM,MAAM,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;IACnC,MAAM,SAAS,GAAG,SAAS,CAAC,WAAW,CAAC,CAAC;IAEzC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;AAC/B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "skybridge",
|
|
3
|
-
"version": "0.0.0-dev.
|
|
3
|
+
"version": "0.0.0-dev.bc56028",
|
|
4
4
|
"description": "Skybridge is a framework for building ChatGPT apps",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/alpic-ai/skybridge.git"
|
|
8
|
+
},
|
|
5
9
|
"type": "module",
|
|
6
10
|
"files": [
|
|
7
11
|
"dist"
|