skybridge 0.0.0-dev.ed29eee → 0.0.0-dev.ed38f16

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 (285) hide show
  1. package/README.md +8 -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 +2 -2
  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/telemetry.js +2 -0
  16. package/dist/cli/telemetry.js.map +1 -1
  17. package/dist/cli/use-execute-steps.d.ts +1 -1
  18. package/dist/cli/use-nodemon.d.ts +11 -1
  19. package/dist/cli/use-nodemon.js +30 -8
  20. package/dist/cli/use-nodemon.js.map +1 -1
  21. package/dist/cli/use-typescript-check.js +1 -1
  22. package/dist/cli/use-typescript-check.js.map +1 -1
  23. package/dist/commands/dev.js +4 -4
  24. package/dist/commands/dev.js.map +1 -1
  25. package/dist/commands/start.js +2 -2
  26. package/dist/commands/start.js.map +1 -1
  27. package/dist/server/app.d.ts +194 -0
  28. package/dist/server/app.js +266 -0
  29. package/dist/server/app.js.map +1 -0
  30. package/dist/server/app.test.js +97 -0
  31. package/dist/server/app.test.js.map +1 -0
  32. package/dist/server/auth/discovery.d.ts +2 -1
  33. package/dist/server/auth/discovery.js +2 -2
  34. package/dist/server/auth/discovery.js.map +1 -1
  35. package/dist/server/auth/index.d.ts +21 -17
  36. package/dist/server/auth/index.js.map +1 -1
  37. package/dist/server/auth/providers/auth0.d.ts +2 -2
  38. package/dist/server/auth/providers/auth0.js +13 -8
  39. package/dist/server/auth/providers/auth0.js.map +1 -1
  40. package/dist/server/auth/providers/auth0.test.js +1 -1
  41. package/dist/server/auth/providers/auth0.test.js.map +1 -1
  42. package/dist/server/auth/providers/authplane.d.ts +2 -2
  43. package/dist/server/auth/providers/authplane.js.map +1 -1
  44. package/dist/server/auth/providers/authplane.test.js +10 -7
  45. package/dist/server/auth/providers/authplane.test.js.map +1 -1
  46. package/dist/server/auth/providers/clerk.d.ts +2 -2
  47. package/dist/server/auth/providers/clerk.js.map +1 -1
  48. package/dist/server/auth/providers/clerk.test.js +1 -1
  49. package/dist/server/auth/providers/clerk.test.js.map +1 -1
  50. package/dist/server/auth/providers/custom.d.ts +8 -6
  51. package/dist/server/auth/providers/custom.js +5 -2
  52. package/dist/server/auth/providers/custom.js.map +1 -1
  53. package/dist/server/auth/providers/custom.test.js +13 -10
  54. package/dist/server/auth/providers/custom.test.js.map +1 -1
  55. package/dist/server/auth/providers/descope.d.ts +2 -2
  56. package/dist/server/auth/providers/descope.js.map +1 -1
  57. package/dist/server/auth/providers/descope.test.js +3 -3
  58. package/dist/server/auth/providers/descope.test.js.map +1 -1
  59. package/dist/server/auth/providers/stytch.d.ts +2 -2
  60. package/dist/server/auth/providers/stytch.js.map +1 -1
  61. package/dist/server/auth/providers/workos.d.ts +5 -4
  62. package/dist/server/auth/providers/workos.js +2 -1
  63. package/dist/server/auth/providers/workos.js.map +1 -1
  64. package/dist/server/auth/setup.d.ts +1 -1
  65. package/dist/server/auth/setup.js +3 -4
  66. package/dist/server/auth/setup.js.map +1 -1
  67. package/dist/server/auth/setup.test.js +83 -77
  68. package/dist/server/auth/setup.test.js.map +1 -1
  69. package/dist/server/auth/verify.d.ts +5 -3
  70. package/dist/server/auth/verify.js +2 -2
  71. package/dist/server/auth/verify.js.map +1 -1
  72. package/dist/server/auth/verify.test.js +16 -0
  73. package/dist/server/auth/verify.test.js.map +1 -1
  74. package/dist/server/auth-extra.test-d.js +97 -49
  75. package/dist/server/auth-extra.test-d.js.map +1 -1
  76. package/dist/server/auth.d.ts +7 -8
  77. package/dist/server/auth.js +4 -5
  78. package/dist/server/auth.js.map +1 -1
  79. package/dist/server/build-manifest.test.js +7 -6
  80. package/dist/server/build-manifest.test.js.map +1 -1
  81. package/dist/server/content-helpers.d.ts +1 -1
  82. package/dist/server/content-helpers.js.map +1 -1
  83. package/dist/server/express.d.ts +23 -3
  84. package/dist/server/express.js +38 -32
  85. package/dist/server/express.js.map +1 -1
  86. package/dist/server/express.test.js +220 -103
  87. package/dist/server/express.test.js.map +1 -1
  88. package/dist/server/file-ref.d.ts +1 -1
  89. package/dist/server/file-ref.js +1 -1
  90. package/dist/server/file-ref.js.map +1 -1
  91. package/dist/server/index.d.ts +6 -3
  92. package/dist/server/index.js +3 -1
  93. package/dist/server/index.js.map +1 -1
  94. package/dist/server/mcp-errors.test.js +41 -0
  95. package/dist/server/mcp-errors.test.js.map +1 -0
  96. package/dist/server/middleware.d.ts +6 -6
  97. package/dist/server/middleware.js.map +1 -1
  98. package/dist/server/middleware.test-d.js +1 -1
  99. package/dist/server/middleware.test-d.js.map +1 -1
  100. package/dist/server/middleware.test.js +222 -150
  101. package/dist/server/middleware.test.js.map +1 -1
  102. package/dist/server/register-tool.test.js +77 -0
  103. package/dist/server/register-tool.test.js.map +1 -0
  104. package/dist/server/server.d.ts +149 -119
  105. package/dist/server/server.js +146 -303
  106. package/dist/server/server.js.map +1 -1
  107. package/dist/server/skills-integration.test.js +19 -12
  108. package/dist/server/skills-integration.test.js.map +1 -1
  109. package/dist/server/skills.d.ts +3 -5
  110. package/dist/server/skills.js +17 -24
  111. package/dist/server/skills.js.map +1 -1
  112. package/dist/server/skills.test.js +8 -12
  113. package/dist/server/skills.test.js.map +1 -1
  114. package/dist/server/templateHelper.d.ts +0 -3
  115. package/dist/server/templateHelper.js.map +1 -1
  116. package/dist/server/templates.generated.js +4 -8
  117. package/dist/server/templates.generated.js.map +1 -1
  118. package/dist/server/tool-extra.test.js +88 -0
  119. package/dist/server/tool-extra.test.js.map +1 -0
  120. package/dist/server/view-resource-resolution.test.js +18 -13
  121. package/dist/server/view-resource-resolution.test.js.map +1 -1
  122. package/dist/test/utils.d.ts +9 -11
  123. package/dist/test/utils.js +220 -201
  124. package/dist/test/utils.js.map +1 -1
  125. package/dist/test/view.test.js +25 -37
  126. package/dist/test/view.test.js.map +1 -1
  127. package/dist/views/index.d.ts +10 -0
  128. package/dist/views/index.js +3 -0
  129. package/dist/views/index.js.map +1 -0
  130. package/dist/{web/plugin → views}/scan-views.js +1 -1
  131. package/dist/views/scan-views.js.map +1 -0
  132. package/dist/views/scan-views.test.js.map +1 -0
  133. package/dist/views/validate-view.d.ts +1 -0
  134. package/dist/{web/plugin → views}/validate-view.js +2 -2
  135. package/dist/views/validate-view.js.map +1 -0
  136. package/dist/views/validate-view.test.js.map +1 -0
  137. package/dist/web/bridges/adaptor.d.ts +6 -2
  138. package/dist/web/bridges/adaptor.js +47 -10
  139. package/dist/web/bridges/adaptor.js.map +1 -1
  140. package/dist/web/bridges/adaptor.test.js +1 -1
  141. package/dist/web/bridges/adaptor.test.js.map +1 -1
  142. package/dist/web/bridges/apps-sdk/use-apps-sdk-context.d.ts +1 -1
  143. package/dist/web/bridges/apps-sdk/use-apps-sdk-context.js +1 -1
  144. package/dist/web/bridges/apps-sdk/use-apps-sdk-context.js.map +1 -1
  145. package/dist/web/bridges/get-adaptor.test.js +2 -2
  146. package/dist/web/bridges/get-adaptor.test.js.map +1 -1
  147. package/dist/web/bridges/mcp-app/bridge.d.ts +1 -1
  148. package/dist/web/bridges/mcp-app/bridge.js +10 -3
  149. package/dist/web/bridges/mcp-app/bridge.js.map +1 -1
  150. package/dist/web/bridges/mcp-app/bridge.test.js +2 -2
  151. package/dist/web/bridges/mcp-app/bridge.test.js.map +1 -1
  152. package/dist/web/bridges/mcp-app/types.d.ts +26 -3
  153. package/dist/web/bridges/mcp-app/types.js.map +1 -1
  154. package/dist/web/bridges/mcp-app/use-mcp-app-context.d.ts +2 -2
  155. package/dist/web/bridges/mcp-app/use-mcp-app-context.js +1 -1
  156. package/dist/web/bridges/mcp-app/use-mcp-app-context.js.map +1 -1
  157. package/dist/web/bridges/mcp-app/use-mcp-app-context.test.js +1 -1
  158. package/dist/web/bridges/mcp-app/use-mcp-app-context.test.js.map +1 -1
  159. package/dist/web/bridges/mcp-app/view-tools.test.js +1 -1
  160. package/dist/web/bridges/mcp-app/view-tools.test.js.map +1 -1
  161. package/dist/web/bridges/types.d.ts +33 -14
  162. package/dist/web/bridges/types.js.map +1 -1
  163. package/dist/web/create-store.test.js +2 -2
  164. package/dist/web/create-store.test.js.map +1 -1
  165. package/dist/web/data-llm.js +3 -2
  166. package/dist/web/data-llm.js.map +1 -1
  167. package/dist/web/data-llm.test.js +8 -2
  168. package/dist/web/data-llm.test.js.map +1 -1
  169. package/dist/web/generate-helpers.d.ts +23 -19
  170. package/dist/web/generate-helpers.js +21 -17
  171. package/dist/web/generate-helpers.js.map +1 -1
  172. package/dist/web/generate-helpers.test-d.js +3 -3
  173. package/dist/web/generate-helpers.test-d.js.map +1 -1
  174. package/dist/web/generate-helpers.test.js +2 -2
  175. package/dist/web/generate-helpers.test.js.map +1 -1
  176. package/dist/web/hooks/index.d.ts +4 -2
  177. package/dist/web/hooks/index.js +4 -2
  178. package/dist/web/hooks/index.js.map +1 -1
  179. package/dist/web/hooks/openai-extensions.test.js +104 -0
  180. package/dist/web/hooks/openai-extensions.test.js.map +1 -0
  181. package/dist/web/hooks/use-call-tool.d.ts +2 -2
  182. package/dist/web/hooks/use-call-tool.js +15 -10
  183. package/dist/web/hooks/use-call-tool.js.map +1 -1
  184. package/dist/web/hooks/use-call-tool.test.js +9 -2
  185. package/dist/web/hooks/use-call-tool.test.js.map +1 -1
  186. package/dist/web/hooks/use-deep-link.d.ts +22 -0
  187. package/dist/web/hooks/use-deep-link.js +60 -0
  188. package/dist/web/hooks/use-deep-link.js.map +1 -0
  189. package/dist/web/hooks/use-display-mode.d.ts +1 -1
  190. package/dist/web/hooks/use-display-mode.js +1 -1
  191. package/dist/web/hooks/use-display-mode.js.map +1 -1
  192. package/dist/web/hooks/use-display-mode.test.js +1 -1
  193. package/dist/web/hooks/use-display-mode.test.js.map +1 -1
  194. package/dist/web/hooks/use-download.d.ts +1 -3
  195. package/dist/web/hooks/use-download.js +1 -2
  196. package/dist/web/hooks/use-download.js.map +1 -1
  197. package/dist/web/hooks/use-download.test.js +7 -7
  198. package/dist/web/hooks/use-download.test.js.map +1 -1
  199. package/dist/web/hooks/use-files.test.js +1 -1
  200. package/dist/web/hooks/use-files.test.js.map +1 -1
  201. package/dist/web/hooks/use-host.d.ts +44 -0
  202. package/dist/web/hooks/use-host.js +45 -0
  203. package/dist/web/hooks/use-host.js.map +1 -0
  204. package/dist/web/hooks/{use-host-info.test.js → use-host.test.js} +7 -7
  205. package/dist/web/hooks/use-host.test.js.map +1 -0
  206. package/dist/web/hooks/use-model-context.d.ts +42 -0
  207. package/dist/web/hooks/use-model-context.js +63 -0
  208. package/dist/web/hooks/use-model-context.js.map +1 -0
  209. package/dist/web/hooks/use-open-external.test.js +2 -2
  210. package/dist/web/hooks/use-open-external.test.js.map +1 -1
  211. package/dist/web/hooks/use-register-view-tool.d.ts +2 -3
  212. package/dist/web/hooks/use-register-view-tool.js.map +1 -1
  213. package/dist/web/hooks/use-request-close.test.js +1 -1
  214. package/dist/web/hooks/use-request-close.test.js.map +1 -1
  215. package/dist/web/hooks/use-request-modal.test.js +1 -1
  216. package/dist/web/hooks/use-request-modal.test.js.map +1 -1
  217. package/dist/web/hooks/use-request-size.d.ts +1 -1
  218. package/dist/web/hooks/use-request-size.js +1 -1
  219. package/dist/web/hooks/use-request-size.js.map +1 -1
  220. package/dist/web/hooks/use-request-size.test.js +1 -1
  221. package/dist/web/hooks/use-request-size.test.js.map +1 -1
  222. package/dist/web/hooks/use-set-open-in-app-url.test.js +2 -8
  223. package/dist/web/hooks/use-set-open-in-app-url.test.js.map +1 -1
  224. package/dist/web/hooks/use-tool-info.d.ts +1 -20
  225. package/dist/web/hooks/use-tool-info.js +0 -1
  226. package/dist/web/hooks/use-tool-info.js.map +1 -1
  227. package/dist/web/hooks/use-tool-info.test-d.js +0 -5
  228. package/dist/web/hooks/use-tool-info.test-d.js.map +1 -1
  229. package/dist/web/hooks/use-tool-info.test.js +2 -7
  230. package/dist/web/hooks/use-tool-info.test.js.map +1 -1
  231. package/dist/web/hooks/use-user.d.ts +3 -2
  232. package/dist/web/hooks/use-user.js +4 -3
  233. package/dist/web/hooks/use-user.js.map +1 -1
  234. package/dist/web/hooks/use-user.test.js +5 -3
  235. package/dist/web/hooks/use-user.test.js.map +1 -1
  236. package/dist/web/hooks/use-view-state.test.js +2 -2
  237. package/dist/web/hooks/use-view-state.test.js.map +1 -1
  238. package/dist/web/hooks/use-viewport.d.ts +20 -0
  239. package/dist/web/hooks/use-viewport.js +21 -0
  240. package/dist/web/hooks/use-viewport.js.map +1 -0
  241. package/dist/web/hooks/use-viewport.test.d.ts +1 -0
  242. package/dist/web/hooks/{use-layout.test.js → use-viewport.test.js} +12 -32
  243. package/dist/web/hooks/use-viewport.test.js.map +1 -0
  244. package/dist/web/mount-view.d.ts +3 -2
  245. package/dist/web/mount-view.js +5 -8
  246. package/dist/web/mount-view.js.map +1 -1
  247. package/package.json +14 -12
  248. package/dist/web/hooks/use-host-info.d.ts +0 -22
  249. package/dist/web/hooks/use-host-info.js +0 -30
  250. package/dist/web/hooks/use-host-info.js.map +0 -1
  251. package/dist/web/hooks/use-host-info.test.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-build.test.js +0 -54
  259. package/dist/web/plugin/plugin-build.test.js.map +0 -1
  260. package/dist/web/plugin/plugin.d.ts +0 -39
  261. package/dist/web/plugin/plugin.js +0 -200
  262. package/dist/web/plugin/plugin.js.map +0 -1
  263. package/dist/web/plugin/plugin.test.js +0 -61
  264. package/dist/web/plugin/plugin.test.js.map +0 -1
  265. package/dist/web/plugin/scan-views.js.map +0 -1
  266. package/dist/web/plugin/scan-views.test.js.map +0 -1
  267. package/dist/web/plugin/transform-data-llm.d.ts +0 -12
  268. package/dist/web/plugin/transform-data-llm.js +0 -96
  269. package/dist/web/plugin/transform-data-llm.js.map +0 -1
  270. package/dist/web/plugin/transform-data-llm.test.js +0 -81
  271. package/dist/web/plugin/transform-data-llm.test.js.map +0 -1
  272. package/dist/web/plugin/validate-view.d.ts +0 -1
  273. package/dist/web/plugin/validate-view.js.map +0 -1
  274. package/dist/web/plugin/validate-view.test.js.map +0 -1
  275. /package/dist/{web/hooks/use-host-info.test.d.ts → server/app.test.d.ts} +0 -0
  276. /package/dist/{web/hooks/use-layout.test.d.ts → server/mcp-errors.test.d.ts} +0 -0
  277. /package/dist/{web/plugin/data-llm.test.d.ts → server/register-tool.test.d.ts} +0 -0
  278. /package/dist/{web/plugin/plugin-build.test.d.ts → server/tool-extra.test.d.ts} +0 -0
  279. /package/dist/{web/plugin → views}/scan-views.d.ts +0 -0
  280. /package/dist/{web/plugin → views}/scan-views.test.d.ts +0 -0
  281. /package/dist/{web/plugin → views}/scan-views.test.js +0 -0
  282. /package/dist/{web/plugin → views}/validate-view.test.d.ts +0 -0
  283. /package/dist/{web/plugin → views}/validate-view.test.js +0 -0
  284. /package/dist/web/{plugin/plugin.test.d.ts → hooks/openai-extensions.test.d.ts} +0 -0
  285. /package/dist/web/{plugin/transform-data-llm.test.d.ts → hooks/use-host.test.d.ts} +0 -0
