skybridge 0.0.0-dev.efe5a46 → 0.0.0-dev.effc12c

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.
Files changed (278) hide show
  1. package/README.md +9 -7
  2. package/dist/cli/build-helpers.d.ts +1 -1
  3. package/dist/cli/build-helpers.js +4 -4
  4. package/dist/cli/build-helpers.js.map +1 -1
  5. package/dist/cli/build-helpers.test.js +6 -4
  6. package/dist/cli/build-helpers.test.js.map +1 -1
  7. package/dist/cli/build-steps.js +1 -1
  8. package/dist/cli/build-steps.js.map +1 -1
  9. package/dist/cli/build-steps.test.js +3 -3
  10. package/dist/cli/build-steps.test.js.map +1 -1
  11. package/dist/cli/detect-port.js +0 -1
  12. package/dist/cli/detect-port.js.map +1 -1
  13. package/dist/cli/run-plain.js +2 -1
  14. package/dist/cli/run-plain.js.map +1 -1
  15. package/dist/cli/use-execute-steps.d.ts +1 -1
  16. package/dist/cli/use-nodemon.d.ts +11 -1
  17. package/dist/cli/use-nodemon.js +30 -8
  18. package/dist/cli/use-nodemon.js.map +1 -1
  19. package/dist/cli/use-typescript-check.js +1 -1
  20. package/dist/cli/use-typescript-check.js.map +1 -1
  21. package/dist/commands/dev.js +4 -4
  22. package/dist/commands/dev.js.map +1 -1
  23. package/dist/commands/start.js +2 -2
  24. package/dist/commands/start.js.map +1 -1
  25. package/dist/context-warnings.d.ts +5 -0
  26. package/dist/context-warnings.js +31 -0
  27. package/dist/context-warnings.js.map +1 -0
  28. package/dist/context-warnings.test.js +28 -0
  29. package/dist/context-warnings.test.js.map +1 -0
  30. package/dist/server/app.d.ts +194 -0
  31. package/dist/server/app.js +266 -0
  32. package/dist/server/app.js.map +1 -0
  33. package/dist/server/app.test.js +97 -0
  34. package/dist/server/app.test.js.map +1 -0
  35. package/dist/server/auth/discovery.d.ts +2 -1
  36. package/dist/server/auth/discovery.js +2 -2
  37. package/dist/server/auth/discovery.js.map +1 -1
  38. package/dist/server/auth/index.d.ts +35 -5
  39. package/dist/server/auth/index.js.map +1 -1
  40. package/dist/server/auth/providers/auth0.d.ts +25 -3
  41. package/dist/server/auth/providers/auth0.js +13 -8
  42. package/dist/server/auth/providers/auth0.js.map +1 -1
  43. package/dist/server/auth/providers/auth0.test.js +5 -3
  44. package/dist/server/auth/providers/auth0.test.js.map +1 -1
  45. package/dist/server/auth/providers/authplane.d.ts +49 -0
  46. package/dist/server/auth/providers/authplane.js +57 -0
  47. package/dist/server/auth/providers/authplane.js.map +1 -0
  48. package/dist/server/auth/providers/authplane.test.js +143 -0
  49. package/dist/server/auth/providers/authplane.test.js.map +1 -0
  50. package/dist/server/auth/providers/clerk.d.ts +40 -3
  51. package/dist/server/auth/providers/clerk.js +4 -1
  52. package/dist/server/auth/providers/clerk.js.map +1 -1
  53. package/dist/server/auth/providers/clerk.test.js +5 -3
  54. package/dist/server/auth/providers/clerk.test.js.map +1 -1
  55. package/dist/server/auth/providers/custom.d.ts +12 -4
  56. package/dist/server/auth/providers/custom.js +14 -4
  57. package/dist/server/auth/providers/custom.js.map +1 -1
  58. package/dist/server/auth/providers/custom.test.js +24 -19
  59. package/dist/server/auth/providers/custom.test.js.map +1 -1
  60. package/dist/server/auth/providers/descope.d.ts +32 -3
  61. package/dist/server/auth/providers/descope.js.map +1 -1
  62. package/dist/server/auth/providers/descope.test.js +8 -6
  63. package/dist/server/auth/providers/descope.test.js.map +1 -1
  64. package/dist/server/auth/providers/stytch.d.ts +16 -3
  65. package/dist/server/auth/providers/stytch.js +4 -1
  66. package/dist/server/auth/providers/stytch.js.map +1 -1
  67. package/dist/server/auth/providers/verify-spy.d.ts +12 -0
  68. package/dist/server/auth/providers/verify-spy.js +21 -0
  69. package/dist/server/auth/providers/verify-spy.js.map +1 -0
  70. package/dist/server/auth/providers/workos.d.ts +25 -3
  71. package/dist/server/auth/providers/workos.js +4 -1
  72. package/dist/server/auth/providers/workos.js.map +1 -1
  73. package/dist/server/auth/setup.d.ts +1 -1
  74. package/dist/server/auth/setup.js +4 -5
  75. package/dist/server/auth/setup.js.map +1 -1
  76. package/dist/server/auth/setup.test.js +97 -57
  77. package/dist/server/auth/setup.test.js.map +1 -1
  78. package/dist/server/auth/verify.d.ts +37 -3
  79. package/dist/server/auth/verify.js +27 -3
  80. package/dist/server/auth/verify.js.map +1 -1
  81. package/dist/server/auth/verify.test.js +49 -0
  82. package/dist/server/auth/verify.test.js.map +1 -1
  83. package/dist/server/auth-extra.test-d.js +130 -0
  84. package/dist/server/auth-extra.test-d.js.map +1 -0
  85. package/dist/server/auth.d.ts +43 -6
  86. package/dist/server/auth.js +4 -5
  87. package/dist/server/auth.js.map +1 -1
  88. package/dist/server/build-manifest.test.js +7 -6
  89. package/dist/server/build-manifest.test.js.map +1 -1
  90. package/dist/server/content-helpers.d.ts +1 -1
  91. package/dist/server/content-helpers.js.map +1 -1
  92. package/dist/server/express.d.ts +23 -3
  93. package/dist/server/express.js +38 -32
  94. package/dist/server/express.js.map +1 -1
  95. package/dist/server/express.test.js +220 -103
  96. package/dist/server/express.test.js.map +1 -1
  97. package/dist/server/file-ref.d.ts +1 -1
  98. package/dist/server/file-ref.js +1 -1
  99. package/dist/server/file-ref.js.map +1 -1
  100. package/dist/server/index.d.ts +14 -8
  101. package/dist/server/index.js +7 -2
  102. package/dist/server/index.js.map +1 -1
  103. package/dist/server/mcp-errors.test.js +41 -0
  104. package/dist/server/mcp-errors.test.js.map +1 -0
  105. package/dist/server/middleware.d.ts +35 -10
  106. package/dist/server/middleware.js +33 -0
  107. package/dist/server/middleware.js.map +1 -1
  108. package/dist/server/middleware.test-d.js +1 -1
  109. package/dist/server/middleware.test-d.js.map +1 -1
  110. package/dist/server/middleware.test.js +242 -134
  111. package/dist/server/middleware.test.js.map +1 -1
  112. package/dist/server/register-tool.test.d.ts +1 -0
  113. package/dist/server/register-tool.test.js +27 -0
  114. package/dist/server/register-tool.test.js.map +1 -0
  115. package/dist/server/server.d.ts +85 -120
  116. package/dist/server/server.js +112 -297
  117. package/dist/server/server.js.map +1 -1
  118. package/dist/server/skills-integration.test.js +44 -21
  119. package/dist/server/skills-integration.test.js.map +1 -1
  120. package/dist/server/skills.d.ts +14 -10
  121. package/dist/server/skills.js +49 -39
  122. package/dist/server/skills.js.map +1 -1
  123. package/dist/server/skills.test.js +77 -44
  124. package/dist/server/skills.test.js.map +1 -1
  125. package/dist/server/templateHelper.d.ts +0 -3
  126. package/dist/server/templateHelper.js.map +1 -1
  127. package/dist/server/templates.generated.js +4 -8
  128. package/dist/server/templates.generated.js.map +1 -1
  129. package/dist/server/tool-extra.test.d.ts +1 -0
  130. package/dist/server/tool-extra.test.js +88 -0
  131. package/dist/server/tool-extra.test.js.map +1 -0
  132. package/dist/server/view-resource-resolution.test.js +18 -13
  133. package/dist/server/view-resource-resolution.test.js.map +1 -1
  134. package/dist/test/utils.d.ts +9 -11
  135. package/dist/test/utils.js +220 -201
  136. package/dist/test/utils.js.map +1 -1
  137. package/dist/test/view.test.js +41 -37
  138. package/dist/test/view.test.js.map +1 -1
  139. package/dist/views/index.d.ts +10 -0
  140. package/dist/views/index.js +3 -0
  141. package/dist/views/index.js.map +1 -0
  142. package/dist/{web/plugin → views}/scan-views.js +1 -1
  143. package/dist/views/scan-views.js.map +1 -0
  144. package/dist/views/scan-views.test.d.ts +1 -0
  145. package/dist/views/scan-views.test.js.map +1 -0
  146. package/dist/views/validate-view.d.ts +1 -0
  147. package/dist/{web/plugin → views}/validate-view.js +2 -2
  148. package/dist/views/validate-view.js.map +1 -0
  149. package/dist/views/validate-view.test.d.ts +1 -0
  150. package/dist/views/validate-view.test.js.map +1 -0
  151. package/dist/web/bridges/adaptor.js +14 -17
  152. package/dist/web/bridges/adaptor.js.map +1 -1
  153. package/dist/web/bridges/adaptor.test.js +24 -7
  154. package/dist/web/bridges/adaptor.test.js.map +1 -1
  155. package/dist/web/bridges/apps-sdk/use-apps-sdk-context.d.ts +1 -1
  156. package/dist/web/bridges/apps-sdk/use-apps-sdk-context.js +1 -1
  157. package/dist/web/bridges/apps-sdk/use-apps-sdk-context.js.map +1 -1
  158. package/dist/web/bridges/get-adaptor.test.js +2 -2
  159. package/dist/web/bridges/get-adaptor.test.js.map +1 -1
  160. package/dist/web/bridges/mcp-app/bridge.js +1 -1
  161. package/dist/web/bridges/mcp-app/bridge.js.map +1 -1
  162. package/dist/web/bridges/mcp-app/bridge.test.js +2 -2
  163. package/dist/web/bridges/mcp-app/bridge.test.js.map +1 -1
  164. package/dist/web/bridges/mcp-app/use-mcp-app-context.d.ts +1 -1
  165. package/dist/web/bridges/mcp-app/use-mcp-app-context.js +1 -1
  166. package/dist/web/bridges/mcp-app/use-mcp-app-context.js.map +1 -1
  167. package/dist/web/bridges/mcp-app/use-mcp-app-context.test.js +1 -1
  168. package/dist/web/bridges/mcp-app/use-mcp-app-context.test.js.map +1 -1
  169. package/dist/web/bridges/mcp-app/view-tools.test.js +1 -1
  170. package/dist/web/bridges/mcp-app/view-tools.test.js.map +1 -1
  171. package/dist/web/bridges/types.d.ts +17 -12
  172. package/dist/web/bridges/types.js.map +1 -1
  173. package/dist/web/create-store.test.js +2 -2
  174. package/dist/web/create-store.test.js.map +1 -1
  175. package/dist/web/data-llm.test.js +5 -4
  176. package/dist/web/data-llm.test.js.map +1 -1
  177. package/dist/web/generate-helpers.d.ts +22 -18
  178. package/dist/web/generate-helpers.js +19 -15
  179. package/dist/web/generate-helpers.js.map +1 -1
  180. package/dist/web/generate-helpers.test-d.js +3 -3
  181. package/dist/web/generate-helpers.test-d.js.map +1 -1
  182. package/dist/web/generate-helpers.test.js +2 -2
  183. package/dist/web/generate-helpers.test.js.map +1 -1
  184. package/dist/web/hooks/index.d.ts +2 -2
  185. package/dist/web/hooks/index.js +2 -2
  186. package/dist/web/hooks/index.js.map +1 -1
  187. package/dist/web/hooks/test/utils.d.ts +2 -1
  188. package/dist/web/hooks/test/utils.js +1 -1
  189. package/dist/web/hooks/test/utils.js.map +1 -1
  190. package/dist/web/hooks/use-call-tool.test.js +2 -2
  191. package/dist/web/hooks/use-call-tool.test.js.map +1 -1
  192. package/dist/web/hooks/use-display-mode.d.ts +1 -1
  193. package/dist/web/hooks/use-display-mode.js +1 -1
  194. package/dist/web/hooks/use-display-mode.js.map +1 -1
  195. package/dist/web/hooks/use-display-mode.test.js +1 -1
  196. package/dist/web/hooks/use-display-mode.test.js.map +1 -1
  197. package/dist/web/hooks/use-download.d.ts +1 -3
  198. package/dist/web/hooks/use-download.js +1 -2
  199. package/dist/web/hooks/use-download.js.map +1 -1
  200. package/dist/web/hooks/use-download.test.js +7 -7
  201. package/dist/web/hooks/use-download.test.js.map +1 -1
  202. package/dist/web/hooks/use-files.test.js +1 -1
  203. package/dist/web/hooks/use-files.test.js.map +1 -1
  204. package/dist/web/hooks/{use-host-info.d.ts → use-host.d.ts} +2 -2
  205. package/dist/web/hooks/{use-host-info.js → use-host.js} +3 -3
  206. package/dist/web/hooks/use-host.js.map +1 -0
  207. package/dist/web/hooks/use-host.test.d.ts +1 -0
  208. package/dist/web/hooks/use-host.test.js +59 -0
  209. package/dist/web/hooks/use-host.test.js.map +1 -0
  210. package/dist/web/hooks/use-open-external.test.js +2 -2
  211. package/dist/web/hooks/use-open-external.test.js.map +1 -1
  212. package/dist/web/hooks/use-register-view-tool.d.ts +2 -3
  213. package/dist/web/hooks/use-register-view-tool.js.map +1 -1
  214. package/dist/web/hooks/use-request-close.test.js +1 -1
  215. package/dist/web/hooks/use-request-close.test.js.map +1 -1
  216. package/dist/web/hooks/use-request-modal.test.js +1 -1
  217. package/dist/web/hooks/use-request-modal.test.js.map +1 -1
  218. package/dist/web/hooks/use-request-size.d.ts +1 -1
  219. package/dist/web/hooks/use-request-size.js +1 -1
  220. package/dist/web/hooks/use-request-size.js.map +1 -1
  221. package/dist/web/hooks/use-request-size.test.js +1 -1
  222. package/dist/web/hooks/use-request-size.test.js.map +1 -1
  223. package/dist/web/hooks/use-set-open-in-app-url.test.js +2 -8
  224. package/dist/web/hooks/use-set-open-in-app-url.test.js.map +1 -1
  225. package/dist/web/hooks/use-tool-info.d.ts +1 -20
  226. package/dist/web/hooks/use-tool-info.js +0 -1
  227. package/dist/web/hooks/use-tool-info.js.map +1 -1
  228. package/dist/web/hooks/use-tool-info.test-d.js +0 -5
  229. package/dist/web/hooks/use-tool-info.test-d.js.map +1 -1
  230. package/dist/web/hooks/use-tool-info.test.js +2 -7
  231. package/dist/web/hooks/use-tool-info.test.js.map +1 -1
  232. package/dist/web/hooks/use-user.d.ts +3 -2
  233. package/dist/web/hooks/use-user.js +4 -3
  234. package/dist/web/hooks/use-user.js.map +1 -1
  235. package/dist/web/hooks/use-user.test.js +5 -3
  236. package/dist/web/hooks/use-user.test.js.map +1 -1
  237. package/dist/web/hooks/use-view-state.js +19 -9
  238. package/dist/web/hooks/use-view-state.js.map +1 -1
  239. package/dist/web/hooks/use-view-state.test.js +33 -2
  240. package/dist/web/hooks/use-view-state.test.js.map +1 -1
  241. package/dist/web/hooks/use-viewport.d.ts +20 -0
  242. package/dist/web/hooks/use-viewport.js +21 -0
  243. package/dist/web/hooks/use-viewport.js.map +1 -0
  244. package/dist/web/hooks/use-viewport.test.d.ts +1 -0
  245. package/dist/web/hooks/{use-layout.test.js → use-viewport.test.js} +12 -32
  246. package/dist/web/hooks/use-viewport.test.js.map +1 -0
  247. package/dist/web/mount-view.d.ts +3 -2
  248. package/dist/web/mount-view.js +5 -8
  249. package/dist/web/mount-view.js.map +1 -1
  250. package/package.json +13 -11
  251. package/dist/web/hooks/use-host-info.js.map +0 -1
  252. package/dist/web/hooks/use-layout.d.ts +0 -24
  253. package/dist/web/hooks/use-layout.js +0 -25
  254. package/dist/web/hooks/use-layout.js.map +0 -1
  255. package/dist/web/hooks/use-layout.test.js.map +0 -1
  256. package/dist/web/plugin/data-llm.test.js +0 -81
  257. package/dist/web/plugin/data-llm.test.js.map +0 -1
  258. package/dist/web/plugin/plugin.d.ts +0 -39
  259. package/dist/web/plugin/plugin.js +0 -189
  260. package/dist/web/plugin/plugin.js.map +0 -1
  261. package/dist/web/plugin/scan-views.js.map +0 -1
  262. package/dist/web/plugin/scan-views.test.js.map +0 -1
  263. package/dist/web/plugin/transform-data-llm.d.ts +0 -12
  264. package/dist/web/plugin/transform-data-llm.js +0 -96
  265. package/dist/web/plugin/transform-data-llm.js.map +0 -1
  266. package/dist/web/plugin/transform-data-llm.test.js +0 -81
  267. package/dist/web/plugin/transform-data-llm.test.js.map +0 -1
  268. package/dist/web/plugin/validate-view.d.ts +0 -1
  269. package/dist/web/plugin/validate-view.js.map +0 -1
  270. package/dist/web/plugin/validate-view.test.js.map +0 -1
  271. /package/dist/{web/hooks/use-layout.test.d.ts → context-warnings.test.d.ts} +0 -0
  272. /package/dist/{web/plugin/data-llm.test.d.ts → server/app.test.d.ts} +0 -0
  273. /package/dist/{web/plugin/transform-data-llm.test.d.ts → server/auth/providers/authplane.test.d.ts} +0 -0
  274. /package/dist/{web/plugin/scan-views.test.d.ts → server/auth-extra.test-d.d.ts} +0 -0
  275. /package/dist/{web/plugin/validate-view.test.d.ts → server/mcp-errors.test.d.ts} +0 -0
  276. /package/dist/{web/plugin → views}/scan-views.d.ts +0 -0
  277. /package/dist/{web/plugin → views}/scan-views.test.js +0 -0
  278. /package/dist/{web/plugin → views}/validate-view.test.js +0 -0
