create-fate 1.3.3 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/create-fate.mjs +41 -3
- package/package.json +1 -1
- package/templates/fate/_shared/vue-app/package.json +14 -16
- package/templates/fate/cloudflare/README.md +11 -0
- package/templates/fate/cloudflare/client/node_modules/.bin/browserslist +22 -0
- package/templates/fate/cloudflare/client/node_modules/.bin/cf-wrangler +22 -0
- package/templates/fate/cloudflare/client/node_modules/.bin/drizzle-kit +22 -0
- package/templates/fate/cloudflare/client/node_modules/.bin/esbuild +22 -0
- package/templates/fate/cloudflare/client/node_modules/.bin/fate +22 -0
- package/templates/fate/cloudflare/client/node_modules/.bin/fbtee +22 -0
- package/templates/fate/cloudflare/client/node_modules/.bin/intent +22 -0
- package/templates/fate/cloudflare/client/node_modules/.bin/jiti +22 -0
- package/templates/fate/cloudflare/client/node_modules/.bin/oxfmt +22 -0
- package/templates/fate/cloudflare/client/node_modules/.bin/oxlint +22 -0
- package/templates/fate/cloudflare/client/node_modules/.bin/rolldown +22 -0
- package/templates/fate/cloudflare/client/node_modules/.bin/tsc +22 -0
- package/templates/fate/cloudflare/client/node_modules/.bin/tsx +22 -0
- package/templates/fate/cloudflare/client/node_modules/.bin/vitest +22 -0
- package/templates/fate/cloudflare/client/node_modules/.bin/void +22 -0
- package/templates/fate/cloudflare/client/node_modules/.bin/vp +22 -0
- package/templates/fate/cloudflare/client/node_modules/.bin/vpr +22 -0
- package/templates/fate/cloudflare/client/node_modules/.bin/workerd +22 -0
- package/templates/fate/cloudflare/client/node_modules/.bin/wrangler +22 -0
- package/templates/fate/cloudflare/client/node_modules/.bin/wrangler2 +22 -0
- package/templates/fate/cloudflare/client/package.json +26 -21
- package/templates/fate/cloudflare/client/pages/layout.tsx +2 -16
- package/templates/fate/cloudflare/client/src/lib/AvailableLanguages.tsx +3 -3
- package/templates/fate/cloudflare/client/src/lib/LocaleContext.tsx +61 -0
- package/templates/fate/cloudflare/client/src/ui/LocaleSwitcher.tsx +26 -44
- package/templates/fate/cloudflare/client/start.mjs +11 -0
- package/templates/fate/cloudflare/client/translations/{de_DE.json → de-DE.json} +56 -113
- package/templates/fate/{graphql/client/translations/ja_JP.json → cloudflare/client/translations/ja-JP.json} +56 -113
- package/templates/fate/cloudflare/client/vite.config.ts +4 -8
- package/templates/fate/cloudflare/package.json +6 -10
- package/templates/fate/cloudflare/pnpm-workspace.yaml +4 -4
- package/templates/fate/cloudflare/server/db/migrations/20260508073357_initial_schema.sql +3 -2
- package/templates/fate/cloudflare/server/db/migrations/20260508120500_seed_cloudflare_demo.sql +10 -10
- package/templates/fate/cloudflare/server/db/migrations/meta/20260508073357_snapshot.json +10 -3
- package/templates/fate/cloudflare/server/db/schema.ts +2 -3
- package/templates/fate/cloudflare/server/node_modules/.bin/cf-wrangler +22 -0
- package/templates/fate/cloudflare/server/node_modules/.bin/drizzle-kit +22 -0
- package/templates/fate/cloudflare/server/node_modules/.bin/esbuild +22 -0
- package/templates/fate/cloudflare/server/node_modules/.bin/fate +22 -0
- package/templates/fate/cloudflare/server/node_modules/.bin/intent +22 -0
- package/templates/fate/cloudflare/server/node_modules/.bin/jiti +22 -0
- package/templates/fate/cloudflare/server/node_modules/.bin/oxfmt +22 -0
- package/templates/fate/cloudflare/server/node_modules/.bin/oxlint +22 -0
- package/templates/fate/cloudflare/server/node_modules/.bin/tsc +22 -0
- package/templates/fate/cloudflare/server/node_modules/.bin/tsx +22 -0
- package/templates/fate/cloudflare/server/node_modules/.bin/vitest +22 -0
- package/templates/fate/cloudflare/server/node_modules/.bin/vp +22 -0
- package/templates/fate/cloudflare/server/node_modules/.bin/vpr +22 -0
- package/templates/fate/cloudflare/server/node_modules/.bin/workerd +22 -0
- package/templates/fate/cloudflare/server/node_modules/.bin/wrangler +22 -0
- package/templates/fate/cloudflare/server/node_modules/.bin/wrangler2 +22 -0
- package/templates/fate/cloudflare/server/package.json +3 -3
- package/templates/fate/cloudflare/server/src/fate/server.ts +5 -2
- package/templates/fate/cloudflare/server/src/lib/auth.ts +0 -2
- package/templates/fate/cloudflare/server/tsconfig.json +1 -1
- package/templates/fate/cloudflare/tsconfig.json +2 -11
- package/templates/fate/cloudflare/vite.config.ts +3 -0
- package/templates/fate/drizzle/README.md +11 -0
- package/templates/fate/drizzle/client/node_modules/.bin/browserslist +22 -0
- package/templates/fate/drizzle/client/node_modules/.bin/cf-wrangler +22 -0
- package/templates/fate/drizzle/client/node_modules/.bin/drizzle-kit +22 -0
- package/templates/fate/drizzle/client/node_modules/.bin/esbuild +22 -0
- package/templates/fate/drizzle/client/node_modules/.bin/fate +22 -0
- package/templates/fate/drizzle/client/node_modules/.bin/fbtee +22 -0
- package/templates/fate/drizzle/client/node_modules/.bin/intent +22 -0
- package/templates/fate/drizzle/client/node_modules/.bin/jiti +22 -0
- package/templates/fate/drizzle/client/node_modules/.bin/oxfmt +22 -0
- package/templates/fate/drizzle/client/node_modules/.bin/oxlint +22 -0
- package/templates/fate/drizzle/client/node_modules/.bin/rolldown +22 -0
- package/templates/fate/drizzle/client/node_modules/.bin/tsc +22 -0
- package/templates/fate/drizzle/client/node_modules/.bin/tsx +22 -0
- package/templates/fate/drizzle/client/node_modules/.bin/vitest +22 -0
- package/templates/fate/drizzle/client/node_modules/.bin/void +22 -0
- package/templates/fate/drizzle/client/node_modules/.bin/vp +22 -0
- package/templates/fate/drizzle/client/node_modules/.bin/vpr +22 -0
- package/templates/fate/drizzle/client/node_modules/.bin/workerd +22 -0
- package/templates/fate/drizzle/client/node_modules/.bin/wrangler +22 -0
- package/templates/fate/drizzle/client/node_modules/.bin/wrangler2 +22 -0
- package/templates/fate/drizzle/client/package.json +28 -24
- package/templates/fate/drizzle/client/pages/layout.tsx +2 -16
- package/templates/fate/drizzle/client/src/lib/AvailableLanguages.tsx +3 -3
- package/templates/fate/drizzle/client/src/lib/LocaleContext.tsx +61 -0
- package/templates/fate/drizzle/client/src/ui/LocaleSwitcher.tsx +26 -44
- package/templates/fate/drizzle/client/start.mjs +11 -0
- package/templates/fate/{graphql/client/translations/de_DE.json → drizzle/client/translations/de-DE.json} +56 -113
- package/templates/fate/{cloudflare/client/translations/ja_JP.json → drizzle/client/translations/ja-JP.json} +56 -113
- package/templates/fate/drizzle/client/vite.config.ts +4 -8
- package/templates/fate/drizzle/package.json +6 -10
- package/templates/fate/drizzle/pnpm-workspace.yaml +4 -4
- package/templates/fate/drizzle/server/node_modules/.bin/drizzle-kit +22 -0
- package/templates/fate/drizzle/server/node_modules/.bin/esbuild +22 -0
- package/templates/fate/drizzle/server/node_modules/.bin/fate +22 -0
- package/templates/fate/drizzle/server/node_modules/.bin/intent +22 -0
- package/templates/fate/drizzle/server/node_modules/.bin/jiti +22 -0
- package/templates/fate/drizzle/server/node_modules/.bin/nodemon +22 -0
- package/templates/fate/drizzle/server/node_modules/.bin/oxfmt +22 -0
- package/templates/fate/drizzle/server/node_modules/.bin/oxlint +22 -0
- package/templates/fate/drizzle/server/node_modules/.bin/tsc +22 -0
- package/templates/fate/drizzle/server/node_modules/.bin/tsx +22 -0
- package/templates/fate/drizzle/server/node_modules/.bin/vitest +22 -0
- package/templates/fate/drizzle/server/node_modules/.bin/vp +22 -0
- package/templates/fate/drizzle/server/node_modules/.bin/vpr +22 -0
- package/templates/fate/drizzle/server/package.json +9 -9
- package/templates/fate/drizzle/server/src/app.tsx +1 -1
- package/templates/fate/drizzle/server/src/drizzle/schema.ts +2 -3
- package/templates/fate/drizzle/server/src/drizzle/seed.tsx +1 -1
- package/templates/fate/drizzle/tsconfig.json +1 -10
- package/templates/fate/graphql/README.md +11 -0
- package/templates/fate/graphql/client/node_modules/.bin/browserslist +22 -0
- package/templates/fate/graphql/client/node_modules/.bin/cf-wrangler +22 -0
- package/templates/fate/graphql/client/node_modules/.bin/drizzle-kit +22 -0
- package/templates/fate/graphql/client/node_modules/.bin/esbuild +22 -0
- package/templates/fate/graphql/client/node_modules/.bin/fate +22 -0
- package/templates/fate/graphql/client/node_modules/.bin/fbtee +22 -0
- package/templates/fate/graphql/client/node_modules/.bin/intent +22 -0
- package/templates/fate/graphql/client/node_modules/.bin/jiti +22 -0
- package/templates/fate/graphql/client/node_modules/.bin/oxfmt +22 -0
- package/templates/fate/graphql/client/node_modules/.bin/oxlint +22 -0
- package/templates/fate/graphql/client/node_modules/.bin/rolldown +22 -0
- package/templates/fate/graphql/client/node_modules/.bin/tsc +22 -0
- package/templates/fate/graphql/client/node_modules/.bin/tsx +22 -0
- package/templates/fate/graphql/client/node_modules/.bin/vitest +22 -0
- package/templates/fate/graphql/client/node_modules/.bin/void +22 -0
- package/templates/fate/graphql/client/node_modules/.bin/vp +22 -0
- package/templates/fate/graphql/client/node_modules/.bin/vpr +22 -0
- package/templates/fate/graphql/client/node_modules/.bin/workerd +22 -0
- package/templates/fate/graphql/client/node_modules/.bin/wrangler +22 -0
- package/templates/fate/graphql/client/node_modules/.bin/wrangler2 +22 -0
- package/templates/fate/graphql/client/node_modules/.bin/yaml +22 -0
- package/templates/fate/graphql/client/package.json +27 -23
- package/templates/fate/graphql/client/pages/layout.tsx +2 -16
- package/templates/fate/graphql/client/src/lib/AvailableLanguages.tsx +3 -3
- package/templates/fate/graphql/client/src/lib/LocaleContext.tsx +61 -0
- package/templates/fate/graphql/client/src/ui/LocaleSwitcher.tsx +26 -44
- package/templates/fate/graphql/client/src/ui/PostCard.tsx +1 -1
- package/templates/fate/graphql/client/start.mjs +11 -0
- package/templates/fate/{drizzle/client/translations/de_DE.json → graphql/client/translations/de-DE.json} +56 -113
- package/templates/fate/{http/client/translations/ja_JP.json → graphql/client/translations/ja-JP.json} +56 -113
- package/templates/fate/graphql/client/vite.config.ts +4 -8
- package/templates/fate/graphql/package.json +7 -11
- package/templates/fate/graphql/pnpm-workspace.yaml +4 -4
- package/templates/fate/graphql/server/package.json +25 -29
- package/templates/fate/graphql/server/prisma.config.ts +9 -1
- package/templates/fate/graphql/server/scripts/generate-graphql.tsx +1 -1
- package/templates/fate/graphql/server/src/index.tsx +1 -1
- package/templates/fate/graphql/server/src/prisma/schema.prisma +2 -1
- package/templates/fate/graphql/server/src/prisma/seed.tsx +1 -1
- package/templates/fate/graphql/server/tsconfig.json +1 -11
- package/templates/fate/graphql/tsconfig.json +1 -10
- package/templates/fate/graphql-client/README.md +9 -0
- package/templates/fate/graphql-client/_gitignore +3 -0
- package/templates/fate/graphql-client/package.json +27 -24
- package/templates/fate/graphql-client/pages/index.tsx +61 -27
- package/templates/fate/graphql-client/pages/layout.tsx +22 -15
- package/templates/fate/graphql-client/pnpm-workspace.yaml +6 -4
- package/templates/fate/graphql-client/src/lib/AvailableLanguages.tsx +5 -0
- package/templates/fate/graphql-client/src/lib/LocaleContext.tsx +61 -0
- package/templates/fate/graphql-client/src/ui/LocaleSwitcher.tsx +34 -0
- package/templates/fate/graphql-client/translations/de-DE.json +225 -0
- package/templates/fate/graphql-client/translations/ja-JP.json +225 -0
- package/templates/fate/graphql-client/vite.config.ts +9 -13
- package/templates/fate/http/README.md +11 -0
- package/templates/fate/http/client/node_modules/.bin/browserslist +22 -0
- package/templates/fate/http/client/node_modules/.bin/cf-wrangler +22 -0
- package/templates/fate/http/client/node_modules/.bin/drizzle-kit +22 -0
- package/templates/fate/http/client/node_modules/.bin/esbuild +22 -0
- package/templates/fate/http/client/node_modules/.bin/fate +22 -0
- package/templates/fate/http/client/node_modules/.bin/fbtee +22 -0
- package/templates/fate/http/client/node_modules/.bin/intent +22 -0
- package/templates/fate/http/client/node_modules/.bin/jiti +22 -0
- package/templates/fate/http/client/node_modules/.bin/oxfmt +22 -0
- package/templates/fate/http/client/node_modules/.bin/oxlint +22 -0
- package/templates/fate/http/client/node_modules/.bin/rolldown +22 -0
- package/templates/fate/http/client/node_modules/.bin/tsc +22 -0
- package/templates/fate/http/client/node_modules/.bin/tsx +22 -0
- package/templates/fate/http/client/node_modules/.bin/vitest +22 -0
- package/templates/fate/http/client/node_modules/.bin/void +22 -0
- package/templates/fate/http/client/node_modules/.bin/vp +22 -0
- package/templates/fate/http/client/node_modules/.bin/vpr +22 -0
- package/templates/fate/http/client/node_modules/.bin/workerd +22 -0
- package/templates/fate/http/client/node_modules/.bin/wrangler +22 -0
- package/templates/fate/http/client/node_modules/.bin/wrangler2 +22 -0
- package/templates/fate/http/client/package.json +26 -22
- package/templates/fate/http/client/pages/layout.tsx +2 -16
- package/templates/fate/http/client/src/lib/AvailableLanguages.tsx +3 -3
- package/templates/fate/http/client/src/lib/LocaleContext.tsx +61 -0
- package/templates/fate/http/client/src/ui/LocaleSwitcher.tsx +26 -44
- package/templates/fate/http/client/start.mjs +11 -0
- package/templates/fate/http/client/translations/{de_DE.json → de-DE.json} +56 -113
- package/templates/fate/{drizzle/client/translations/ja_JP.json → http/client/translations/ja-JP.json} +56 -113
- package/templates/fate/http/client/vite.config.ts +4 -8
- package/templates/fate/http/package.json +6 -10
- package/templates/fate/http/pnpm-workspace.yaml +4 -4
- package/templates/fate/http/server/node_modules/.bin/drizzle-kit +22 -0
- package/templates/fate/http/server/node_modules/.bin/esbuild +22 -0
- package/templates/fate/http/server/node_modules/.bin/fate +22 -0
- package/templates/fate/http/server/node_modules/.bin/intent +22 -0
- package/templates/fate/http/server/node_modules/.bin/jiti +22 -0
- package/templates/fate/http/server/node_modules/.bin/nodemon +22 -0
- package/templates/fate/http/server/node_modules/.bin/oxfmt +22 -0
- package/templates/fate/http/server/node_modules/.bin/oxlint +22 -0
- package/templates/fate/http/server/node_modules/.bin/tsc +22 -0
- package/templates/fate/http/server/node_modules/.bin/tsx +22 -0
- package/templates/fate/http/server/node_modules/.bin/vitest +22 -0
- package/templates/fate/http/server/node_modules/.bin/vp +22 -0
- package/templates/fate/http/server/node_modules/.bin/vpr +22 -0
- package/templates/fate/http/server/package.json +8 -8
- package/templates/fate/http/server/src/app.tsx +1 -1
- package/templates/fate/http/server/src/drizzle/schema.ts +2 -3
- package/templates/fate/http/server/src/drizzle/seed.tsx +1 -1
- package/templates/fate/http/tsconfig.json +1 -10
- package/templates/fate/prisma/README.md +11 -0
- package/templates/fate/prisma/client/node_modules/.bin/browserslist +22 -0
- package/templates/fate/prisma/client/node_modules/.bin/cf-wrangler +22 -0
- package/templates/fate/prisma/client/node_modules/.bin/drizzle-kit +22 -0
- package/templates/fate/prisma/client/node_modules/.bin/esbuild +22 -0
- package/templates/fate/prisma/client/node_modules/.bin/fate +22 -0
- package/templates/fate/prisma/client/node_modules/.bin/fbtee +22 -0
- package/templates/fate/prisma/client/node_modules/.bin/intent +22 -0
- package/templates/fate/prisma/client/node_modules/.bin/jiti +22 -0
- package/templates/fate/prisma/client/node_modules/.bin/oxfmt +22 -0
- package/templates/fate/prisma/client/node_modules/.bin/oxlint +22 -0
- package/templates/fate/prisma/client/node_modules/.bin/rolldown +22 -0
- package/templates/fate/prisma/client/node_modules/.bin/tsc +22 -0
- package/templates/fate/prisma/client/node_modules/.bin/tsx +22 -0
- package/templates/fate/prisma/client/node_modules/.bin/vitest +22 -0
- package/templates/fate/prisma/client/node_modules/.bin/void +22 -0
- package/templates/fate/prisma/client/node_modules/.bin/vp +22 -0
- package/templates/fate/prisma/client/node_modules/.bin/vpr +22 -0
- package/templates/fate/prisma/client/node_modules/.bin/workerd +22 -0
- package/templates/fate/prisma/client/node_modules/.bin/wrangler +22 -0
- package/templates/fate/prisma/client/node_modules/.bin/wrangler2 +22 -0
- package/templates/fate/prisma/client/node_modules/.bin/yaml +22 -0
- package/templates/fate/prisma/client/package.json +28 -24
- package/templates/fate/prisma/client/pages/layout.tsx +2 -16
- package/templates/fate/prisma/client/src/lib/AvailableLanguages.tsx +3 -3
- package/templates/fate/prisma/client/src/lib/LocaleContext.tsx +61 -0
- package/templates/fate/prisma/client/src/ui/LocaleSwitcher.tsx +26 -44
- package/templates/fate/prisma/client/start.mjs +11 -0
- package/templates/fate/prisma/client/translations/de-DE.json +632 -0
- package/templates/fate/prisma/client/translations/ja-JP.json +632 -0
- package/templates/fate/prisma/client/vite.config.ts +4 -8
- package/templates/fate/prisma/package.json +7 -11
- package/templates/fate/prisma/pnpm-workspace.yaml +4 -4
- package/templates/fate/prisma/server/node_modules/.bin/esbuild +22 -0
- package/templates/fate/prisma/server/node_modules/.bin/fate +22 -0
- package/templates/fate/prisma/server/node_modules/.bin/intent +22 -0
- package/templates/fate/prisma/server/node_modules/.bin/jiti +22 -0
- package/templates/fate/prisma/server/node_modules/.bin/nft +22 -0
- package/templates/fate/prisma/server/node_modules/.bin/nodemon +22 -0
- package/templates/fate/prisma/server/node_modules/.bin/oxfmt +22 -0
- package/templates/fate/prisma/server/node_modules/.bin/oxlint +22 -0
- package/templates/fate/prisma/server/node_modules/.bin/prisma +22 -0
- package/templates/fate/prisma/server/node_modules/.bin/tsc +22 -0
- package/templates/fate/prisma/server/node_modules/.bin/tsx +22 -0
- package/templates/fate/prisma/server/node_modules/.bin/vitest +22 -0
- package/templates/fate/prisma/server/node_modules/.bin/vp +22 -0
- package/templates/fate/prisma/server/node_modules/.bin/vpr +22 -0
- package/templates/fate/prisma/server/node_modules/.bin/yaml +22 -0
- package/templates/fate/prisma/server/package.json +9 -9
- package/templates/fate/prisma/server/prisma.config.ts +2 -1
- package/templates/fate/prisma/server/src/app.tsx +1 -1
- package/templates/fate/prisma/server/src/prisma/schema.prisma +2 -1
- package/templates/fate/prisma/server/src/prisma/seed.tsx +1 -1
- package/templates/fate/prisma/tsconfig.json +1 -10
- package/templates/fate/void/README.md +9 -0
- package/templates/fate/void/_gitignore +3 -0
- package/templates/fate/void/db/migrations/20260508073357_initial_schema.sql +3 -2
- package/templates/fate/void/db/migrations/20260508120500_seed_void_demo.sql +10 -10
- package/templates/fate/void/db/migrations/meta/20260508073357_snapshot.json +10 -3
- package/templates/fate/void/db/schema.ts +2 -3
- package/templates/fate/void/middleware/01.shared.ts +3 -0
- package/templates/fate/void/package.json +30 -25
- package/templates/fate/void/pages/index.tsx +23 -10
- package/templates/fate/void/pages/layout.tsx +22 -19
- package/templates/fate/void/pages/login.tsx +22 -18
- package/templates/fate/void/pages/search.tsx +18 -4
- package/templates/fate/void/pnpm-workspace.yaml +4 -4
- package/templates/fate/void/src/fate/server.ts +2 -1
- package/templates/fate/void/src/lib/AvailableLanguages.tsx +5 -0
- package/templates/fate/void/src/lib/LocaleContext.tsx +61 -0
- package/templates/fate/void/src/ui/CategoryCard.tsx +22 -4
- package/templates/fate/void/src/ui/CreatePost.tsx +12 -7
- package/templates/fate/void/src/ui/Error.tsx +4 -2
- package/templates/fate/void/src/ui/EventCard.tsx +18 -5
- package/templates/fate/void/src/ui/Header.tsx +10 -4
- package/templates/fate/void/src/ui/LocaleSwitcher.tsx +34 -0
- package/templates/fate/void/src/ui/PostCard.tsx +29 -14
- package/templates/fate/void/src/ui/UserCard.tsx +15 -8
- package/templates/fate/void/translations/de-DE.json +863 -0
- package/templates/fate/void/translations/ja-JP.json +863 -0
- package/templates/fate/void/vite.config.ts +6 -6
- package/templates/fate/prisma/client/translations/de_DE.json +0 -689
- package/templates/fate/prisma/client/translations/ja_JP.json +0 -689
|
@@ -9,9 +9,17 @@ dotenv.config({
|
|
|
9
9
|
quiet: true,
|
|
10
10
|
});
|
|
11
11
|
|
|
12
|
+
const databaseUrl = process.env.DATABASE_URL;
|
|
13
|
+
if (!databaseUrl) {
|
|
14
|
+
throw new Error('Missing DATABASE_URL.');
|
|
15
|
+
}
|
|
16
|
+
|
|
12
17
|
export default defineConfig({
|
|
18
|
+
datasource: {
|
|
19
|
+
url: databaseUrl,
|
|
20
|
+
},
|
|
13
21
|
migrations: {
|
|
14
|
-
seed: `node --no-warnings --experimental-specifier-resolution=node --
|
|
22
|
+
seed: `node --no-warnings --experimental-specifier-resolution=node --import @oxc-node/core/register --env-file .env src/prisma/seed.tsx`,
|
|
15
23
|
},
|
|
16
24
|
schema: './src/prisma/schema.prisma',
|
|
17
25
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#!/usr/bin/env node --no-warnings --experimental-specifier-resolution=node --
|
|
1
|
+
#!/usr/bin/env node --no-warnings --experimental-specifier-resolution=node --import @oxc-node/core/register
|
|
2
2
|
import { createHash } from 'node:crypto';
|
|
3
3
|
import { writeFileSync } from 'node:fs';
|
|
4
4
|
import { join, posix, relative, sep } from 'node:path';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#!/usr/bin/env NODE_ENV=development node_modules/.bin/nodemon -q -I --exec node --no-warnings --experimental-specifier-resolution=node --
|
|
1
|
+
#!/usr/bin/env NODE_ENV=development node_modules/.bin/nodemon -q -I --exec node --no-warnings --experimental-specifier-resolution=node --import @oxc-node/core/register --env-file .env
|
|
2
2
|
import { parseArgs, styleText } from 'node:util';
|
|
3
3
|
import { serve } from '@hono/node-server';
|
|
4
4
|
import parseInteger from '@nkzw/core/parseInteger.js';
|
|
@@ -69,6 +69,7 @@ model Account {
|
|
|
69
69
|
id String @unique @default(uuid(7))
|
|
70
70
|
accountId String
|
|
71
71
|
providerId String
|
|
72
|
+
issuer String
|
|
72
73
|
userId String
|
|
73
74
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
74
75
|
accessToken String?
|
|
@@ -81,7 +82,7 @@ model Account {
|
|
|
81
82
|
createdAt DateTime
|
|
82
83
|
updatedAt DateTime
|
|
83
84
|
|
|
84
|
-
@@unique([
|
|
85
|
+
@@unique([issuer, accountId])
|
|
85
86
|
@@map("account")
|
|
86
87
|
}
|
|
87
88
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#!/usr/bin/env NODE_ENV=development node --no-warnings --experimental-specifier-resolution=node --
|
|
1
|
+
#!/usr/bin/env NODE_ENV=development node --no-warnings --experimental-specifier-resolution=node --import @oxc-node/core/register --env-file .env
|
|
2
2
|
import { styleText } from 'node:util';
|
|
3
3
|
import randomEntry from '@nkzw/core/randomEntry.js';
|
|
4
4
|
import { categories, comments, events, posts, tags, users } from '../../../seedData.ts';
|
|
@@ -19,15 +19,5 @@
|
|
|
19
19
|
"target": "es2022"
|
|
20
20
|
},
|
|
21
21
|
"exclude": ["node_modules", "src/prisma/pothos-types.ts", "src/prisma/prisma-client"],
|
|
22
|
-
"include": ["**/*.ts", "**/*.tsx"]
|
|
23
|
-
"ts-node": {
|
|
24
|
-
"transpileOnly": true,
|
|
25
|
-
"transpiler": "ts-node/transpilers/swc",
|
|
26
|
-
"files": true,
|
|
27
|
-
"compilerOptions": {
|
|
28
|
-
"module": "esnext",
|
|
29
|
-
"isolatedModules": false,
|
|
30
|
-
"target": "es2022"
|
|
31
|
-
}
|
|
32
|
-
}
|
|
22
|
+
"include": ["../seedData.ts", "**/*.ts", "**/*.tsx"]
|
|
33
23
|
}
|
|
@@ -20,14 +20,5 @@
|
|
|
20
20
|
"types": ["vite/client"]
|
|
21
21
|
},
|
|
22
22
|
"exclude": ["**/.void/**/*.ts", "node_modules"],
|
|
23
|
-
"include": ["**/.fate/*.ts", "**/*.ts", "**/*.tsx"]
|
|
24
|
-
"ts-node": {
|
|
25
|
-
"transpileOnly": true,
|
|
26
|
-
"transpiler": "ts-node/transpilers/swc",
|
|
27
|
-
"files": true,
|
|
28
|
-
"compilerOptions": {
|
|
29
|
-
"module": "esnext",
|
|
30
|
-
"isolatedModules": false
|
|
31
|
-
}
|
|
32
|
-
}
|
|
23
|
+
"include": ["**/.fate/*.ts", "**/*.ts", "**/*.tsx"]
|
|
33
24
|
}
|
|
@@ -67,3 +67,12 @@ Common commands:
|
|
|
67
67
|
- `vp run fate:generate` refreshes _fate_ client support after changing `src/fate/graphql.ts`.
|
|
68
68
|
- `vp check --fix` formats, lints, and type-checks the project.
|
|
69
69
|
- `vp run test:all` verifies the project.
|
|
70
|
+
|
|
71
|
+
## Translations
|
|
72
|
+
|
|
73
|
+
The React app uses fbtee 4 with its native Oxc Vite plugin and CLI. Setup and builds generate the runtime translation files automatically.
|
|
74
|
+
|
|
75
|
+
- Wrap UI text in `<fbt desc="Translator context">Text</fbt>`; use `fbs('Text', 'Translator context')` from `fbtee` for string attributes such as placeholders.
|
|
76
|
+
- Run `vp run fbtee:collect` in the app root to extract strings, then `vp run fbtee:prepare` to update the editable German and Japanese files in `translations/`.
|
|
77
|
+
- Translate entries marked `"status": "new"`, remove that status when finished, and run `vp run fbtee:translate` (or `vp run fbtee:all`). Commit `translations/`; runtime files in `src/translations/` are generated and ignored.
|
|
78
|
+
- Add locales to `src/lib/AvailableLanguages.tsx` and the `fbtee:prepare` script. The language selector remembers the choice. Server rendering starts in English and restores the browser preference after hydration.
|
|
@@ -10,41 +10,44 @@
|
|
|
10
10
|
},
|
|
11
11
|
"type": "module",
|
|
12
12
|
"scripts": {
|
|
13
|
-
"build": "vp build",
|
|
13
|
+
"build": "vp run fbtee:all && vp build",
|
|
14
14
|
"dev": "vp dev",
|
|
15
|
-
"dev:setup": "vp run prepare:void && vp run fate:generate",
|
|
15
|
+
"dev:setup": "vp run fbtee:all && vp run prepare:void && vp run fate:generate",
|
|
16
16
|
"fate:generate": "vp exec fate generate",
|
|
17
|
+
"fbtee:all": "vp run fbtee:collect && vp run fbtee:translate",
|
|
18
|
+
"fbtee:collect": "vp exec fbtee collect",
|
|
19
|
+
"fbtee:prepare": "vp run fbtee:collect && vp exec fbtee prepare-translations --source-strings source_strings.json --output-dir translations --locales de-DE ja-JP",
|
|
20
|
+
"fbtee:translate": "vp exec fbtee translate --source-strings source_strings.json --output-dir src/translations --output-locale-style=bcp47",
|
|
17
21
|
"prepare:void": "void prepare",
|
|
18
22
|
"test:all": "vp check && vp test"
|
|
19
23
|
},
|
|
20
24
|
"dependencies": {
|
|
21
25
|
"@nkzw/fate": "latest",
|
|
22
|
-
"@void/react": "^0.
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"react": "^
|
|
26
|
-
"react
|
|
27
|
-
"react-
|
|
26
|
+
"@void/react": "^0.10.12",
|
|
27
|
+
"fbtee": "^4.0.0",
|
|
28
|
+
"graphql-sse": "^2.6.1",
|
|
29
|
+
"lucide-react": "^1.34.0",
|
|
30
|
+
"react": "^19.2.8",
|
|
31
|
+
"react-dom": "^19.2.8",
|
|
32
|
+
"react-error-boundary": "^6.1.3",
|
|
28
33
|
"react-fate": "latest",
|
|
29
|
-
"void": "^0.
|
|
34
|
+
"void": "^0.10.12"
|
|
30
35
|
},
|
|
31
36
|
"devDependencies": {
|
|
32
37
|
"@nkzw/eslint-plugin": "^2.0.0",
|
|
33
|
-
"@nkzw/
|
|
34
|
-
"@
|
|
35
|
-
"@
|
|
36
|
-
"@
|
|
37
|
-
"@
|
|
38
|
-
"@
|
|
39
|
-
"@types/
|
|
40
|
-
"@
|
|
41
|
-
"@
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"tailwindcss": "^4.2.4",
|
|
47
|
-
"ts-node": "^10.9.2",
|
|
38
|
+
"@nkzw/fbtee-cli": "^4.0.0",
|
|
39
|
+
"@nkzw/oxlint-config": "^2.0.1",
|
|
40
|
+
"@nkzw/vite-plugin-fbtee": "^4.0.0",
|
|
41
|
+
"@oxc-node/core": "^0.1.0",
|
|
42
|
+
"@swc/core": "^1.16.1",
|
|
43
|
+
"@tailwindcss/vite": "^4.3.3",
|
|
44
|
+
"@types/node": "^26.4.0",
|
|
45
|
+
"@types/react": "^19.2.18",
|
|
46
|
+
"@types/react-dom": "^19.2.5",
|
|
47
|
+
"@vitejs/plugin-react": "^6.1.0",
|
|
48
|
+
"oxc-transform-react": "^0.147.0",
|
|
49
|
+
"tailwindcss": "^4.3.3",
|
|
50
|
+
"typescript": "^7.0.2",
|
|
48
51
|
"vite": "catalog:",
|
|
49
52
|
"vite-plus": "catalog:",
|
|
50
53
|
"vitest": "catalog:"
|
|
@@ -1,34 +1,71 @@
|
|
|
1
|
-
import { ConnectionRef, useListView, useRequest } from 'react-fate';
|
|
2
|
-
import {
|
|
1
|
+
import { ConnectionRef, useListView, useRequest, useView, view, ViewRef } from 'react-fate';
|
|
2
|
+
import type { Post, User } from '../src/fate/graphql.ts';
|
|
3
|
+
|
|
4
|
+
const UserView = view<User>()({
|
|
5
|
+
id: true,
|
|
6
|
+
name: true,
|
|
7
|
+
username: true,
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
const PostView = view<Post>()({
|
|
11
|
+
author: UserView,
|
|
12
|
+
title: true,
|
|
13
|
+
});
|
|
3
14
|
|
|
4
15
|
const PostConnectionView = {
|
|
5
16
|
args: { first: 10 },
|
|
6
17
|
items: {
|
|
7
|
-
node:
|
|
18
|
+
node: PostView,
|
|
8
19
|
},
|
|
9
20
|
pagination: {
|
|
10
21
|
hasNext: true,
|
|
11
22
|
},
|
|
12
23
|
};
|
|
13
24
|
|
|
25
|
+
const UserName = ({ user: userRef }: { user: ViewRef<'User'> }) => {
|
|
26
|
+
const user = useView(UserView, userRef);
|
|
27
|
+
|
|
28
|
+
return user.name ?? user.username ?? user.id;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const PostItem = ({ post: postRef }: { post: ViewRef<'Post'> }) => {
|
|
32
|
+
const post = useView(PostView, postRef);
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<article className="rounded-lg border border-slate-200 bg-white p-5 shadow-sm dark:border-slate-800 dark:bg-slate-900">
|
|
36
|
+
<h3 className="text-lg font-semibold">{post.title}</h3>
|
|
37
|
+
{post.author ? (
|
|
38
|
+
<p className="mt-2 text-sm text-slate-500 dark:text-slate-400">
|
|
39
|
+
<UserName user={post.author} />
|
|
40
|
+
</p>
|
|
41
|
+
) : null}
|
|
42
|
+
</article>
|
|
43
|
+
);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const Viewer = ({ viewer: viewerRef }: { viewer: ViewRef<'User'> }) => {
|
|
47
|
+
return (
|
|
48
|
+
<section className="rounded-lg border border-slate-200 bg-white p-5 shadow-sm dark:border-slate-800 dark:bg-slate-900">
|
|
49
|
+
<h2 className="text-sm font-medium text-slate-500 dark:text-slate-400">
|
|
50
|
+
<fbt desc="index: Viewer">Viewer</fbt>
|
|
51
|
+
</h2>
|
|
52
|
+
<p className="mt-2 text-lg font-semibold">
|
|
53
|
+
<UserName user={viewerRef} />
|
|
54
|
+
</p>
|
|
55
|
+
</section>
|
|
56
|
+
);
|
|
57
|
+
};
|
|
58
|
+
|
|
14
59
|
const PostList = ({ posts: postsRef }: { posts: ConnectionRef<'Post'> }) => {
|
|
15
60
|
const [posts] = useListView(PostConnectionView, postsRef);
|
|
16
61
|
|
|
17
62
|
return (
|
|
18
63
|
<section className="space-y-4">
|
|
19
|
-
<h2 className="text-2xl font-semibold">
|
|
64
|
+
<h2 className="text-2xl font-semibold">
|
|
65
|
+
<fbt desc="index: Posts">Posts</fbt>
|
|
66
|
+
</h2>
|
|
20
67
|
{posts.map(({ node }) => (
|
|
21
|
-
<
|
|
22
|
-
className="rounded-lg border border-slate-200 bg-white p-5 shadow-sm dark:border-slate-800 dark:bg-slate-900"
|
|
23
|
-
key={node.id}
|
|
24
|
-
>
|
|
25
|
-
<h3 className="text-lg font-semibold">{node.title}</h3>
|
|
26
|
-
{node.author ? (
|
|
27
|
-
<p className="mt-2 text-sm text-slate-500 dark:text-slate-400">
|
|
28
|
-
{node.author.name ?? node.author.username ?? node.author.id}
|
|
29
|
-
</p>
|
|
30
|
-
) : null}
|
|
31
|
-
</article>
|
|
68
|
+
<PostItem key={node.id} post={node} />
|
|
32
69
|
))}
|
|
33
70
|
</section>
|
|
34
71
|
);
|
|
@@ -37,7 +74,7 @@ const PostList = ({ posts: postsRef }: { posts: ConnectionRef<'Post'> }) => {
|
|
|
37
74
|
export default function HomePage() {
|
|
38
75
|
const { posts, viewer } = useRequest({
|
|
39
76
|
posts: { list: PostConnectionView },
|
|
40
|
-
viewer: { view:
|
|
77
|
+
viewer: { view: UserView },
|
|
41
78
|
});
|
|
42
79
|
|
|
43
80
|
return (
|
|
@@ -47,22 +84,19 @@ export default function HomePage() {
|
|
|
47
84
|
fate + GraphQL
|
|
48
85
|
</p>
|
|
49
86
|
<h1 className="text-4xl font-semibold tracking-tight text-slate-950 dark:text-white">
|
|
50
|
-
Use fate with an existing GraphQL server
|
|
87
|
+
<fbt desc="index: Use fate with an existing GraphQL server">
|
|
88
|
+
Use fate with an existing GraphQL server
|
|
89
|
+
</fbt>{' '}
|
|
51
90
|
</h1>
|
|
52
91
|
<p className="max-w-2xl text-slate-600 dark:text-slate-300">
|
|
53
|
-
|
|
54
|
-
|
|
92
|
+
<fbt desc="GraphQL client setup instructions">
|
|
93
|
+
Replace the sample views in <code>src/fate/graphql.ts</code> with your schema types and
|
|
94
|
+
point <code>VITE_GRAPHQL_URL</code> at your API.
|
|
95
|
+
</fbt>
|
|
55
96
|
</p>
|
|
56
97
|
</header>
|
|
57
98
|
|
|
58
|
-
{viewer ?
|
|
59
|
-
<section className="rounded-lg border border-slate-200 bg-white p-5 shadow-sm dark:border-slate-800 dark:bg-slate-900">
|
|
60
|
-
<h2 className="text-sm font-medium text-slate-500 dark:text-slate-400">Viewer</h2>
|
|
61
|
-
<p className="mt-2 text-lg font-semibold">
|
|
62
|
-
{viewer.name ?? viewer.username ?? viewer.id}
|
|
63
|
-
</p>
|
|
64
|
-
</section>
|
|
65
|
-
) : null}
|
|
99
|
+
{viewer ? <Viewer viewer={viewer} /> : null}
|
|
66
100
|
<PostList posts={posts} />
|
|
67
101
|
</main>
|
|
68
102
|
);
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import '../src/App.css';
|
|
2
1
|
import { ReactNode, Suspense, useMemo } from 'react';
|
|
3
2
|
import { ErrorBoundary } from 'react-error-boundary';
|
|
3
|
+
import '../src/App.css';
|
|
4
4
|
import { FateClient } from 'react-fate';
|
|
5
5
|
import { createFateClient } from 'react-fate/client';
|
|
6
|
+
import LocaleContext from '../src/lib/LocaleContext.tsx';
|
|
7
|
+
import LocaleSwitcher from '../src/ui/LocaleSwitcher.tsx';
|
|
6
8
|
|
|
7
9
|
const graphQLURL = import.meta.env.VITE_GRAPHQL_URL;
|
|
8
10
|
const graphQLLiveURL = import.meta.env.VITE_GRAPHQL_LIVE_URL;
|
|
9
11
|
|
|
10
12
|
const Loading = () => (
|
|
11
13
|
<main className="mx-auto flex min-h-screen max-w-4xl items-center px-6 py-16 text-slate-500">
|
|
12
|
-
Loading...
|
|
14
|
+
<fbt desc="layout: Loading...">Loading...</fbt>{' '}
|
|
13
15
|
</main>
|
|
14
16
|
);
|
|
15
17
|
|
|
@@ -24,18 +26,23 @@ export default function Layout({ children }: { children: ReactNode }) {
|
|
|
24
26
|
);
|
|
25
27
|
|
|
26
28
|
return (
|
|
27
|
-
<
|
|
28
|
-
<
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
29
|
+
<LocaleContext>
|
|
30
|
+
<div className="mx-auto max-w-4xl px-6 pt-6">
|
|
31
|
+
<LocaleSwitcher />
|
|
32
|
+
</div>
|
|
33
|
+
<FateClient client={fate}>
|
|
34
|
+
<ErrorBoundary
|
|
35
|
+
fallbackRender={({ error }) => (
|
|
36
|
+
<main className="mx-auto min-h-screen max-w-4xl px-6 py-16">
|
|
37
|
+
<div className="rounded-lg border border-red-200 bg-red-50 p-5 text-red-950 dark:border-red-900 dark:bg-red-950 dark:text-red-50">
|
|
38
|
+
{error instanceof Error ? error.message : String(error)}
|
|
39
|
+
</div>
|
|
40
|
+
</main>
|
|
41
|
+
)}
|
|
42
|
+
>
|
|
43
|
+
<Suspense fallback={<Loading />}>{children}</Suspense>
|
|
44
|
+
</ErrorBoundary>
|
|
45
|
+
</FateClient>
|
|
46
|
+
</LocaleContext>
|
|
40
47
|
);
|
|
41
48
|
}
|
|
@@ -3,29 +3,31 @@ packages:
|
|
|
3
3
|
|
|
4
4
|
allowBuilds:
|
|
5
5
|
'@swc/core': true
|
|
6
|
+
better-sqlite3: true
|
|
6
7
|
esbuild: true
|
|
7
8
|
sharp: true
|
|
8
9
|
workerd: true
|
|
9
10
|
|
|
10
11
|
catalog:
|
|
11
|
-
vite: npm:@voidzero-dev/vite-plus-core@^0.
|
|
12
|
-
vite-plus: ^0.
|
|
13
|
-
vitest:
|
|
12
|
+
vite: npm:@voidzero-dev/vite-plus-core@^0.3.0
|
|
13
|
+
vite-plus: ^0.3.0
|
|
14
|
+
vitest: ^4.1.11
|
|
14
15
|
|
|
15
16
|
minimumReleaseAgeExclude:
|
|
16
17
|
- '@voidzero-dev/vite-plus-core'
|
|
17
|
-
- '@voidzero-dev/vite-plus-test'
|
|
18
18
|
- vite-plus
|
|
19
19
|
|
|
20
20
|
onlyBuiltDependencies:
|
|
21
21
|
- '@swc/core'
|
|
22
22
|
- '@tailwindcss/oxide'
|
|
23
|
+
- better-sqlite3
|
|
23
24
|
- esbuild
|
|
24
25
|
- msgpackr-extract
|
|
25
26
|
- sharp
|
|
26
27
|
- workerd
|
|
27
28
|
|
|
28
29
|
overrides:
|
|
30
|
+
better-auth: 1.7.2
|
|
29
31
|
vite: 'catalog:'
|
|
30
32
|
vitest: 'catalog:'
|
|
31
33
|
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/// <reference types="fbtee/ReactTypes.d.ts" />
|
|
2
|
+
|
|
3
|
+
import { createLocaleContext, useLocaleContext } from 'fbtee';
|
|
4
|
+
import { ReactNode, startTransition, useEffect, useState } from 'react';
|
|
5
|
+
import AvailableLanguages from './AvailableLanguages.tsx';
|
|
6
|
+
|
|
7
|
+
const Context = createLocaleContext({
|
|
8
|
+
availableLanguages: AvailableLanguages,
|
|
9
|
+
// Keep the server and first client render identical; restore preferences after hydration.
|
|
10
|
+
clientLocales: ['en-US'],
|
|
11
|
+
fallbackLocale: 'en-US',
|
|
12
|
+
loadLocale: async (locale) => {
|
|
13
|
+
if (locale !== 'en-US' && AvailableLanguages.has(locale)) {
|
|
14
|
+
return (await import(`../translations/${locale}.json`)).default[locale];
|
|
15
|
+
}
|
|
16
|
+
return {};
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
function RestoreLocale({ restored, onRestore }: { restored: boolean; onRestore: () => void }) {
|
|
21
|
+
const { locale, setLocale } = useLocaleContext();
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
if (restored) return;
|
|
24
|
+
onRestore();
|
|
25
|
+
let savedLocale: string | null = null;
|
|
26
|
+
try {
|
|
27
|
+
savedLocale = localStorage.getItem('fbtee:locale');
|
|
28
|
+
} catch {
|
|
29
|
+
// Browser storage can be unavailable.
|
|
30
|
+
}
|
|
31
|
+
const preferred = [savedLocale, ...navigator.languages, navigator.language]
|
|
32
|
+
.filter((value): value is string => !!value)
|
|
33
|
+
.map((value) => value.replaceAll('_', '-'));
|
|
34
|
+
const nextLocale = preferred
|
|
35
|
+
.map((value) =>
|
|
36
|
+
AvailableLanguages.has(value)
|
|
37
|
+
? value
|
|
38
|
+
: [...AvailableLanguages.keys()].find(
|
|
39
|
+
(available) => available.split('-')[0] === value.split('-')[0],
|
|
40
|
+
),
|
|
41
|
+
)
|
|
42
|
+
.find(Boolean);
|
|
43
|
+
if (nextLocale && nextLocale !== locale) {
|
|
44
|
+
startTransition(() => setLocale(nextLocale));
|
|
45
|
+
}
|
|
46
|
+
}, [locale, setLocale, restored, onRestore]);
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
document.documentElement.lang = locale;
|
|
49
|
+
}, [locale]);
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export default function LocaleContext({ children }: { children: ReactNode }) {
|
|
54
|
+
const [restored, setRestored] = useState(false);
|
|
55
|
+
return (
|
|
56
|
+
<Context>
|
|
57
|
+
<RestoreLocale restored={restored} onRestore={() => setRestored(true)} />
|
|
58
|
+
{children}
|
|
59
|
+
</Context>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { useLocaleContext } from 'fbtee';
|
|
2
|
+
import { startTransition } from 'react';
|
|
3
|
+
import AvailableLanguages from '../lib/AvailableLanguages.tsx';
|
|
4
|
+
|
|
5
|
+
export default function LocaleSwitcher() {
|
|
6
|
+
const { locale, localeChangeIsPending, setLocale } = useLocaleContext();
|
|
7
|
+
return (
|
|
8
|
+
<label className="inline-flex items-center gap-2 text-sm">
|
|
9
|
+
<span className="sr-only">
|
|
10
|
+
<fbt desc="Locale switcher button">Change Language</fbt>
|
|
11
|
+
</span>
|
|
12
|
+
<select
|
|
13
|
+
className="rounded-md border border-gray-300 bg-background px-2 py-1 text-foreground"
|
|
14
|
+
disabled={localeChangeIsPending}
|
|
15
|
+
onChange={(event) => {
|
|
16
|
+
const nextLocale = event.target.value;
|
|
17
|
+
try {
|
|
18
|
+
localStorage.setItem('fbtee:locale', nextLocale);
|
|
19
|
+
} catch {
|
|
20
|
+
// Changing the language still works without browser storage.
|
|
21
|
+
}
|
|
22
|
+
startTransition(() => setLocale(nextLocale));
|
|
23
|
+
}}
|
|
24
|
+
value={locale}
|
|
25
|
+
>
|
|
26
|
+
{[...AvailableLanguages].map(([value, name]) => (
|
|
27
|
+
<option key={value} value={value}>
|
|
28
|
+
{name}
|
|
29
|
+
</option>
|
|
30
|
+
))}
|
|
31
|
+
</select>
|
|
32
|
+
</label>
|
|
33
|
+
);
|
|
34
|
+
}
|