@forgewp/compiler 0.4.3 → 0.4.4
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/README.md +59 -0
- package/bin/add.js +20 -14
- package/bin/cli.js +145 -70
- package/bin/doctor.js +21 -12
- package/bin/export.js +69 -20
- package/bin/fresh.js +5 -0
- package/bin/i18n-extract.js +3 -10
- package/bin/i18n-translate.js +15 -24
- package/bin/make-block.js +13 -0
- package/bin/make-editable.js +166 -0
- package/bin/make-form.js +131 -0
- package/bin/make-loop.js +40 -43
- package/bin/make-mail.js +27 -0
- package/bin/make-post-type.js +57 -29
- package/bin/make-sandbox.js +62 -11
- package/bin/make-section.js +221 -0
- package/bin/make-shell.js +375 -0
- package/bin/repair.js +14 -26
- package/bin/seed.js +119 -0
- package/bin/sync-routes.js +107 -85
- package/lib/adapters/html-adapter.js +5 -0
- package/lib/adapters/stub-adapter.js +4 -0
- package/lib/add-component.js +153 -92
- package/lib/asset-loader.js +313 -3
- package/lib/assets/asset-graph.js +432 -0
- package/lib/assets/asset-pipeline.js +125 -0
- package/lib/assets/diagnostics-report.js +345 -0
- package/lib/assets/external-fetcher.js +173 -0
- package/lib/assets/font-orchestrator.js +348 -0
- package/lib/assets/font-usage-scanner.js +242 -0
- package/lib/assets/image-optimizer.js +229 -0
- package/lib/assets/index.js +51 -0
- package/lib/assets/preload-generator.js +70 -0
- package/lib/assets/public-url.js +153 -0
- package/lib/block-authoring-help.js +11 -0
- package/lib/blocks/ast-parser.js +67 -0
- package/lib/blocks/discover-blocks.js +146 -0
- package/lib/blocks/editor-scope.js +733 -0
- package/lib/blocks/editor-transpiler.js +1229 -0
- package/lib/blocks/index.js +2838 -0
- package/lib/blocks/php-transpiler.js +4928 -0
- package/lib/blocks/scanner.js +1487 -0
- package/lib/blocks/shared-utils.js +290 -0
- package/lib/blocks/source-sanitize.js +1449 -0
- package/lib/blueprints.js +31 -91
- package/lib/build-assets.js +38 -33
- package/lib/collect-page-template-routes.js +102 -0
- package/lib/collect-static-routes.js +175 -0
- package/lib/diagnostics.js +58 -33
- package/lib/export-theme.js +84 -5
- package/lib/extract-template-content.js +90 -0
- package/lib/forms-preview.js +42 -0
- package/lib/functions/cpt-routing.js +69 -0
- package/lib/functions/forms.js +2461 -0
- package/lib/functions/hydration-enqueuer.js +400 -0
- package/lib/functions/index.js +1623 -0
- package/lib/functions/load-menus.js +112 -0
- package/lib/functions/load-translations.js +148 -0
- package/lib/functions/rest-endpoints.js +2923 -0
- package/lib/functions/routing.js +765 -0
- package/lib/functions/seed-mock-data.js +392 -0
- package/lib/functions/seed-products.js +481 -0
- package/lib/functions/settings-page.js +273 -0
- package/lib/functions/theme-setup.js +494 -0
- package/lib/generate-theme.js +1916 -339
- package/lib/hydration/editable-schemas.js +332 -0
- package/lib/hydration/enter-hidden-initial.js +65 -0
- package/lib/hydration/form-schemas.js +227 -0
- package/lib/hydration/index.js +12 -0
- package/lib/hydration/is-interactive.js +951 -0
- package/lib/hydration/island-split.js +1231 -0
- package/lib/hydration/islands-scanner.js +599 -0
- package/lib/hydration/resolve-island-chunk.js +103 -0
- package/lib/hydration/resolve-island-component.js +52 -0
- package/lib/hydration/rollup-inputs.js +81 -0
- package/lib/hydration/root-class-extractor.js +220 -0
- package/lib/hydration/scan-app-providers.js +154 -0
- package/lib/hydration/static-lint.js +382 -0
- package/lib/hydration/transform.js +257 -0
- package/lib/hydration/uses-block-area.js +49 -0
- package/lib/hydration/utils.js +119 -0
- package/lib/i18n/translation-cache.js +141 -0
- package/lib/icon-registry.js +72 -0
- package/lib/index.d.ts +287 -8
- package/lib/index.js +2 -1
- package/lib/load-config.js +338 -242
- package/lib/mail-templates.js +37 -0
- package/lib/markup-processor.js +388 -102
- package/lib/node-runtime.js +7 -0
- package/lib/page-config-plugin.js +64 -20
- package/lib/php-builders.js +383 -44
- package/lib/react-adapter.js +983 -235
- package/lib/registration-metadata.js +11 -0
- package/lib/render-theme.mts +1410 -616
- package/lib/route-layout.js +76 -0
- package/lib/template-discovery.js +58 -0
- package/lib/theme-compatibility.js +32 -0
- package/lib/validate-export.js +2 -2
- package/lib/validate.js +27 -5
- package/lib/virtual-plugin.js +319 -0
- package/lib/walkthrough.md +26 -0
- package/package.json +16 -5
- package/templates/auth/cms/email-logs.json +9 -0
- package/templates/auth/cms/menus.json +11 -0
- package/templates/auth/cms/mock-data.json +123 -0
- package/templates/auth/cms/roles.json +7 -0
- package/templates/auth/cms/sessions.json +1 -0
- package/templates/auth/cms/site-settings.json +28 -0
- package/templates/auth/cms/translations.json +4 -0
- package/templates/auth/cms/users.json +46 -0
- package/templates/auth/components/forgot-password-form-wrapper.tsx +10 -2
- package/templates/auth/components/login-form-wrapper.tsx +118 -21
- package/templates/auth/components/reset-password-form-wrapper.tsx +10 -2
- package/templates/auth/components/signup-form-wrapper.tsx +2 -2
- package/templates/auth/components/verify-email-view-wrapper.tsx +5 -5
- package/templates/auth/pages/DashboardPage.tsx +1 -4
- package/templates/auth/pages/ForgotPasswordPage.tsx +1 -4
- package/templates/auth/pages/LoginPage.tsx +1 -4
- package/templates/auth/pages/ResetPasswordPage.tsx +1 -4
- package/templates/auth/pages/SignUpPage.tsx +1 -4
- package/templates/auth/pages/VerifyEmailPage.tsx +1 -4
- package/templates/auth/ui/button.tsx +57 -0
- package/templates/auth/ui/card.tsx +76 -0
- package/templates/auth/ui/field.tsx +242 -0
- package/templates/auth/ui/input.tsx +22 -0
- package/templates/auth/ui/label.tsx +24 -0
- package/templates/auth/ui/separator.tsx +31 -0
- package/templates/menus.json +12 -10
- package/templates/users.json +8 -4
- package/templates/wordpress.tsx +690 -245
- package/lib/block-compiler.js +0 -552
- package/lib/functions-builder.js +0 -2970
- package/lib/hydration-scanner.js +0 -833
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
{
|
|
2
|
+
"post": [
|
|
3
|
+
{
|
|
4
|
+
"id": 1,
|
|
5
|
+
"title": "Welcome to ForgeWP: The Headless Revolution",
|
|
6
|
+
"excerpt": "Discover how ForgeWP bridges standard WordPress themes with blistering fast React architectures.",
|
|
7
|
+
"content": "<p>This is the first mock post. In local dev, you can modify <code>cms/mock-data.json</code> to test layout content changes.</p>",
|
|
8
|
+
"date": "2026-05-10T09:00:00Z",
|
|
9
|
+
"author": "Antigravity",
|
|
10
|
+
"featuredImage": {
|
|
11
|
+
"id": 101,
|
|
12
|
+
"url": "https://picsum.photos/seed/forgewp/1200/630",
|
|
13
|
+
"alt": "ForgeWP Logo and Brand Artwork",
|
|
14
|
+
"title": "ForgeWP Logo",
|
|
15
|
+
"caption": "A high-fidelity minimalist logo graphic.",
|
|
16
|
+
"width": 1200,
|
|
17
|
+
"height": 630,
|
|
18
|
+
"sizes": {
|
|
19
|
+
"thumbnail": { "url": "https://picsum.photos/seed/forgewp/150/150", "width": 150, "height": 150 },
|
|
20
|
+
"medium": { "url": "https://picsum.photos/seed/forgewp/300/300", "width": 300, "height": 300 },
|
|
21
|
+
"large": { "url": "https://picsum.photos/seed/forgewp/1024/768", "width": 1024, "height": 768 }
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"customFields": { "read_time": "5" },
|
|
25
|
+
"_terms": {
|
|
26
|
+
"category": [
|
|
27
|
+
{ "id": 1, "slug": "tutorials", "name": "Tutorials" },
|
|
28
|
+
{ "id": 2, "slug": "framework", "name": "Framework" }
|
|
29
|
+
],
|
|
30
|
+
"post_tag": [
|
|
31
|
+
{ "id": 10, "slug": "react", "name": "React" },
|
|
32
|
+
{ "id": 11, "slug": "wordpress", "name": "WordPress" }
|
|
33
|
+
]
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"id": 2,
|
|
38
|
+
"title": "Unlocking Brutalist Web Design Aesthetics",
|
|
39
|
+
"excerpt": "A deep dive into high-contrast grids, sharp corners, and premium flat shadows in modern interfaces.",
|
|
40
|
+
"content": "<p>This is the second mock post. Style these grids using beautiful Tailwind utilities.</p>",
|
|
41
|
+
"date": "2026-05-12T14:30:00Z",
|
|
42
|
+
"author": "DeepMind Partner",
|
|
43
|
+
"featuredImage": "https://picsum.photos/seed/brutalist/1200/630",
|
|
44
|
+
"customFields": { "read_time": "8" },
|
|
45
|
+
"_terms": {
|
|
46
|
+
"category": [
|
|
47
|
+
{ "id": 3, "slug": "design", "name": "Design" },
|
|
48
|
+
{ "id": 4, "slug": "css", "name": "CSS" }
|
|
49
|
+
],
|
|
50
|
+
"post_tag": [
|
|
51
|
+
{ "id": 12, "slug": "brutalism", "name": "Brutalism" },
|
|
52
|
+
{ "id": 13, "slug": "tailwind", "name": "Tailwind" }
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
],
|
|
57
|
+
"project": [
|
|
58
|
+
{
|
|
59
|
+
"id": 1,
|
|
60
|
+
"title": "ForgeWP Scaffolding Platform",
|
|
61
|
+
"excerpt": "Building a custom compiler framework to transpile React elements into standard PHP themes.",
|
|
62
|
+
"content": "<p>Detailed description of the ForgeWP compiler pipeline project.</p>",
|
|
63
|
+
"date": "2026-05-15T12:00:00Z",
|
|
64
|
+
"author": "Lead Architect",
|
|
65
|
+
"featuredImage": "https://picsum.photos/seed/platform/1200/630",
|
|
66
|
+
"customFields": {
|
|
67
|
+
"client_name": "El Dorado",
|
|
68
|
+
"project_budget": "45000",
|
|
69
|
+
"status": "active"
|
|
70
|
+
},
|
|
71
|
+
"_terms": {
|
|
72
|
+
"project_type": [{ "id": 20, "slug": "open-source", "name": "Open Source" }],
|
|
73
|
+
"technology": [{ "id": 30, "slug": "react", "name": "React" }]
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"id": 2,
|
|
78
|
+
"title": "Brutalist Starter Theme",
|
|
79
|
+
"excerpt": "A clean, responsive, and robust high-contrast interface leveraging Tailwind CSS v4.",
|
|
80
|
+
"content": "<p>A brutalist theme showcasing raw black borders and vivid accent colors.</p>",
|
|
81
|
+
"date": "2026-05-16T16:00:00Z",
|
|
82
|
+
"author": "Theme Engineer",
|
|
83
|
+
"featuredImage": "https://picsum.photos/seed/starter/1200/630",
|
|
84
|
+
"customFields": {
|
|
85
|
+
"client_name": "ForgeWP Community",
|
|
86
|
+
"project_budget": "0",
|
|
87
|
+
"status": "completed"
|
|
88
|
+
},
|
|
89
|
+
"_terms": {
|
|
90
|
+
"project_type": [{ "id": 20, "slug": "open-source", "name": "Open Source" }],
|
|
91
|
+
"technology": [{ "id": 32, "slug": "tailwind", "name": "Tailwind CSS" }]
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
],
|
|
95
|
+
"attachment": [
|
|
96
|
+
{
|
|
97
|
+
"id": 101,
|
|
98
|
+
"url": "https://picsum.photos/seed/forgewp/1200/630",
|
|
99
|
+
"alt": "ForgeWP Logo and Brand Artwork",
|
|
100
|
+
"title": "ForgeWP Logo",
|
|
101
|
+
"caption": "A high-fidelity minimalist logo graphic.",
|
|
102
|
+
"width": 1200,
|
|
103
|
+
"height": 630,
|
|
104
|
+
"sizes": {
|
|
105
|
+
"thumbnail": { "url": "https://picsum.photos/seed/forgewp/150/150", "width": 150, "height": 150 },
|
|
106
|
+
"medium": { "url": "https://picsum.photos/seed/forgewp/300/300", "width": 300, "height": 300 },
|
|
107
|
+
"large": { "url": "https://picsum.photos/seed/forgewp/1024/768", "width": 1024, "height": 768 }
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"id": 102,
|
|
112
|
+
"url": "https://picsum.photos/seed/layout/1200/800",
|
|
113
|
+
"alt": "Brutalist Layout Preview",
|
|
114
|
+
"title": "Layout Preview",
|
|
115
|
+
"width": 1200,
|
|
116
|
+
"height": 800,
|
|
117
|
+
"sizes": {
|
|
118
|
+
"thumbnail": { "url": "https://picsum.photos/seed/layout/150/150", "width": 150, "height": 150 },
|
|
119
|
+
"medium": { "url": "https://picsum.photos/seed/layout/300/300", "width": 300, "height": 300 }
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
]
|
|
123
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"administrator": ["manage_options", "edit_theme_options", "edit_posts", "edit_others_posts", "publish_posts", "read"],
|
|
3
|
+
"editor": ["edit_posts", "edit_others_posts", "publish_posts", "read"],
|
|
4
|
+
"author": ["edit_posts", "publish_posts", "read"],
|
|
5
|
+
"subscriber": ["read"],
|
|
6
|
+
"customer": ["read"]
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
[]
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"options": {
|
|
3
|
+
"blogname": "ForgeWP Starter",
|
|
4
|
+
"blogdescription": "A clean default canvas for building block-themes with ForgeWP.",
|
|
5
|
+
"admin_email": "admin@forgewp.local",
|
|
6
|
+
"posts_per_page": "10",
|
|
7
|
+
"blogurl": "http://forgewp.local",
|
|
8
|
+
"home": "http://forgewp.local",
|
|
9
|
+
"siteurl": "http://forgewp.local",
|
|
10
|
+
"users_can_register": "0",
|
|
11
|
+
"contact_phone": "+1 (555) 019-9000",
|
|
12
|
+
"contact_email": "admin@forgewp.local",
|
|
13
|
+
"social_facebook": "https://facebook.com",
|
|
14
|
+
"social_instagram": "https://instagram.com",
|
|
15
|
+
"social_twitter": "https://twitter.com",
|
|
16
|
+
"social_youtube": "",
|
|
17
|
+
"social_tiktok": "",
|
|
18
|
+
"social_linkedin": "",
|
|
19
|
+
"social_pinterest": "",
|
|
20
|
+
"editor_note": "ForgeWP Canvas"
|
|
21
|
+
},
|
|
22
|
+
"theme_mods": {
|
|
23
|
+
"custom_logo": "",
|
|
24
|
+
"header_textcolor": "#0f172a",
|
|
25
|
+
"footer_text": "© 2026 Hotelchecker24. All rights reserved.",
|
|
26
|
+
"nav_menu_locations": {}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": 1,
|
|
4
|
+
"username": "admin",
|
|
5
|
+
"email": "admin@forgewp.local",
|
|
6
|
+
"displayName": "Concrete Designer",
|
|
7
|
+
"roles": [
|
|
8
|
+
"administrator"
|
|
9
|
+
],
|
|
10
|
+
"avatarUrl": "https://picsum.photos/seed/avatar1/150/150",
|
|
11
|
+
"emailVerified": true
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"id": 2,
|
|
15
|
+
"username": "subscriber",
|
|
16
|
+
"email": "user@forgewp.local",
|
|
17
|
+
"displayName": "Sub Concrete",
|
|
18
|
+
"roles": [
|
|
19
|
+
"subscriber"
|
|
20
|
+
],
|
|
21
|
+
"avatarUrl": "https://picsum.photos/seed/avatar2/150/150",
|
|
22
|
+
"emailVerified": true
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"id": 3,
|
|
26
|
+
"username": "editor",
|
|
27
|
+
"email": "editor@forgewp.local",
|
|
28
|
+
"displayName": "Concrete Editor",
|
|
29
|
+
"roles": [
|
|
30
|
+
"editor"
|
|
31
|
+
],
|
|
32
|
+
"avatarUrl": "https://picsum.photos/seed/avatar3/150/150",
|
|
33
|
+
"emailVerified": true
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"id": 4,
|
|
37
|
+
"username": "customer",
|
|
38
|
+
"email": "customer@forgewp.local",
|
|
39
|
+
"displayName": "Concrete Customer",
|
|
40
|
+
"roles": [
|
|
41
|
+
"customer"
|
|
42
|
+
],
|
|
43
|
+
"avatarUrl": "https://picsum.photos/seed/avatar4/150/150",
|
|
44
|
+
"emailVerified": true
|
|
45
|
+
}
|
|
46
|
+
]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { useWpAuth } from '@forgewp/auth';
|
|
3
|
-
import { useWpPageLink, useLocation } from '
|
|
2
|
+
import { useWpAuth, useWpUser } from '@forgewp/auth';
|
|
3
|
+
import { useWpPageLink, useLocation } from '@forgewp/react';
|
|
4
4
|
import { Button } from '@/components/ui/button';
|
|
5
5
|
import {
|
|
6
6
|
Card,
|
|
@@ -20,13 +20,21 @@ import { AlertTriangleIcon, ArrowLeftIcon } from 'lucide-react';
|
|
|
20
20
|
|
|
21
21
|
export default function ForgotPasswordFormWrapper() {
|
|
22
22
|
const { forgotPassword, error, initializing } = useWpAuth();
|
|
23
|
+
const user = useWpUser();
|
|
23
24
|
const [_, setLocation] = useLocation();
|
|
24
25
|
const [emailOrUsername, setEmailOrUsername] = React.useState('');
|
|
25
26
|
const loginUrl = useWpPageLink('login-page', '/login');
|
|
27
|
+
const dashboardUrl = useWpPageLink('account-page', '/account');
|
|
26
28
|
const [success, setSuccess] = React.useState(false);
|
|
27
29
|
const [localError, setLocalError] = React.useState<string | null>(null);
|
|
28
30
|
const [submitting, setSubmitting] = React.useState(false);
|
|
29
31
|
|
|
32
|
+
React.useEffect(() => {
|
|
33
|
+
if (user) {
|
|
34
|
+
setLocation(dashboardUrl);
|
|
35
|
+
}
|
|
36
|
+
}, [user, setLocation, dashboardUrl]);
|
|
37
|
+
|
|
30
38
|
const handleSubmit = async (e: React.FormEvent) => {
|
|
31
39
|
e.preventDefault();
|
|
32
40
|
setLocalError(null);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { useWpAuth, useWpUser } from '@forgewp/auth';
|
|
3
|
-
import { useWpPageLink, useLocation } from '
|
|
3
|
+
import { useWpPageLink, useLocation } from '@forgewp/react';
|
|
4
4
|
import { cn } from '@/lib/utils';
|
|
5
5
|
import { Button } from '@/components/ui/button';
|
|
6
6
|
import {
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
FieldDescription,
|
|
18
18
|
} from '@/components/ui/field';
|
|
19
19
|
import { Input } from '@/components/ui/input';
|
|
20
|
-
import { AlertTriangleIcon } from 'lucide-react';
|
|
20
|
+
import { AlertTriangleIcon, MailIcon, CheckCircle2Icon, RefreshCwIcon } from 'lucide-react';
|
|
21
21
|
|
|
22
22
|
export default function LoginFormWrapper({
|
|
23
23
|
className,
|
|
@@ -30,14 +30,25 @@ export default function LoginFormWrapper({
|
|
|
30
30
|
const [username, setUsername] = React.useState('');
|
|
31
31
|
const [password, setPassword] = React.useState('');
|
|
32
32
|
const [localError, setLocalError] = React.useState<string | null>(null);
|
|
33
|
+
const [unverifiedNotice, setUnverifiedNotice] = React.useState<string | null>(null);
|
|
33
34
|
const [submitting, setSubmitting] = React.useState(false);
|
|
34
35
|
|
|
35
36
|
const [resendStatus, setResendStatus] = React.useState<'idle' | 'sending' | 'success' | 'failed'>('idle');
|
|
36
37
|
const [resendErrorMessage, setResendErrorMessage] = React.useState<string | null>(null);
|
|
38
|
+
const [resendCooldown, setResendCooldown] = React.useState(0);
|
|
39
|
+
const cooldownTimerRef = React.useRef<any>(null);
|
|
37
40
|
|
|
38
41
|
const forgotPasswordUrl = useWpPageLink('forgot-password-page', '/forgot-password');
|
|
39
42
|
const signUpUrl = useWpPageLink('sign-up-page', '/signup');
|
|
40
|
-
const dashboardUrl = useWpPageLink('
|
|
43
|
+
const dashboardUrl = useWpPageLink('account-page', '/account');
|
|
44
|
+
|
|
45
|
+
React.useEffect(() => {
|
|
46
|
+
return () => {
|
|
47
|
+
if (cooldownTimerRef.current) {
|
|
48
|
+
clearInterval(cooldownTimerRef.current);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
}, []);
|
|
41
52
|
|
|
42
53
|
React.useEffect(() => {
|
|
43
54
|
if (user) {
|
|
@@ -45,6 +56,13 @@ export default function LoginFormWrapper({
|
|
|
45
56
|
}
|
|
46
57
|
}, [user, setLocation, dashboardUrl]);
|
|
47
58
|
|
|
59
|
+
React.useEffect(() => {
|
|
60
|
+
const activeErr = localError || error;
|
|
61
|
+
if (activeErr && /verif/i.test(activeErr)) {
|
|
62
|
+
setUnverifiedNotice(activeErr);
|
|
63
|
+
}
|
|
64
|
+
}, [localError, error]);
|
|
65
|
+
|
|
48
66
|
const handleResendVerification = async () => {
|
|
49
67
|
const input = username.trim();
|
|
50
68
|
if (!input) {
|
|
@@ -59,6 +77,25 @@ export default function LoginFormWrapper({
|
|
|
59
77
|
const ok = await resendVerificationEmail(input);
|
|
60
78
|
if (ok) {
|
|
61
79
|
setResendStatus('success');
|
|
80
|
+
// Ensure unverifiedNotice stays active so the box never collapses
|
|
81
|
+
if (!unverifiedNotice) {
|
|
82
|
+
setUnverifiedNotice('Please verify your email address before logging in.');
|
|
83
|
+
}
|
|
84
|
+
// 60-second cooldown before they can request again
|
|
85
|
+
setResendCooldown(60);
|
|
86
|
+
if (cooldownTimerRef.current) {
|
|
87
|
+
clearInterval(cooldownTimerRef.current);
|
|
88
|
+
}
|
|
89
|
+
cooldownTimerRef.current = setInterval(() => {
|
|
90
|
+
setResendCooldown((prev: number) => {
|
|
91
|
+
if (prev <= 1) {
|
|
92
|
+
clearInterval(cooldownTimerRef.current);
|
|
93
|
+
cooldownTimerRef.current = null;
|
|
94
|
+
return 0;
|
|
95
|
+
}
|
|
96
|
+
return prev - 1;
|
|
97
|
+
});
|
|
98
|
+
}, 1000);
|
|
62
99
|
} else {
|
|
63
100
|
setResendStatus('failed');
|
|
64
101
|
setResendErrorMessage(error || 'Failed to resend verification email.');
|
|
@@ -72,6 +109,7 @@ export default function LoginFormWrapper({
|
|
|
72
109
|
const handleSubmit = async (e: React.FormEvent) => {
|
|
73
110
|
e.preventDefault();
|
|
74
111
|
setLocalError(null);
|
|
112
|
+
setUnverifiedNotice(null);
|
|
75
113
|
setResendStatus('idle');
|
|
76
114
|
setResendErrorMessage(null);
|
|
77
115
|
|
|
@@ -87,7 +125,11 @@ export default function LoginFormWrapper({
|
|
|
87
125
|
try {
|
|
88
126
|
await login(trimmedUsername, trimmedPassword, dashboardUrl);
|
|
89
127
|
} catch (err: any) {
|
|
90
|
-
|
|
128
|
+
const msg = err.message || 'Login failed. Please try again.';
|
|
129
|
+
setLocalError(msg);
|
|
130
|
+
if (/verif/i.test(msg)) {
|
|
131
|
+
setUnverifiedNotice(msg);
|
|
132
|
+
}
|
|
91
133
|
} finally {
|
|
92
134
|
setSubmitting(false);
|
|
93
135
|
}
|
|
@@ -104,6 +146,10 @@ export default function LoginFormWrapper({
|
|
|
104
146
|
);
|
|
105
147
|
}
|
|
106
148
|
|
|
149
|
+
const activeRawError = localError || error;
|
|
150
|
+
const isUnverified = Boolean(unverifiedNotice || (activeRawError && /verif/i.test(activeRawError)));
|
|
151
|
+
const displayedError = unverifiedNotice || activeRawError;
|
|
152
|
+
|
|
107
153
|
return (
|
|
108
154
|
<div
|
|
109
155
|
className={cn('flex flex-col gap-6', className)}
|
|
@@ -119,37 +165,88 @@ export default function LoginFormWrapper({
|
|
|
119
165
|
<CardContent>
|
|
120
166
|
<form onSubmit={handleSubmit}>
|
|
121
167
|
<FieldGroup>
|
|
122
|
-
{
|
|
123
|
-
|
|
124
|
-
<div className="flex
|
|
125
|
-
<
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
<
|
|
132
|
-
|
|
168
|
+
{isUnverified ? (
|
|
169
|
+
resendStatus === 'success' ? (
|
|
170
|
+
<div className="bg-emerald-50 text-emerald-950 border border-emerald-200/80 text-sm p-4 rounded-lg flex flex-col gap-3 shadow-xs">
|
|
171
|
+
<div className="flex items-start gap-3">
|
|
172
|
+
<div className="p-1.5 bg-emerald-100 rounded-md text-emerald-700 shrink-0">
|
|
173
|
+
<CheckCircle2Icon className="h-4 w-4" />
|
|
174
|
+
</div>
|
|
175
|
+
<div className="flex flex-col gap-1 flex-1">
|
|
176
|
+
<span className="font-semibold text-emerald-950 text-sm">Verification Link Sent</span>
|
|
177
|
+
<p className="text-emerald-800 text-xs leading-relaxed">
|
|
178
|
+
A fresh verification link has been sent to your email. Please check your inbox (and spam folder).
|
|
179
|
+
</p>
|
|
180
|
+
</div>
|
|
181
|
+
</div>
|
|
182
|
+
|
|
183
|
+
<div className="flex items-center gap-1.5 flex-wrap text-xs text-emerald-900 pt-2.5 border-t border-emerald-200/60">
|
|
184
|
+
<span>Didn't receive it?</span>
|
|
185
|
+
{resendCooldown > 0 ? (
|
|
186
|
+
<span className="text-emerald-700/90 font-medium">
|
|
187
|
+
Resend available in {resendCooldown}s
|
|
133
188
|
</span>
|
|
134
189
|
) : (
|
|
135
190
|
<button
|
|
136
191
|
type="button"
|
|
137
|
-
disabled={resendStatus === 'sending'}
|
|
138
192
|
onClick={handleResendVerification}
|
|
139
|
-
className="
|
|
193
|
+
className="font-semibold underline underline-offset-2 hover:text-emerald-950 cursor-pointer inline-flex items-center gap-1 transition-colors"
|
|
140
194
|
>
|
|
141
|
-
|
|
195
|
+
Resend verification email
|
|
142
196
|
</button>
|
|
143
197
|
)}
|
|
198
|
+
</div>
|
|
199
|
+
</div>
|
|
200
|
+
) : (
|
|
201
|
+
<div className="bg-amber-50 text-amber-950 border border-amber-200/80 text-sm p-4 rounded-lg flex flex-col gap-3 shadow-xs">
|
|
202
|
+
<div className="flex items-start gap-3">
|
|
203
|
+
<div className="p-1.5 bg-amber-100 rounded-md text-amber-700 shrink-0">
|
|
204
|
+
<MailIcon className="h-4 w-4" />
|
|
205
|
+
</div>
|
|
206
|
+
<div className="flex flex-col gap-1 flex-1">
|
|
207
|
+
<span className="font-semibold text-amber-950 text-sm">Email Verification Required</span>
|
|
208
|
+
<p className="text-amber-800 text-xs leading-relaxed">
|
|
209
|
+
{displayedError || 'Please verify your email address before logging in.'}
|
|
210
|
+
</p>
|
|
211
|
+
</div>
|
|
212
|
+
</div>
|
|
213
|
+
|
|
214
|
+
<div className="flex flex-col gap-2 pt-2.5 border-t border-amber-200/60">
|
|
215
|
+
<div className="flex items-center gap-1.5 flex-wrap text-xs text-amber-900">
|
|
216
|
+
<span>Need a new link sent to your inbox?</span>
|
|
217
|
+
{resendCooldown > 0 ? (
|
|
218
|
+
<span className="text-amber-800/80 font-medium">
|
|
219
|
+
Resend available in {resendCooldown}s
|
|
220
|
+
</span>
|
|
221
|
+
) : (
|
|
222
|
+
<button
|
|
223
|
+
type="button"
|
|
224
|
+
disabled={resendStatus === 'sending'}
|
|
225
|
+
onClick={handleResendVerification}
|
|
226
|
+
className="font-semibold underline underline-offset-2 hover:text-amber-950 disabled:opacity-50 cursor-pointer inline-flex items-center gap-1 transition-colors"
|
|
227
|
+
>
|
|
228
|
+
{resendStatus === 'sending' ? (
|
|
229
|
+
<><RefreshCwIcon className="h-3 w-3 animate-spin inline" /> Sending...</>
|
|
230
|
+
) : (
|
|
231
|
+
'Resend verification email'
|
|
232
|
+
)}
|
|
233
|
+
</button>
|
|
234
|
+
)}
|
|
235
|
+
</div>
|
|
144
236
|
{resendStatus === 'failed' && resendErrorMessage && (
|
|
145
|
-
<span className="text-red-
|
|
237
|
+
<span className="text-red-600 text-xs font-medium bg-red-50 p-2 rounded border border-red-100">
|
|
146
238
|
{resendErrorMessage}
|
|
147
239
|
</span>
|
|
148
240
|
)}
|
|
149
241
|
</div>
|
|
150
|
-
|
|
242
|
+
</div>
|
|
243
|
+
)
|
|
244
|
+
) : activeRawError ? (
|
|
245
|
+
<div className="bg-red-50 text-red-700 border border-red-200 text-sm p-3.5 rounded-lg flex items-start gap-2.5 shadow-xs">
|
|
246
|
+
<AlertTriangleIcon className="h-4 w-4 shrink-0 text-red-600 mt-0.5" />
|
|
247
|
+
<span className="font-medium text-xs leading-relaxed">{activeRawError}</span>
|
|
151
248
|
</div>
|
|
152
|
-
)}
|
|
249
|
+
) : null}
|
|
153
250
|
<Field>
|
|
154
251
|
<FieldLabel htmlFor='username'>
|
|
155
252
|
{loginField === 'usernameOnly' ? 'Username' : loginField === 'emailOnly' ? 'Email Address' : 'Username or Email'}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { useWpAuth } from '@forgewp/auth';
|
|
3
|
-
import { useWpPageLink, useLocation } from '
|
|
2
|
+
import { useWpAuth, useWpUser } from '@forgewp/auth';
|
|
3
|
+
import { useWpPageLink, useLocation } from '@forgewp/react';
|
|
4
4
|
import { Button } from '@/components/ui/button';
|
|
5
5
|
import {
|
|
6
6
|
Card,
|
|
@@ -20,8 +20,16 @@ import { AlertTriangleIcon, ArrowLeftIcon } from 'lucide-react';
|
|
|
20
20
|
|
|
21
21
|
export default function ResetPasswordFormWrapper() {
|
|
22
22
|
const { resetPassword, error, initializing } = useWpAuth();
|
|
23
|
+
const user = useWpUser();
|
|
23
24
|
const [_, setLocation] = useLocation();
|
|
24
25
|
const loginUrl = useWpPageLink('login-page', '/login');
|
|
26
|
+
const dashboardUrl = useWpPageLink('account-page', '/account');
|
|
27
|
+
|
|
28
|
+
React.useEffect(() => {
|
|
29
|
+
if (user) {
|
|
30
|
+
setLocation(dashboardUrl);
|
|
31
|
+
}
|
|
32
|
+
}, [user, setLocation, dashboardUrl]);
|
|
25
33
|
|
|
26
34
|
const [key, setKey] = React.useState('');
|
|
27
35
|
const [login, setLogin] = React.useState('');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { useWpAuth, useWpUser } from '@forgewp/auth';
|
|
3
|
-
import { useWpPageLink, useLocation } from '
|
|
3
|
+
import { useWpPageLink, useLocation } from '@forgewp/react';
|
|
4
4
|
import { Button } from '@/components/ui/button';
|
|
5
5
|
import {
|
|
6
6
|
Card,
|
|
@@ -31,7 +31,7 @@ export default function SignupFormWrapper({ ...props }: React.ComponentProps<typ
|
|
|
31
31
|
const [submitting, setSubmitting] = React.useState(false);
|
|
32
32
|
|
|
33
33
|
const loginUrl = useWpPageLink('login-page', '/login');
|
|
34
|
-
const dashboardUrl = useWpPageLink('
|
|
34
|
+
const dashboardUrl = useWpPageLink('account-page', '/account');
|
|
35
35
|
const verifyEmailUrl = useWpPageLink('verify-email-page', '/verify-email');
|
|
36
36
|
|
|
37
37
|
const [errors, setErrors] = React.useState<{
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { useWpAuth } from '@forgewp/auth';
|
|
3
|
-
import { useWpPageLink, useLocation } from '
|
|
3
|
+
import { useWpPageLink, useLocation } from '@forgewp/react';
|
|
4
4
|
import { Button } from '@/components/ui/button';
|
|
5
5
|
import {
|
|
6
6
|
Card,
|
|
@@ -16,7 +16,7 @@ export default function VerifyEmailViewWrapper() {
|
|
|
16
16
|
const { verifyEmail, logout, error, initializing, resendVerificationEmail } = useWpAuth();
|
|
17
17
|
const [_, setLocation] = useLocation();
|
|
18
18
|
const loginUrl = useWpPageLink('login-page', '/login');
|
|
19
|
-
const dashboardUrl = useWpPageLink('
|
|
19
|
+
const dashboardUrl = useWpPageLink('account-page', '/account');
|
|
20
20
|
|
|
21
21
|
const [status, setStatus] = React.useState<'pending' | 'verifying' | 'success' | 'failed'>('pending');
|
|
22
22
|
const [errorMessage, setErrorMessage] = React.useState<string | null>(null);
|
|
@@ -67,10 +67,10 @@ export default function VerifyEmailViewWrapper() {
|
|
|
67
67
|
setStatus('success');
|
|
68
68
|
setTimeout(() => {
|
|
69
69
|
setLocation(dashboardUrl);
|
|
70
|
-
},
|
|
70
|
+
}, 2500);
|
|
71
71
|
} else {
|
|
72
72
|
setStatus('failed');
|
|
73
|
-
setErrorMessage(
|
|
73
|
+
setErrorMessage('Verification failed. The token may be expired or invalid.');
|
|
74
74
|
}
|
|
75
75
|
})
|
|
76
76
|
.catch((err) => {
|
|
@@ -80,7 +80,7 @@ export default function VerifyEmailViewWrapper() {
|
|
|
80
80
|
} else {
|
|
81
81
|
setStatus('pending');
|
|
82
82
|
}
|
|
83
|
-
}, [verifyEmail, setLocation, dashboardUrl
|
|
83
|
+
}, [verifyEmail, setLocation, dashboardUrl]);
|
|
84
84
|
|
|
85
85
|
if (initializing) {
|
|
86
86
|
return (
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import DashboardViewWrapper from "@/components/dashboard-view-wrapper";
|
|
2
|
-
import { Hydrate } from "@forgewp/react";
|
|
3
2
|
|
|
4
3
|
export const pageConfig = {
|
|
5
4
|
protected: true,
|
|
@@ -8,8 +7,6 @@ export const pageConfig = {
|
|
|
8
7
|
|
|
9
8
|
export function DashboardPage() {
|
|
10
9
|
return (
|
|
11
|
-
<
|
|
12
|
-
<DashboardViewWrapper />
|
|
13
|
-
</Hydrate>
|
|
10
|
+
<DashboardViewWrapper />
|
|
14
11
|
);
|
|
15
12
|
}
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import ForgotPasswordFormWrapper from "@/components/forgot-password-form-wrapper";
|
|
2
|
-
import { Hydrate } from "@forgewp/react";
|
|
3
2
|
|
|
4
3
|
export default function ForgotPasswordPage() {
|
|
5
4
|
return (
|
|
6
5
|
<div className='flex min-h-svh w-full items-center justify-center p-6 md:p-10 bg-[#fafafa]'>
|
|
7
6
|
<div className='w-full max-w-md'>
|
|
8
|
-
<
|
|
9
|
-
<ForgotPasswordFormWrapper />
|
|
10
|
-
</Hydrate>
|
|
7
|
+
<ForgotPasswordFormWrapper />
|
|
11
8
|
</div>
|
|
12
9
|
</div>
|
|
13
10
|
);
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import LoginFormWrapper from "@/components/login-form-wrapper";
|
|
2
|
-
import { Hydrate } from '@forgewp/react';
|
|
3
2
|
|
|
4
3
|
export default function LoginPage() {
|
|
5
4
|
return (
|
|
6
5
|
<div className='flex min-h-svh w-full items-center justify-center p-6 md:p-10 bg-[#fafafa]'>
|
|
7
6
|
<div className='w-full max-w-sm'>
|
|
8
|
-
<
|
|
9
|
-
<LoginFormWrapper />
|
|
10
|
-
</Hydrate>
|
|
7
|
+
<LoginFormWrapper />
|
|
11
8
|
</div>
|
|
12
9
|
</div>
|
|
13
10
|
);
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import ResetPasswordFormWrapper from "@/components/reset-password-form-wrapper";
|
|
2
|
-
import { Hydrate } from "@forgewp/react";
|
|
3
2
|
|
|
4
3
|
export default function ResetPasswordPage() {
|
|
5
4
|
return (
|
|
6
5
|
<div className='flex min-h-svh w-full items-center justify-center p-6 md:p-10 bg-[#fafafa]'>
|
|
7
6
|
<div className='w-full max-w-md'>
|
|
8
|
-
<
|
|
9
|
-
<ResetPasswordFormWrapper />
|
|
10
|
-
</Hydrate>
|
|
7
|
+
<ResetPasswordFormWrapper />
|
|
11
8
|
</div>
|
|
12
9
|
</div>
|
|
13
10
|
);
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import SignupFormWrapper from "@/components/signup-form-wrapper";
|
|
2
|
-
import { Hydrate } from '@forgewp/react';
|
|
3
2
|
|
|
4
3
|
export default function SignUpPage() {
|
|
5
4
|
return (
|
|
6
5
|
<div className='flex min-h-svh w-full items-center justify-center p-6 md:p-10 bg-[#fafafa]'>
|
|
7
6
|
<div className='w-full max-w-sm'>
|
|
8
|
-
<
|
|
9
|
-
<SignupFormWrapper />
|
|
10
|
-
</Hydrate>
|
|
7
|
+
<SignupFormWrapper />
|
|
11
8
|
</div>
|
|
12
9
|
</div>
|
|
13
10
|
);
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import VerifyEmailViewWrapper from "@/components/verify-email-view-wrapper";
|
|
2
|
-
import { Hydrate } from "@forgewp/react";
|
|
3
2
|
|
|
4
3
|
export default function VerifyEmailPage() {
|
|
5
4
|
return (
|
|
6
5
|
<div className='flex min-h-svh w-full items-center justify-center p-6 md:p-10 bg-[#fafafa]'>
|
|
7
6
|
<div className='w-full max-w-md'>
|
|
8
|
-
<
|
|
9
|
-
<VerifyEmailViewWrapper />
|
|
10
|
-
</Hydrate>
|
|
7
|
+
<VerifyEmailViewWrapper />
|
|
11
8
|
</div>
|
|
12
9
|
</div>
|
|
13
10
|
);
|