arcanajs 1.0.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/README.md +10 -108
  2. package/babel.config.js +7 -0
  3. package/lib/client/index.d.ts +2 -0
  4. package/lib/client/index.js +40 -0
  5. package/lib/index.d.ts +17 -0
  6. package/lib/index.js +33 -0
  7. package/lib/server/ArcanaJSMiddleware.d.ts +16 -0
  8. package/lib/server/ArcanaJSMiddleware.js +99 -0
  9. package/lib/server/ArcanaJSServer.d.ts +21 -0
  10. package/lib/server/ArcanaJSServer.js +140 -0
  11. package/lib/server/ControllerBinder.d.ts +4 -0
  12. package/lib/server/ControllerBinder.js +32 -0
  13. package/lib/server/CsrfMiddleware.d.ts +2 -0
  14. package/lib/server/CsrfMiddleware.js +34 -0
  15. package/lib/server/DynamicRouter.d.ts +2 -0
  16. package/lib/server/DynamicRouter.js +50 -0
  17. package/lib/server/ResponseHandlerMiddleware.d.ts +27 -0
  18. package/lib/server/ResponseHandlerMiddleware.js +30 -0
  19. package/lib/server/Router.d.ts +94 -0
  20. package/lib/server/Router.js +203 -0
  21. package/lib/server.d.ts +6 -0
  22. package/lib/server.js +28 -0
  23. package/lib/shared/ArcanaJSApp.d.ts +11 -0
  24. package/lib/shared/ArcanaJSApp.js +79 -0
  25. package/lib/shared/components/Body.d.ts +6 -0
  26. package/lib/shared/components/Body.js +11 -0
  27. package/lib/shared/components/Head.d.ts +4 -0
  28. package/lib/shared/components/Head.js +125 -0
  29. package/lib/shared/components/Link.d.ts +6 -0
  30. package/lib/shared/components/Link.js +17 -0
  31. package/lib/shared/components/NavLink.d.ts +8 -0
  32. package/lib/shared/components/NavLink.js +16 -0
  33. package/lib/shared/components/Page.d.ts +6 -0
  34. package/lib/shared/components/Page.js +16 -0
  35. package/lib/shared/context/HeadContext.d.ts +6 -0
  36. package/lib/shared/context/HeadContext.js +5 -0
  37. package/lib/shared/context/PageContext.d.ts +1 -0
  38. package/lib/shared/context/PageContext.js +5 -0
  39. package/lib/shared/context/RouterContext.d.ts +13 -0
  40. package/lib/shared/context/RouterContext.js +13 -0
  41. package/lib/shared/core/ArcanaJSApp.d.ts +13 -0
  42. package/lib/shared/core/ArcanaJSApp.js +98 -0
  43. package/lib/shared/hooks/useDynamicComponents.d.ts +1 -0
  44. package/lib/shared/hooks/useDynamicComponents.js +20 -0
  45. package/lib/shared/hooks/useHead.d.ts +1 -0
  46. package/lib/shared/hooks/useHead.js +7 -0
  47. package/lib/shared/hooks/useLocation.d.ts +5 -0
  48. package/lib/shared/hooks/useLocation.js +13 -0
  49. package/lib/shared/hooks/usePage.d.ts +1 -0
  50. package/lib/shared/hooks/usePage.js +7 -0
  51. package/lib/shared/hooks/useParams.d.ts +1 -0
  52. package/lib/shared/hooks/useParams.js +13 -0
  53. package/lib/shared/hooks/useQuery.d.ts +1 -0
  54. package/lib/shared/hooks/useQuery.js +9 -0
  55. package/lib/shared/hooks/useRouter.d.ts +1 -0
  56. package/lib/shared/hooks/useRouter.js +13 -0
  57. package/lib/shared/utils/createSingletonContext.d.ts +11 -0
  58. package/lib/shared/utils/createSingletonContext.js +21 -0
  59. package/package.json +65 -25
  60. package/postcss.config.js +6 -0
  61. package/tailwind.config.js +8 -0
  62. package/tsconfig.json +6 -17
  63. package/webpack.client.js +71 -0
  64. package/webpack.server.js +39 -0
  65. package/.env.example +0 -0
  66. package/.prettierrc +0 -4
  67. package/arcanajs +0 -0
  68. package/arcanajs-cli.json +0 -8
  69. package/arcanajs.config.mjs +0 -0
  70. package/eslint.config.mjs +0 -35
  71. package/jest.config.mjs +0 -8
  72. package/src/app/Http/Controllers/Controller.ts +0 -0
  73. package/src/app/Http/Controllers/UserController.ts +0 -0
  74. package/src/app/Http/Middleware/AuthMiddleware.ts +0 -0
  75. package/src/app/Http/Middleware/ValidationMiddleware.ts +0 -0
  76. package/src/app/Models/User.ts +0 -0
  77. package/src/app/Providers/AppServiceProvider.ts +0 -0
  78. package/src/app/Providers/DatabaseProvider.ts +0 -0
  79. package/src/app/Repositories/UserRepository.ts +0 -0
  80. package/src/app/Services/UserService.ts +0 -0
  81. package/src/bootstrap/app.ts +0 -0
  82. package/src/config/app.ts +0 -0
  83. package/src/config/cache.ts +0 -0
  84. package/src/config/database.ts +0 -0
  85. package/src/config/mail.ts +0 -0
  86. package/src/config/server.ts +0 -0
  87. package/src/core/App.ts +0 -0
  88. package/src/core/Cache.ts +0 -0
  89. package/src/core/Container.ts +0 -0
  90. package/src/core/Controller.ts +0 -0
  91. package/src/core/Kernel.ts +0 -0
  92. package/src/core/Logger.ts +0 -0
  93. package/src/core/Repository.ts +0 -0
  94. package/src/core/Response.ts +0 -0
  95. package/src/core/Service.ts +0 -0
  96. package/src/core/Validator.ts +0 -0
  97. package/src/resources/css/style.css +0 -0
  98. package/src/resources/views/back-office/components/common/Footer/main.tsx +0 -161
  99. package/src/resources/views/back-office/components/common/Header/main.tsx +0 -151
  100. package/src/resources/views/back-office/components/common/Layout/main.tsx +0 -15
  101. package/src/resources/views/back-office/components/ui/CodeBlock/index.tsx +0 -350
  102. package/src/resources/views/back-office/pages/About/index.tsx +0 -0
  103. package/src/resources/views/back-office/pages/Contact/index.tsx +0 -0
  104. package/src/resources/views/back-office/pages/Home/index.tsx +0 -0
  105. package/src/resources/views/back-office/pages/NotFound/index.tsx +0 -0
  106. package/src/resources/views/back-office/types/global.d.ts +0 -0
  107. package/src/resources/views/front-office/components/common/Footer/main.tsx +0 -161
  108. package/src/resources/views/front-office/components/common/Header/main.tsx +0 -151
  109. package/src/resources/views/front-office/components/common/Layout/main.tsx +0 -15
  110. package/src/resources/views/front-office/components/ui/CodeBlock/index.tsx +0 -350
  111. package/src/resources/views/front-office/pages/About/index.tsx +0 -0
  112. package/src/resources/views/front-office/pages/Contact/index.tsx +0 -0
  113. package/src/resources/views/front-office/pages/Home/index.tsx +0 -0
  114. package/src/resources/views/front-office/pages/NotFound/index.tsx +0 -0
  115. package/src/resources/views/front-office/types/global.d.ts +0 -0
  116. package/src/resources/views/main.tsx +0 -0
  117. package/src/routes/api.routes.ts +0 -0
  118. package/src/routes/web.routes.ts +0 -0
  119. package/tests/integration/jest.ts +0 -0
  120. package/tests/unit/jest.ts +0 -0
  121. package/tsconfig.build.json +0 -4
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.NavLink = void 0;
7
+ const react_1 = __importDefault(require("react"));
8
+ const Link_1 = require("./Link");
9
+ const useRouter_1 = require("../hooks/useRouter");
10
+ const NavLink = ({ href, activeClassName = "active", className = "", exact = false, children, ...props }) => {
11
+ const { currentUrl } = (0, useRouter_1.useRouter)();
12
+ const isActive = exact ? currentUrl === href : currentUrl.startsWith(href);
13
+ const combinedClassName = `${className} ${isActive ? activeClassName : ""}`.trim();
14
+ return (react_1.default.createElement(Link_1.Link, { href: href, className: combinedClassName, ...props }, children));
15
+ };
16
+ exports.NavLink = NavLink;
@@ -0,0 +1,6 @@
1
+ import React from "react";
2
+ export declare const Page: React.FC<{
3
+ data?: any;
4
+ title?: string;
5
+ children: React.ReactNode;
6
+ }>;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Page = void 0;
7
+ const react_1 = __importDefault(require("react"));
8
+ const PageContext_1 = require("../context/PageContext");
9
+ const Head_1 = require("./Head");
10
+ const Page = ({ data, title, children }) => {
11
+ return (react_1.default.createElement(PageContext_1.PageContext.Provider, { value: data },
12
+ title && (react_1.default.createElement(Head_1.Head, null,
13
+ react_1.default.createElement("title", null, title))),
14
+ children));
15
+ };
16
+ exports.Page = Page;
@@ -0,0 +1,6 @@
1
+ import React from "react";
2
+ export interface HeadManager {
3
+ tags: React.ReactNode[];
4
+ push: (tags: React.ReactNode) => void;
5
+ }
6
+ export declare const HeadContext: React.Context<HeadManager | null>;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HeadContext = void 0;
4
+ const createSingletonContext_1 = require("../utils/createSingletonContext");
5
+ exports.HeadContext = (0, createSingletonContext_1.createSingletonContext)("HeadContext", null);
@@ -0,0 +1 @@
1
+ export declare const PageContext: import("react").Context<any>;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PageContext = void 0;
4
+ const createSingletonContext_1 = require("../utils/createSingletonContext");
5
+ exports.PageContext = (0, createSingletonContext_1.createSingletonContext)("PageContext", null);
@@ -0,0 +1,13 @@
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
+ }
9
+ export declare const RouterContext: React.Context<RouterContextType | null>;
10
+ export declare const RouterProvider: React.FC<{
11
+ value: RouterContextType;
12
+ children: React.ReactNode;
13
+ }>;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.RouterProvider = exports.RouterContext = void 0;
7
+ const react_1 = __importDefault(require("react"));
8
+ const createSingletonContext_1 = require("../utils/createSingletonContext");
9
+ exports.RouterContext = (0, createSingletonContext_1.createSingletonContext)("RouterContext", null);
10
+ const RouterProvider = ({ value, children }) => {
11
+ return (react_1.default.createElement(exports.RouterContext.Provider, { value: value }, children));
12
+ };
13
+ exports.RouterProvider = RouterProvider;
@@ -0,0 +1,13 @@
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
+ }
13
+ export declare const ArcanaJSApp: React.FC<ArcanaJSAppProps>;
@@ -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,5 @@
1
+ export declare const useLocation: () => {
2
+ pathname: string;
3
+ search: string;
4
+ hash: string;
5
+ };
@@ -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,31 +1,71 @@
1
1
  {
2
2
  "name": "arcanajs",
3
- "author": {
4
- "name": "Mohammed Ben Cheikh",
5
- "email": "mohammed.bencheikh.dev@gmail.com",
6
- "url": "https://mohammedbencheikh.com/"
3
+ "version": "2.0.1",
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": "1.0.0",
9
- "description": "A powerful full-stack framework combining Express, React and MongoDB with server-side rendering",
10
- "keywords": [
11
- "framework",
12
- "full-stack",
13
- "express",
14
- "react",
15
- "mongodb",
16
- "ssr",
17
- "mvc",
18
- "arcana",
19
- "routing",
20
- "server-side-rendering"
11
+ "files": [
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"
21
19
  ],
22
- "repository": {
23
- "type": "git",
24
- "url": "https://github.com/arcanajs/arcanajs.git"
20
+ "scripts": {
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"
25
29
  },
26
- "bugs": {
27
- "url": "https://github.com/arcanajs/arcanajs/issues"
30
+ "dependencies": {
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"
28
60
  },
29
- "homepage": "https://arcanajs.com",
30
- "license": "MIT"
31
- }
61
+ "devDependencies": {
62
+ "@types/compression": "^1.8.1",
63
+ "@types/cookie-parser": "^1.4.10",
64
+ "@types/express": "^5.0.5",
65
+ "@types/node": "^24.10.1",
66
+ "@types/react": "^19.2.7",
67
+ "@types/react-dom": "^19.2.3",
68
+ "ts-node": "^10.9.2",
69
+ "tsx": "^4.20.6"
70
+ }
71
+ }
@@ -0,0 +1,6 @@
1
+ module.exports = {
2
+ plugins: {
3
+ "@tailwindcss/postcss": {},
4
+ autoprefixer: {},
5
+ },
6
+ };
@@ -0,0 +1,8 @@
1
+ /** @type {import('tailwindcss').Config} */
2
+ module.exports = {
3
+ content: ["./src/**/*.{js,jsx,ts,tsx}"],
4
+ theme: {
5
+ extend: {},
6
+ },
7
+ plugins: [],
8
+ };
package/tsconfig.json CHANGED
@@ -1,27 +1,16 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  "target": "ES2020",
4
- "module": "commonjs",
5
- "lib": ["ES2020"],
4
+ "module": "CommonJS",
5
+ "lib": ["DOM", "ES2020"],
6
6
  "jsx": "react",
7
- "outDir": "./dist",
8
- "rootDir": ".",
9
7
  "strict": true,
10
8
  "esModuleInterop": true,
11
9
  "skipLibCheck": true,
12
10
  "forceConsistentCasingInFileNames": true,
13
- "resolveJsonModule": true,
14
- "moduleResolution": "node",
15
- "declaration": true,
16
- "declarationMap": true,
17
- "sourceMap": true,
18
- "allowSyntheticDefaultImports": true,
19
- "types": ["node"],
20
- "baseUrl": ".",
21
- "paths": {
22
- "@/*": ["src/*"]
23
- }
11
+ "outDir": "./dist",
12
+ "rootDir": "./src",
13
+ "moduleResolution": "node"
24
14
  },
25
- "include": ["src/**/*", "config/**/*", "bin/**/*"],
26
- "exclude": ["node_modules", "dist", "tests"]
15
+ "include": ["src/**/*"]
27
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/.env.example DELETED
File without changes
package/.prettierrc DELETED
@@ -1,4 +0,0 @@
1
- {
2
- "singleQuote": true,
3
- "trailingComma": "all"
4
- }
package/arcanajs DELETED
File without changes
package/arcanajs-cli.json DELETED
@@ -1,8 +0,0 @@
1
- {
2
- "$schema": "https://json.schemastore.org/nest-cli",
3
- "collection": "@nestjs/schematics",
4
- "sourceRoot": "src",
5
- "compilerOptions": {
6
- "deleteOutDir": true
7
- }
8
- }
File without changes