arcanajs 1.0.0 → 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.
Files changed (121) hide show
  1. package/babel.config.js +7 -0
  2. package/lib/client/index.d.ts +2 -0
  3. package/lib/client/index.js +40 -0
  4. package/lib/index.d.ts +17 -0
  5. package/lib/index.js +33 -0
  6. package/lib/server/ArcanaJSMiddleware.d.ts +16 -0
  7. package/lib/server/ArcanaJSMiddleware.js +99 -0
  8. package/lib/server/ArcanaJSServer.d.ts +21 -0
  9. package/lib/server/ArcanaJSServer.js +140 -0
  10. package/lib/server/ControllerBinder.d.ts +4 -0
  11. package/lib/server/ControllerBinder.js +32 -0
  12. package/lib/server/CsrfMiddleware.d.ts +2 -0
  13. package/lib/server/CsrfMiddleware.js +34 -0
  14. package/lib/server/DynamicRouter.d.ts +2 -0
  15. package/lib/server/DynamicRouter.js +50 -0
  16. package/lib/server/ResponseHandlerMiddleware.d.ts +27 -0
  17. package/lib/server/ResponseHandlerMiddleware.js +30 -0
  18. package/lib/server/Router.d.ts +94 -0
  19. package/lib/server/Router.js +203 -0
  20. package/lib/server.d.ts +6 -0
  21. package/lib/server.js +28 -0
  22. package/lib/shared/ArcanaJSApp.d.ts +11 -0
  23. package/lib/shared/ArcanaJSApp.js +79 -0
  24. package/lib/shared/components/Body.d.ts +6 -0
  25. package/lib/shared/components/Body.js +11 -0
  26. package/lib/shared/components/Head.d.ts +4 -0
  27. package/lib/shared/components/Head.js +125 -0
  28. package/lib/shared/components/Link.d.ts +6 -0
  29. package/lib/shared/components/Link.js +17 -0
  30. package/lib/shared/components/NavLink.d.ts +8 -0
  31. package/lib/shared/components/NavLink.js +16 -0
  32. package/lib/shared/components/Page.d.ts +6 -0
  33. package/lib/shared/components/Page.js +16 -0
  34. package/lib/shared/context/HeadContext.d.ts +6 -0
  35. package/lib/shared/context/HeadContext.js +5 -0
  36. package/lib/shared/context/PageContext.d.ts +1 -0
  37. package/lib/shared/context/PageContext.js +5 -0
  38. package/lib/shared/context/RouterContext.d.ts +13 -0
  39. package/lib/shared/context/RouterContext.js +13 -0
  40. package/lib/shared/core/ArcanaJSApp.d.ts +13 -0
  41. package/lib/shared/core/ArcanaJSApp.js +98 -0
  42. package/lib/shared/hooks/useDynamicComponents.d.ts +1 -0
  43. package/lib/shared/hooks/useDynamicComponents.js +20 -0
  44. package/lib/shared/hooks/useHead.d.ts +1 -0
  45. package/lib/shared/hooks/useHead.js +7 -0
  46. package/lib/shared/hooks/useLocation.d.ts +5 -0
  47. package/lib/shared/hooks/useLocation.js +13 -0
  48. package/lib/shared/hooks/usePage.d.ts +1 -0
  49. package/lib/shared/hooks/usePage.js +7 -0
  50. package/lib/shared/hooks/useParams.d.ts +1 -0
  51. package/lib/shared/hooks/useParams.js +13 -0
  52. package/lib/shared/hooks/useQuery.d.ts +1 -0
  53. package/lib/shared/hooks/useQuery.js +9 -0
  54. package/lib/shared/hooks/useRouter.d.ts +1 -0
  55. package/lib/shared/hooks/useRouter.js +13 -0
  56. package/lib/shared/utils/createSingletonContext.d.ts +11 -0
  57. package/lib/shared/utils/createSingletonContext.js +21 -0
  58. package/package.json +65 -25
  59. package/postcss.config.js +6 -0
  60. package/tailwind.config.js +8 -0
  61. package/tsconfig.json +6 -17
  62. package/webpack.client.js +71 -0
  63. package/webpack.server.js +39 -0
  64. package/.env.example +0 -0
  65. package/.prettierrc +0 -4
  66. package/README.md +0 -115
  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
