@better-t-stack/template-generator 3.13.2-dev.6c6cffb

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 (425) hide show
  1. package/dist/fs-writer.d.mts +8 -0
  2. package/dist/fs-writer.d.mts.map +1 -0
  3. package/dist/fs-writer.mjs +50 -0
  4. package/dist/fs-writer.mjs.map +1 -0
  5. package/dist/index.d.mts +182 -0
  6. package/dist/index.d.mts.map +1 -0
  7. package/dist/index.mjs +26727 -0
  8. package/dist/index.mjs.map +1 -0
  9. package/dist/template-reader.d.mts +30 -0
  10. package/dist/template-reader.d.mts.map +1 -0
  11. package/dist/template-reader.mjs +2860 -0
  12. package/dist/template-reader.mjs.map +1 -0
  13. package/dist/types-BubFnV2d.d.mts +36 -0
  14. package/dist/types-BubFnV2d.d.mts.map +1 -0
  15. package/package.json +66 -0
  16. package/scripts/generate-templates.ts +97 -0
  17. package/templates/addons/biome/biome.json.hbs +96 -0
  18. package/templates/addons/husky/.husky/pre-commit +1 -0
  19. package/templates/addons/pwa/apps/web/next/public/favicon/apple-touch-icon.png +0 -0
  20. package/templates/addons/pwa/apps/web/next/public/favicon/favicon-96x96.png +0 -0
  21. package/templates/addons/pwa/apps/web/next/public/favicon/favicon.svg +6 -0
  22. package/templates/addons/pwa/apps/web/next/public/favicon/site.webmanifest.hbs +21 -0
  23. package/templates/addons/pwa/apps/web/next/public/favicon/web-app-manifest-192x192.png +0 -0
  24. package/templates/addons/pwa/apps/web/next/public/favicon/web-app-manifest-512x512.png +0 -0
  25. package/templates/addons/pwa/apps/web/next/src/app/manifest.ts.hbs +26 -0
  26. package/templates/addons/pwa/apps/web/vite/public/logo.png +0 -0
  27. package/templates/addons/pwa/apps/web/vite/pwa-assets.config.ts.hbs +12 -0
  28. package/templates/addons/ruler/.ruler/bts.md.hbs +142 -0
  29. package/templates/addons/ruler/.ruler/ruler.toml.hbs +80 -0
  30. package/templates/addons/turborepo/turbo.json.hbs +74 -0
  31. package/templates/addons/ultracite/biome.json.hbs +26 -0
  32. package/templates/api/orpc/fullstack/next/src/app/api/rpc/[[...rest]]/route.ts.hbs +50 -0
  33. package/templates/api/orpc/fullstack/tanstack-start/src/routes/api/rpc/$.ts.hbs +58 -0
  34. package/templates/api/orpc/native/utils/orpc.ts.hbs +39 -0
  35. package/templates/api/orpc/server/_gitignore +34 -0
  36. package/templates/api/orpc/server/package.json.hbs +15 -0
  37. package/templates/api/orpc/server/src/context.ts.hbs +148 -0
  38. package/templates/api/orpc/server/src/index.ts.hbs +21 -0
  39. package/templates/api/orpc/server/src/routers/index.ts.hbs +55 -0
  40. package/templates/api/orpc/server/tsconfig.json.hbs +10 -0
  41. package/templates/api/orpc/web/nuxt/app/plugins/orpc.ts.hbs +32 -0
  42. package/templates/api/orpc/web/nuxt/app/plugins/vue-query.ts.hbs +44 -0
  43. package/templates/api/orpc/web/react/base/src/utils/orpc.ts.hbs +113 -0
  44. package/templates/api/orpc/web/solid/src/utils/orpc.ts.hbs +30 -0
  45. package/templates/api/orpc/web/svelte/src/lib/orpc.ts.hbs +30 -0
  46. package/templates/api/trpc/fullstack/next/src/app/api/trpc/[trpc]/route.ts.hbs +14 -0
  47. package/templates/api/trpc/fullstack/tanstack-start/src/routes/api/trpc/$.ts.hbs +22 -0
  48. package/templates/api/trpc/native/utils/trpc.ts.hbs +37 -0
  49. package/templates/api/trpc/server/_gitignore +34 -0
  50. package/templates/api/trpc/server/package.json.hbs +14 -0
  51. package/templates/api/trpc/server/src/context.ts.hbs +148 -0
  52. package/templates/api/trpc/server/src/index.ts.hbs +26 -0
  53. package/templates/api/trpc/server/src/routers/index.ts.hbs +55 -0
  54. package/templates/api/trpc/server/tsconfig.json.hbs +10 -0
  55. package/templates/api/trpc/web/react/base/src/utils/trpc.ts.hbs +97 -0
  56. package/templates/auth/better-auth/convex/backend/convex/auth.config.ts.hbs +6 -0
  57. package/templates/auth/better-auth/convex/backend/convex/auth.ts.hbs +68 -0
  58. package/templates/auth/better-auth/convex/backend/convex/http.ts.hbs +12 -0
  59. package/templates/auth/better-auth/convex/backend/convex/privateData.ts.hbs +17 -0
  60. package/templates/auth/better-auth/convex/native/bare/components/sign-in.tsx.hbs +127 -0
  61. package/templates/auth/better-auth/convex/native/bare/components/sign-up.tsx.hbs +138 -0
  62. package/templates/auth/better-auth/convex/native/base/lib/auth-client.ts.hbs +18 -0
  63. package/templates/auth/better-auth/convex/native/unistyles/components/sign-in.tsx.hbs +127 -0
  64. package/templates/auth/better-auth/convex/native/unistyles/components/sign-up.tsx.hbs +145 -0
  65. package/templates/auth/better-auth/convex/native/uniwind/components/sign-in.tsx.hbs +73 -0
  66. package/templates/auth/better-auth/convex/native/uniwind/components/sign-up.tsx.hbs +85 -0
  67. package/templates/auth/better-auth/convex/web/react/next/src/app/api/auth/[...all]/route.ts.hbs +3 -0
  68. package/templates/auth/better-auth/convex/web/react/next/src/app/dashboard/page.tsx.hbs +40 -0
  69. package/templates/auth/better-auth/convex/web/react/next/src/components/sign-in-form.tsx.hbs +129 -0
  70. package/templates/auth/better-auth/convex/web/react/next/src/components/sign-up-form.tsx.hbs +154 -0
  71. package/templates/auth/better-auth/convex/web/react/next/src/components/user-menu.tsx.hbs +48 -0
  72. package/templates/auth/better-auth/convex/web/react/next/src/lib/auth-client.ts.hbs +6 -0
  73. package/templates/auth/better-auth/convex/web/react/next/src/lib/auth-server.ts.hbs +16 -0
  74. package/templates/auth/better-auth/convex/web/react/tanstack-router/src/components/sign-in-form.tsx.hbs +133 -0
  75. package/templates/auth/better-auth/convex/web/react/tanstack-router/src/components/sign-up-form.tsx.hbs +158 -0
  76. package/templates/auth/better-auth/convex/web/react/tanstack-router/src/components/user-menu.tsx.hbs +52 -0
  77. package/templates/auth/better-auth/convex/web/react/tanstack-router/src/lib/auth-client.ts.hbs +11 -0
  78. package/templates/auth/better-auth/convex/web/react/tanstack-router/src/routes/dashboard.tsx.hbs +43 -0
  79. package/templates/auth/better-auth/convex/web/react/tanstack-start/src/components/sign-in-form.tsx.hbs +133 -0
  80. package/templates/auth/better-auth/convex/web/react/tanstack-start/src/components/sign-up-form.tsx.hbs +158 -0
  81. package/templates/auth/better-auth/convex/web/react/tanstack-start/src/components/user-menu.tsx.hbs +47 -0
  82. package/templates/auth/better-auth/convex/web/react/tanstack-start/src/lib/auth-client.ts.hbs +6 -0
  83. package/templates/auth/better-auth/convex/web/react/tanstack-start/src/lib/auth-server.ts.hbs +13 -0
  84. package/templates/auth/better-auth/convex/web/react/tanstack-start/src/routes/api/auth/$.ts.hbs +11 -0
  85. package/templates/auth/better-auth/convex/web/react/tanstack-start/src/routes/dashboard.tsx.hbs +43 -0
  86. package/templates/auth/better-auth/fullstack/next/src/app/api/auth/[...all]/route.ts.hbs +4 -0
  87. package/templates/auth/better-auth/fullstack/tanstack-start/src/routes/api/auth/$.ts.hbs +15 -0
  88. package/templates/auth/better-auth/native/bare/app/(drawer)/index.tsx.hbs +186 -0
  89. package/templates/auth/better-auth/native/bare/components/sign-in.tsx.hbs +131 -0
  90. package/templates/auth/better-auth/native/bare/components/sign-up.tsx.hbs +150 -0
  91. package/templates/auth/better-auth/native/base/lib/auth-client.ts.hbs +16 -0
  92. package/templates/auth/better-auth/native/unistyles/app/(drawer)/index.tsx.hbs +187 -0
  93. package/templates/auth/better-auth/native/unistyles/components/sign-in.tsx.hbs +139 -0
  94. package/templates/auth/better-auth/native/unistyles/components/sign-up.tsx.hbs +157 -0
  95. package/templates/auth/better-auth/native/uniwind/app/(drawer)/index.tsx.hbs +123 -0
  96. package/templates/auth/better-auth/native/uniwind/components/sign-in.tsx.hbs +87 -0
  97. package/templates/auth/better-auth/native/uniwind/components/sign-up.tsx.hbs +128 -0
  98. package/templates/auth/better-auth/server/base/_gitignore +34 -0
  99. package/templates/auth/better-auth/server/base/package.json.hbs +14 -0
  100. package/templates/auth/better-auth/server/base/src/index.ts.hbs +304 -0
  101. package/templates/auth/better-auth/server/base/tsconfig.json.hbs +10 -0
  102. package/templates/auth/better-auth/server/db/drizzle/mysql/src/schema/auth.ts.hbs +100 -0
  103. package/templates/auth/better-auth/server/db/drizzle/postgres/src/schema/auth.ts.hbs +93 -0
  104. package/templates/auth/better-auth/server/db/drizzle/sqlite/src/schema/auth.ts.hbs +107 -0
  105. package/templates/auth/better-auth/server/db/mongoose/mongodb/src/models/auth.model.ts.hbs +68 -0
  106. package/templates/auth/better-auth/server/db/prisma/mongodb/prisma/schema/auth.prisma.hbs +62 -0
  107. package/templates/auth/better-auth/server/db/prisma/mysql/prisma/schema/auth.prisma.hbs +62 -0
  108. package/templates/auth/better-auth/server/db/prisma/postgres/prisma/schema/auth.prisma.hbs +62 -0
  109. package/templates/auth/better-auth/server/db/prisma/sqlite/prisma/schema/auth.prisma.hbs +62 -0
  110. package/templates/auth/better-auth/web/nuxt/app/components/SignInForm.vue.hbs +82 -0
  111. package/templates/auth/better-auth/web/nuxt/app/components/SignUpForm.vue.hbs +91 -0
  112. package/templates/auth/better-auth/web/nuxt/app/components/UserMenu.vue.hbs +42 -0
  113. package/templates/auth/better-auth/web/nuxt/app/middleware/auth.ts.hbs +14 -0
  114. package/templates/auth/better-auth/web/nuxt/app/pages/dashboard.vue.hbs +99 -0
  115. package/templates/auth/better-auth/web/nuxt/app/pages/login.vue.hbs +27 -0
  116. package/templates/auth/better-auth/web/nuxt/app/plugins/auth-client.ts.hbs +21 -0
  117. package/templates/auth/better-auth/web/react/base/src/lib/auth-client.ts.hbs +16 -0
  118. package/templates/auth/better-auth/web/react/next/src/app/dashboard/dashboard.tsx.hbs +60 -0
  119. package/templates/auth/better-auth/web/react/next/src/app/dashboard/page.tsx.hbs +42 -0
  120. package/templates/auth/better-auth/web/react/next/src/app/login/page.tsx.hbs +16 -0
  121. package/templates/auth/better-auth/web/react/next/src/components/sign-in-form.tsx.hbs +135 -0
  122. package/templates/auth/better-auth/web/react/next/src/components/sign-up-form.tsx.hbs +160 -0
  123. package/templates/auth/better-auth/web/react/next/src/components/user-menu.tsx.hbs +62 -0
  124. package/templates/auth/better-auth/web/react/react-router/src/components/sign-in-form.tsx.hbs +135 -0
  125. package/templates/auth/better-auth/web/react/react-router/src/components/sign-up-form.tsx.hbs +160 -0
  126. package/templates/auth/better-auth/web/react/react-router/src/components/user-menu.tsx.hbs +61 -0
  127. package/templates/auth/better-auth/web/react/react-router/src/routes/dashboard.tsx.hbs +80 -0
  128. package/templates/auth/better-auth/web/react/react-router/src/routes/login.tsx.hbs +13 -0
  129. package/templates/auth/better-auth/web/react/tanstack-router/src/components/sign-in-form.tsx.hbs +135 -0
  130. package/templates/auth/better-auth/web/react/tanstack-router/src/components/sign-up-form.tsx.hbs +160 -0
  131. package/templates/auth/better-auth/web/react/tanstack-router/src/components/user-menu.tsx.hbs +63 -0
  132. package/templates/auth/better-auth/web/react/tanstack-router/src/routes/dashboard.tsx.hbs +71 -0
  133. package/templates/auth/better-auth/web/react/tanstack-router/src/routes/login.tsx.hbs +18 -0
  134. package/templates/auth/better-auth/web/react/tanstack-start/src/components/sign-in-form.tsx.hbs +135 -0
  135. package/templates/auth/better-auth/web/react/tanstack-start/src/components/sign-up-form.tsx.hbs +160 -0
  136. package/templates/auth/better-auth/web/react/tanstack-start/src/components/user-menu.tsx.hbs +63 -0
  137. package/templates/auth/better-auth/web/react/tanstack-start/src/functions/get-user.ts.hbs +6 -0
  138. package/templates/auth/better-auth/web/react/tanstack-start/src/middleware/auth.ts.hbs +31 -0
  139. package/templates/auth/better-auth/web/react/tanstack-start/src/routes/dashboard.tsx.hbs +84 -0
  140. package/templates/auth/better-auth/web/react/tanstack-start/src/routes/login.tsx.hbs +18 -0
  141. package/templates/auth/better-auth/web/solid/src/components/sign-in-form.tsx.hbs +124 -0
  142. package/templates/auth/better-auth/web/solid/src/components/sign-up-form.tsx.hbs +148 -0
  143. package/templates/auth/better-auth/web/solid/src/components/user-menu.tsx.hbs +55 -0
  144. package/templates/auth/better-auth/web/solid/src/lib/auth-client.ts.hbs +12 -0
  145. package/templates/auth/better-auth/web/solid/src/routes/dashboard.tsx.hbs +67 -0
  146. package/templates/auth/better-auth/web/solid/src/routes/login.tsx.hbs +23 -0
  147. package/templates/auth/better-auth/web/svelte/src/components/SignInForm.svelte.hbs +109 -0
  148. package/templates/auth/better-auth/web/svelte/src/components/SignUpForm.svelte.hbs +142 -0
  149. package/templates/auth/better-auth/web/svelte/src/components/UserMenu.svelte.hbs +52 -0
  150. package/templates/auth/better-auth/web/svelte/src/lib/auth-client.ts.hbs +12 -0
  151. package/templates/auth/better-auth/web/svelte/src/routes/dashboard/+page.svelte.hbs +59 -0
  152. package/templates/auth/better-auth/web/svelte/src/routes/login/+page.svelte.hbs +12 -0
  153. package/templates/auth/clerk/convex/backend/convex/auth.config.ts.hbs +12 -0
  154. package/templates/auth/clerk/convex/backend/convex/privateData.ts.hbs +16 -0
  155. package/templates/auth/clerk/convex/native/base/app/(auth)/_layout.tsx.hbs +12 -0
  156. package/templates/auth/clerk/convex/native/base/app/(auth)/sign-in.tsx.hbs +67 -0
  157. package/templates/auth/clerk/convex/native/base/app/(auth)/sign-up.tsx.hbs +110 -0
  158. package/templates/auth/clerk/convex/native/base/components/sign-out-button.tsx.hbs +27 -0
  159. package/templates/auth/clerk/convex/web/react/next/src/app/dashboard/page.tsx.hbs +29 -0
  160. package/templates/auth/clerk/convex/web/react/next/src/middleware.ts.hbs +12 -0
  161. package/templates/auth/clerk/convex/web/react/react-router/src/routes/dashboard.tsx.hbs +32 -0
  162. package/templates/auth/clerk/convex/web/react/tanstack-router/src/routes/dashboard.tsx.hbs +37 -0
  163. package/templates/auth/clerk/convex/web/react/tanstack-start/src/routes/dashboard.tsx.hbs +37 -0
  164. package/templates/auth/clerk/convex/web/react/tanstack-start/src/start.ts.hbs +8 -0
  165. package/templates/backend/convex/packages/backend/_gitignore +2 -0
  166. package/templates/backend/convex/packages/backend/convex/README.md +90 -0
  167. package/templates/backend/convex/packages/backend/convex/convex.config.ts.hbs +17 -0
  168. package/templates/backend/convex/packages/backend/convex/healthCheck.ts.hbs +7 -0
  169. package/templates/backend/convex/packages/backend/convex/schema.ts.hbs +11 -0
  170. package/templates/backend/convex/packages/backend/convex/tsconfig.json.hbs +25 -0
  171. package/templates/backend/convex/packages/backend/package.json.hbs +15 -0
  172. package/templates/backend/server/base/_gitignore +55 -0
  173. package/templates/backend/server/base/package.json.hbs +17 -0
  174. package/templates/backend/server/base/tsconfig.json.hbs +13 -0
  175. package/templates/backend/server/base/tsdown.config.ts.hbs +9 -0
  176. package/templates/backend/server/elysia/src/index.ts.hbs +122 -0
  177. package/templates/backend/server/express/src/index.ts.hbs +126 -0
  178. package/templates/backend/server/fastify/src/index.ts.hbs +187 -0
  179. package/templates/backend/server/hono/src/index.ts.hbs +171 -0
  180. package/templates/base/_gitignore +50 -0
  181. package/templates/base/package.json.hbs +10 -0
  182. package/templates/base/tsconfig.json.hbs +3 -0
  183. package/templates/db/base/_gitignore +35 -0
  184. package/templates/db/base/package.json.hbs +14 -0
  185. package/templates/db/base/tsconfig.json.hbs +10 -0
  186. package/templates/db/drizzle/base/src/schema/index.ts.hbs +7 -0
  187. package/templates/db/drizzle/mysql/drizzle.config.ts.hbs +19 -0
  188. package/templates/db/drizzle/mysql/src/index.ts.hbs +54 -0
  189. package/templates/db/drizzle/postgres/drizzle.config.ts.hbs +19 -0
  190. package/templates/db/drizzle/postgres/src/index.ts.hbs +44 -0
  191. package/templates/db/drizzle/sqlite/drizzle.config.ts.hbs +28 -0
  192. package/templates/db/drizzle/sqlite/src/index.ts.hbs +39 -0
  193. package/templates/db/mongoose/mongodb/src/index.ts.hbs +10 -0
  194. package/templates/db/prisma/mongodb/prisma/schema/schema.prisma.hbs +19 -0
  195. package/templates/db/prisma/mongodb/prisma.config.ts.hbs +18 -0
  196. package/templates/db/prisma/mongodb/src/index.ts.hbs +5 -0
  197. package/templates/db/prisma/mysql/prisma/schema/schema.prisma.hbs +21 -0
  198. package/templates/db/prisma/mysql/prisma.config.ts.hbs +21 -0
  199. package/templates/db/prisma/mysql/src/index.ts.hbs +55 -0
  200. package/templates/db/prisma/postgres/prisma/schema/schema.prisma.hbs +21 -0
  201. package/templates/db/prisma/postgres/prisma.config.ts.hbs +21 -0
  202. package/templates/db/prisma/postgres/src/index.ts.hbs +69 -0
  203. package/templates/db/prisma/sqlite/prisma/schema/schema.prisma.hbs +18 -0
  204. package/templates/db/prisma/sqlite/prisma.config.ts.hbs +25 -0
  205. package/templates/db/prisma/sqlite/src/index.ts.hbs +25 -0
  206. package/templates/db-setup/docker-compose/mongodb/docker-compose.yml.hbs +23 -0
  207. package/templates/db-setup/docker-compose/mysql/docker-compose.yml.hbs +24 -0
  208. package/templates/db-setup/docker-compose/postgres/docker-compose.yml.hbs +23 -0
  209. package/templates/examples/ai/convex/packages/backend/convex/agent.ts.hbs +9 -0
  210. package/templates/examples/ai/convex/packages/backend/convex/chat.ts.hbs +67 -0
  211. package/templates/examples/ai/fullstack/next/src/app/api/ai/route.ts.hbs +20 -0
  212. package/templates/examples/ai/fullstack/tanstack-start/src/routes/api/ai/$.ts.hbs +36 -0
  213. package/templates/examples/ai/native/bare/app/(drawer)/ai.tsx.hbs +586 -0
  214. package/templates/examples/ai/native/bare/polyfills.js +22 -0
  215. package/templates/examples/ai/native/unistyles/app/(drawer)/ai.tsx.hbs +588 -0
  216. package/templates/examples/ai/native/unistyles/polyfills.js +22 -0
  217. package/templates/examples/ai/native/uniwind/app/(drawer)/ai.tsx.hbs +331 -0
  218. package/templates/examples/ai/native/uniwind/polyfills.js +22 -0
  219. package/templates/examples/ai/web/nuxt/app/pages/ai.vue.hbs +54 -0
  220. package/templates/examples/ai/web/react/next/src/app/ai/page.tsx.hbs +267 -0
  221. package/templates/examples/ai/web/react/react-router/src/routes/ai.tsx.hbs +235 -0
  222. package/templates/examples/ai/web/react/tanstack-router/src/routes/ai.tsx.hbs +242 -0
  223. package/templates/examples/ai/web/react/tanstack-start/src/routes/ai.tsx.hbs +243 -0
  224. package/templates/examples/ai/web/svelte/src/routes/ai/+page.svelte.hbs +107 -0
  225. package/templates/examples/todo/convex/packages/backend/convex/todos.ts.hbs +42 -0
  226. package/templates/examples/todo/native/bare/app/(drawer)/todos.tsx.hbs +521 -0
  227. package/templates/examples/todo/native/unistyles/app/(drawer)/todos.tsx.hbs +340 -0
  228. package/templates/examples/todo/native/uniwind/app/(drawer)/todos.tsx.hbs +282 -0
  229. package/templates/examples/todo/server/drizzle/base/src/routers/todo.ts.hbs +75 -0
  230. package/templates/examples/todo/server/drizzle/mysql/src/schema/todo.ts +7 -0
  231. package/templates/examples/todo/server/drizzle/postgres/src/schema/todo.ts +7 -0
  232. package/templates/examples/todo/server/drizzle/sqlite/src/schema/todo.ts +7 -0
  233. package/templates/examples/todo/server/mongoose/base/src/routers/todo.ts.hbs +66 -0
  234. package/templates/examples/todo/server/mongoose/mongodb/src/models/todo.model.ts.hbs +24 -0
  235. package/templates/examples/todo/server/prisma/base/src/routers/todo.ts.hbs +116 -0
  236. package/templates/examples/todo/server/prisma/mongodb/prisma/schema/todo.prisma.hbs +7 -0
  237. package/templates/examples/todo/server/prisma/mysql/prisma/schema/todo.prisma.hbs +7 -0
  238. package/templates/examples/todo/server/prisma/postgres/prisma/schema/todo.prisma.hbs +7 -0
  239. package/templates/examples/todo/server/prisma/sqlite/prisma/schema/todo.prisma.hbs +7 -0
  240. package/templates/examples/todo/web/nuxt/app/pages/todos.vue.hbs +220 -0
  241. package/templates/examples/todo/web/react/next/src/app/todos/page.tsx.hbs +245 -0
  242. package/templates/examples/todo/web/react/react-router/src/routes/todos.tsx.hbs +242 -0
  243. package/templates/examples/todo/web/react/tanstack-router/src/routes/todos.tsx.hbs +247 -0
  244. package/templates/examples/todo/web/react/tanstack-start/src/routes/todos.tsx.hbs +272 -0
  245. package/templates/examples/todo/web/solid/src/routes/todos.tsx.hbs +132 -0
  246. package/templates/examples/todo/web/svelte/src/routes/todos/+page.svelte.hbs +317 -0
  247. package/templates/extras/_npmrc.hbs +5 -0
  248. package/templates/extras/bunfig.toml.hbs +6 -0
  249. package/templates/extras/pnpm-workspace.yaml +3 -0
  250. package/templates/frontend/native/bare/_gitignore +18 -0
  251. package/templates/frontend/native/bare/app/(drawer)/(tabs)/_layout.tsx.hbs +41 -0
  252. package/templates/frontend/native/bare/app/(drawer)/(tabs)/index.tsx.hbs +43 -0
  253. package/templates/frontend/native/bare/app/(drawer)/(tabs)/two.tsx.hbs +43 -0
  254. package/templates/frontend/native/bare/app/(drawer)/_layout.tsx.hbs +90 -0
  255. package/templates/frontend/native/bare/app/(drawer)/index.tsx.hbs +234 -0
  256. package/templates/frontend/native/bare/app/+not-found.tsx.hbs +65 -0
  257. package/templates/frontend/native/bare/app/_layout.tsx.hbs +165 -0
  258. package/templates/frontend/native/bare/app/modal.tsx.hbs +34 -0
  259. package/templates/frontend/native/bare/app.json.hbs +50 -0
  260. package/templates/frontend/native/bare/components/container.tsx.hbs +25 -0
  261. package/templates/frontend/native/bare/components/header-button.tsx.hbs +47 -0
  262. package/templates/frontend/native/bare/components/tabbar-icon.tsx.hbs +9 -0
  263. package/templates/frontend/native/bare/lib/android-navigation-bar.tsx.hbs +12 -0
  264. package/templates/frontend/native/bare/lib/constants.ts.hbs +19 -0
  265. package/templates/frontend/native/bare/lib/use-color-scheme.ts.hbs +20 -0
  266. package/templates/frontend/native/bare/metro.config.js.hbs +9 -0
  267. package/templates/frontend/native/bare/package.json.hbs +51 -0
  268. package/templates/frontend/native/bare/tsconfig.json.hbs +11 -0
  269. package/templates/frontend/native/base/assets/images/android-icon-background.png +0 -0
  270. package/templates/frontend/native/base/assets/images/android-icon-foreground.png +0 -0
  271. package/templates/frontend/native/base/assets/images/android-icon-monochrome.png +0 -0
  272. package/templates/frontend/native/base/assets/images/favicon.png +0 -0
  273. package/templates/frontend/native/base/assets/images/icon.png +0 -0
  274. package/templates/frontend/native/base/assets/images/partial-react-logo.png +0 -0
  275. package/templates/frontend/native/base/assets/images/react-logo.png +0 -0
  276. package/templates/frontend/native/base/assets/images/react-logo@2x.png +0 -0
  277. package/templates/frontend/native/base/assets/images/react-logo@3x.png +0 -0
  278. package/templates/frontend/native/base/assets/images/splash-icon.png +0 -0
  279. package/templates/frontend/native/unistyles/_gitignore +24 -0
  280. package/templates/frontend/native/unistyles/app/(drawer)/(tabs)/_layout.tsx.hbs +39 -0
  281. package/templates/frontend/native/unistyles/app/(drawer)/(tabs)/index.tsx.hbs +37 -0
  282. package/templates/frontend/native/unistyles/app/(drawer)/(tabs)/two.tsx.hbs +37 -0
  283. package/templates/frontend/native/unistyles/app/(drawer)/_layout.tsx.hbs +87 -0
  284. package/templates/frontend/native/unistyles/app/(drawer)/index.tsx.hbs +333 -0
  285. package/templates/frontend/native/unistyles/app/+not-found.tsx.hbs +65 -0
  286. package/templates/frontend/native/unistyles/app/_layout.tsx.hbs +169 -0
  287. package/templates/frontend/native/unistyles/app/modal.tsx.hbs +33 -0
  288. package/templates/frontend/native/unistyles/app.json.hbs +49 -0
  289. package/templates/frontend/native/unistyles/babel.config.js.hbs +21 -0
  290. package/templates/frontend/native/unistyles/breakpoints.ts.hbs +9 -0
  291. package/templates/frontend/native/unistyles/components/container.tsx.hbs +15 -0
  292. package/templates/frontend/native/unistyles/components/header-button.tsx.hbs +36 -0
  293. package/templates/frontend/native/unistyles/components/tabbar-icon.tsx.hbs +8 -0
  294. package/templates/frontend/native/unistyles/index.js.hbs +2 -0
  295. package/templates/frontend/native/unistyles/metro.config.js.hbs +5 -0
  296. package/templates/frontend/native/unistyles/package.json.hbs +51 -0
  297. package/templates/frontend/native/unistyles/theme.ts.hbs +98 -0
  298. package/templates/frontend/native/unistyles/tsconfig.json.hbs +12 -0
  299. package/templates/frontend/native/unistyles/unistyles.ts.hbs +27 -0
  300. package/templates/frontend/native/uniwind/_gitignore +21 -0
  301. package/templates/frontend/native/uniwind/app/(drawer)/(tabs)/_layout.tsx.hbs +46 -0
  302. package/templates/frontend/native/uniwind/app/(drawer)/(tabs)/index.tsx.hbs +15 -0
  303. package/templates/frontend/native/uniwind/app/(drawer)/(tabs)/two.tsx.hbs +15 -0
  304. package/templates/frontend/native/uniwind/app/(drawer)/_layout.tsx.hbs +91 -0
  305. package/templates/frontend/native/uniwind/app/(drawer)/index.tsx.hbs +191 -0
  306. package/templates/frontend/native/uniwind/app/+not-found.tsx.hbs +27 -0
  307. package/templates/frontend/native/uniwind/app/_layout.tsx.hbs +132 -0
  308. package/templates/frontend/native/uniwind/app/modal.tsx.hbs +37 -0
  309. package/templates/frontend/native/uniwind/app.json.hbs +19 -0
  310. package/templates/frontend/native/uniwind/components/container.tsx.hbs +33 -0
  311. package/templates/frontend/native/uniwind/components/theme-toggle.tsx.hbs +35 -0
  312. package/templates/frontend/native/uniwind/contexts/app-theme-context.tsx.hbs +62 -0
  313. package/templates/frontend/native/uniwind/global.css +5 -0
  314. package/templates/frontend/native/uniwind/metro.config.js.hbs +13 -0
  315. package/templates/frontend/native/uniwind/package.json.hbs +54 -0
  316. package/templates/frontend/native/uniwind/tsconfig.json.hbs +14 -0
  317. package/templates/frontend/nuxt/_gitignore +27 -0
  318. package/templates/frontend/nuxt/app/app.config.ts.hbs +15 -0
  319. package/templates/frontend/nuxt/app/app.vue.hbs +17 -0
  320. package/templates/frontend/nuxt/app/assets/css/main.css +2 -0
  321. package/templates/frontend/nuxt/app/components/Header.vue.hbs +40 -0
  322. package/templates/frontend/nuxt/app/layouts/default.vue.hbs +10 -0
  323. package/templates/frontend/nuxt/app/pages/index.vue.hbs +97 -0
  324. package/templates/frontend/nuxt/nuxt.config.ts.hbs +29 -0
  325. package/templates/frontend/nuxt/package.json.hbs +24 -0
  326. package/templates/frontend/nuxt/public/favicon.ico +0 -0
  327. package/templates/frontend/nuxt/public/robots.txt +2 -0
  328. package/templates/frontend/nuxt/server/tsconfig.json +3 -0
  329. package/templates/frontend/nuxt/tsconfig.json.hbs +18 -0
  330. package/templates/frontend/react/next/next-env.d.ts.hbs +5 -0
  331. package/templates/frontend/react/next/next.config.ts.hbs +22 -0
  332. package/templates/frontend/react/next/package.json.hbs +34 -0
  333. package/templates/frontend/react/next/postcss.config.mjs.hbs +5 -0
  334. package/templates/frontend/react/next/src/app/favicon.ico +0 -0
  335. package/templates/frontend/react/next/src/app/layout.tsx.hbs +76 -0
  336. package/templates/frontend/react/next/src/app/page.tsx.hbs +79 -0
  337. package/templates/frontend/react/next/src/components/mode-toggle.tsx.hbs +37 -0
  338. package/templates/frontend/react/next/src/components/providers.tsx.hbs +89 -0
  339. package/templates/frontend/react/next/src/components/theme-provider.tsx.hbs +11 -0
  340. package/templates/frontend/react/next/tsconfig.json.hbs +41 -0
  341. package/templates/frontend/react/react-router/package.json.hbs +42 -0
  342. package/templates/frontend/react/react-router/public/favicon.ico +0 -0
  343. package/templates/frontend/react/react-router/react-router.config.ts +6 -0
  344. package/templates/frontend/react/react-router/src/components/mode-toggle.tsx.hbs +29 -0
  345. package/templates/frontend/react/react-router/src/components/theme-provider.tsx.hbs +11 -0
  346. package/templates/frontend/react/react-router/src/root.tsx.hbs +190 -0
  347. package/templates/frontend/react/react-router/src/routes/_index.tsx.hbs +85 -0
  348. package/templates/frontend/react/react-router/src/routes.ts +4 -0
  349. package/templates/frontend/react/react-router/tsconfig.json.hbs +27 -0
  350. package/templates/frontend/react/react-router/vite.config.ts.hbs +12 -0
  351. package/templates/frontend/react/tanstack-router/index.html.hbs +13 -0
  352. package/templates/frontend/react/tanstack-router/package.json.hbs +41 -0
  353. package/templates/frontend/react/tanstack-router/src/components/mode-toggle.tsx.hbs +29 -0
  354. package/templates/frontend/react/tanstack-router/src/components/theme-provider.tsx.hbs +11 -0
  355. package/templates/frontend/react/tanstack-router/src/main.tsx.hbs +90 -0
  356. package/templates/frontend/react/tanstack-router/src/routes/__root.tsx.hbs +103 -0
  357. package/templates/frontend/react/tanstack-router/src/routes/index.tsx.hbs +85 -0
  358. package/templates/frontend/react/tanstack-router/tsconfig.json.hbs +18 -0
  359. package/templates/frontend/react/tanstack-router/vite.config.ts.hbs +21 -0
  360. package/templates/frontend/react/tanstack-start/package.json.hbs +43 -0
  361. package/templates/frontend/react/tanstack-start/public/robots.txt +3 -0
  362. package/templates/frontend/react/tanstack-start/src/router.tsx.hbs +144 -0
  363. package/templates/frontend/react/tanstack-start/src/routes/__root.tsx.hbs +208 -0
  364. package/templates/frontend/react/tanstack-start/src/routes/index.tsx.hbs +85 -0
  365. package/templates/frontend/react/tanstack-start/tsconfig.json.hbs +28 -0
  366. package/templates/frontend/react/tanstack-start/vite.config.ts.hbs +22 -0
  367. package/templates/frontend/react/web-base/_gitignore +60 -0
  368. package/templates/frontend/react/web-base/components.json +24 -0
  369. package/templates/frontend/react/web-base/src/components/header.tsx.hbs +78 -0
  370. package/templates/frontend/react/web-base/src/components/loader.tsx.hbs +9 -0
  371. package/templates/frontend/react/web-base/src/components/ui/button.tsx.hbs +57 -0
  372. package/templates/frontend/react/web-base/src/components/ui/card.tsx.hbs +103 -0
  373. package/templates/frontend/react/web-base/src/components/ui/checkbox.tsx.hbs +26 -0
  374. package/templates/frontend/react/web-base/src/components/ui/dropdown-menu.tsx.hbs +262 -0
  375. package/templates/frontend/react/web-base/src/components/ui/input.tsx.hbs +20 -0
  376. package/templates/frontend/react/web-base/src/components/ui/label.tsx.hbs +20 -0
  377. package/templates/frontend/react/web-base/src/components/ui/skeleton.tsx.hbs +13 -0
  378. package/templates/frontend/react/web-base/src/components/ui/sonner.tsx.hbs +44 -0
  379. package/templates/frontend/react/web-base/src/index.css.hbs +131 -0
  380. package/templates/frontend/react/web-base/src/lib/utils.ts.hbs +6 -0
  381. package/templates/frontend/solid/_gitignore +11 -0
  382. package/templates/frontend/solid/index.html +13 -0
  383. package/templates/frontend/solid/package.json.hbs +24 -0
  384. package/templates/frontend/solid/public/robots.txt +3 -0
  385. package/templates/frontend/solid/src/components/header.tsx.hbs +38 -0
  386. package/templates/frontend/solid/src/components/loader.tsx +9 -0
  387. package/templates/frontend/solid/src/main.tsx.hbs +41 -0
  388. package/templates/frontend/solid/src/routes/__root.tsx.hbs +34 -0
  389. package/templates/frontend/solid/src/routes/index.tsx.hbs +72 -0
  390. package/templates/frontend/solid/src/styles.css +5 -0
  391. package/templates/frontend/solid/tsconfig.json.hbs +29 -0
  392. package/templates/frontend/solid/vite.config.ts.hbs +21 -0
  393. package/templates/frontend/svelte/_gitignore +24 -0
  394. package/templates/frontend/svelte/_npmrc +1 -0
  395. package/templates/frontend/svelte/package.json.hbs +27 -0
  396. package/templates/frontend/svelte/src/app.css +5 -0
  397. package/templates/frontend/svelte/src/app.d.ts +13 -0
  398. package/templates/frontend/svelte/src/app.html +12 -0
  399. package/templates/frontend/svelte/src/components/Header.svelte.hbs +40 -0
  400. package/templates/frontend/svelte/src/lib/index.ts +2 -0
  401. package/templates/frontend/svelte/src/routes/+layout.svelte.hbs +54 -0
  402. package/templates/frontend/svelte/src/routes/+page.svelte.hbs +92 -0
  403. package/templates/frontend/svelte/static/favicon.png +0 -0
  404. package/templates/frontend/svelte/svelte.config.js.hbs +18 -0
  405. package/templates/frontend/svelte/tsconfig.json.hbs +19 -0
  406. package/templates/frontend/svelte/vite.config.ts.hbs +7 -0
  407. package/templates/packages/config/package.json.hbs +5 -0
  408. package/templates/packages/config/tsconfig.base.json.hbs +33 -0
  409. package/templates/packages/env/env.d.ts.hbs +16 -0
  410. package/templates/packages/env/package.json.hbs +7 -0
  411. package/templates/packages/env/src/native.ts.hbs +21 -0
  412. package/templates/packages/env/src/server.ts.hbs +39 -0
  413. package/templates/packages/env/src/web.ts.hbs +98 -0
  414. package/templates/packages/env/tsconfig.json.hbs +3 -0
  415. package/templates/packages/infra/alchemy.run.ts.hbs +271 -0
  416. package/templates/packages/infra/package.json.hbs +10 -0
  417. package/templates/payments/polar/server/base/src/lib/payments.ts.hbs +7 -0
  418. package/templates/payments/polar/web/nuxt/app/pages/success.vue.hbs +11 -0
  419. package/templates/payments/polar/web/react/next/src/app/success/page.tsx.hbs +15 -0
  420. package/templates/payments/polar/web/react/react-router/src/routes/success.tsx.hbs +13 -0
  421. package/templates/payments/polar/web/react/tanstack-router/src/routes/success.tsx.hbs +19 -0
  422. package/templates/payments/polar/web/react/tanstack-start/src/functions/get-payment.ts.hbs +15 -0
  423. package/templates/payments/polar/web/react/tanstack-start/src/routes/success.tsx.hbs +19 -0
  424. package/templates/payments/polar/web/solid/src/routes/success.tsx.hbs +23 -0
  425. package/templates/payments/polar/web/svelte/src/routes/success/+page.svelte.hbs +12 -0