@@ -3,13 +3,13 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
3
3
  import { HostAdaptor } from "../bridges/adaptor.js";
4
4
  import { McpAppBridge } from "../bridges/mcp-app/bridge.js";
5
5
  import { getMcpAppHostPostMessageMock, MockResizeObserver, } from "./test/utils.js";
6
- import { useLayout } from "./use-layout.js";
7
- describe("useLayout", () => {
6
+ import { useViewport } from "./use-viewport.js";
7
+ describe("useViewport", () => {
8
8
  describe("apps-sdk host type", () => {
9
9
  beforeEach(() => {
10
10
  HostAdaptor.resetInstance();
11
11
  McpAppBridge.resetInstance();
12
- vi.stubGlobal("skybridge", { hostType: "apps-sdk" });
12
+ vi.stubGlobal("skybridge", {});
13
13
  vi.stubGlobal("openai", { view: { mode: "inline" } });
14
14
  vi.stubGlobal("ResizeObserver", MockResizeObserver);
15
15
  });
@@ -19,45 +19,29 @@ describe("useLayout", () => {
19
19
  McpAppBridge.resetInstance();
20
20
  HostAdaptor.resetInstance();
21
21
  });
22
- it("should return theme, maxHeight, and safeArea from mcp host context", async () => {
22
+ it("should return maxHeight and safeArea from mcp host context", async () => {
23
23
  vi.stubGlobal("parent", {
24
24
  postMessage: getMcpAppHostPostMessageMock({
25
- theme: "light",
26
25
  containerDimensions: { maxHeight: 500, width: 400 },
27
26
  safeAreaInsets: { top: 0, bottom: 0, left: 0, right: 0 },
28
27
  }),
29
28
  });
30
- const { result } = renderHook(() => useLayout());
29
+ const { result } = renderHook(() => useViewport());
31
30
  await waitFor(() => {
32
- expect(result.current.theme).toBe("light");
33
31
  expect(result.current.maxHeight).toBe(500);
34
32
  expect(result.current.safeArea).toEqual({
35
33
  insets: { top: 0, bottom: 0, left: 0, right: 0 },
36
34
  });
37
35
  });
38
36
  });
39
- it("should return dark theme when set to dark", async () => {
40
- vi.stubGlobal("parent", {
41
- postMessage: getMcpAppHostPostMessageMock({
42
- theme: "dark",
43
- containerDimensions: { maxHeight: 500, width: 400 },
44
- safeAreaInsets: { top: 0, bottom: 0, left: 0, right: 0 },
45
- }),
46
- });
47
- const { result } = renderHook(() => useLayout());
48
- await waitFor(() => {
49
- expect(result.current.theme).toBe("dark");
50
- });
51
- });
52
37
  it("should return different maxHeight when set", async () => {
53
38
  vi.stubGlobal("parent", {
54
39
  postMessage: getMcpAppHostPostMessageMock({
55
- theme: "light",
56
40
  containerDimensions: { maxHeight: 800, width: 400 },
57
41
  safeAreaInsets: { top: 0, bottom: 0, left: 0, right: 0 },
58
42
  }),
59
43
  });
60
- const { result } = renderHook(() => useLayout());
44
+ const { result } = renderHook(() => useViewport());
61
45
  await waitFor(() => {
62
46
  expect(result.current.maxHeight).toBe(800);
63
47
  });
@@ -65,12 +49,11 @@ describe("useLayout", () => {
65
49
  it("should return safeArea with insets when set", async () => {
66
50
  vi.stubGlobal("parent", {
67
51
  postMessage: getMcpAppHostPostMessageMock({
68
- theme: "light",
69
52
  containerDimensions: { maxHeight: 500, width: 400 },
70
53
  safeAreaInsets: { top: 44, bottom: 34, left: 0, right: 0 },
71
54
  }),
72
55
  });
73
- const { result } = renderHook(() => useLayout());
56
+ const { result } = renderHook(() => useViewport());
74
57
  await waitFor(() => {
75
58
  expect(result.current.safeArea.insets.top).toBe(44);
76
59
  expect(result.current.safeArea.insets.bottom).toBe(34);
@@ -81,7 +64,7 @@ describe("useLayout", () => {
81
64
  beforeEach(() => {
82
65
  HostAdaptor.resetInstance();
83
66
  McpAppBridge.resetInstance();
84
- vi.stubGlobal("skybridge", { hostType: "mcp-app" });
67
+ vi.stubGlobal("skybridge", {});
85
68
  vi.stubGlobal("openai", undefined);
86
69
  vi.stubGlobal("ResizeObserver", MockResizeObserver);
87
70
  });
@@ -91,17 +74,15 @@ describe("useLayout", () => {
91
74
  McpAppBridge.resetInstance();
92
75
  HostAdaptor.resetInstance();
93
76
  });
94
- it("should return theme, maxHeight, and safeArea from mcp host context", async () => {
77
+ it("should return maxHeight and safeArea from mcp host context", async () => {
95
78
  vi.stubGlobal("parent", {
96
79
  postMessage: getMcpAppHostPostMessageMock({
97
- theme: "dark",
98
80
  containerDimensions: { maxHeight: 800, width: 400 },
99
81
  safeAreaInsets: { top: 20, right: 0, bottom: 34, left: 0 },
100
82
  }),
101
83
  });
102
- const { result } = renderHook(() => useLayout());
84
+ const { result } = renderHook(() => useViewport());
103
85
  await waitFor(() => {
104
- expect(result.current.theme).toBe("dark");
105
86
  expect(result.current.maxHeight).toBe(800);
106
87
  expect(result.current.safeArea).toEqual({
107
88
  insets: { top: 20, right: 0, bottom: 34, left: 0 },
@@ -111,12 +92,11 @@ describe("useLayout", () => {
111
92
  it("should maintain safeArea referential stability when data has not changed", async () => {
112
93
  vi.stubGlobal("parent", {
113
94
  postMessage: getMcpAppHostPostMessageMock({
114
- theme: "light",
115
95
  containerDimensions: { maxHeight: 500, width: 400 },
116
96
  safeAreaInsets: { top: 44, right: 0, bottom: 34, left: 0 },
117
97
  }),
118
98
  });
119
- const { result, rerender } = renderHook(() => useLayout());
99
+ const { result, rerender } = renderHook(() => useViewport());
120
100
  await waitFor(() => {
121
101
  expect(result.current.safeArea).toBeDefined();
122
102
  });
@@ -126,4 +106,4 @@ describe("useLayout", () => {
126
106
  });
127
107
  });
128
108
  });
129
- //# sourceMappingURL=use-layout.test.js.map
109
+ //# sourceMappingURL=use-viewport.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-viewport.test.js","sourceRoot":"","sources":["../../../src/web/hooks/use-viewport.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EACL,4BAA4B,EAC5B,kBAAkB,GACnB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IAC3B,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;QAClC,UAAU,CAAC,GAAG,EAAE;YACd,WAAW,CAAC,aAAa,EAAE,CAAC;YAC5B,YAAY,CAAC,aAAa,EAAE,CAAC;YAC7B,EAAE,CAAC,UAAU,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;YAC/B,EAAE,CAAC,UAAU,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC;YACtD,EAAE,CAAC,UAAU,CA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AC,QAAQ,CAAC,CAAC,OAAO,CAAC;oBACtC,MAAM,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE;iBACnD,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,0EAA0E,EAAE,KAAK,IAAI,EAAE;YACxF,EAAE,CAAC,UAAU,CAAC,QAAQ,EAAE;gBACtB,WAAW,EAAE,4BAA4B,CAAC;oBACxC,mBAAmB,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE;oBACnD,cAAc,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE;iBAC3D,CAAC;aACH,CAAC,CAAC;YACH,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC;YAE7D,MAAM,OAAO,CAAC,GAAG,EAAE;gBACjB,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,WAAW,EAAE,CAAC;YAChD,CAAC,CAAC,CAAC;YAEH,MAAM,eAAe,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC;YAEhD,QAAQ,EAAE,CAAC;YAEX,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QACxD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { renderHook, waitFor } from \"@testing-library/react\";\nimport { afterEach, beforeEach, describe, expect, it, vi } from \"vitest\";\nimport { HostAdaptor } from \"../bridges/adaptor.js\";\nimport { McpAppBridge } from \"../bridges/mcp-app/bridge.js\";\nimport {\n getMcpAppHostPostMessageMock,\n MockResizeObserver,\n} from \"./test/utils.js\";\nimport { useViewport } from \"./use-viewport.js\";\n\ndescribe(\"useViewport\", () => {\n describe(\"apps-sdk host type\", () => {\n beforeEach(() => {\n HostAdaptor.resetInstance();\n McpAppBridge.resetInstance();\n vi.stubGlobal(\"skybridge\", {});\n vi.stubGlobal(\"openai\", { view: { mode: \"inline\" } });\n vi.stubGlobal(\"ResizeObserver\", MockResizeObserver);\n });\n\n afterEach(() => {\n vi.unstubAllGlobals();\n vi.resetAllMocks();\n McpAppBridge.resetInstance();\n HostAdaptor.resetInstance();\n });\n\n it(\"should return maxHeight and safeArea from mcp host context\", async () => {\n vi.stubGlobal(\"parent\", {\n postMessage: getMcpAppHostPostMessageMock({\n containerDimensions: { maxHeight: 500, width: 400 },\n safeAreaInsets: { top: 0, bottom: 0, left: 0, right: 0 },\n }),\n });\n const { result } = renderHook(() => useViewport());\n\n await waitFor(() => {\n expect(result.current.maxHeight).toBe(500);\n expect(result.current.safeArea).toEqual({\n insets: { top: 0, bottom: 0, left: 0, right: 0 },\n });\n });\n });\n\n it(\"should return different maxHeight when set\", async () => {\n vi.stubGlobal(\"parent\", {\n postMessage: getMcpAppHostPostMessageMock({\n containerDimensions: { maxHeight: 800, width: 400 },\n safeAreaInsets: { top: 0, bottom: 0, left: 0, right: 0 },\n }),\n });\n const { result } = renderHook(() => useViewport());\n\n await waitFor(() => {\n expect(result.current.maxHeight).toBe(800);\n });\n });\n\n it(\"should return safeArea with insets when set\", async () => {\n vi.stubGlobal(\"parent\", {\n postMessage: getMcpAppHostPostMessageMock({\n containerDimensions: { maxHeight: 500, width: 400 },\n safeAreaInsets: { top: 44, bottom: 34, left: 0, right: 0 },\n }),\n });\n const { result } = renderHook(() => useViewport());\n\n await waitFor(() => {\n expect(result.current.safeArea.insets.top).toBe(44);\n expect(result.current.safeArea.insets.bottom).toBe(34);\n });\n });\n });\n\n describe(\"mcp-app host type\", () => {\n beforeEach(() => {\n HostAdaptor.resetInstance();\n McpAppBridge.resetInstance();\n vi.stubGlobal(\"skybridge\", {});\n vi.stubGlobal(\"openai\", undefined);\n vi.stubGlobal(\"ResizeObserver\", MockResizeObserver);\n });\n\n afterEach(async () => {\n vi.unstubAllGlobals();\n vi.resetAllMocks();\n McpAppBridge.resetInstance();\n HostAdaptor.resetInstance();\n });\n\n it(\"should return maxHeight and safeArea from mcp host context\", async () => {\n vi.stubGlobal(\"parent\", {\n postMessage: getMcpAppHostPostMessageMock({\n containerDimensions: { maxHeight: 800, width: 400 },\n safeAreaInsets: { top: 20, right: 0, bottom: 34, left: 0 },\n }),\n });\n const { result } = renderHook(() => useViewport());\n\n await waitFor(() => {\n expect(result.current.maxHeight).toBe(800);\n expect(result.current.safeArea).toEqual({\n insets: { top: 20, right: 0, bottom: 34, left: 0 },\n });\n });\n });\n\n it(\"should maintain safeArea referential stability when data has not changed\", async () => {\n vi.stubGlobal(\"parent\", {\n postMessage: getMcpAppHostPostMessageMock({\n containerDimensions: { maxHeight: 500, width: 400 },\n safeAreaInsets: { top: 44, right: 0, bottom: 34, left: 0 },\n }),\n });\n const { result, rerender } = renderHook(() => useViewport());\n\n await waitFor(() => {\n expect(result.current.safeArea).toBeDefined();\n });\n\n const initialSafeArea = result.current.safeArea;\n\n rerender();\n\n expect(result.current.safeArea).toBe(initialSafeArea);\n });\n });\n});\n"]}
@@ -1,6 +1,7 @@
1
1
  /**
2
- * Mount a view's root React component into `#root`. Each view file's entry
3
- * point should call this exactly once.
2
+ * Mount a view's root React component into `#root`. The Vite plugin
3
+ * auto-mounts every view, so apps normally never call this themselves —
4
+ * it is the entry point the generated view wrappers use.
4
5
  *
5
6
  * Wraps the component in `StrictMode`, applies host-specific providers
6
7
  * automatically (e.g. modal support for MCP Apps), and installs the dev-mode
@@ -4,8 +4,9 @@ import { createRoot } from "react-dom/client";
4
4
  import { installOpenAILoggingProxy } from "./proxy.js";
5
5
  let rootInstance = null;
6
6
  /**
7
- * Mount a view's root React component into `#root`. Each view file's entry
8
- * point should call this exactly once.
7
+ * Mount a view's root React component into `#root`. The Vite plugin
8
+ * auto-mounts every view, so apps normally never call this themselves —
9
+ * it is the entry point the generated view wrappers use.
9
10
  *
10
11
  * Wraps the component in `StrictMode`, applies host-specific providers
11
12
  * automatically (e.g. modal support for MCP Apps), and installs the dev-mode
@@ -33,13 +34,9 @@ export const mountView = (component) => {
33
34
  if (import.meta.env.DEV) {
34
35
  installOpenAILoggingProxy();
35
36
  }
36
- const hostType = window.skybridge?.hostType;
37
37
  (async () => {
38
- let app = component;
39
- if (hostType === "mcp-app") {
40
- const { ModalProvider } = await import("./components/modal-provider.js");
41
- app = createElement(ModalProvider, null, component);
42
- }
38
+ const { ModalProvider } = await import("./components/modal-provider.js");
39
+ const app = createElement(ModalProvider, null, component);
43
40
  rootInstance.render(createElement(StrictMode, null, app));
44
41
  })();
45
42
  };
@@ -1 +1 @@
1
- {"version":3,"file":"mount-view.js","sourceRoot":"","sources":["../../src/web/mount-view.ts"],"names":[],"mappings":"AAAA,qCAAqC;AAErC,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAClD,OAAO,EAAE,UAAU,EAAa,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAEvD,IAAI,YAAY,GAAgB,IAAI,CAAC;AAErC;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,SAA0B,EAAE,EAAE;IACtD,MAAM,WAAW,GAAG,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;IACpD,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAC5C,CAAC;IAED,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,YAAY,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC;IACzC,CAAC;IAED,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;QACxB,yBAAyB,EAAE,CAAC;IAC9B,CAAC;IAED,MAAM,QAAQ,GAAG,MAAM,CAAC,SAAS,EAAE,QAAQ,CAAC;IAE5C,CAAC,KAAK,IAAI,EAAE;QACV,IAAI,GAAG,GAAG,SAAS,CAAC;QACpB,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC3B,MAAM,EAAE,aAAa,EAAE,GAAG,MAAM,MAAM,CAAC,gCAAgC,CAAC,CAAC;YACzE,GAAG,GAAG,aAAa,CAAC,aAAa,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC;QACtD,CAAC;QACD,YAAY,CAAC,MAAM,CAAC,aAAa,CAAC,UAAU,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;IAC5D,CAAC,CAAC,EAAE,CAAC;AACP,CAAC,CAAC","sourcesContent":["/// <reference types=\"vite/client\" />\n\nimport { createElement, StrictMode } from \"react\";\nimport { createRoot, type Root } from \"react-dom/client\";\nimport { installOpenAILoggingProxy } from \"./proxy.js\";\n\nlet rootInstance: Root | null = null;\n\n/**\n * Mount a view's root React component into `#root`. Each view file's entry\n * point should call this exactly once.\n *\n * Wraps the component in `StrictMode`, applies host-specific providers\n * automatically (e.g. modal support for MCP Apps), and installs the dev-mode\n * logging proxy for `window.openai` calls.\n *\n * @param component - Your root React element (already constructed, e.g. `<App />`).\n *\n * @example\n * ```tsx\n * // src/views/search.tsx\n * import { mountView } from \"skybridge/web\";\n * import { App } from \"./App\";\n *\n * mountView(<App />);\n * ```\n */\nexport const mountView = (component: React.ReactNode) => {\n const rootElement = document.getElementById(\"root\");\n if (!rootElement) {\n throw new Error(\"Root element not found\");\n }\n\n if (!rootInstance) {\n rootInstance = createRoot(rootElement);\n }\n\n if (import.meta.env.DEV) {\n installOpenAILoggingProxy();\n }\n\n const hostType = window.skybridge?.hostType;\n\n (async () => {\n let app = component;\n if (hostType === \"mcp-app\") {\n const { ModalProvider } = await import(\"./components/modal-provider.js\");\n app = createElement(ModalProvider, null, component);\n }\n rootInstance.render(createElement(StrictMode, null, app));\n })();\n};\n"]}
1
+ {"version":3,"file":"mount-view.js","sourceRoot":"","sources":["../../src/web/mount-view.ts"],"names":[],"mappings":"AAAA,qCAAqC;AAErC,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAClD,OAAO,EAAE,UAAU,EAAa,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAEvD,IAAI,YAAY,GAAgB,IAAI,CAAC;AAErC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,SAA0B,EAAE,EAAE;IACtD,MAAM,WAAW,GAAG,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;IACpD,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAC5C,CAAC;IAED,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,YAAY,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC;IACzC,CAAC;IAED,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;QACxB,yBAAyB,EAAE,CAAC;IAC9B,CAAC;IAED,CAAC,KAAK,IAAI,EAAE;QACV,MAAM,EAAE,aAAa,EAAE,GAAG,MAAM,MAAM,CAAC,gCAAgC,CAAC,CAAC;QACzE,MAAM,GAAG,GAAG,aAAa,CAAC,aAAa,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC;QAC1D,YAAY,CAAC,MAAM,CAAC,aAAa,CAAC,UAAU,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;IAC5D,CAAC,CAAC,EAAE,CAAC;AACP,CAAC,CAAC","sourcesContent":["/// <reference types=\"vite/client\" />\n\nimport { createElement, StrictMode } from \"react\";\nimport { createRoot, type Root } from \"react-dom/client\";\nimport { installOpenAILoggingProxy } from \"./proxy.js\";\n\nlet rootInstance: Root | null = null;\n\n/**\n * Mount a view's root React component into `#root`. The Vite plugin\n * auto-mounts every view, so apps normally never call this themselves —\n * it is the entry point the generated view wrappers use.\n *\n * Wraps the component in `StrictMode`, applies host-specific providers\n * automatically (e.g. modal support for MCP Apps), and installs the dev-mode\n * logging proxy for `window.openai` calls.\n *\n * @param component - Your root React element (already constructed, e.g. `<App />`).\n *\n * @example\n * ```tsx\n * // src/views/search.tsx\n * import { mountView } from \"skybridge/web\";\n * import { App } from \"./App\";\n *\n * mountView(<App />);\n * ```\n */\nexport const mountView = (component: React.ReactNode) => {\n const rootElement = document.getElementById(\"root\");\n if (!rootElement) {\n throw new Error(\"Root element not found\");\n }\n\n if (!rootInstance) {\n rootInstance = createRoot(rootElement);\n }\n\n if (import.meta.env.DEV) {\n installOpenAILoggingProxy();\n }\n\n (async () => {\n const { ModalProvider } = await import(\"./components/modal-provider.js\");\n const app = createElement(ModalProvider, null, component);\n rootInstance.render(createElement(StrictMode, null, app));\n })();\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skybridge",
3
- "version": "0.0.0-dev.efe5a46",
3
+ "version": "0.0.0-dev.effc12c",
4
4
  "description": "Skybridge is a framework for building ChatGPT and MCP Apps",
5
5
  "repository": {
6
6
  "type": "git",
@@ -27,9 +27,9 @@
27
27
  "types": "./dist/web/index.d.ts",
28
28
  "default": "./dist/web/index.js"
29
29
  },
30
- "./vite": {
31
- "types": "./dist/web/plugin/plugin.d.ts",
32
- "default": "./dist/web/plugin/plugin.js"
30
+ "./views": {
31
+ "types": "./dist/views/index.d.ts",
32
+ "default": "./dist/views/index.js"
33
33
  }
34
34
  },
35
35
  "keywords": [
@@ -41,22 +41,25 @@
41
41
  "author": "Frédéric Barthelet",
42
42
  "license": "ISC",
43
43
  "peerDependencies": {
44
- "@modelcontextprotocol/sdk": ">=1.27.0",
45
- "@skybridge/devtools": "^1.1.0",
44
+ "@skybridge/devtools": "^2.0.0",
46
45
  "nodemon": ">=3.0.0",
47
46
  "react": ">=18.0.0",
48
47
  "react-dom": ">=18.0.0",
49
- "vite": ">=7.3.1"
48
+ "vite": ">=7.3.1",
49
+ "zod": "^4.2.0"
50
50
  },
51
51
  "dependencies": {
52
- "@babel/core": "^7.29.7",
52
+ "@modelcontextprotocol/core": "^2.0.0",
53
53
  "@modelcontextprotocol/ext-apps": "^1.7.4",
54
+ "@modelcontextprotocol/express": "^2.0.0",
55
+ "@modelcontextprotocol/node": "^2.0.0",
56
+ "@modelcontextprotocol/sdk": "^1.29.0",
57
+ "@modelcontextprotocol/server": "^2.0.0",
54
58
  "@oclif/core": "^4.11.14",
55
59
  "ci-info": "^4.4.0",
56
60
  "cors": "^2.8.6",
57
61
  "cross-spawn": "^7.0.6",
58
62
  "dequal": "^2.0.3",
59
- "es-toolkit": "^1.49.0",
60
63
  "esbuild": "^0.28.1",
61
64
  "express": "^5.2.1",
62
65
  "handlebars": "^4.7.9",
@@ -69,11 +72,10 @@
69
72
  "zustand": "^5.0.14"
70
73
  },
71
74
  "devDependencies": {
72
- "@modelcontextprotocol/sdk": "^1.29.0",
75
+ "@modelcontextprotocol/client": "^2.0.0",
73
76
  "@testing-library/dom": "^10.4.1",
74
77
  "@testing-library/react": "^16.3.2",
75
78
  "@total-typescript/tsconfig": "^1.0.4",
76
- "@types/babel__core": "^7.20.5",
77
79
  "@types/cors": "^2.8.19",
78
80
  "@types/cross-spawn": "^6.0.6",
79
81
  "@types/express": "^5.0.6",
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-host-info.js","sourceRoot":"","sources":["../../../src/web/hooks/use-host-info.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAcvD,MAAM,qBAAqB,GAAyB;IAClD,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,QAAQ;IAChB,MAAM,EAAE,QAAQ;IAChB,aAAa,EAAE,OAAO;IACtB,SAAS,EAAE,cAAc;IACzB,kBAAkB,EAAE,OAAO;CAC5B,CAAC;AAOF;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,WAAW;IACzB,MAAM,QAAQ,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAAC;IAC9C,MAAM,IAAI,GAAG,QAAQ,EAAE,IAAI,CAAC;IAE5B,OAAO;QACL,IAAI,EACF,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS;QACxE,OAAO,EAAE,QAAQ,EAAE,OAAO;KAC3B,CAAC;AACJ,CAAC","sourcesContent":["import { useMcpAppContext } from \"../bridges/index.js\";\n\n/**\n * Known host applications, as normalized slugs. Unrecognized hosts surface\n * their raw `hostInfo.name` string instead.\n */\nexport type Host =\n | \"chatgpt\"\n | \"claude\"\n | \"cursor\"\n | \"goose\"\n | \"mistral-vibe\"\n | \"alpic\";\n\nconst HOST_BY_REPORTED_NAME: Record<string, Host> = {\n chatgpt: \"chatgpt\",\n Claude: \"claude\",\n Cursor: \"cursor\",\n \"MCP-UI Host\": \"goose\",\n \"Le Chat\": \"mistral-vibe\",\n \"alpic-playground\": \"alpic\",\n};\n\nexport type HostInfo = {\n name: Host | (string & {}) | undefined;\n version: string | undefined;\n};\n\n/**\n * Identity of the host application rendering the view, from the MCP Apps\n * `ui/initialize` handshake. `name` is normalized to a {@link Host} slug when\n * recognized, otherwise the raw string; both fields are `undefined` until the\n * handshake resolves (the view renders first and re-renders once it lands).\n *\n * @example\n * ```tsx\n * const { name } = useHostInfo();\n * if (name === \"claude\") return <ClaudeLayout />;\n * ```\n */\nexport function useHostInfo(): HostInfo {\n const hostInfo = useMcpAppContext(\"hostInfo\");\n const name = hostInfo?.name;\n\n return {\n name:\n name !== undefined ? (HOST_BY_REPORTED_NAME[name] ?? name) : undefined,\n version: hostInfo?.version,\n };\n}\n"]}
@@ -1,24 +0,0 @@
1
- import { type SafeArea, type Theme } from "../bridges/index.js";
2
- export type LayoutState = {
3
- theme: Theme;
4
- maxHeight: number | undefined;
5
- safeArea: SafeArea;
6
- };
7
- /**
8
- * Hook for accessing layout and visual environment information.
9
- * These values may change on resize or theme toggle.
10
- *
11
- * @example
12
- * ```tsx
13
- * const { theme, maxHeight, safeArea } = useLayout();
14
- *
15
- * // Apply theme-aware styling
16
- * const backgroundColor = theme === "dark" ? "#1a1a1a" : "#ffffff";
17
- *
18
- * // Respect safe area insets
19
- * const paddingTop = safeArea.insets.top;
20
- * ```
21
- *
22
- * @see https://docs.skybridge.tech/api-reference/use-layout
23
- */
24
- export declare function useLayout(): LayoutState;
@@ -1,25 +0,0 @@
1
- import { useHostContext } from "../bridges/index.js";
2
- /**
3
- * Hook for accessing layout and visual environment information.
4
- * These values may change on resize or theme toggle.
5
- *
6
- * @example
7
- * ```tsx
8
- * const { theme, maxHeight, safeArea } = useLayout();
9
- *
10
- * // Apply theme-aware styling
11
- * const backgroundColor = theme === "dark" ? "#1a1a1a" : "#ffffff";
12
- *
13
- * // Respect safe area insets
14
- * const paddingTop = safeArea.insets.top;
15
- * ```
16
- *
17
- * @see https://docs.skybridge.tech/api-reference/use-layout
18
- */
19
- export function useLayout() {
20
- const theme = useHostContext("theme");
21
- const maxHeight = useHostContext("maxHeight");
22
- const safeArea = useHostContext("safeArea");
23
- return { theme, maxHeight, safeArea };
24
- }
25
- //# sourceMappingURL=use-layout.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-layout.js","sourceRoot":"","sources":["../../../src/web/hooks/use-layout.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6B,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAQhF;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,SAAS;IACvB,MAAM,KAAK,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC;IACtC,MAAM,SAAS,GAAG,cAAc,CAAC,WAAW,CAAC,CAAC;IAC9C,MAAM,QAAQ,GAAG,cAAc,CAAC,UAAU,CAAC,CAAC;IAE5C,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC;AACxC,CAAC","sourcesContent":["import { type SafeArea, type Theme, useHostContext } from \"../bridges/index.js\";\n\nexport type LayoutState = {\n theme: Theme;\n maxHeight: number | undefined;\n safeArea: SafeArea;\n};\n\n/**\n * Hook for accessing layout and visual environment information.\n * These values may change on resize or theme toggle.\n *\n * @example\n * ```tsx\n * const { theme, maxHeight, safeArea } = useLayout();\n *\n * // Apply theme-aware styling\n * const backgroundColor = theme === \"dark\" ? \"#1a1a1a\" : \"#ffffff\";\n *\n * // Respect safe area insets\n * const paddingTop = safeArea.insets.top;\n * ```\n *\n * @see https://docs.skybridge.tech/api-reference/use-layout\n */\nexport function useLayout(): LayoutState {\n const theme = useHostContext(\"theme\");\n const maxHeight = useHostContext(\"maxHeight\");\n const safeArea = useHostContext(\"safeArea\");\n\n return { theme, maxHeight, safeArea };\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-layout.test.js","sourceRoot":"","sources":["../../../src/web/hooks/use-layout.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EACL,4BAA4B,EAC5B,kBAAkB,GACnB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;IACzB,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;QAClC,UAAU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AAM,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC;oBACtC,MAAM,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE;iBACnD,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,0EAA0E,EAAE,KAAK,IAAI,EAAE;YACxF,EAAE,CAAC,UAAU,CAAC,QAAQ,EAAE;gBACtB,WAAW,EAAE,4BAA4B,CAAC;oBACxC,KAAK,EAAE,OAAO;oBACd,mBAAmB,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE;oBACnD,cAAc,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE;iBAC3D,CAAC;aACH,CAAC,CAAC;YACH,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,SAAS,EAAE,CAAC,CAAC;YAE3D,MAAM,OAAO,CAAC,GAAG,EAAE;gBACjB,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,WAAW,EAAE,CAAC;YAChD,CAAC,CAAC,CAAC;YAEH,MAAM,eAAe,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC;YAEhD,QAAQ,EAAE,CAAC;YAEX,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QACxD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { renderHook, waitFor } from \"@testing-library/react\";\nimport { afterEach, beforeEach, describe, expect, it, vi } from \"vitest\";\nimport { HostAdaptor } from \"../bridges/adaptor.js\";\nimport { McpAppBridge } from \"../bridges/mcp-app/bridge.js\";\nimport {\n getMcpAppHostPostMessageMock,\n MockResizeObserver,\n} from \"./test/utils.js\";\nimport { useLayout } from \"./use-layout.js\";\n\ndescribe(\"useLayout\", () => {\n describe(\"apps-sdk host type\", () => {\n beforeEach(() => {\n HostAdaptor.resetInstance();\n McpAppBridge.resetInstance();\n vi.stubGlobal(\"skybridge\", { hostType: \"apps-sdk\" });\n vi.stubGlobal(\"openai\", { view: { mode: \"inline\" } });\n vi.stubGlobal(\"ResizeObserver\", MockResizeObserver);\n });\n\n afterEach(() => {\n vi.unstubAllGlobals();\n vi.resetAllMocks();\n McpAppBridge.resetInstance();\n HostAdaptor.resetInstance();\n });\n\n it(\"should return theme, maxHeight, and safeArea from mcp host context\", async () => {\n vi.stubGlobal(\"parent\", {\n postMessage: getMcpAppHostPostMessageMock({\n theme: \"light\",\n containerDimensions: { maxHeight: 500, width: 400 },\n safeAreaInsets: { top: 0, bottom: 0, left: 0, right: 0 },\n }),\n });\n const { result } = renderHook(() => useLayout());\n\n await waitFor(() => {\n expect(result.current.theme).toBe(\"light\");\n expect(result.current.maxHeight).toBe(500);\n expect(result.current.safeArea).toEqual({\n insets: { top: 0, bottom: 0, left: 0, right: 0 },\n });\n });\n });\n\n it(\"should return dark theme when set to dark\", async () => {\n vi.stubGlobal(\"parent\", {\n postMessage: getMcpAppHostPostMessageMock({\n theme: \"dark\",\n containerDimensions: { maxHeight: 500, width: 400 },\n safeAreaInsets: { top: 0, bottom: 0, left: 0, right: 0 },\n }),\n });\n const { result } = renderHook(() => useLayout());\n\n await waitFor(() => {\n expect(result.current.theme).toBe(\"dark\");\n });\n });\n\n it(\"should return different maxHeight when set\", async () => {\n vi.stubGlobal(\"parent\", {\n postMessage: getMcpAppHostPostMessageMock({\n theme: \"light\",\n containerDimensions: { maxHeight: 800, width: 400 },\n safeAreaInsets: { top: 0, bottom: 0, left: 0, right: 0 },\n }),\n });\n const { result } = renderHook(() => useLayout());\n\n await waitFor(() => {\n expect(result.current.maxHeight).toBe(800);\n });\n });\n\n it(\"should return safeArea with insets when set\", async () => {\n vi.stubGlobal(\"parent\", {\n postMessage: getMcpAppHostPostMessageMock({\n theme: \"light\",\n containerDimensions: { maxHeight: 500, width: 400 },\n safeAreaInsets: { top: 44, bottom: 34, left: 0, right: 0 },\n }),\n });\n const { result } = renderHook(() => useLayout());\n\n await waitFor(() => {\n expect(result.current.safeArea.insets.top).toBe(44);\n expect(result.current.safeArea.insets.bottom).toBe(34);\n });\n });\n });\n\n describe(\"mcp-app host type\", () => {\n beforeEach(() => {\n HostAdaptor.resetInstance();\n McpAppBridge.resetInstance();\n vi.stubGlobal(\"skybridge\", { hostType: \"mcp-app\" });\n vi.stubGlobal(\"openai\", undefined);\n vi.stubGlobal(\"ResizeObserver\", MockResizeObserver);\n });\n\n afterEach(async () => {\n vi.unstubAllGlobals();\n vi.resetAllMocks();\n McpAppBridge.resetInstance();\n HostAdaptor.resetInstance();\n });\n\n it(\"should return theme, maxHeight, and safeArea from mcp host context\", async () => {\n vi.stubGlobal(\"parent\", {\n postMessage: getMcpAppHostPostMessageMock({\n theme: \"dark\",\n containerDimensions: { maxHeight: 800, width: 400 },\n safeAreaInsets: { top: 20, right: 0, bottom: 34, left: 0 },\n }),\n });\n const { result } = renderHook(() => useLayout());\n\n await waitFor(() => {\n expect(result.current.theme).toBe(\"dark\");\n expect(result.current.maxHeight).toBe(800);\n expect(result.current.safeArea).toEqual({\n insets: { top: 20, right: 0, bottom: 34, left: 0 },\n });\n });\n });\n\n it(\"should maintain safeArea referential stability when data has not changed\", async () => {\n vi.stubGlobal(\"parent\", {\n postMessage: getMcpAppHostPostMessageMock({\n theme: \"light\",\n containerDimensions: { maxHeight: 500, width: 400 },\n safeAreaInsets: { top: 44, right: 0, bottom: 34, left: 0 },\n }),\n });\n const { result, rerender } = renderHook(() => useLayout());\n\n await waitFor(() => {\n expect(result.current.safeArea).toBeDefined();\n });\n\n const initialSafeArea = result.current.safeArea;\n\n rerender();\n\n expect(result.current.safeArea).toBe(initialSafeArea);\n });\n });\n});\n"]}
@@ -1,81 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import { transform } from "./transform-data-llm.js";
3
- describe("data-llm plugin", () => {
4
- it("should transform JSX element with data-llm string attribute", async () => {
5
- const code = `
6
- function Component() {
7
- return <div data-llm="Test description">Content</div>;
8
- }
9
- `;
10
- const result = await transform(code, "test.tsx");
11
- expect(result).not.toBeNull();
12
- expect(result?.code).toContain("DataLLM");
13
- expect(result?.code).toContain('content="Test description"');
14
- expect(result?.code).not.toContain("data-llm");
15
- });
16
- it("should transform JSX element with data-llm expression attribute", async () => {
17
- const code = `
18
- function Component() {
19
- const desc = "Dynamic description";
20
- return <div data-llm={desc}>Content</div>;
21
- }
22
- `;
23
- const result = await transform(code, "test.tsx");
24
- expect(result).not.toBeNull();
25
- expect(result?.code).toContain("DataLLM");
26
- expect(result?.code).toContain("content={desc}");
27
- expect(result?.code).not.toContain("data-llm");
28
- });
29
- it("should add import for DataLLM when not present", async () => {
30
- const code = `
31
- function Component() {
32
- return <div data-llm="Test">Content</div>;
33
- }
34
- `;
35
- const result = await transform(code, "test.tsx");
36
- expect(result).not.toBeNull();
37
- expect(result?.code).toContain('import { DataLLM } from "skybridge/web"');
38
- });
39
- it("should handle DataLLM imports correctly", async () => {
40
- // No duplicate import
41
- const codeWithImport = `
42
- import { DataLLM } from "skybridge/web";
43
- function Component() {
44
- return <div data-llm="Test">Content</div>;
45
- }
46
- `;
47
- const result1 = await transform(codeWithImport, "test.tsx");
48
- expect(result1?.code.match(/import.*DataLLM.*from.*skybridge\/web/g)).toHaveLength(1);
49
- // Preserve other imports and add missing DataLLM
50
- const codeWithOthers = `
51
- import React from "react";
52
- import { useState } from "react";
53
- function Component() {
54
- return <div data-llm="Test">Content</div>;
55
- }
56
- `;
57
- const result2 = await transform(codeWithOthers, "test.tsx");
58
- expect(result2?.code).toContain('import React from "react"');
59
- expect(result2?.code).toContain('import { useState } from "react"');
60
- expect(result2?.code).toContain('import { DataLLM } from "skybridge/web"');
61
- });
62
- it("should handle complex JSX with multiple data-llm attributes", async () => {
63
- const code = `
64
- function Component() {
65
- return (
66
- <div>
67
- <section data-llm="Section 1">
68
- <p>Content 1</p>
69
- </section>
70
- <section data-llm="Section 2">
71
- <p>Content 2</p>
72
- </section>
73
- </div>
74
- );
75
- }
76
- `;
77
- const result = await transform(code, "test.tsx");
78
- expect(result).toMatchSnapshot();
79
- });
80
- });
81
- //# sourceMappingURL=data-llm.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"data-llm.test.js","sourceRoot":"","sources":["../../../src/web/plugin/data-llm.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC/B,EAAE,CAAC,6DAA6D,EAAE,KAAK,IAAI,EAAE;QAC3E,MAAM,IAAI,GAAG;;;;KAIZ,CAAC;QAEF,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QAEjD,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;QAC9B,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAC1C,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,SAAS,CAAC,4BAA4B,CAAC,CAAC;QAC7D,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;IACjD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,iEAAiE,EAAE,KAAK,IAAI,EAAE;QAC/E,MAAM,IAAI,GAAG;;;;;KAKZ,CAAC;QAEF,MAAM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2B,CAAC,CAAC;QAC7D,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,SAAS,CAAC,kCAAkC,CAAC,CAAC;QACpE,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,SAAS,CAAC,yCAAyC,CAAC,CAAC;IAC7E,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,6DAA6D,EAAE,KAAK,IAAI,EAAE;QAC3E,MAAM,IAAI,GAAG;;;;;;;;;;;;;KAaZ,CAAC;QAEF,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QAEjD,MAAM,CAAC,MAAM,CAAC,CAAC,eAAe,EAAE,CAAC;IACnC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { describe, expect, it } from \"vitest\";\nimport { transform } from \"./transform-data-llm.js\";\n\ndescribe(\"data-llm plugin\", () => {\n it(\"should transform JSX element with data-llm string attribute\", async () => {\n const code = `\n function Component() {\n return <div data-llm=\"Test description\">Content</div>;\n }\n `;\n\n const result = await transform(code, \"test.tsx\");\n\n expect(result).not.toBeNull();\n expect(result?.code).toContain(\"DataLLM\");\n expect(result?.code).toContain('content=\"Test description\"');\n expect(result?.code).not.toContain(\"data-llm\");\n });\n\n it(\"should transform JSX element with data-llm expression attribute\", async () => {\n const code = `\n function Component() {\n const desc = \"Dynamic description\";\n return <div data-llm={desc}>Content</div>;\n }\n `;\n\n const result = await transform(code, \"test.tsx\");\n\n expect(result).not.toBeNull();\n expect(result?.code).toContain(\"DataLLM\");\n expect(result?.code).toContain(\"content={desc}\");\n expect(result?.code).not.toContain(\"data-llm\");\n });\n\n it(\"should add import for DataLLM when not present\", async () => {\n const code = `\n function Component() {\n return <div data-llm=\"Test\">Content</div>;\n }\n `;\n\n const result = await transform(code, \"test.tsx\");\n\n expect(result).not.toBeNull();\n expect(result?.code).toContain('import { DataLLM } from \"skybridge/web\"');\n });\n\n it(\"should handle DataLLM imports correctly\", async () => {\n // No duplicate import\n const codeWithImport = `\n import { DataLLM } from \"skybridge/web\";\n function Component() {\n return <div data-llm=\"Test\">Content</div>;\n }\n `;\n const result1 = await transform(codeWithImport, \"test.tsx\");\n expect(\n result1?.code.match(/import.*DataLLM.*from.*skybridge\\/web/g),\n ).toHaveLength(1);\n\n // Preserve other imports and add missing DataLLM\n const codeWithOthers = `\n import React from \"react\";\n import { useState } from \"react\";\n function Component() {\n return <div data-llm=\"Test\">Content</div>;\n }\n `;\n const result2 = await transform(codeWithOthers, \"test.tsx\");\n expect(result2?.code).toContain('import React from \"react\"');\n expect(result2?.code).toContain('import { useState } from \"react\"');\n expect(result2?.code).toContain('import { DataLLM } from \"skybridge/web\"');\n });\n\n it(\"should handle complex JSX with multiple data-llm attributes\", async () => {\n const code = `\n function Component() {\n return (\n <div>\n <section data-llm=\"Section 1\">\n <p>Content 1</p>\n </section>\n <section data-llm=\"Section 2\">\n <p>Content 2</p>\n </section>\n </div>\n );\n }\n `;\n\n const result = await transform(code, \"test.tsx\");\n\n expect(result).toMatchSnapshot();\n });\n});\n"]}
@@ -1,39 +0,0 @@
1
- import type { Plugin } from "vite";
2
- /** Options for the {@link skybridge} Vite plugin. */
3
- export interface SkybridgePluginOptions {
4
- /** Directory scanned for view modules. Defaults to `"src/views"`. */
5
- viewsDir?: string;
6
- /**
7
- * Package names to leave unbundled when `skybridge build` bundles the server
8
- * for deployment. Use it for dependencies esbuild can't resolve or load —
9
- * typically optional native modules pulled in by a transitive dependency.
10
- */
11
- serverExternal?: string[];
12
- }
13
- /**
14
- * Vite plugin that wires a Skybridge project's view files into Vite.
15
- *
16
- * For each `.tsx` / `.jsx` file in `viewsDir` with a default export, the
17
- * plugin:
18
- * - exposes a virtual entry that calls {@link mountView} with the view's
19
- * default export,
20
- * - generates `.skybridge/views.d.ts` to augment {@link ViewNameRegistry} so
21
- * {@link ViewName} narrows to the actual view names,
22
- * - rewrites `<DataLLM>` JSX so the host can extract its content,
23
- * - warns in dev if a view file is missing a default export.
24
- *
25
- * Add it to your `vite.config.ts` alongside `@vitejs/plugin-react`.
26
- *
27
- * @example
28
- * ```ts
29
- * // vite.config.ts
30
- * import { defineConfig } from "vite";
31
- * import react from "@vitejs/plugin-react";
32
- * import { skybridge } from "skybridge/vite";
33
- *
34
- * export default defineConfig({
35
- * plugins: [react(), skybridge({ viewsDir: "src/views" })],
36
- * });
37
- * ```
38
- */
39
- export declare function skybridge(options?: SkybridgePluginOptions): Plugin;