create-warlock 5.2.4 → 5.3.1

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 (39) hide show
  1. package/esm/commands/create-warlock-app/index.mjs +1 -1
  2. package/esm/commands/create-warlock-app/index.mjs.map +1 -1
  3. package/esm/helpers/app.mjs +44 -17
  4. package/esm/helpers/app.mjs.map +1 -1
  5. package/package.json +2 -2
  6. package/templates/warlock/eslint.config.js +98 -98
  7. package/templates/warlock/postcss.config.mjs +6 -0
  8. package/templates/warlock/src/app/contact/controllers/contact.controller.ts +21 -0
  9. package/templates/warlock/src/app/contact/routes.ts +4 -0
  10. package/templates/warlock/src/app/{shared → home}/controllers/home-page.controller.ts +1 -7
  11. package/templates/warlock/src/app/home/services/home.service.ts +86 -0
  12. package/templates/warlock/src/app/locale/controllers/locale.controller.ts +16 -0
  13. package/templates/warlock/src/app/locale/routes.ts +4 -0
  14. package/templates/warlock/src/shared/contact.schema.ts +7 -0
  15. package/templates/warlock/src/shared/locale.schema.ts +11 -0
  16. package/templates/warlock/src/shared/locales.ts +7 -0
  17. package/templates/warlock/src/web/404.css +113 -0
  18. package/templates/warlock/src/web/404.page.tsx +23 -0
  19. package/templates/warlock/src/web/app.css +3 -0
  20. package/templates/warlock/src/web/home/components/contact-form-controls.tsx +42 -0
  21. package/templates/warlock/src/web/home/components/contact-section.tsx +108 -0
  22. package/templates/warlock/src/web/home/components/content-sections.tsx +61 -0
  23. package/templates/warlock/src/web/home/components/hero-section.tsx +68 -0
  24. package/templates/warlock/src/web/home/components/home-footer.tsx +35 -0
  25. package/templates/warlock/src/web/home/components/home-header.tsx +26 -0
  26. package/templates/warlock/src/web/home/components/logo.tsx +19 -0
  27. package/templates/warlock/src/web/home/components/runtime-preview.tsx +75 -0
  28. package/templates/warlock/src/web/home/hooks/use-contact-form.ts +57 -0
  29. package/templates/warlock/src/web/home/hooks/use-locale-switcher.ts +35 -0
  30. package/templates/warlock/src/web/home/index.page.tsx +44 -0
  31. package/templates/warlock/src/web/home/register.ts +30 -0
  32. package/templates/warlock/src/web/home/styles/home.css +1185 -0
  33. package/templates/warlock/src/web/root.tsx +49 -0
  34. package/templates/warlock/src/web/shared/utils/set-form-errors.ts +60 -0
  35. package/templates/warlock/tsconfig.json +3 -1
  36. package/templates/warlock/public/home.css +0 -523
  37. package/templates/warlock/src/app/shared/components/HomePageComponent.tsx +0 -229
  38. package/templates/warlock/src/app/shared/controllers/home-page.controller.tsx +0 -17
  39. /package/templates/warlock/src/app/{shared → home}/routes.ts +0 -0