@@ -0,0 +1,331 @@
1
+ {{#if (eq backend "convex")}}
2
+ import { Ionicons } from "@expo/vector-icons";
3
+ import {
4
+ useUIMessages,
5
+ useSmoothText,
6
+ type UIMessage,
7
+ } from "@convex-dev/agent/react";
8
+ import { api } from "@{{projectName}}/backend/convex/_generated/api";
9
+ import { useMutation } from "convex/react";
10
+ import { Button, Divider, Spinner, Surface, TextField, useThemeColor } from "heroui-native";
11
+ import { useRef, useEffect, useState } from "react";
12
+ import {
13
+ View,
14
+ Text,
15
+ ScrollView,
16
+ KeyboardAvoidingView,
17
+ Platform,
18
+ } from "react-native";
19
+
20
+ import { Container } from "@/components/container";
21
+
22
+ function MessageContent({
23
+ text,
24
+ isStreaming,
25
+ }: {
26
+ text: string;
27
+ isStreaming: boolean;
28
+ }) {
29
+ const [visibleText] = useSmoothText(text, {
30
+ startStreaming: isStreaming,
31
+ });
32
+ return <Text className="text-foreground text-sm leading-relaxed">{visibleText}</Text>;
33
+ }
34
+
35
+ export default function AIScreen() {
36
+ const [input, setInput] = useState("");
37
+ const [threadId, setThreadId] = useState<string | null>(null);
38
+ const [isLoading, setIsLoading] = useState(false);
39
+ const scrollViewRef = useRef<ScrollView>(null);
40
+ const mutedColor = useThemeColor("muted");
41
+ const foregroundColor = useThemeColor("foreground");
42
+
43
+ const createThread = useMutation(api.chat.createNewThread);
44
+ const sendMessage = useMutation(api.chat.sendMessage);
45
+
46
+ const { results: messages } = useUIMessages(
47
+ api.chat.listMessages,
48
+ threadId ? { threadId } : "skip",
49
+ { initialNumItems: 50, stream: true },
50
+ );
51
+
52
+ const hasStreamingMessage = messages?.some(
53
+ (m: UIMessage) => m.status === "streaming",
54
+ );
55
+
56
+ useEffect(() => {
57
+ scrollViewRef.current?.scrollToEnd({ animated: true });
58
+ }, [messages]);
59
+
60
+ const onSubmit = async () => {
61
+ const value = input.trim();
62
+ if (!value || isLoading) return;
63
+
64
+ setIsLoading(true);
65
+ setInput("");
66
+
67
+ try {
68
+ let currentThreadId = threadId;
69
+ if (!currentThreadId) {
70
+ currentThreadId = await createThread();
71
+ setThreadId(currentThreadId);
72
+ }
73
+
74
+ await sendMessage({ threadId: currentThreadId, prompt: value });
75
+ } catch (error) {
76
+ console.error("Failed to send message:", error);
77
+ } finally {
78
+ setIsLoading(false);
79
+ }
80
+ };
81
+
82
+ return (
83
+ <Container>
84
+ <KeyboardAvoidingView
85
+ className="flex-1"
86
+ behavior={Platform.OS === "ios" ? "padding" : "height"}
87
+ >
88
+ <View className="flex-1 px-4 py-4">
89
+ <View className="py-4 mb-4">
90
+ <Text className="text-2xl font-semibold text-foreground tracking-tight">AI Chat</Text>
91
+ <Text className="text-muted text-sm mt-1">Chat with our AI assistant</Text>
92
+ </View>
93
+
94
+ <ScrollView
95
+ ref={scrollViewRef}
96
+ className="flex-1 mb-4"
97
+ showsVerticalScrollIndicator={false}
98
+ >
99
+ {!messages || messages.length === 0 ? (
100
+ <View className="flex-1 justify-center items-center py-10">
101
+ <Ionicons name="chatbubble-ellipses-outline" size={32} color={mutedColor} />
102
+ <Text className="text-muted text-sm mt-3">Ask me anything to get started</Text>
103
+ </View>
104
+ ) : (
105
+ <View className="gap-2">
106
+ {messages.map((message: UIMessage) => (
107
+ <Surface
108
+ key={message.key}
109
+ variant={message.role === "user" ? "tertiary" : "secondary"}
110
+ className={`p-3 rounded-lg ${message.role === "user" ? "ml-10" : "mr-10"}`}
111
+ >
112
+ <Text className="text-xs font-medium mb-1 text-muted">
113
+ {message.role === "user" ? "You" : "AI"}
114
+ </Text>
115
+ <MessageContent
116
+ text={message.text ?? ""}
117
+ isStreaming={message.status === "streaming"}
118
+ />
119
+ </Surface>
120
+ ))}
121
+ {isLoading && !hasStreamingMessage && (
122
+ <Surface variant="secondary" className="p-3 mr-10 rounded-lg">
123
+ <Text className="text-xs font-medium mb-1 text-muted">AI</Text>
124
+ <View className="flex-row items-center gap-2">
125
+ <Spinner size="sm" />
126
+ <Text className="text-muted text-sm">Thinking...</Text>
127
+ </View>
128
+ </Surface>
129
+ )}
130
+ </View>
131
+ )}
132
+ </ScrollView>
133
+
134
+ <Divider className="mb-3" />
135
+
136
+ <View className="flex-row items-center gap-2">
137
+ <View className="flex-1">
138
+ <TextField>
139
+ <TextField.Input
140
+ value={input}
141
+ onChangeText={setInput}
142
+ placeholder="Type a message..."
143
+ onSubmitEditing={onSubmit}
144
+ editable={!isLoading}
145
+ autoFocus
146
+ />
147
+ </TextField>
148
+ </View>
149
+ <Button
150
+ isIconOnly
151
+ variant={input.trim() && !isLoading ? "primary" : "secondary"}
152
+ onPress={onSubmit}
153
+ isDisabled={!input.trim() || isLoading}
154
+ size="sm"
155
+ >
156
+ <Ionicons
157
+ name="arrow-up"
158
+ size={18}
159
+ color={input.trim() && !isLoading ? foregroundColor : mutedColor}
160
+ />
161
+ </Button>
162
+ </View>
163
+ </View>
164
+ </KeyboardAvoidingView>
165
+ </Container>
166
+ );
167
+ }
168
+ {{else}}
169
+ import { useRef, useEffect, useState } from "react";
170
+ import {
171
+ View,
172
+ Text,
173
+ ScrollView,
174
+ KeyboardAvoidingView,
175
+ Platform,
176
+ } from "react-native";
177
+ import { useChat } from "@ai-sdk/react";
178
+ import { DefaultChatTransport } from "ai";
179
+ import { fetch as expoFetch } from "expo/fetch";
180
+ import { Ionicons } from "@expo/vector-icons";
181
+ import { Container } from "@/components/container";
182
+ import { Button, Divider, ErrorView, Spinner, Surface, TextField, useThemeColor } from "heroui-native";
183
+ import { env } from "@{{projectName}}/env/native";
184
+
185
+ const generateAPIUrl = (relativePath: string) => {
186
+ const serverUrl = env.EXPO_PUBLIC_SERVER_URL;
187
+ if (!serverUrl) {
188
+ throw new Error(
189
+ "EXPO_PUBLIC_SERVER_URL environment variable is not defined"
190
+ );
191
+ }
192
+ const path = relativePath.startsWith("/") ? relativePath : `/${relativePath}`;
193
+ return serverUrl.concat(path);
194
+ };
195
+
196
+ export default function AIScreen() {
197
+ const [input, setInput] = useState("");
198
+ const { messages, error, sendMessage } = useChat({
199
+ transport: new DefaultChatTransport({
200
+ fetch: expoFetch as unknown as typeof globalThis.fetch,
201
+ api: generateAPIUrl("/ai"),
202
+ }),
203
+ onError: (error) => console.error(error, "AI Chat Error"),
204
+ });
205
+ const scrollViewRef = useRef<ScrollView>(null);
206
+ const foregroundColor = useThemeColor("foreground");
207
+ const mutedColor = useThemeColor("muted");
208
+
209
+ useEffect(() => {
210
+ scrollViewRef.current?.scrollToEnd({ animated: true });
211
+ }, [messages]);
212
+
213
+ const onSubmit = () => {
214
+ const value = input.trim();
215
+ if (value) {
216
+ sendMessage({ text: value });
217
+ setInput("");
218
+ }
219
+ };
220
+
221
+ if (error) {
222
+ return (
223
+ <Container>
224
+ <View className="flex-1 justify-center items-center px-4">
225
+ <Surface variant="secondary" className="p-4 rounded-lg">
226
+ <ErrorView isInvalid>
227
+ <Text className="text-danger text-center font-medium mb-1">
228
+ {error.message}
229
+ </Text>
230
+ <Text className="text-muted text-center text-xs">
231
+ Please check your connection and try again.
232
+ </Text>
233
+ </ErrorView>
234
+ </Surface>
235
+ </View>
236
+ </Container>
237
+ );
238
+ }
239
+
240
+ return (
241
+ <Container>
242
+ <KeyboardAvoidingView
243
+ className="flex-1"
244
+ behavior={Platform.OS === "ios" ? "padding" : "height"}
245
+ >
246
+ <View className="flex-1 px-4 py-4">
247
+ <View className="py-4 mb-4">
248
+ <Text className="text-2xl font-semibold text-foreground tracking-tight">AI Chat</Text>
249
+ <Text className="text-muted text-sm mt-1">Chat with our AI assistant</Text>
250
+ </View>
251
+
252
+ <ScrollView
253
+ ref={scrollViewRef}
254
+ className="flex-1 mb-4"
255
+ showsVerticalScrollIndicator={false}
256
+ >
257
+ {messages.length === 0 ? (
258
+ <View className="flex-1 justify-center items-center py-10">
259
+ <Ionicons name="chatbubble-ellipses-outline" size={32} color={mutedColor} />
260
+ <Text className="text-muted text-sm mt-3">Ask me anything to get started</Text>
261
+ </View>
262
+ ) : (
263
+ <View className="gap-2">
264
+ {messages.map((message) => (
265
+ <Surface
266
+ key={message.id}
267
+ variant={message.role === "user" ? "tertiary" : "secondary"}
268
+ className={`p-3 rounded-lg ${message.role === "user" ? "ml-10" : "mr-10"}`}
269
+ >
270
+ <Text className="text-xs font-medium mb-1 text-muted">
271
+ {message.role === "user" ? "You" : "AI"}
272
+ </Text>
273
+ <View className="gap-1">
274
+ {message.parts.map((part, i) =>
275
+ part.type === "text" ? (
276
+ <Text
277
+ key={`${message.id}-${i}`}
278
+ className="text-foreground text-sm leading-relaxed"
279
+ >
280
+ {part.text}
281
+ </Text>
282
+ ) : (
283
+ <Text
284
+ key={`${message.id}-${i}`}
285
+ className="text-foreground text-sm leading-relaxed"
286
+ >
287
+ {JSON.stringify(part)}
288
+ </Text>
289
+ )
290
+ )}
291
+ </View>
292
+ </Surface>
293
+ ))}
294
+ </View>
295
+ )}
296
+ </ScrollView>
297
+
298
+ <Divider className="mb-3" />
299
+
300
+ <View className="flex-row items-center gap-2">
301
+ <View className="flex-1">
302
+ <TextField>
303
+ <TextField.Input
304
+ value={input}
305
+ onChangeText={setInput}
306
+ placeholder="Type a message..."
307
+ onSubmitEditing={onSubmit}
308
+ autoFocus
309
+ />
310
+ </TextField>
311
+ </View>
312
+ <Button
313
+ isIconOnly
314
+ variant={input.trim() ? "primary" : "secondary"}
315
+ onPress={onSubmit}
316
+ isDisabled={!input.trim()}
317
+ size="sm"
318
+ >
319
+ <Ionicons
320
+ name="arrow-up"
321
+ size={18}
322
+ color={input.trim() ? foregroundColor : mutedColor}
323
+ />
324
+ </Button>
325
+ </View>
326
+ </View>
327
+ </KeyboardAvoidingView>
328
+ </Container>
329
+ );
330
+ }
331
+ {{/if}}
@@ -0,0 +1,22 @@
1
+ import structuredClone from "@ungap/structured-clone";
2
+ import { Platform } from "react-native";
3
+
4
+ if (Platform.OS !== "web") {
5
+ const setupPolyfills = async () => {
6
+ const { polyfillGlobal } = await import("react-native/Libraries/Utilities/PolyfillFunctions");
7
+
8
+ const { TextEncoderStream, TextDecoderStream } =
9
+ await import("@stardazed/streams-text-encoding");
10
+
11
+ if (!("structuredClone" in global)) {
12
+ polyfillGlobal("structuredClone", () => structuredClone);
13
+ }
14
+
15
+ polyfillGlobal("TextEncoderStream", () => TextEncoderStream);
16
+ polyfillGlobal("TextDecoderStream", () => TextDecoderStream);
17
+ };
18
+
19
+ setupPolyfills();
20
+ }
21
+
22
+ export {};
@@ -0,0 +1,54 @@
1
+ <script setup lang="ts">
2
+ import { Chat } from '@ai-sdk/vue'
3
+ import type { UIMessage } from 'ai'
4
+ import { getTextFromMessage } from '@nuxt/ui/utils/ai'
5
+ import { DefaultChatTransport } from 'ai'
6
+ import { ref } from 'vue'
7
+
8
+ const config = useRuntimeConfig()
9
+ const messages: UIMessage[] = []
10
+ const input = ref('')
11
+
12
+ const chat = new Chat({
13
+ messages,
14
+ transport: new DefaultChatTransport({
15
+ api: `${config.public.serverUrl}/ai`,
16
+ }),
17
+ onError(error) {
18
+ console.error('Chat error:', error)
19
+ }
20
+ })
21
+
22
+ async function handleSubmit(e: Event) {
23
+ e.preventDefault()
24
+ const userInput = input.value
25
+ input.value = ''
26
+
27
+ if (!userInput.trim()) return
28
+
29
+ chat.sendMessage({ text: userInput })
30
+ }
31
+ </script>
32
+
33
+ <template>
34
+ <UContainer class="h-full flex flex-col overflow-hidden py-4">
35
+ <div class="flex-1 min-h-0 overflow-y-auto">
36
+ <UChatMessages :messages="chat.messages" :status="chat.status">
37
+ <template #content="{ message }">
38
+ <div class="whitespace-pre-wrap">\{{ getTextFromMessage(message) }}</div>
39
+ </template>
40
+ </UChatMessages>
41
+ </div>
42
+
43
+ <div class="shrink-0 pt-4 border-t border-gray-200 dark:border-gray-800">
44
+ <UChatPrompt
45
+ v-model="input"
46
+ :error="chat.error"
47
+ @submit="handleSubmit"
48
+ placeholder="Type your message..."
49
+ >
50
+ <UChatPromptSubmit :status="chat.status" @stop="() => chat.stop()" @reload="() => chat.regenerate()" />
51
+ </UChatPrompt>
52
+ </div>
53
+ </UContainer>
54
+ </template>
@@ -0,0 +1,267 @@
1
+ {{#if (eq backend "convex")}}
2
+ "use client";
3
+
4
+ import { api } from "@{{projectName}}/backend/convex/_generated/api";
5
+ import {
6
+ useUIMessages,
7
+ useSmoothText,
8
+ type UIMessage,
9
+ } from "@convex-dev/agent/react";
10
+ import { useMutation } from "convex/react";
11
+ import { Send, Loader2 } from "lucide-react";
12
+ {{#if (eq webDeploy "cloudflare")}}
13
+ import dynamic from "next/dynamic";
14
+
15
+ const Streamdown = dynamic(
16
+ () => import("streamdown").then((mod) => ({ default: mod.Streamdown })),
17
+ {
18
+ loading: () => (
19
+ <div className="flex h-full items-center justify-center">
20
+ <div className="text-muted-foreground">Loading response...</div>
21
+ </div>
22
+ ),
23
+ ssr: false,
24
+ }
25
+ );
26
+ {{else}}
27
+ import { Streamdown } from "streamdown";
28
+ {{/if}}
29
+ import { useEffect, useRef, useState } from "react";
30
+
31
+ import { Button } from "@/components/ui/button";
32
+ import { Input } from "@/components/ui/input";
33
+
34
+ function MessageContent({
35
+ text,
36
+ isStreaming,
37
+ }: {
38
+ text: string;
39
+ isStreaming: boolean;
40
+ }) {
41
+ const [visibleText] = useSmoothText(text, {
42
+ startStreaming: isStreaming,
43
+ });
44
+ return <Streamdown>{visibleText}</Streamdown>;
45
+ }
46
+
47
+ export default function AIPage() {
48
+ const [input, setInput] = useState("");
49
+ const [threadId, setThreadId] = useState<string | null>(null);
50
+ const [isLoading, setIsLoading] = useState(false);
51
+ const messagesEndRef = useRef<HTMLDivElement>(null);
52
+
53
+ const createThread = useMutation(api.chat.createNewThread);
54
+ const sendMessage = useMutation(api.chat.sendMessage);
55
+
56
+ const { results: messages } = useUIMessages(
57
+ api.chat.listMessages,
58
+ threadId ? { threadId } : "skip",
59
+ { initialNumItems: 50, stream: true },
60
+ );
61
+
62
+ useEffect(() => {
63
+ messagesEndRef.current?.scrollIntoView({ behavior: "smooth" });
64
+ }, [messages]);
65
+
66
+ const hasStreamingMessage = messages?.some(
67
+ (m: UIMessage) => m.status === "streaming",
68
+ );
69
+
70
+ const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
71
+ e.preventDefault();
72
+ const text = input.trim();
73
+ if (!text || isLoading) return;
74
+
75
+ setIsLoading(true);
76
+ setInput("");
77
+
78
+ try {
79
+ let currentThreadId = threadId;
80
+ if (!currentThreadId) {
81
+ currentThreadId = await createThread();
82
+ setThreadId(currentThreadId);
83
+ }
84
+
85
+ await sendMessage({ threadId: currentThreadId, prompt: text });
86
+ } catch (error) {
87
+ console.error("Failed to send message:", error);
88
+ } finally {
89
+ setIsLoading(false);
90
+ }
91
+ };
92
+
93
+ return (
94
+ <div className="grid grid-rows-[1fr_auto] overflow-hidden w-full mx-auto p-4">
95
+ <div className="overflow-y-auto space-y-4 pb-4">
96
+ {!messages || messages.length === 0 ? (
97
+ <div className="text-center text-muted-foreground mt-8">
98
+ Ask me anything to get started!
99
+ </div>
100
+ ) : (
101
+ messages.map((message: UIMessage) => (
102
+ <div
103
+ key={message.key}
104
+ className={`p-3 rounded-lg ${
105
+ message.role === "user"
106
+ ? "bg-primary/10 ml-8"
107
+ : "bg-secondary/20 mr-8"
108
+ }`}
109
+ >
110
+ <p className="text-sm font-semibold mb-1">
111
+ {message.role === "user" ? "You" : "AI Assistant"}
112
+ </p>
113
+ <MessageContent
114
+ text={message.text ?? ""}
115
+ isStreaming={message.status === "streaming"}
116
+ />
117
+ </div>
118
+ ))
119
+ )}
120
+ {isLoading && !hasStreamingMessage && (
121
+ <div className="p-3 rounded-lg bg-secondary/20 mr-8">
122
+ <p className="text-sm font-semibold mb-1">AI Assistant</p>
123
+ <div className="flex items-center gap-2 text-muted-foreground">
124
+ <Loader2 className="h-4 w-4 animate-spin" />
125
+ <span>Thinking...</span>
126
+ </div>
127
+ </div>
128
+ )}
129
+ <div ref={messagesEndRef} />
130
+ </div>
131
+
132
+ <form
133
+ onSubmit={handleSubmit}
134
+ className="w-full flex items-center space-x-2 pt-2 border-t"
135
+ >
136
+ <Input
137
+ name="prompt"
138
+ value={input}
139
+ onChange={(e) => setInput(e.target.value)}
140
+ placeholder="Type your message..."
141
+ className="flex-1"
142
+ autoComplete="off"
143
+ autoFocus
144
+ disabled={isLoading}
145
+ />
146
+ <Button type="submit" size="icon" disabled={isLoading || !input.trim()}>
147
+ {isLoading ? (
148
+ <Loader2 className="h-4 w-4 animate-spin" />
149
+ ) : (
150
+ <Send size={18} />
151
+ )}
152
+ </Button>
153
+ </form>
154
+ </div>
155
+ );
156
+ }
157
+ {{else}}
158
+ "use client";
159
+
160
+ import { useChat } from "@ai-sdk/react";
161
+ import { DefaultChatTransport } from "ai";
162
+ import { Send } from "lucide-react";
163
+ {{#if (eq webDeploy "cloudflare")}}
164
+ import dynamic from "next/dynamic";
165
+
166
+ const Streamdown = dynamic(
167
+ () => import("streamdown").then((mod) => ({ default: mod.Streamdown })),
168
+ {
169
+ loading: () => (
170
+ <div className="flex h-full items-center justify-center">
171
+ <div className="text-muted-foreground">Loading response...</div>
172
+ </div>
173
+ ),
174
+ ssr: false,
175
+ }
176
+ );
177
+ {{else}}
178
+ import { Streamdown } from "streamdown";
179
+ {{/if}}
180
+ import { useEffect, useRef, useState } from "react";
181
+
182
+ import { Button } from "@/components/ui/button";
183
+ import { Input } from "@/components/ui/input";
184
+ import { env } from "@{{projectName}}/env/web";
185
+
186
+ export default function AIPage() {
187
+ const [input, setInput] = useState("");
188
+ const { messages, sendMessage, status } = useChat({
189
+ transport: new DefaultChatTransport({
190
+ api: {{#if (eq backend "self")}}"/api/ai"{{else}}`${env.NEXT_PUBLIC_SERVER_URL}/ai`{{/if}},
191
+ }),
192
+ });
193
+
194
+ const messagesEndRef = useRef<HTMLDivElement>(null);
195
+
196
+ useEffect(() => {
197
+ messagesEndRef.current?.scrollIntoView({ behavior: "smooth" });
198
+ }, [messages]);
199
+
200
+ const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {
201
+ e.preventDefault();
202
+ const text = input.trim();
203
+ if (!text) return;
204
+ sendMessage({ text });
205
+ setInput("");
206
+ };
207
+
208
+ return (
209
+ <div className="grid grid-rows-[1fr_auto] overflow-hidden w-full mx-auto p-4">
210
+ <div className="overflow-y-auto space-y-4 pb-4">
211
+ {messages.length === 0 ? (
212
+ <div className="text-center text-muted-foreground mt-8">
213
+ Ask me anything to get started!
214
+ </div>
215
+ ) : (
216
+ messages.map((message) => (
217
+ <div
218
+ key={message.id}
219
+ className={`p-3 rounded-lg ${
220
+ message.role === "user"
221
+ ? "bg-primary/10 ml-8"
222
+ : "bg-secondary/20 mr-8"
223
+ }`}
224
+ >
225
+ <p className="text-sm font-semibold mb-1">
226
+ {message.role === "user" ? "You" : "AI Assistant"}
227
+ </p>
228
+ {message.parts?.map((part, index) => {
229
+ if (part.type === "text") {
230
+ return (
231
+ <Streamdown
232
+ key={index}
233
+ isAnimating={status === "streaming" && message.role === "assistant"}
234
+ >
235
+ {part.text}
236
+ </Streamdown>
237
+ );
238
+ }
239
+ return null;
240
+ })}
241
+ </div>
242
+ ))
243
+ )}
244
+ <div ref={messagesEndRef} />
245
+ </div>
246
+
247
+ <form
248
+ onSubmit={handleSubmit}
249
+ className="w-full flex items-center space-x-2 pt-2 border-t"
250
+ >
251
+ <Input
252
+ name="prompt"
253
+ value={input}
254
+ onChange={(e) => setInput(e.target.value)}
255
+ placeholder="Type your message..."
256
+ className="flex-1"
257
+ autoComplete="off"
258
+ autoFocus
259
+ />
260
+ <Button type="submit" size="icon">
261
+ <Send size={18} />
262
+ </Button>
263
+ </form>
264
+ </div>
265
+ );
266
+ }
267
+ {{/if}}