@@ -1,350 +0,0 @@
1
- import { useEffect, useRef, useState } from "react";
2
- import { Prism as SyntaxHighlighter } from "react-syntax-highlighter";
3
- import { vscDarkPlus } from "react-syntax-highlighter/dist/esm/styles/prism";
4
- import dracula from "react-syntax-highlighter/dist/esm/styles/prism/dracula";
5
- import okaidia from "react-syntax-highlighter/dist/esm/styles/prism/okaidia";
6
-
7
- interface CodeBlockProps {
8
- code: string;
9
- language?: string;
10
- showLineNumbers?: boolean;
11
- showCopyButton?: boolean;
12
- showHeader?: boolean;
13
- maxHeight?: string;
14
- expandable?: boolean;
15
- filename?: string;
16
- theme?: "vscDarkPlus" | "dracula" | "okaidia";
17
- }
18
-
19
- const CodeBlock = ({
20
- code,
21
- language = "tsx",
22
- showLineNumbers = true,
23
- showCopyButton = true,
24
- showHeader = true,
25
- maxHeight = "none",
26
- expandable = false,
27
- filename,
28
- theme = "vscDarkPlus",
29
- }: CodeBlockProps) => {
30
- const [isCopied, setIsCopied] = useState(false);
31
- const [isExpanded, setIsExpanded] = useState(!expandable);
32
- const [showScrollIndicator, setShowScrollIndicator] = useState(false);
33
- const codeRef = useRef<HTMLDivElement>(null);
34
-
35
- const themes = {
36
- vscDarkPlus,
37
- dracula,
38
- okaidia,
39
- };
40
-
41
- const copyToClipboard = async () => {
42
- try {
43
- await navigator.clipboard.writeText(code);
44
- setIsCopied(true);
45
- setTimeout(() => setIsCopied(false), 2000);
46
- } catch (err) {
47
- console.error("Failed to copy code: ", err);
48
- }
49
- };
50
-
51
- const toggleExpand = () => {
52
- setIsExpanded(!isExpanded);
53
- };
54
-
55
- const checkScrollable = () => {
56
- if (codeRef.current) {
57
- const { scrollHeight, clientHeight } = codeRef.current;
58
- setShowScrollIndicator(scrollHeight > clientHeight);
59
- }
60
- };
61
-
62
- useEffect(() => {
63
- checkScrollable();
64
- window.addEventListener("resize", checkScrollable);
65
- return () => window.removeEventListener("resize", checkScrollable);
66
- }, [code, maxHeight]);
67
-
68
- const simpleFormat = (src: string) => {
69
- const indentUnit = " ";
70
- const lines = src.replace(/\r/g, "").split("\n");
71
- let level = 0;
72
- const out: string[] = [];
73
-
74
- for (let rawLine of lines) {
75
- if (/^\s*$/.test(rawLine)) {
76
- if (out.length === 0 || /^\s*$/.test(out[out.length - 1])) continue;
77
- out.push("");
78
- continue;
79
- }
80
-
81
- rawLine = rawLine.replace(/\t/g, indentUnit).trim();
82
- if (/^[)}\]]/.test(rawLine)) {
83
- level = Math.max(0, level - 1);
84
- }
85
-
86
- out.push(indentUnit.repeat(level) + rawLine);
87
-
88
- if (/[{[(]$/.test(rawLine) || /:\s*$/.test(rawLine)) {
89
- level++;
90
- }
91
- }
92
-
93
- while (out.length && out[0].trim() === "") out.shift();
94
- while (out.length && out[out.length - 1].trim() === "") out.pop();
95
- return out.join("\n");
96
- };
97
-
98
- const formattedCode = (() => {
99
- try {
100
- return simpleFormat(code);
101
- } catch {
102
- return code;
103
- }
104
- })();
105
-
106
- const getLanguageDisplayName = (lang: string) => {
107
- const languageMap: { [key: string]: string } = {
108
- tsx: "TypeScript",
109
- jsx: "JavaScript",
110
- javascript: "JavaScript",
111
- typescript: "TypeScript",
112
- python: "Python",
113
- java: "Java",
114
- cpp: "C++",
115
- css: "CSS",
116
- html: "HTML",
117
- json: "JSON",
118
- bash: "Bash",
119
- shell: "Shell",
120
- sql: "SQL",
121
- };
122
- return languageMap[lang] || lang.toUpperCase();
123
- };
124
-
125
- return (
126
- <div className="bg-[#1e1e1e] rounded-lg border border-white/10 overflow-hidden shadow-xl hover:shadow-2xl transition-all duration-300">
127
- {/* Header */}
128
- {showHeader && (
129
- <div className="flex items-center justify-between px-4 py-3 bg-gray-900/50 border-b border-white/10">
130
- <div className="flex items-center gap-3">
131
- {/* Language Indicator */}
132
- <div className="flex items-center gap-2">
133
- <div className="flex gap-1">
134
- <div className="w-3 h-3 rounded-full bg-red-500"></div>
135
- <div className="w-3 h-3 rounded-full bg-yellow-500"></div>
136
- <div className="w-3 h-3 rounded-full bg-green-500"></div>
137
- </div>
138
- <span className="text-sm font-medium text-gray-300">
139
- {getLanguageDisplayName(language)}
140
- </span>
141
- </div>
142
-
143
- {/* Filename */}
144
- {filename && (
145
- <div className="flex items-center gap-2 text-xs text-gray-400">
146
- <svg
147
- className="w-4 h-4"
148
- fill="none"
149
- stroke="currentColor"
150
- viewBox="0 0 24 24"
151
- >
152
- <path
153
- strokeLinecap="round"
154
- strokeLinejoin="round"
155
- strokeWidth={2}
156
- d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"
157
- />
158
- </svg>
159
- {filename}
160
- </div>
161
- )}
162
- </div>
163
-
164
- <div className="flex items-center gap-2">
165
- {/* Expand/Collapse Button */}
166
- {expandable && (
167
- <button
168
- onClick={toggleExpand}
169
- className="p-1.5 rounded-md hover:bg-white/10 transition-colors duration-200"
170
- title={isExpanded ? "Collapse" : "Expand"}
171
- >
172
- <svg
173
- className={`w-4 h-4 text-gray-400 transition-transform duration-200 ${
174
- isExpanded ? "rotate-180" : ""
175
- }`}
176
- fill="none"
177
- stroke="currentColor"
178
- viewBox="0 0 24 24"
179
- >
180
- <path
181
- strokeLinecap="round"
182
- strokeLinejoin="round"
183
- strokeWidth={2}
184
- d="M19 9l-7 7-7-7"
185
- />
186
- </svg>
187
- </button>
188
- )}
189
-
190
- {/* Copy Button */}
191
- {showCopyButton && (
192
- <button
193
- onClick={copyToClipboard}
194
- className="flex items-center gap-2 px-3 py-1.5 text-xs font-medium rounded-md bg-blue-600 hover:bg-blue-700 text-white transition-all duration-200 active:scale-95"
195
- >
196
- {isCopied ? (
197
- <>
198
- <svg
199
- className="w-4 h-4"
200
- fill="none"
201
- stroke="currentColor"
202
- viewBox="0 0 24 24"
203
- >
204
- <path
205
- strokeLinecap="round"
206
- strokeLinejoin="round"
207
- strokeWidth={2}
208
- d="M5 13l4 4L19 7"
209
- />
210
- </svg>
211
- Copied!
212
- </>
213
- ) : (
214
- <>
215
- <svg
216
- className="w-4 h-4"
217
- fill="none"
218
- stroke="currentColor"
219
- viewBox="0 0 24 24"
220
- >
221
- <path
222
- strokeLinecap="round"
223
- strokeLinejoin="round"
224
- strokeWidth={2}
225
- d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"
226
- />
227
- </svg>
228
- Copy
229
- </>
230
- )}
231
- </button>
232
- )}
233
- </div>
234
- </div>
235
- )}
236
-
237
- {/* Code Content */}
238
- <div
239
- ref={codeRef}
240
- className={`relative transition-all duration-300 ${
241
- isExpanded ? "max-h-none" : `max-h-96 overflow-hidden`
242
- }`}
243
- style={
244
- isExpanded
245
- ? {}
246
- : { maxHeight: maxHeight !== "none" ? maxHeight : "24rem" }
247
- }
248
- >
249
- {/* Scroll Indicator */}
250
- {showScrollIndicator && !isExpanded && (
251
- <div className="absolute bottom-0 left-0 right-0 h-8 bg-gradient-to-t from-gray-900 to-transparent flex items-center justify-center">
252
- <div className="flex items-center gap-1 text-xs text-gray-400 bg-gray-800 px-2 py-1 rounded-full">
253
- <svg
254
- className="w-3 h-3"
255
- fill="none"
256
- stroke="currentColor"
257
- viewBox="0 0 24 24"
258
- >
259
- <path
260
- strokeLinecap="round"
261
- strokeLinejoin="round"
262
- strokeWidth={2}
263
- d="M19 14l-7 7m0 0l-7-7m7 7V3"
264
- />
265
- </svg>
266
- Scroll to see more
267
- </div>
268
- </div>
269
- )}
270
-
271
- <SyntaxHighlighter
272
- language={language}
273
- style={themes[theme]}
274
- showLineNumbers={showLineNumbers}
275
- customStyle={{
276
- margin: 0,
277
- padding: "1.5rem",
278
- background: "#1e1e1e",
279
- fontSize: "0.875rem",
280
- lineHeight: "1.5",
281
- border: "none",
282
- borderRadius: 0,
283
- }}
284
- lineNumberStyle={{
285
- minWidth: "3em",
286
- paddingRight: "1em",
287
- color: "#858585",
288
- userSelect: "none",
289
- background: "transparent",
290
- }}
291
- wrapLines={true}
292
- wrapLongLines={true}
293
- >
294
- {formattedCode}
295
- </SyntaxHighlighter>
296
-
297
- {/* Expand Overlay */}
298
- {expandable && !isExpanded && (
299
- <div
300
- className="absolute inset-0 bg-gradient-to-b from-transparent to-gray-900/80 cursor-pointer flex items-end justify-center pb-4"
301
- onClick={toggleExpand}
302
- >
303
- <div className="flex items-center gap-2 px-4 py-2 bg-gray-800 rounded-lg text-sm text-gray-300 hover:bg-gray-700 transition-colors">
304
- <svg
305
- className="w-4 h-4"
306
- fill="none"
307
- stroke="currentColor"
308
- viewBox="0 0 24 24"
309
- >
310
- <path
311
- strokeLinecap="round"
312
- strokeLinejoin="round"
313
- strokeWidth={2}
314
- d="M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5v-4m0 4h-4m4 0l-5-5"
315
- />
316
- </svg>
317
- Click to expand
318
- </div>
319
- </div>
320
- )}
321
- </div>
322
-
323
- {/* Footer with character/lines count */}
324
- <div className="px-4 py-2 bg-gray-900/30 border-t border-white/5 flex justify-between items-center text-xs text-gray-500">
325
- <div className="flex items-center gap-4">
326
- <span>{formattedCode.split("\n").length} lines</span>
327
- <span>{formattedCode.length} characters</span>
328
- </div>
329
- <div className="flex items-center gap-1">
330
- <svg
331
- className="w-3 h-3"
332
- fill="none"
333
- stroke="currentColor"
334
- viewBox="0 0 24 24"
335
- >
336
- <path
337
- strokeLinecap="round"
338
- strokeLinejoin="round"
339
- strokeWidth={2}
340
- d="M13 10V3L4 14h7v7l9-11h-7z"
341
- />
342
- </svg>
343
- routerkit.com
344
- </div>
345
- </div>
346
- </div>
347
- );
348
- };
349
-
350
- export default CodeBlock;
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -1,4 +0,0 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "exclude": ["node_modules", "test", "dist", "**/*spec.ts"]
4
- }