@@ -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,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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.ed29eee",
3
+ "version": "0.0.0-dev.ed38f16",
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",
53
- "@modelcontextprotocol/ext-apps": "^1.7.4",
52
+ "@modelcontextprotocol/client": "^2.0.0",
53
+ "@modelcontextprotocol/core": "^2.0.0",
54
+ "@modelcontextprotocol/ext-apps": "^2.0.0",
55
+ "@modelcontextprotocol/express": "^2.0.0",
56
+ "@modelcontextprotocol/node": "^2.0.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",
@@ -64,16 +67,15 @@
64
67
  "jose": "^6.2.3",
65
68
  "open": "^11.0.0",
66
69
  "posthog-node": "^5.45.2",
70
+ "std-env": "^4.2.0",
67
71
  "superjson": "^2.2.6",
68
72
  "yaml": "^2.9.0",
69
73
  "zustand": "^5.0.14"
70
74
  },
71
75
  "devDependencies": {
72
- "@modelcontextprotocol/sdk": "^1.29.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,22 +0,0 @@
1
- /**
2
- * Known host applications, as normalized slugs. Unrecognized hosts surface
3
- * their raw `hostInfo.name` string instead.
4
- */
5
- export type Host = "chatgpt" | "claude" | "cursor" | "goose" | "mistral-vibe" | "alpic";
6
- export type HostInfo = {
7
- name: Host | (string & {}) | undefined;
8
- version: string | undefined;
9
- };
10
- /**
11
- * Identity of the host application rendering the view, from the MCP Apps
12
- * `ui/initialize` handshake. `name` is normalized to a {@link Host} slug when
13
- * recognized, otherwise the raw string; both fields are `undefined` until the
14
- * handshake resolves (the view renders first and re-renders once it lands).
15
- *
16
- * @example
17
- * ```tsx
18
- * const { name } = useHostInfo();
19
- * if (name === "claude") return <ClaudeLayout />;
20
- * ```
21
- */
22
- export declare function useHostInfo(): HostInfo;
@@ -1,30 +0,0 @@
1
- import { useMcpAppContext } from "../bridges/index.js";
2
- const HOST_BY_REPORTED_NAME = {
3
- chatgpt: "chatgpt",
4
- Claude: "claude",
5
- Cursor: "cursor",
6
- "MCP-UI Host": "goose",
7
- "Le Chat": "mistral-vibe",
8
- "alpic-playground": "alpic",
9
- };
10
- /**
11
- * Identity of the host application rendering the view, from the MCP Apps
12
- * `ui/initialize` handshake. `name` is normalized to a {@link Host} slug when
13
- * recognized, otherwise the raw string; both fields are `undefined` until the
14
- * handshake resolves (the view renders first and re-renders once it lands).
15
- *
16
- * @example
17
- * ```tsx
18
- * const { name } = useHostInfo();
19
- * if (name === "claude") return <ClaudeLayout />;
20
- * ```
21
- */
22
- export function useHostInfo() {
23
- const hostInfo = useMcpAppContext("hostInfo");
24
- const name = hostInfo?.name;
25
- return {
26
- name: name !== undefined ? (HOST_BY_REPORTED_NAME[name] ?? name) : undefined,
27
- version: hostInfo?.version,
28
- };
29
- }
30
- //# sourceMappingURL=use-host-info.js.map
@@ -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 +0,0 @@
1
- {"version":3,"file":"use-host-info.test.js","sourceRoot":"","sources":["../../../src/web/hooks/use-host-info.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,EA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AO,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;YACrD,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC/C,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 { type Host, useHostInfo } from \"./use-host-info.js\";\n\nconst stubHost = (hostInfo?: { name: string; version: string }) => {\n vi.stubGlobal(\"parent\", {\n postMessage: getMcpAppHostPostMessageMock({}, { hostInfo }),\n });\n};\n\ndescribe(\"useHostInfo\", () => {\n beforeEach(() => {\n HostAdaptor.resetInstance();\n McpAppBridge.resetInstance();\n vi.stubGlobal(\"openai\", undefined);\n vi.stubGlobal(\"skybridge\", { hostType: \"mcp-app\" });\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(\"is undefined before the handshake resolves, then populated after\", async () => {\n stubHost({ name: \"Claude\", version: \"1.2.3\" });\n const { result } = renderHook(() => useHostInfo());\n\n expect(result.current.name).toBeUndefined();\n expect(result.current.version).toBeUndefined();\n\n await waitFor(() => {\n expect(result.current.name).toBe(\"claude\");\n expect(result.current.version).toBe(\"1.2.3\");\n });\n });\n\n it.each<[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 ])(\"normalizes reported name %j to slug %j\", async (reported, slug) => {\n stubHost({ name: reported, version: \"1.0.0\" });\n const { result } = renderHook(() => useHostInfo());\n\n await waitFor(() => {\n expect(result.current.name).toBe(slug);\n });\n });\n\n it(\"preserves an unrecognized reported name as-is\", async () => {\n stubHost({ name: \"Some Future Host\", version: \"9.9.9\" });\n const { result } = renderHook(() => useHostInfo());\n\n await waitFor(() => {\n expect(result.current.name).toBe(\"Some Future Host\");\n expect(result.current.version).toBe(\"9.9.9\");\n });\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,EA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,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,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SAAS,CAAC,cAAc,EAAE,UAAU,CAAC,CAAC;QAC5D,MAAM,CACJ,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,wCAAwC,CAAC,CAC9D,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;QAElB,iDAAiD;QACjD,MAAM,cAAc,GAAG;;;;;;KAMtB,CAAC;QACF,MAAM,OAAO,GAAG,MAAM,SAAS,CAAC,cAAc,EAAE,UAAU,CAAC,CAAC;QAC5D,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,SAAS,CAAC,2BAA2B,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,54 +0,0 @@
1
- // @vitest-environment node
2
- import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
3
- import { tmpdir } from "node:os";
4
- import { join } from "node:path";
5
- import { build } from "vite";
6
- import { afterEach, beforeEach, describe, expect, it } from "vitest";
7
- import { skybridge } from "./plugin.js";
8
- /**
9
- * Full `vite build` over a fixture whose stylesheet contains a `url()`. The
10
- * unit test pins the `renderBuiltUrl` contract; this one proves Vite actually
11
- * accepts what the plugin returns.
12
- */
13
- describe("skybridge plugin build", () => {
14
- let root;
15
- beforeEach(() => {
16
- root = mkdtempSync(join(tmpdir(), "skybridge-build-"));
17
- mkdirSync(join(root, "views"), { recursive: true });
18
- mkdirSync(join(root, "src"), { recursive: true });
19
- writeFileSync(join(root, "src/demo.woff2"), Buffer.alloc(64, 1));
20
- writeFileSync(join(root, "src/styles.css"), [
21
- "@font-face {",
22
- ' font-family: "Demo";',
23
- ' src: url("./demo.woff2") format("woff2");',
24
- "}",
25
- ].join("\n"));
26
- writeFileSync(join(root, "src/entry.js"), `import "./styles.css";\n`);
27
- });
28
- afterEach(() => {
29
- rmSync(root, { recursive: true, force: true });
30
- });
31
- it("builds a view stylesheet that references a font", async () => {
32
- const result = await build({
33
- root,
34
- logLevel: "silent",
35
- plugins: [skybridge({ viewsDir: join(root, "views") })],
36
- build: {
37
- // Force the font to be emitted as a file rather than inlined, so the
38
- // stylesheet actually carries a `url()`.
39
- assetsInlineLimit: 0,
40
- rollupOptions: { input: { entry: join(root, "src/entry.js") } },
41
- },
42
- });
43
- const outputs = (Array.isArray(result) ? result : [result]).flatMap((bundle) => ("output" in bundle ? bundle.output : []));
44
- const css = outputs.find((chunk) => chunk.type === "asset" && chunk.fileName.endsWith(".css"));
45
- if (css?.type !== "asset") {
46
- throw new Error("no CSS asset was emitted");
47
- }
48
- // The font resolves relative to the stylesheet, which the server hands out
49
- // from `${serverUrl}/assets/` — no runtime expression, which CSS can't run.
50
- expect(String(css.source)).toMatch(/url\(\.\/demo-[\w-]+\.woff2\)/);
51
- expect(String(css.source)).not.toContain("window.skybridge");
52
- });
53
- });
54
- //# sourceMappingURL=plugin-build.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"plugin-build.test.js","sourceRoot":"","sources":["../../../src/web/plugin/plugin-build.test.ts"],"names":[],"mappings":"AAAA,2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,CAAC,CAAC;QACpE,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,kBAAkB,CAAC,CAAC;IAC/D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["// @vitest-environment node\nimport { mkdirSync, mkdtempSync, rmSync, writeFileSync } from \"node:fs\";\nimport { tmpdir } from \"node:os\";\nimport { join } from \"node:path\";\nimport { build } from \"vite\";\nimport { afterEach, beforeEach, describe, expect, it } from \"vitest\";\nimport { skybridge } from \"./plugin.js\";\n\n/**\n * Full `vite build` over a fixture whose stylesheet contains a `url()`. The\n * unit test pins the `renderBuiltUrl` contract; this one proves Vite actually\n * accepts what the plugin returns.\n */\ndescribe(\"skybridge plugin build\", () => {\n let root: string;\n\n beforeEach(() => {\n root = mkdtempSync(join(tmpdir(), \"skybridge-build-\"));\n mkdirSync(join(root, \"views\"), { recursive: true });\n mkdirSync(join(root, \"src\"), { recursive: true });\n\n writeFileSync(join(root, \"src/demo.woff2\"), Buffer.alloc(64, 1));\n writeFileSync(\n join(root, \"src/styles.css\"),\n [\n \"@font-face {\",\n ' font-family: \"Demo\";',\n ' src: url(\"./demo.woff2\") format(\"woff2\");',\n \"}\",\n ].join(\"\\n\"),\n );\n writeFileSync(join(root, \"src/entry.js\"), `import \"./styles.css\";\\n`);\n });\n\n afterEach(() => {\n rmSync(root, { recursive: true, force: true });\n });\n\n it(\"builds a view stylesheet that references a font\", async () => {\n const result = await build({\n root,\n logLevel: \"silent\",\n plugins: [skybridge({ viewsDir: join(root, \"views\") })],\n build: {\n // Force the font to be emitted as a file rather than inlined, so the\n // stylesheet actually carries a `url()`.\n assetsInlineLimit: 0,\n rollupOptions: { input: { entry: join(root, \"src/entry.js\") } },\n },\n });\n\n const outputs = (Array.isArray(result) ? result : [result]).flatMap(\n (bundle) => (\"output\" in bundle ? bundle.output : []),\n );\n const css = outputs.find(\n (chunk) => chunk.type === \"asset\" && chunk.fileName.endsWith(\".css\"),\n );\n if (css?.type !== \"asset\") {\n throw new Error(\"no CSS asset was emitted\");\n }\n\n // The font resolves relative to the stylesheet, which the server hands out\n // from `${serverUrl}/assets/` — no runtime expression, which CSS can't run.\n expect(String(css.source)).toMatch(/url\\(\\.\\/demo-[\\w-]+\\.woff2\\)/);\n expect(String(css.source)).not.toContain(\"window.skybridge\");\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;