@@ -0,0 +1,35 @@
1
+ import { http } from "@mongez/http";
2
+ import { useState } from "react";
3
+ import { type LocaleCode } from "../../../shared/locales";
4
+
5
+ type LocalePreferenceResponse = {
6
+ locale: LocaleCode;
7
+ };
8
+
9
+ export function useLocaleSwitcher() {
10
+ const [isSwitching, setIsSwitching] = useState(false);
11
+ const [error, setError] = useState("");
12
+
13
+ async function switchLocale(locale: LocaleCode): Promise<void> {
14
+ setIsSwitching(true);
15
+ setError("");
16
+
17
+ try {
18
+ const result = await http.post<LocalePreferenceResponse>("/api/locale", { locale });
19
+
20
+ if (result.error) {
21
+ setError(result.error.message || "Could not update the locale.");
22
+ setIsSwitching(false);
23
+ return;
24
+ }
25
+
26
+ window.location.hash = "contact";
27
+ window.location.reload();
28
+ } catch (caughtError) {
29
+ setError(caughtError instanceof Error ? caughtError.message : "Could not update the locale.");
30
+ setIsSwitching(false);
31
+ }
32
+ }
33
+
34
+ return { error, isSwitching, switchLocale };
35
+ }
@@ -0,0 +1,44 @@
1
+ import type { PageLoader, PageProps } from "@warlock.js/web";
2
+ import { getHomeService } from "app/home/services/home.service";
3
+ import { isLocaleCode } from "../../shared/locales";
4
+ import { ContactSection } from "./components/contact-section";
5
+ import { ContentSections } from "./components/content-sections";
6
+ import { HeroSection } from "./components/hero-section";
7
+ import { HomeFooter } from "./components/home-footer";
8
+ import { HomeHeader } from "./components/home-header";
9
+ import "./styles/home.css";
10
+
11
+ export { register } from "./register";
12
+
13
+ export const route = { path: "/", name: "home" };
14
+ export const metadata = {
15
+ title: "Warlock.js — Build with uncommon power",
16
+ description:
17
+ "A TypeScript framework for production backends, server-rendered React applications, and AI-native systems.",
18
+ };
19
+ type HomeLoaderOptions = Parameters<PageLoader>[0];
20
+
21
+ export async function loader({ request, response }: HomeLoaderOptions) {
22
+ const locale = request.locale;
23
+ if (!isLocaleCode(locale)) {
24
+ return response.notFound();
25
+ }
26
+
27
+ const homeData = await getHomeService();
28
+
29
+ return { locale, ...homeData };
30
+ }
31
+
32
+ type HomePageProps = PageProps<typeof loader>;
33
+
34
+ export default function HomePage({ data }: HomePageProps) {
35
+ return (
36
+ <main className="warlock-home">
37
+ <HomeHeader />
38
+ <HeroSection statusMessage={data.statusMessage} />
39
+ <ContentSections capabilities={data.capabilities} packages={data.packages} />
40
+ <ContactSection locale={data.locale} />
41
+ <HomeFooter />
42
+ </main>
43
+ );
44
+ }
@@ -0,0 +1,30 @@
1
+ import { groupedTranslations } from "@mongez/localization";
2
+
3
+ export function register() {
4
+ groupedTranslations({
5
+ contact: {
6
+ overline: { en: "Live full-stack example", ar: "مثال حي لتطبيق متكامل" },
7
+ title: { en: "Send a typed request.", ar: "أرسل طلبًا مضبوط الأنواع." },
8
+ description: {
9
+ en: "One form. One validated request. One runtime shared by the browser and server.",
10
+ ar: "نموذج واحد. طلب واحد خاضع للتحقق. وبيئة تشغيل واحدة للمتصفح والخادم.",
11
+ },
12
+ toggle: { en: "العربية", ar: "English" },
13
+ name: { en: "Name", ar: "الاسم" },
14
+ namePlaceholder: { en: "Ada Lovelace", ar: "آدا لوفلايس" },
15
+ email: { en: "Email", ar: "البريد الإلكتروني" },
16
+ emailPlaceholder: { en: "ada@example.com", ar: "ada@example.com" },
17
+ message: { en: "Message", ar: "الرسالة" },
18
+ messagePlaceholder: {
19
+ en: "Tell us what you are building...",
20
+ ar: "أخبرنا بما تعمل على بنائه...",
21
+ },
22
+ submit: { en: "Send request", ar: "إرسال الطلب" },
23
+ submitting: { en: "Sending...", ar: "جارٍ الإرسال..." },
24
+ idle: {
25
+ en: "The response from Warlock will appear here.",
26
+ ar: "ستظهر استجابة Warlock هنا.",
27
+ },
28
+ },
29
+ });
30
+ }