skybridge 0.0.0-dev.cb16b5e → 0.0.0-dev.cc48d14
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/hooks/use-bridge.d.ts +1 -1
- package/dist/src/web/bridges/hooks/use-bridge.js +19 -51
- package/dist/src/web/bridges/hooks/use-bridge.js.map +1 -1
- package/dist/src/web/bridges/types.d.ts +0 -10
- 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,2 @@
|
|
|
1
1
|
import type { BridgeInterface } from "../types";
|
|
2
|
-
export declare const useBridge: <K extends keyof BridgeInterface>(key: K
|
|
2
|
+
export declare const useBridge: <K extends keyof BridgeInterface>(key: K) => BridgeInterface[K];
|
|
@@ -1,30 +1,25 @@
|
|
|
1
1
|
import { useSyncExternalStore } from "react";
|
|
2
2
|
import { AppsSdkBridge } from "../apps-sdk-bridge";
|
|
3
3
|
import { McpAppBridge } from "../mcp-app-bridge";
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
maxHeight: window.innerHeight,
|
|
17
|
-
userAgent: {
|
|
18
|
-
device: {
|
|
19
|
-
type: "unknown",
|
|
20
|
-
},
|
|
21
|
-
capabilities: {
|
|
22
|
-
hover: false,
|
|
23
|
-
touch: false,
|
|
4
|
+
const getDefaultValueFromMcpAppBridge = (key) => {
|
|
5
|
+
const DEFAULT_VALUES_FOR_MCP_APP_BRIDGE = {
|
|
6
|
+
theme: "light",
|
|
7
|
+
locale: "en-US",
|
|
8
|
+
displayMode: "inline",
|
|
9
|
+
safeArea: {
|
|
10
|
+
insets: {
|
|
11
|
+
top: 0,
|
|
12
|
+
right: 0,
|
|
13
|
+
bottom: 0,
|
|
14
|
+
left: 0,
|
|
15
|
+
},
|
|
24
16
|
},
|
|
25
|
-
|
|
17
|
+
maxHeight: window.innerHeight,
|
|
18
|
+
};
|
|
19
|
+
return DEFAULT_VALUES_FOR_MCP_APP_BRIDGE[key];
|
|
26
20
|
};
|
|
27
|
-
const getExternalStore = (key
|
|
21
|
+
const getExternalStore = (key) => {
|
|
22
|
+
const defaultValue = getDefaultValueFromMcpAppBridge(key);
|
|
28
23
|
const hostType = window.skybridge.hostType;
|
|
29
24
|
if (hostType === "apps-sdk") {
|
|
30
25
|
const bridge = AppsSdkBridge.getInstance();
|
|
@@ -54,40 +49,13 @@ const getExternalStore = (key, defaultValue = DEFAULT_VALUE_FOR_MCP_APP_BRIDGE[k
|
|
|
54
49
|
},
|
|
55
50
|
};
|
|
56
51
|
}
|
|
57
|
-
if (key === "userAgent") {
|
|
58
|
-
return {
|
|
59
|
-
subscribe: (onChange) => () => {
|
|
60
|
-
bridge.subscribe("deviceCapabilities")(onChange);
|
|
61
|
-
bridge.subscribe("platform")(onChange);
|
|
62
|
-
},
|
|
63
|
-
getSnapshot: () => {
|
|
64
|
-
const userAgentDefaultValue = defaultValue;
|
|
65
|
-
const capabilities = {
|
|
66
|
-
...userAgentDefaultValue.capabilities,
|
|
67
|
-
...(bridge.getSnapshot("deviceCapabilities") ?? {}),
|
|
68
|
-
};
|
|
69
|
-
const mcpAppPlatform = bridge.getSnapshot("platform");
|
|
70
|
-
const deviceType = mcpAppPlatform
|
|
71
|
-
? mcpAppPlatform === "web"
|
|
72
|
-
? "desktop"
|
|
73
|
-
: mcpAppPlatform
|
|
74
|
-
: userAgentDefaultValue.device.type;
|
|
75
|
-
return {
|
|
76
|
-
device: {
|
|
77
|
-
type: deviceType,
|
|
78
|
-
},
|
|
79
|
-
capabilities,
|
|
80
|
-
};
|
|
81
|
-
},
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
52
|
return {
|
|
85
53
|
subscribe: bridge.subscribe(key),
|
|
86
54
|
getSnapshot: () => (bridge.getSnapshot(key) ?? defaultValue),
|
|
87
55
|
};
|
|
88
56
|
};
|
|
89
|
-
export const useBridge = (key
|
|
90
|
-
const externalStore = getExternalStore(key
|
|
57
|
+
export const useBridge = (key) => {
|
|
58
|
+
const externalStore = getExternalStore(key);
|
|
91
59
|
return useSyncExternalStore(externalStore.subscribe, externalStore.getSnapshot);
|
|
92
60
|
};
|
|
93
61
|
//# 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,oBAAoB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAQjD,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;A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AAC,CAAE,EAAE,MAAM,EAAE,QAAQ,EAAyB;oBAC9C,CAAC,CAAC,YAAY,CAAC;YACnB,CAAC;SACF,CAAC;IACJ,CAAC;IACD,IAAI,GAAG,KAAK,WAAW,EAAE,CAAC;QACxB,OAAO;YACL,SAAS,EAAE,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC;YACvC,WAAW,EAAE,GAAG,EAAE;gBAChB,MAAM,QAAQ,GAAG,MAAM,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;gBAChD,OAAO,CAAC,QAAQ,EAAE,SAAS,IAAI,YAAY,CAAuB,CAAC;YACrE,CAAC;SACF,CAAC;IACJ,CAAC;IACD,OAAO;QACL,SAAS,EAAE,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC;QAChC,WAAW,EAAE,GAAG,EAAE,CAChB,CAAC,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,YAAY,CAAuB;KAClE,CAAC;AACJ,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"}
|
|
@@ -6,7 +6,6 @@ export type Methods = {
|
|
|
6
6
|
}>;
|
|
7
7
|
};
|
|
8
8
|
export type DisplayMode = "pip" | "inline" | "fullscreen" | "modal";
|
|
9
|
-
export type DeviceType = "mobile" | "tablet" | "desktop" | "unknown";
|
|
10
9
|
export interface BridgeInterface {
|
|
11
10
|
theme: "light" | "dark";
|
|
12
11
|
locale: string;
|
|
@@ -20,13 +19,4 @@ export interface BridgeInterface {
|
|
|
20
19
|
};
|
|
21
20
|
};
|
|
22
21
|
maxHeight: number;
|
|
23
|
-
userAgent: {
|
|
24
|
-
device: {
|
|
25
|
-
type: DeviceType;
|
|
26
|
-
};
|
|
27
|
-
capabilities: {
|
|
28
|
-
hover: boolean;
|
|
29
|
-
touch: boolean;
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
22
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useBridge } from "../bridges/index.js";
|
|
1
|
+
import { useAppsSdkBridge, 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 { useBridge } from "../bridges/index.js";
|
|
|
13
13
|
*/
|
|
14
14
|
export function useUser() {
|
|
15
15
|
const locale = useBridge("locale");
|
|
16
|
-
const userAgent =
|
|
16
|
+
const userAgent = useAppsSdkBridge("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,SAAS,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"use-user.js","sourceRoot":"","sources":["../../../../src/web/hooks/use-user.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAQlE;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,OAAO;IACrB,MAAM,MAAM,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;IACnC,MAAM,SAAS,GAAG,gBAAgB,CAAC,WAAW,CAAC,CAAC;IAEhD,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.cc48d14",
|
|
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"
|