arcanajs 2.5.0 → 2.5.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.
- package/framework/cli/index.d.ts +1 -0
- package/framework/cli/index.js +204 -0
- package/framework/cli/templates.d.ts +6 -0
- package/framework/cli/templates.js +59 -0
- package/framework/cli/webpack.config.d.ts +3 -0
- package/framework/cli/webpack.config.js +310 -0
- package/framework/lib/client/index.d.ts +59 -0
- package/framework/lib/client/index.js +97 -0
- package/framework/lib/config/index.d.ts +46 -0
- package/framework/lib/config/index.js +115 -0
- package/framework/lib/global.d.ts +65 -0
- package/framework/lib/index.d.ts +19 -0
- package/framework/lib/index.js +59 -0
- package/framework/lib/server/ArcanaJSMiddleware.d.ts +24 -0
- package/framework/lib/server/ArcanaJSMiddleware.js +114 -0
- package/framework/lib/server/ArcanaJSServer.d.ts +55 -0
- package/framework/lib/server/ArcanaJSServer.js +441 -0
- package/framework/lib/server/ControllerBinder.d.ts +4 -0
- package/framework/lib/server/ControllerBinder.js +32 -0
- package/framework/lib/server/CsrfMiddleware.d.ts +2 -0
- package/framework/lib/server/CsrfMiddleware.js +34 -0
- package/framework/lib/server/DynamicRouter.d.ts +2 -0
- package/framework/lib/server/DynamicRouter.js +50 -0
- package/framework/lib/server/ResponseHandlerMiddleware.d.ts +27 -0
- package/framework/lib/server/ResponseHandlerMiddleware.js +30 -0
- package/framework/lib/server/Router.d.ts +94 -0
- package/framework/lib/server/Router.js +203 -0
- package/framework/lib/server/default-index.html +12 -0
- package/framework/lib/server.d.ts +32 -0
- package/framework/lib/server.js +69 -0
- package/framework/lib/shared/components/Body.d.ts +6 -0
- package/framework/lib/shared/components/Body.js +8 -0
- package/framework/lib/shared/components/Head.d.ts +4 -0
- package/framework/lib/shared/components/Head.js +125 -0
- package/framework/lib/shared/components/Link.d.ts +7 -0
- package/framework/lib/shared/components/Link.js +27 -0
- package/framework/lib/shared/components/NavLink.d.ts +9 -0
- package/framework/lib/shared/components/NavLink.js +13 -0
- package/framework/lib/shared/components/Page.d.ts +6 -0
- package/framework/lib/shared/components/Page.js +10 -0
- package/framework/lib/shared/context/HeadContext.d.ts +6 -0
- package/framework/lib/shared/context/HeadContext.js +5 -0
- package/framework/lib/shared/context/PageContext.d.ts +1 -0
- package/framework/lib/shared/context/PageContext.js +5 -0
- package/framework/lib/shared/context/RouterContext.d.ts +15 -0
- package/framework/lib/shared/context/RouterContext.js +10 -0
- package/framework/lib/shared/core/ArcanaJSApp.d.ts +14 -0
- package/framework/lib/shared/core/ArcanaJSApp.js +153 -0
- package/framework/lib/shared/hooks/useHead.d.ts +1 -0
- package/framework/lib/shared/hooks/useHead.js +7 -0
- package/framework/lib/shared/hooks/useLocation.d.ts +5 -0
- package/framework/lib/shared/hooks/useLocation.js +13 -0
- package/framework/lib/shared/hooks/usePage.d.ts +1 -0
- package/framework/lib/shared/hooks/usePage.js +7 -0
- package/framework/lib/shared/hooks/useParams.d.ts +1 -0
- package/framework/lib/shared/hooks/useParams.js +13 -0
- package/framework/lib/shared/hooks/useQuery.d.ts +1 -0
- package/framework/lib/shared/hooks/useQuery.js +9 -0
- package/framework/lib/shared/hooks/useRouter.d.ts +1 -0
- package/framework/lib/shared/hooks/useRouter.js +13 -0
- package/framework/lib/shared/utils/createSingletonContext.d.ts +11 -0
- package/framework/lib/shared/utils/createSingletonContext.js +21 -0
- package/framework/lib/shared/views/ErrorPage.d.ts +7 -0
- package/framework/lib/shared/views/ErrorPage.js +12 -0
- package/framework/lib/shared/views/NotFoundPage.d.ts +5 -0
- package/framework/lib/shared/views/NotFoundPage.js +11 -0
- package/framework/lib/types.d.ts +174 -0
- package/framework/lib/types.js +8 -0
- package/framework/templates/arcanajs.config.ts +44 -0
- package/framework/templates/package.json +15 -0
- package/framework/templates/postcss.config.js +6 -0
- package/framework/templates/public/arcanajs.png +0 -0
- package/framework/templates/public/arcanajs.svg +12 -0
- package/framework/templates/public/favicon.ico +0 -0
- package/framework/templates/src/arcanajs.d.ts +8 -0
- package/framework/templates/src/client/globals.css +199 -0
- package/framework/templates/src/client/index.tsx +7 -0
- package/framework/templates/src/db/mongo.ts +10 -0
- package/framework/templates/src/db/mongoose.ts +12 -0
- package/framework/templates/src/db/mysql.ts +15 -0
- package/framework/templates/src/db/postgres.ts +8 -0
- package/framework/templates/src/server/controllers/HomeController.ts +7 -0
- package/framework/templates/src/server/controllers/UsersController.ts +37 -0
- package/framework/templates/src/server/index.ts +35 -0
- package/framework/templates/src/server/routes/api.ts +6 -0
- package/framework/templates/src/server/routes/web.ts +7 -0
- package/framework/templates/src/views/ErrorPage.tsx +136 -0
- package/framework/templates/src/views/HomePage.tsx +344 -0
- package/framework/templates/src/views/NotFoundPage.tsx +108 -0
- package/framework/templates/tsconfig.json +27 -0
- package/package.json +1 -1
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface RouterContextType {
|
|
3
|
+
navigateTo: (url: string) => void;
|
|
4
|
+
currentPage: string;
|
|
5
|
+
currentUrl: string;
|
|
6
|
+
params: Record<string, string>;
|
|
7
|
+
csrfToken?: string;
|
|
8
|
+
onNavigate?: (url: string) => void;
|
|
9
|
+
isNavigating: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare const RouterContext: React.Context<RouterContextType | null>;
|
|
12
|
+
export declare const RouterProvider: React.FC<{
|
|
13
|
+
value: RouterContextType;
|
|
14
|
+
children: React.ReactNode;
|
|
15
|
+
}>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RouterProvider = exports.RouterContext = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const createSingletonContext_1 = require("../utils/createSingletonContext");
|
|
6
|
+
exports.RouterContext = (0, createSingletonContext_1.createSingletonContext)("RouterContext", null);
|
|
7
|
+
const RouterProvider = ({ value, children }) => {
|
|
8
|
+
return ((0, jsx_runtime_1.jsx)(exports.RouterContext.Provider, { value: value, children: children }));
|
|
9
|
+
};
|
|
10
|
+
exports.RouterProvider = RouterProvider;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface ArcanaJSAppProps {
|
|
3
|
+
initialPage: string;
|
|
4
|
+
initialData: any;
|
|
5
|
+
initialParams?: Record<string, string>;
|
|
6
|
+
initialUrl?: string;
|
|
7
|
+
csrfToken?: string;
|
|
8
|
+
views: Record<string, React.FC<any>>;
|
|
9
|
+
layout?: React.FC<{
|
|
10
|
+
children: React.ReactNode;
|
|
11
|
+
}>;
|
|
12
|
+
onNavigate?: (url: string) => void;
|
|
13
|
+
}
|
|
14
|
+
export declare const ArcanaJSApp: React.FC<ArcanaJSAppProps>;
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.ArcanaJSApp = void 0;
|
|
37
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
38
|
+
const react_1 = __importStar(require("react"));
|
|
39
|
+
const Page_1 = require("../components/Page");
|
|
40
|
+
const RouterContext_1 = require("../context/RouterContext");
|
|
41
|
+
const ArcanaJSApp = ({ initialPage, initialData, initialParams = {}, initialUrl, csrfToken, views, layout: Layout, onNavigate, }) => {
|
|
42
|
+
const [page, setPage] = (0, react_1.useState)(initialPage);
|
|
43
|
+
const [data, setData] = (0, react_1.useState)(initialData);
|
|
44
|
+
const [params, setParams] = (0, react_1.useState)(initialParams);
|
|
45
|
+
const [url, setUrl] = (0, react_1.useState)(initialUrl ||
|
|
46
|
+
(typeof window !== "undefined" ? window.location.pathname : "/"));
|
|
47
|
+
const [isNavigating, setIsNavigating] = (0, react_1.useState)(false);
|
|
48
|
+
// Navigation cache to store previously visited pages
|
|
49
|
+
const navigationCache = react_1.default.useRef(new Map());
|
|
50
|
+
(0, react_1.useEffect)(() => {
|
|
51
|
+
if (typeof window !== "undefined" && !window.history.state) {
|
|
52
|
+
window.history.replaceState({ page: initialPage, data: initialData, params: initialParams }, "", window.location.href);
|
|
53
|
+
}
|
|
54
|
+
const handlePopState = (event) => {
|
|
55
|
+
if (event.state) {
|
|
56
|
+
setPage(event.state.page);
|
|
57
|
+
setData(event.state.data);
|
|
58
|
+
setParams(event.state.params || {});
|
|
59
|
+
setUrl(window.location.pathname);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
window.location.reload();
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
window.addEventListener("popstate", handlePopState);
|
|
66
|
+
return () => window.removeEventListener("popstate", handlePopState);
|
|
67
|
+
}, []);
|
|
68
|
+
const navigateTo = async (newUrl) => {
|
|
69
|
+
// Check cache first for instant navigation
|
|
70
|
+
if (navigationCache.current.has(newUrl)) {
|
|
71
|
+
const cached = navigationCache.current.get(newUrl);
|
|
72
|
+
setPage(cached.page);
|
|
73
|
+
setData(cached.data);
|
|
74
|
+
setParams(cached.params || {});
|
|
75
|
+
setUrl(newUrl);
|
|
76
|
+
window.history.pushState(cached, "", newUrl);
|
|
77
|
+
// Scroll to top
|
|
78
|
+
if (typeof window !== "undefined") {
|
|
79
|
+
window.scrollTo({ top: 0, behavior: "smooth" });
|
|
80
|
+
}
|
|
81
|
+
if (onNavigate) {
|
|
82
|
+
onNavigate(newUrl);
|
|
83
|
+
}
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
setIsNavigating(true);
|
|
87
|
+
try {
|
|
88
|
+
const response = await fetch(newUrl, {
|
|
89
|
+
headers: { "X-ArcanaJS-Request": "true" },
|
|
90
|
+
// prevent caching in dev navigation
|
|
91
|
+
cache: "no-store",
|
|
92
|
+
});
|
|
93
|
+
if (!response.ok) {
|
|
94
|
+
if (response.status === 404) {
|
|
95
|
+
setPage("NotFoundPage");
|
|
96
|
+
setUrl(newUrl);
|
|
97
|
+
window.history.pushState({ page: "NotFoundPage", data: {} }, "", newUrl);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
throw new Error(`Navigation failed: ${response.status} ${response.statusText}`);
|
|
101
|
+
}
|
|
102
|
+
// Ensure server returned JSON. If not, fallback to full navigation reload
|
|
103
|
+
const contentType = response.headers.get("content-type") || "";
|
|
104
|
+
if (!contentType.includes("application/json")) {
|
|
105
|
+
// The server returned HTML (or something else) instead of JSON.
|
|
106
|
+
// Do a full reload so the browser displays the correct page instead
|
|
107
|
+
// of trying to parse HTML as JSON (which causes the SyntaxError).
|
|
108
|
+
window.location.href = newUrl;
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
const json = await response.json();
|
|
112
|
+
// Cache the navigation result
|
|
113
|
+
navigationCache.current.set(newUrl, {
|
|
114
|
+
page: json.page,
|
|
115
|
+
data: json.data,
|
|
116
|
+
params: json.params,
|
|
117
|
+
});
|
|
118
|
+
window.history.pushState({ page: json.page, data: json.data, params: json.params }, "", newUrl);
|
|
119
|
+
setPage(json.page);
|
|
120
|
+
setData(json.data);
|
|
121
|
+
setParams(json.params || {});
|
|
122
|
+
setUrl(newUrl);
|
|
123
|
+
// Scroll to top after navigation
|
|
124
|
+
if (typeof window !== "undefined") {
|
|
125
|
+
window.scrollTo({ top: 0, behavior: "smooth" });
|
|
126
|
+
}
|
|
127
|
+
if (onNavigate) {
|
|
128
|
+
onNavigate(newUrl);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
catch (error) {
|
|
132
|
+
console.error("Navigation failed", error);
|
|
133
|
+
}
|
|
134
|
+
finally {
|
|
135
|
+
setIsNavigating(false);
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
const renderPage = () => {
|
|
139
|
+
const Component = views[page] || views["NotFoundPage"] || (() => (0, jsx_runtime_1.jsx)("div", { children: "404 Not Found" }));
|
|
140
|
+
return ((0, jsx_runtime_1.jsx)(Page_1.Page, { data: data, children: (0, jsx_runtime_1.jsx)(Component, { data: data, navigateTo: navigateTo, params: params }) }));
|
|
141
|
+
};
|
|
142
|
+
const content = renderPage();
|
|
143
|
+
return ((0, jsx_runtime_1.jsx)(RouterContext_1.RouterProvider, { value: {
|
|
144
|
+
navigateTo,
|
|
145
|
+
currentPage: page,
|
|
146
|
+
currentUrl: url,
|
|
147
|
+
params,
|
|
148
|
+
csrfToken,
|
|
149
|
+
onNavigate,
|
|
150
|
+
isNavigating,
|
|
151
|
+
}, children: Layout ? (0, jsx_runtime_1.jsx)(Layout, { children: content }) : (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: content }) }));
|
|
152
|
+
};
|
|
153
|
+
exports.ArcanaJSApp = ArcanaJSApp;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useHead: () => import("../context/HeadContext").HeadManager | null;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useHead = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const HeadContext_1 = require("../context/HeadContext");
|
|
6
|
+
const useHead = () => (0, react_1.useContext)(HeadContext_1.HeadContext);
|
|
7
|
+
exports.useHead = useHead;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useLocation = void 0;
|
|
4
|
+
const useRouter_1 = require("./useRouter");
|
|
5
|
+
const useLocation = () => {
|
|
6
|
+
const { currentUrl } = (0, useRouter_1.useRouter)();
|
|
7
|
+
return {
|
|
8
|
+
pathname: currentUrl,
|
|
9
|
+
search: typeof window !== "undefined" ? window.location.search : "",
|
|
10
|
+
hash: typeof window !== "undefined" ? window.location.hash : "",
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
exports.useLocation = useLocation;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const usePage: <T = any>() => T;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.usePage = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const PageContext_1 = require("../context/PageContext");
|
|
6
|
+
const usePage = () => (0, react_1.useContext)(PageContext_1.PageContext);
|
|
7
|
+
exports.usePage = usePage;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useParams: () => Record<string, string>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useParams = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const RouterContext_1 = require("../context/RouterContext");
|
|
6
|
+
const useParams = () => {
|
|
7
|
+
const context = (0, react_1.useContext)(RouterContext_1.RouterContext);
|
|
8
|
+
if (!context) {
|
|
9
|
+
throw new Error("useParams must be used within an ArcanaJSApp");
|
|
10
|
+
}
|
|
11
|
+
return context.params;
|
|
12
|
+
};
|
|
13
|
+
exports.useParams = useParams;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useQuery: () => URLSearchParams;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useQuery = void 0;
|
|
4
|
+
const useLocation_1 = require("./useLocation");
|
|
5
|
+
const useQuery = () => {
|
|
6
|
+
const { search } = (0, useLocation_1.useLocation)();
|
|
7
|
+
return new URLSearchParams(search);
|
|
8
|
+
};
|
|
9
|
+
exports.useQuery = useQuery;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useRouter: () => import("../context/RouterContext").RouterContextType;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useRouter = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const RouterContext_1 = require("../context/RouterContext");
|
|
6
|
+
const useRouter = () => {
|
|
7
|
+
const context = (0, react_1.useContext)(RouterContext_1.RouterContext);
|
|
8
|
+
if (!context) {
|
|
9
|
+
throw new Error("useRouter must be used within an ArcanaJSApp");
|
|
10
|
+
}
|
|
11
|
+
return context;
|
|
12
|
+
};
|
|
13
|
+
exports.useRouter = useRouter;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Creates a React Context that persists across multiple module loads (Webpack bundles vs Node require).
|
|
4
|
+
* This is essential for SSR applications where the server bundle and dynamically loaded views
|
|
5
|
+
* might reference different instances of the "same" context module.
|
|
6
|
+
*
|
|
7
|
+
* @param key A unique string key to identify this context globally
|
|
8
|
+
* @param defaultValue The default value for the context
|
|
9
|
+
* @returns A React Context instance (singleton)
|
|
10
|
+
*/
|
|
11
|
+
export declare function createSingletonContext<T>(key: string, defaultValue: T): React.Context<T>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createSingletonContext = createSingletonContext;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
/**
|
|
6
|
+
* Creates a React Context that persists across multiple module loads (Webpack bundles vs Node require).
|
|
7
|
+
* This is essential for SSR applications where the server bundle and dynamically loaded views
|
|
8
|
+
* might reference different instances of the "same" context module.
|
|
9
|
+
*
|
|
10
|
+
* @param key A unique string key to identify this context globally
|
|
11
|
+
* @param defaultValue The default value for the context
|
|
12
|
+
* @returns A React Context instance (singleton)
|
|
13
|
+
*/
|
|
14
|
+
function createSingletonContext(key, defaultValue) {
|
|
15
|
+
const globalAny = global;
|
|
16
|
+
const symbolKey = Symbol.for(`ARCANAJS_CONTEXT_${key}`);
|
|
17
|
+
if (!globalAny[symbolKey]) {
|
|
18
|
+
globalAny[symbolKey] = (0, react_1.createContext)(defaultValue);
|
|
19
|
+
}
|
|
20
|
+
return globalAny[symbolKey];
|
|
21
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = ErrorPage;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const Body_1 = require("../components/Body");
|
|
6
|
+
const Head_1 = require("../components/Head");
|
|
7
|
+
const Link_1 = require("../components/Link");
|
|
8
|
+
const Page_1 = require("../components/Page");
|
|
9
|
+
function ErrorPage({ message = "Something went wrong", statusCode = 500, stack, }) {
|
|
10
|
+
const isDevelopment = process.env.NODE_ENV === "development";
|
|
11
|
+
return ((0, jsx_runtime_1.jsxs)(Page_1.Page, { children: [(0, jsx_runtime_1.jsxs)(Head_1.Head, { children: [(0, jsx_runtime_1.jsxs)("title", { children: [statusCode, " - Server Error"] }), (0, jsx_runtime_1.jsx)("meta", { name: "description", content: "An error occurred on the server" })] }), (0, jsx_runtime_1.jsx)(Body_1.Body, { children: (0, jsx_runtime_1.jsxs)("div", { className: "relative min-h-screen overflow-hidden bg-black text-white flex flex-col justify-center items-center px-4 font-sans", children: [(0, jsx_runtime_1.jsxs)("div", { className: "fixed inset-0 z-0 overflow-hidden pointer-events-none", children: [(0, jsx_runtime_1.jsx)("div", { className: "absolute inset-0 grid-pattern opacity-30" }), (0, jsx_runtime_1.jsx)("div", { className: "absolute top-1/4 right-1/4 w-96 h-96 bg-red-600 rounded-full opacity-20 blur-3xl animate-glow" }), (0, jsx_runtime_1.jsx)("div", { className: "absolute bottom-1/4 left-1/4 w-96 h-96 bg-orange-600 rounded-full opacity-10 blur-3xl animate-glow", style: { animationDelay: "2s" } }), (0, jsx_runtime_1.jsx)("div", { className: "absolute inset-0 hero-gradient" })] }), (0, jsx_runtime_1.jsxs)("div", { className: "relative z-10 max-w-2xl w-full text-center animate-scale-in", children: [(0, jsx_runtime_1.jsxs)("div", { className: "glass-card rounded-3xl p-12 border border-white/10 shadow-2xl", children: [(0, jsx_runtime_1.jsxs)("div", { className: "mb-8", children: [(0, jsx_runtime_1.jsx)("div", { className: "text-6xl mb-6 animate-float", children: (0, jsx_runtime_1.jsx)("span", { className: "text-red-500 drop-shadow-lg filter", children: "\u26A0\uFE0F" }) }), (0, jsx_runtime_1.jsx)("h1", { className: "text-8xl font-bold text-transparent bg-clip-text bg-gradient-to-br from-red-500 to-orange-500 mb-4", children: statusCode }), (0, jsx_runtime_1.jsx)("h2", { className: "text-3xl font-bold text-white mb-4", children: "Server Error" }), (0, jsx_runtime_1.jsx)("p", { className: "text-gray-400 text-lg leading-relaxed", children: message })] }), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col sm:flex-row gap-4 justify-center mb-8", children: [(0, jsx_runtime_1.jsxs)(Link_1.Link, { href: "/", className: "btn-primary px-8 py-3.5 text-white font-semibold rounded-xl inline-flex items-center justify-center gap-2 w-full sm:w-auto bg-gradient-to-r from-red-600 to-orange-600 hover:from-red-500 hover:to-orange-500 border-none shadow-red-900/20", children: [(0, jsx_runtime_1.jsx)("svg", { className: "w-5 h-5", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: (0, jsx_runtime_1.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6" }) }), "Go Home"] }), (0, jsx_runtime_1.jsxs)("button", { onClick: () => window.location.reload(), className: "btn-secondary px-8 py-3.5 text-white font-semibold rounded-xl inline-flex items-center justify-center gap-2 w-full sm:w-auto", children: [(0, jsx_runtime_1.jsx)("svg", { className: "w-5 h-5", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: (0, jsx_runtime_1.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15" }) }), "Try Again"] })] }), isDevelopment && stack && ((0, jsx_runtime_1.jsx)("div", { className: "mt-8 text-left animate-slide-up", children: (0, jsx_runtime_1.jsxs)("details", { className: "bg-black/40 border border-white/10 rounded-xl overflow-hidden group", children: [(0, jsx_runtime_1.jsxs)("summary", { className: "cursor-pointer font-medium text-gray-300 p-4 hover:bg-white/5 transition-colors flex items-center justify-between select-none", children: [(0, jsx_runtime_1.jsx)("span", { children: "Stack Trace (Development Only)" }), (0, jsx_runtime_1.jsx)("svg", { className: "w-5 h-5 text-gray-500 group-open:rotate-180 transition-transform", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: (0, jsx_runtime_1.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M19 9l-7 7-7-7" }) })] }), (0, jsx_runtime_1.jsx)("pre", { className: "text-xs text-red-300/80 p-4 overflow-x-auto whitespace-pre-wrap font-mono border-t border-white/5 bg-black/20", children: stack })] }) }))] }), (0, jsx_runtime_1.jsxs)("div", { className: "mt-8 text-gray-500 text-sm", children: ["If this problem persists, please", " ", (0, jsx_runtime_1.jsx)(Link_1.Link, { href: "/contact", className: "text-red-400 hover:text-red-300 underline transition-colors", children: "contact support" }), "."] })] })] }) })] }));
|
|
12
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = NotFoundPage;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const Body_1 = require("../components/Body");
|
|
6
|
+
const Head_1 = require("../components/Head");
|
|
7
|
+
const Link_1 = require("../components/Link");
|
|
8
|
+
const Page_1 = require("../components/Page");
|
|
9
|
+
function NotFoundPage({ url }) {
|
|
10
|
+
return ((0, jsx_runtime_1.jsxs)(Page_1.Page, { children: [(0, jsx_runtime_1.jsxs)(Head_1.Head, { children: [(0, jsx_runtime_1.jsx)("title", { children: "404 - Page Not Found" }), (0, jsx_runtime_1.jsx)("meta", { name: "description", content: "The page you're looking for doesn't exist" })] }), (0, jsx_runtime_1.jsx)(Body_1.Body, { children: (0, jsx_runtime_1.jsxs)("div", { className: "relative min-h-screen overflow-hidden bg-black text-white flex flex-col justify-center items-center px-4 font-sans", children: [(0, jsx_runtime_1.jsxs)("div", { className: "fixed inset-0 z-0 overflow-hidden pointer-events-none", children: [(0, jsx_runtime_1.jsx)("div", { className: "absolute inset-0 grid-pattern opacity-30" }), (0, jsx_runtime_1.jsx)("div", { className: "absolute top-1/4 left-1/4 w-96 h-96 bg-orange-500 rounded-full opacity-20 blur-3xl animate-glow" }), (0, jsx_runtime_1.jsx)("div", { className: "absolute bottom-1/4 right-1/4 w-96 h-96 bg-purple-500 rounded-full opacity-10 blur-3xl animate-glow", style: { animationDelay: "2s" } }), (0, jsx_runtime_1.jsx)("div", { className: "absolute inset-0 hero-gradient" })] }), (0, jsx_runtime_1.jsxs)("div", { className: "relative z-10 max-w-lg w-full text-center animate-scale-in", children: [(0, jsx_runtime_1.jsxs)("div", { className: "glass-card rounded-3xl p-12 border border-white/10 shadow-2xl", children: [(0, jsx_runtime_1.jsxs)("div", { className: "mb-8", children: [(0, jsx_runtime_1.jsx)("h1", { className: "text-9xl font-bold text-transparent bg-clip-text bg-gradient-to-br from-white to-gray-500 mb-4 animate-float", children: "404" }), (0, jsx_runtime_1.jsx)("h2", { className: "text-3xl font-bold text-white mb-4", children: "Page Not Found" }), (0, jsx_runtime_1.jsx)("p", { className: "text-gray-400 text-lg leading-relaxed", children: url ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: ["The page ", (0, jsx_runtime_1.jsxs)("span", { className: "text-orange-400", children: ["\"", url, "\""] }), " ", "you're looking for doesn't exist."] })) : ("The page you're looking for doesn't exist.") })] }), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col sm:flex-row gap-4 justify-center", children: [(0, jsx_runtime_1.jsxs)(Link_1.Link, { href: "/", className: "btn-primary px-8 py-3.5 text-white font-semibold rounded-xl inline-flex items-center justify-center gap-2 w-full sm:w-auto", children: [(0, jsx_runtime_1.jsx)("svg", { className: "w-5 h-5", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: (0, jsx_runtime_1.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6" }) }), "Go Home"] }), (0, jsx_runtime_1.jsxs)("button", { onClick: () => window.history.back(), className: "btn-secondary px-8 py-3.5 text-white font-semibold rounded-xl inline-flex items-center justify-center gap-2 w-full sm:w-auto", children: [(0, jsx_runtime_1.jsx)("svg", { className: "w-5 h-5", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: (0, jsx_runtime_1.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M10 19l-7-7m0 0l7-7m-7 7h18" }) }), "Go Back"] })] })] }), (0, jsx_runtime_1.jsxs)("div", { className: "mt-8 text-gray-500 text-sm", children: ["If you believe this is an error, please", " ", (0, jsx_runtime_1.jsx)(Link_1.Link, { href: "/contact", className: "text-orange-400 hover:text-orange-300 underline transition-colors", children: "contact support" }), "."] })] })] }) })] }));
|
|
11
|
+
}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ArcanaJS Framework - Centralized Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* This file exports all public TypeScript types and interfaces
|
|
5
|
+
* for the ArcanaJS framework.
|
|
6
|
+
*/
|
|
7
|
+
export type { ArcanaJSConfig } from "./server/ArcanaJSServer";
|
|
8
|
+
export type { ArcanaJSAppProps } from "./shared/core/ArcanaJSApp";
|
|
9
|
+
export type { HeadManager } from "./shared/context/HeadContext";
|
|
10
|
+
export type { RouterContextType } from "./shared/context/RouterContext";
|
|
11
|
+
import type React from "react";
|
|
12
|
+
/**
|
|
13
|
+
* Props for the Page component
|
|
14
|
+
*/
|
|
15
|
+
export interface PageProps {
|
|
16
|
+
data?: any;
|
|
17
|
+
children?: React.ReactNode;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Props for the Head component
|
|
21
|
+
*/
|
|
22
|
+
export interface HeadProps {
|
|
23
|
+
children?: React.ReactNode;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Props for the Body component
|
|
27
|
+
*/
|
|
28
|
+
export interface BodyProps {
|
|
29
|
+
children?: React.ReactNode;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Props for the Link component
|
|
33
|
+
*/
|
|
34
|
+
export interface LinkProps {
|
|
35
|
+
to: string;
|
|
36
|
+
children?: React.ReactNode;
|
|
37
|
+
className?: string;
|
|
38
|
+
[key: string]: any;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Props for the NavLink component
|
|
42
|
+
*/
|
|
43
|
+
export interface NavLinkProps extends LinkProps {
|
|
44
|
+
activeClassName?: string;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Return type for useRouter hook
|
|
48
|
+
*/
|
|
49
|
+
export interface UseRouterReturn {
|
|
50
|
+
navigateTo: (url: string) => void;
|
|
51
|
+
currentPage: string;
|
|
52
|
+
currentUrl: string;
|
|
53
|
+
params: Record<string, string>;
|
|
54
|
+
csrfToken?: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Return type for useParams hook
|
|
58
|
+
*/
|
|
59
|
+
export type UseParamsReturn = Record<string, string>;
|
|
60
|
+
/**
|
|
61
|
+
* Return type for useLocation hook
|
|
62
|
+
*/
|
|
63
|
+
export interface UseLocationReturn {
|
|
64
|
+
pathname: string;
|
|
65
|
+
search: string;
|
|
66
|
+
hash: string;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Return type for useQuery hook
|
|
70
|
+
*/
|
|
71
|
+
export type UseQueryReturn = URLSearchParams;
|
|
72
|
+
/**
|
|
73
|
+
* Return type for usePage hook
|
|
74
|
+
*/
|
|
75
|
+
export type UsePageReturn = any;
|
|
76
|
+
/**
|
|
77
|
+
* Return type for useHead hook
|
|
78
|
+
*/
|
|
79
|
+
export interface UseHeadReturn {
|
|
80
|
+
push: (tags: React.ReactNode) => void;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* View component type - a React functional component that can receive data and params
|
|
84
|
+
*/
|
|
85
|
+
export type ViewComponent<T = any> = React.FC<{
|
|
86
|
+
data?: T;
|
|
87
|
+
params?: Record<string, string>;
|
|
88
|
+
navigateTo?: (url: string) => void;
|
|
89
|
+
}>;
|
|
90
|
+
/**
|
|
91
|
+
* Views registry - maps view names to view components
|
|
92
|
+
*/
|
|
93
|
+
export type ViewsRegistry = Record<string, React.FC<any>>;
|
|
94
|
+
/**
|
|
95
|
+
* Layout component type
|
|
96
|
+
*/
|
|
97
|
+
export type LayoutComponent = React.FC<{
|
|
98
|
+
children: React.ReactNode;
|
|
99
|
+
}>;
|
|
100
|
+
import type { RequestHandler } from "express";
|
|
101
|
+
/**
|
|
102
|
+
* Controller class type
|
|
103
|
+
*/
|
|
104
|
+
export type ControllerClass = new (...args: any[]) => any;
|
|
105
|
+
/**
|
|
106
|
+
* Route action - can be a handler function or a controller/method pair
|
|
107
|
+
*/
|
|
108
|
+
export type RouteAction = RequestHandler | [ControllerClass, string];
|
|
109
|
+
/**
|
|
110
|
+
* User-facing configuration for ArcanaJS
|
|
111
|
+
*/
|
|
112
|
+
export interface ArcanaJSUserConfig {
|
|
113
|
+
/**
|
|
114
|
+
* Server configuration
|
|
115
|
+
*/
|
|
116
|
+
server?: {
|
|
117
|
+
/**
|
|
118
|
+
* Port to run the server on
|
|
119
|
+
* @default 3000
|
|
120
|
+
*/
|
|
121
|
+
port?: number | string;
|
|
122
|
+
/**
|
|
123
|
+
* Static files directory
|
|
124
|
+
* @default "public"
|
|
125
|
+
*/
|
|
126
|
+
staticDir?: string;
|
|
127
|
+
/**
|
|
128
|
+
* Distribution directory for built assets
|
|
129
|
+
* @default "dist/public"
|
|
130
|
+
*/
|
|
131
|
+
distDir?: string;
|
|
132
|
+
};
|
|
133
|
+
/**
|
|
134
|
+
* Build configuration
|
|
135
|
+
*/
|
|
136
|
+
build?: {
|
|
137
|
+
/**
|
|
138
|
+
* Output directory for build
|
|
139
|
+
* @default "dist"
|
|
140
|
+
*/
|
|
141
|
+
outDir?: string;
|
|
142
|
+
/**
|
|
143
|
+
* Enable source maps
|
|
144
|
+
* @default true in development, false in production
|
|
145
|
+
*/
|
|
146
|
+
sourcemap?: boolean;
|
|
147
|
+
/**
|
|
148
|
+
* Enable minification
|
|
149
|
+
* @default true in production, false in development
|
|
150
|
+
*/
|
|
151
|
+
minify?: boolean;
|
|
152
|
+
};
|
|
153
|
+
/**
|
|
154
|
+
* Views configuration
|
|
155
|
+
*/
|
|
156
|
+
views?: {
|
|
157
|
+
/**
|
|
158
|
+
* Directory containing view files
|
|
159
|
+
* @default "src/views"
|
|
160
|
+
*/
|
|
161
|
+
dir?: string;
|
|
162
|
+
/**
|
|
163
|
+
* Custom layout component
|
|
164
|
+
*/
|
|
165
|
+
layout?: LayoutComponent;
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Resolved internal configuration
|
|
170
|
+
*/
|
|
171
|
+
export interface ResolvedArcanaJSConfig extends Required<ArcanaJSUserConfig> {
|
|
172
|
+
root: string;
|
|
173
|
+
mode: "development" | "production";
|
|
174
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { defineConfig } from "arcanajs/config";
|
|
2
|
+
import type { ArcanaJSUserConfig } from "arcanajs/types";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* ArcanaJS Configuration
|
|
6
|
+
*
|
|
7
|
+
* This file defines the configuration for your ArcanaJS application.
|
|
8
|
+
*
|
|
9
|
+
* @see https://github.com/arcanajs/arcanajs for documentation
|
|
10
|
+
*/
|
|
11
|
+
export default defineConfig({
|
|
12
|
+
// Server configuration
|
|
13
|
+
server: {
|
|
14
|
+
// Port to run the server on
|
|
15
|
+
port: 3000,
|
|
16
|
+
|
|
17
|
+
// Static files directory
|
|
18
|
+
staticDir: "public",
|
|
19
|
+
|
|
20
|
+
// Distribution directory for built assets
|
|
21
|
+
distDir: "dist/public",
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
// Build configuration
|
|
25
|
+
build: {
|
|
26
|
+
// Output directory for build
|
|
27
|
+
outDir: "dist",
|
|
28
|
+
|
|
29
|
+
// Enable source maps (automatically set based on NODE_ENV)
|
|
30
|
+
// sourcemap: true,
|
|
31
|
+
|
|
32
|
+
// Enable minification (automatically set based on NODE_ENV)
|
|
33
|
+
// minify: true,
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
// Views configuration
|
|
37
|
+
views: {
|
|
38
|
+
// Directory containing view files
|
|
39
|
+
dir: "src/views",
|
|
40
|
+
|
|
41
|
+
// Custom layout component (optional)
|
|
42
|
+
// layout: undefined,
|
|
43
|
+
},
|
|
44
|
+
} satisfies ArcanaJSUserConfig);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "arcanajs-app",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"scripts": {
|
|
6
|
+
"dev": "arcanajs dev",
|
|
7
|
+
"build": "arcanajs build",
|
|
8
|
+
"start": "arcanajs start"
|
|
9
|
+
},
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"arcanajs": "^2.5.1",
|
|
12
|
+
"react": "^19.2.0",
|
|
13
|
+
"react-dom": "^19.2.0"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
Binary file
|