arcanajs 0.2.2 → 2.0.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/babel.config.js +7 -0
- package/lib/client/index.d.ts +2 -0
- package/lib/client/index.js +40 -0
- package/lib/index.d.ts +17 -0
- package/lib/index.js +33 -0
- package/lib/server/ArcanaJSMiddleware.d.ts +16 -0
- package/lib/server/ArcanaJSMiddleware.js +99 -0
- package/lib/server/ArcanaJSServer.d.ts +21 -0
- package/lib/server/ArcanaJSServer.js +140 -0
- package/lib/server/ControllerBinder.d.ts +4 -0
- package/lib/server/ControllerBinder.js +32 -0
- package/lib/server/CsrfMiddleware.d.ts +2 -0
- package/lib/server/CsrfMiddleware.js +34 -0
- package/lib/server/DynamicRouter.d.ts +2 -0
- package/lib/server/DynamicRouter.js +50 -0
- package/lib/server/ResponseHandlerMiddleware.d.ts +27 -0
- package/lib/server/ResponseHandlerMiddleware.js +30 -0
- package/lib/server/Router.d.ts +94 -0
- package/lib/server/Router.js +203 -0
- package/lib/server.d.ts +6 -0
- package/lib/server.js +28 -0
- package/lib/shared/ArcanaJSApp.d.ts +11 -0
- package/lib/shared/ArcanaJSApp.js +79 -0
- package/lib/shared/components/Body.d.ts +6 -0
- package/lib/shared/components/Body.js +11 -0
- package/lib/shared/components/Head.d.ts +4 -0
- package/lib/shared/components/Head.js +125 -0
- package/lib/shared/components/Link.d.ts +6 -0
- package/lib/shared/components/Link.js +17 -0
- package/lib/shared/components/NavLink.d.ts +8 -0
- package/lib/shared/components/NavLink.js +16 -0
- package/lib/shared/components/Page.d.ts +6 -0
- package/lib/shared/components/Page.js +16 -0
- package/lib/shared/context/HeadContext.d.ts +6 -0
- package/lib/shared/context/HeadContext.js +5 -0
- package/lib/shared/context/PageContext.d.ts +1 -0
- package/lib/shared/context/PageContext.js +5 -0
- package/lib/shared/context/RouterContext.d.ts +13 -0
- package/lib/shared/context/RouterContext.js +13 -0
- package/lib/shared/core/ArcanaJSApp.d.ts +13 -0
- package/lib/shared/core/ArcanaJSApp.js +98 -0
- package/lib/shared/hooks/useDynamicComponents.d.ts +1 -0
- package/lib/shared/hooks/useDynamicComponents.js +20 -0
- package/lib/shared/hooks/useHead.d.ts +1 -0
- package/lib/shared/hooks/useHead.js +7 -0
- package/lib/shared/hooks/useLocation.d.ts +5 -0
- package/lib/shared/hooks/useLocation.js +13 -0
- package/lib/shared/hooks/usePage.d.ts +1 -0
- package/lib/shared/hooks/usePage.js +7 -0
- package/lib/shared/hooks/useParams.d.ts +1 -0
- package/lib/shared/hooks/useParams.js +13 -0
- package/lib/shared/hooks/useQuery.d.ts +1 -0
- package/lib/shared/hooks/useQuery.js +9 -0
- package/lib/shared/hooks/useRouter.d.ts +1 -0
- package/lib/shared/hooks/useRouter.js +13 -0
- package/lib/shared/utils/createSingletonContext.d.ts +11 -0
- package/lib/shared/utils/createSingletonContext.js +21 -0
- package/package.json +58 -68
- package/postcss.config.js +6 -0
- package/tailwind.config.js +8 -0
- package/tsconfig.json +16 -0
- package/webpack.client.js +71 -0
- package/webpack.server.js +39 -0
- package/LICENSE +0 -21
- package/README.md +0 -284
- package/bin/arcana.ts +0 -19
- package/dist/bin/arcana.d.ts +0 -4
- package/dist/bin/arcana.d.ts.map +0 -1
- package/dist/bin/arcana.js +0 -17
- package/dist/bin/arcana.js.map +0 -1
- package/dist/config/default.d.ts +0 -7
- package/dist/config/default.d.ts.map +0 -1
- package/dist/config/default.js +0 -8
- package/dist/config/default.js.map +0 -1
- package/dist/src/controllers/HomeController.d.ts +0 -6
- package/dist/src/controllers/HomeController.d.ts.map +0 -1
- package/dist/src/controllers/HomeController.js +0 -9
- package/dist/src/controllers/HomeController.js.map +0 -1
- package/dist/src/middleware/auth.d.ts +0 -3
- package/dist/src/middleware/auth.d.ts.map +0 -1
- package/dist/src/middleware/auth.js +0 -9
- package/dist/src/middleware/auth.js.map +0 -1
- package/dist/src/models/User.d.ts +0 -11
- package/dist/src/models/User.d.ts.map +0 -1
- package/dist/src/models/User.js +0 -45
- package/dist/src/models/User.js.map +0 -1
- package/dist/src/repositories/UserRepository.d.ts +0 -9
- package/dist/src/repositories/UserRepository.d.ts.map +0 -1
- package/dist/src/repositories/UserRepository.js +0 -19
- package/dist/src/repositories/UserRepository.js.map +0 -1
- package/dist/src/routes/index.d.ts +0 -3
- package/dist/src/routes/index.d.ts.map +0 -1
- package/dist/src/routes/index.js +0 -14
- package/dist/src/routes/index.js.map +0 -1
- package/dist/src/server.d.ts +0 -2
- package/dist/src/server.d.ts.map +0 -1
- package/dist/src/server.js +0 -34
- package/dist/src/server.js.map +0 -1
- package/dist/src/services/UserService.d.ts +0 -8
- package/dist/src/services/UserService.d.ts.map +0 -1
- package/dist/src/services/UserService.js +0 -16
- package/dist/src/services/UserService.js.map +0 -1
- package/dist/src/views/pages/home.d.ts +0 -2
- package/dist/src/views/pages/home.d.ts.map +0 -1
- package/dist/src/views/pages/home.js +0 -13
- package/dist/src/views/pages/home.js.map +0 -1
|
@@ -0,0 +1,98 @@
|
|
|
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 react_1 = __importStar(require("react"));
|
|
38
|
+
const Page_1 = require("../components/Page");
|
|
39
|
+
const RouterContext_1 = require("../context/RouterContext");
|
|
40
|
+
const ArcanaJSApp = ({ initialPage, initialData, initialParams = {}, initialUrl, csrfToken, views, layout: Layout, }) => {
|
|
41
|
+
const [page, setPage] = (0, react_1.useState)(initialPage);
|
|
42
|
+
const [data, setData] = (0, react_1.useState)(initialData);
|
|
43
|
+
const [params, setParams] = (0, react_1.useState)(initialParams);
|
|
44
|
+
const [url, setUrl] = (0, react_1.useState)(initialUrl ||
|
|
45
|
+
(typeof window !== "undefined" ? window.location.pathname : "/"));
|
|
46
|
+
(0, react_1.useEffect)(() => {
|
|
47
|
+
const handlePopState = (event) => {
|
|
48
|
+
if (event.state) {
|
|
49
|
+
setPage(event.state.page);
|
|
50
|
+
setData(event.state.data);
|
|
51
|
+
setParams(event.state.params || {});
|
|
52
|
+
setUrl(window.location.pathname);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
window.addEventListener("popstate", handlePopState);
|
|
56
|
+
return () => window.removeEventListener("popstate", handlePopState);
|
|
57
|
+
}, []);
|
|
58
|
+
const navigateTo = async (newUrl) => {
|
|
59
|
+
try {
|
|
60
|
+
const response = await fetch(newUrl, {
|
|
61
|
+
headers: { "x-arcanajs-request": "true" },
|
|
62
|
+
});
|
|
63
|
+
if (!response.ok) {
|
|
64
|
+
if (response.status === 404) {
|
|
65
|
+
setPage("NotFoundPage");
|
|
66
|
+
setUrl(newUrl);
|
|
67
|
+
window.history.pushState({ page: "NotFoundPage", data: {} }, "", newUrl);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
throw new Error(`Navigation failed: ${response.status} ${response.statusText}`);
|
|
71
|
+
}
|
|
72
|
+
const json = await response.json();
|
|
73
|
+
window.history.pushState({ page: json.page, data: json.data, params: json.params }, "", newUrl);
|
|
74
|
+
setPage(json.page);
|
|
75
|
+
setData(json.data);
|
|
76
|
+
setParams(json.params || {});
|
|
77
|
+
setUrl(newUrl);
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
console.error("Navigation failed", error);
|
|
81
|
+
// Optionally set an error state here to show a UI toast or error page
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
const renderPage = () => {
|
|
85
|
+
const Component = views[page] || views["NotFoundPage"] || (() => react_1.default.createElement("div", null, "404 Not Found"));
|
|
86
|
+
return (react_1.default.createElement(Page_1.Page, { data: data },
|
|
87
|
+
react_1.default.createElement(Component, { data: data, navigateTo: navigateTo, params: params })));
|
|
88
|
+
};
|
|
89
|
+
const content = renderPage();
|
|
90
|
+
return (react_1.default.createElement(RouterContext_1.RouterProvider, { value: {
|
|
91
|
+
navigateTo,
|
|
92
|
+
currentPage: page,
|
|
93
|
+
currentUrl: url,
|
|
94
|
+
params,
|
|
95
|
+
csrfToken,
|
|
96
|
+
} }, Layout ? react_1.default.createElement(Layout, null, content) : react_1.default.createElement(react_1.default.Fragment, null, content)));
|
|
97
|
+
};
|
|
98
|
+
exports.ArcanaJSApp = ArcanaJSApp;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useDynamicComponents: (loader: () => Promise<any>) => any;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useDynamicComponents = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const useDynamicComponents = (loader) => {
|
|
6
|
+
const [component, setComponent] = (0, react_1.useState)(null);
|
|
7
|
+
(0, react_1.useEffect)(() => {
|
|
8
|
+
let mounted = true;
|
|
9
|
+
loader().then((mod) => {
|
|
10
|
+
if (mounted) {
|
|
11
|
+
setComponent(mod.default || mod);
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
return () => {
|
|
15
|
+
mounted = false;
|
|
16
|
+
};
|
|
17
|
+
}, []); // loader dependency omitted to avoid loops if loader is inline
|
|
18
|
+
return component;
|
|
19
|
+
};
|
|
20
|
+
exports.useDynamicComponents = useDynamicComponents;
|
|
@@ -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
|
+
}
|
package/package.json
CHANGED
|
@@ -1,81 +1,71 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "arcanajs",
|
|
3
|
-
"
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "ArcanaJS Framework",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"types": "lib/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./lib/index.js",
|
|
9
|
+
"./server": "./lib/server.js"
|
|
7
10
|
},
|
|
8
|
-
"version": "0.2.2",
|
|
9
|
-
"description": "A powerful full-stack framework combining Express, React and MongoDB with server-side rendering",
|
|
10
|
-
"main": "dist/server.js",
|
|
11
|
-
"types": "dist/server.d.ts",
|
|
12
11
|
"files": [
|
|
13
|
-
"
|
|
14
|
-
"
|
|
12
|
+
"lib",
|
|
13
|
+
"webpack.client.js",
|
|
14
|
+
"webpack.server.js",
|
|
15
|
+
"tsconfig.json",
|
|
16
|
+
"babel.config.js",
|
|
17
|
+
"postcss.config.js",
|
|
18
|
+
"tailwind.config.js"
|
|
15
19
|
],
|
|
16
20
|
"scripts": {
|
|
17
|
-
"
|
|
18
|
-
"build": "
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"dev": "
|
|
24
|
-
"start": "node dist/server.js"
|
|
25
|
-
"lint": "eslint . || true",
|
|
26
|
-
"test": "jest --runInBand"
|
|
27
|
-
},
|
|
28
|
-
"peerDependencies": {
|
|
29
|
-
"react": ">=16 <20",
|
|
30
|
-
"react-dom": ">=16 <20"
|
|
21
|
+
"build": "tsc -p tsconfig.lib.json",
|
|
22
|
+
"build:app": "cross-env NODE_ENV=production webpack --config webpack.server.js && cross-env NODE_ENV=production webpack --config webpack.client.js",
|
|
23
|
+
"dev:server": "cross-env NODE_ENV=development webpack --config webpack.server.js --watch",
|
|
24
|
+
"dev:server:tsx": "tsx watch src/example/server/index.ts",
|
|
25
|
+
"dev:client": "cross-env NODE_ENV=development webpack --config webpack.client.js --watch",
|
|
26
|
+
"dev": "concurrently \"npm run dev:server\" \"npm run dev:client\"",
|
|
27
|
+
"dev:tsx": "concurrently \"npm run dev:server:tsx\" \"npm run dev:client\"",
|
|
28
|
+
"start": "cross-env NODE_ENV=production node dist/server.js"
|
|
31
29
|
},
|
|
32
30
|
"dependencies": {
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
31
|
+
"@babel/core": "^7.23.0",
|
|
32
|
+
"@babel/preset-env": "^7.23.0",
|
|
33
|
+
"@babel/preset-react": "^7.22.15",
|
|
34
|
+
"@babel/preset-typescript": "^7.23.0",
|
|
35
|
+
"@tailwindcss/postcss": "^4.1.17",
|
|
36
|
+
"autoprefixer": "^10.4.22",
|
|
37
|
+
"babel-loader": "^10.0.0",
|
|
38
|
+
"clean-webpack-plugin": "^4.0.0",
|
|
39
|
+
"compression": "^1.8.1",
|
|
40
|
+
"concurrently": "^9.2.1",
|
|
41
|
+
"cookie-parser": "^1.4.7",
|
|
42
|
+
"cross-env": "^10.1.0",
|
|
43
|
+
"css-loader": "^7.1.2",
|
|
44
|
+
"express": "^5.1.0",
|
|
45
|
+
"helmet": "^8.1.0",
|
|
46
|
+
"html-webpack-plugin": "^5.6.5",
|
|
47
|
+
"mini-css-extract-plugin": "^2.9.4",
|
|
48
|
+
"null-loader": "^4.0.1",
|
|
49
|
+
"postcss": "^8.5.6",
|
|
50
|
+
"postcss-loader": "^8.2.0",
|
|
51
|
+
"react": "^19.2.0",
|
|
52
|
+
"react-dom": "^19.2.0",
|
|
53
|
+
"style-loader": "^4.0.0",
|
|
54
|
+
"tailwindcss": "^4.1.17",
|
|
55
|
+
"ts-loader": "^9.4.4",
|
|
56
|
+
"typescript": "^5.2.2",
|
|
57
|
+
"webpack": "^5.88.2",
|
|
58
|
+
"webpack-cli": "^6.0.1",
|
|
59
|
+
"webpack-node-externals": "^3.0.0"
|
|
39
60
|
},
|
|
40
61
|
"devDependencies": {
|
|
41
|
-
"@types/
|
|
62
|
+
"@types/compression": "^1.8.1",
|
|
63
|
+
"@types/cookie-parser": "^1.4.10",
|
|
42
64
|
"@types/express": "^5.0.5",
|
|
43
|
-
"@types/
|
|
44
|
-
"@types/
|
|
45
|
-
"@types/react": "^
|
|
46
|
-
"@types/react-dom": "^18.2.0",
|
|
47
|
-
"@types/url-join": "^4.0.3",
|
|
48
|
-
"eslint": "^8.0.0",
|
|
49
|
-
"jest": "^29.0.0",
|
|
50
|
-
"nodemon": "^3.0.1",
|
|
65
|
+
"@types/node": "^24.10.1",
|
|
66
|
+
"@types/react": "^19.2.7",
|
|
67
|
+
"@types/react-dom": "^19.2.3",
|
|
51
68
|
"ts-node": "^10.9.2",
|
|
52
|
-
"
|
|
53
|
-
}
|
|
54
|
-
"keywords": [
|
|
55
|
-
"framework",
|
|
56
|
-
"full-stack",
|
|
57
|
-
"express",
|
|
58
|
-
"react",
|
|
59
|
-
"mongodb",
|
|
60
|
-
"ssr",
|
|
61
|
-
"mvc",
|
|
62
|
-
"arcana",
|
|
63
|
-
"routing",
|
|
64
|
-
"server-side-rendering"
|
|
65
|
-
],
|
|
66
|
-
"repository": {
|
|
67
|
-
"type": "git",
|
|
68
|
-
"url": "https://github.com/Mohammed-Ben-Cheikh/arcanajs.git"
|
|
69
|
-
},
|
|
70
|
-
"bugs": {
|
|
71
|
-
"url": "https://github.com/Mohammed-Ben-Cheikh/arcanajs/issues"
|
|
72
|
-
},
|
|
73
|
-
"homepage": "https://github.com/Mohammed-Ben-Cheikh/arcanajs#readme",
|
|
74
|
-
"bin": {
|
|
75
|
-
"arcana": "dist/bin/arcana.js"
|
|
76
|
-
},
|
|
77
|
-
"engines": {
|
|
78
|
-
"node": ">=16"
|
|
79
|
-
},
|
|
80
|
-
"license": "MIT"
|
|
69
|
+
"tsx": "^4.20.6"
|
|
70
|
+
}
|
|
81
71
|
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"module": "CommonJS",
|
|
5
|
+
"lib": ["DOM", "ES2020"],
|
|
6
|
+
"jsx": "react",
|
|
7
|
+
"strict": true,
|
|
8
|
+
"esModuleInterop": true,
|
|
9
|
+
"skipLibCheck": true,
|
|
10
|
+
"forceConsistentCasingInFileNames": true,
|
|
11
|
+
"outDir": "./dist",
|
|
12
|
+
"rootDir": "./src",
|
|
13
|
+
"moduleResolution": "node"
|
|
14
|
+
},
|
|
15
|
+
"include": ["src/**/*"]
|
|
16
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
const path = require("path");
|
|
2
|
+
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
|
|
3
|
+
const HtmlWebpackPlugin = require("html-webpack-plugin");
|
|
4
|
+
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
|
5
|
+
|
|
6
|
+
const isProduction = process.env.NODE_ENV === "production";
|
|
7
|
+
|
|
8
|
+
module.exports = {
|
|
9
|
+
mode: isProduction ? "production" : "development",
|
|
10
|
+
target: "web",
|
|
11
|
+
entry: {
|
|
12
|
+
client: "./src/example/client/index.tsx",
|
|
13
|
+
},
|
|
14
|
+
output: {
|
|
15
|
+
path: path.resolve(__dirname, "dist/public"),
|
|
16
|
+
filename: isProduction
|
|
17
|
+
? "[name].[contenthash].bundle.js"
|
|
18
|
+
: "[name].bundle.js",
|
|
19
|
+
publicPath: "/",
|
|
20
|
+
assetModuleFilename: "assets/[hash][ext][query]",
|
|
21
|
+
},
|
|
22
|
+
resolve: {
|
|
23
|
+
extensions: [".ts", ".tsx", ".js", ".jsx"],
|
|
24
|
+
},
|
|
25
|
+
module: {
|
|
26
|
+
rules: [
|
|
27
|
+
{
|
|
28
|
+
test: /\.(ts|tsx|js|jsx)$/,
|
|
29
|
+
exclude: /node_modules/,
|
|
30
|
+
use: "babel-loader",
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
test: /\.css$/,
|
|
34
|
+
use: [
|
|
35
|
+
isProduction ? MiniCssExtractPlugin.loader : "style-loader",
|
|
36
|
+
"css-loader",
|
|
37
|
+
"postcss-loader",
|
|
38
|
+
],
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
test: /\.(png|jpg|jpeg|gif|svg|woff|woff2|eot|ttf|otf)$/i,
|
|
42
|
+
type: "asset/resource",
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
},
|
|
46
|
+
plugins: [
|
|
47
|
+
new CleanWebpackPlugin(),
|
|
48
|
+
new HtmlWebpackPlugin({
|
|
49
|
+
template: "./src/lib/server/default-index.html",
|
|
50
|
+
filename: "index.html",
|
|
51
|
+
inject: "body",
|
|
52
|
+
minify: isProduction,
|
|
53
|
+
}),
|
|
54
|
+
new MiniCssExtractPlugin({
|
|
55
|
+
filename: isProduction ? "[name].[contenthash].css" : "[name].css",
|
|
56
|
+
}),
|
|
57
|
+
],
|
|
58
|
+
optimization: {
|
|
59
|
+
splitChunks: {
|
|
60
|
+
chunks: "all",
|
|
61
|
+
cacheGroups: {
|
|
62
|
+
vendor: {
|
|
63
|
+
test: /[\\/]node_modules[\\/]/,
|
|
64
|
+
name: "vendors",
|
|
65
|
+
chunks: "all",
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
devtool: isProduction ? "source-map" : "eval-source-map",
|
|
71
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
const path = require("path");
|
|
2
|
+
const nodeExternals = require("webpack-node-externals");
|
|
3
|
+
|
|
4
|
+
const isProduction = process.env.NODE_ENV === "production";
|
|
5
|
+
|
|
6
|
+
module.exports = {
|
|
7
|
+
mode: isProduction ? "production" : "development",
|
|
8
|
+
target: "node",
|
|
9
|
+
entry: "./src/example/server/index.ts",
|
|
10
|
+
output: {
|
|
11
|
+
path: path.resolve(__dirname, "dist"),
|
|
12
|
+
filename: "server.js",
|
|
13
|
+
},
|
|
14
|
+
externals: [nodeExternals()],
|
|
15
|
+
resolve: {
|
|
16
|
+
extensions: [".ts", ".tsx", ".js", ".jsx"],
|
|
17
|
+
},
|
|
18
|
+
module: {
|
|
19
|
+
rules: [
|
|
20
|
+
{
|
|
21
|
+
test: /\.(ts|tsx|js|jsx)$/,
|
|
22
|
+
exclude: /node_modules/,
|
|
23
|
+
use: "babel-loader",
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
test: /\.css$/,
|
|
27
|
+
use: "null-loader", // Ignore CSS on server side
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
test: /\.(png|jpg|jpeg|gif|svg|woff|woff2|eot|ttf|otf)$/i,
|
|
31
|
+
type: "asset/resource",
|
|
32
|
+
generator: {
|
|
33
|
+
emit: false, // Don't emit files for server build, just get paths
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
},
|
|
38
|
+
devtool: isProduction ? "source-map" : "eval-source-map",
|
|
39
|
+
};
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 Mohammed Ben Cheikh
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|