vortez 5.0.0-dev.19 → 5.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 (106) hide show
  1. package/.gitignore +2 -0
  2. package/README.md +26 -9
  3. package/build/Template/Compiler.d.ts +70 -0
  4. package/build/Template/Compiler.js +135 -0
  5. package/build/Template/Compiler.js.map +1 -0
  6. package/build/Template/StreamCompiler.d.ts +16 -0
  7. package/build/Template/StreamCompiler.js +54 -0
  8. package/build/Template/StreamCompiler.js.map +1 -0
  9. package/build/Template/Template.d.ts +49 -0
  10. package/build/Template/Template.js +77 -0
  11. package/build/Template/Template.js.map +1 -0
  12. package/build/Vortez.d.ts +1 -1
  13. package/build/Vortez.js +1 -1
  14. package/build/Vortez.js.map +1 -1
  15. package/build/beta/JwtManager/JwtError.d.ts +8 -0
  16. package/build/beta/JwtManager/JwtError.js +10 -0
  17. package/build/beta/JwtManager/JwtError.js.map +1 -0
  18. package/build/beta/JwtManager/JwtManager.d.ts +3 -0
  19. package/build/beta/JwtManager/JwtManager.js +24 -7
  20. package/build/beta/JwtManager/JwtManager.js.map +1 -1
  21. package/build/server/BodyParser.d.ts +6 -0
  22. package/build/server/BodyParser.js +18 -3
  23. package/build/server/BodyParser.js.map +1 -1
  24. package/build/server/Request.d.ts +6 -4
  25. package/build/server/Request.js +15 -10
  26. package/build/server/Request.js.map +1 -1
  27. package/build/server/Response.d.ts +24 -9
  28. package/build/server/Response.js +160 -74
  29. package/build/server/Response.js.map +1 -1
  30. package/build/server/Server.js +29 -6
  31. package/build/server/Server.js.map +1 -1
  32. package/build/server/config/Config.d.ts +15 -13
  33. package/build/server/config/Config.js +8 -6
  34. package/build/server/config/Config.js.map +1 -1
  35. package/build/server/config/Loader.js +1 -1
  36. package/build/server/config/Loader.js.map +1 -1
  37. package/build/server/router/Router.d.ts +1 -1
  38. package/build/server/router/Router.js +3 -3
  39. package/build/server/router/Router.js.map +1 -1
  40. package/build/server/router/middleware/HttpMiddleware.js +1 -1
  41. package/build/server/router/middleware/HttpMiddleware.js.map +1 -1
  42. package/build/server/router/middleware/WsMiddleware.js +1 -1
  43. package/build/server/router/middleware/WsMiddleware.js.map +1 -1
  44. package/build/server/security/PathSecurity.d.ts +45 -0
  45. package/build/server/security/PathSecurity.js +108 -0
  46. package/build/server/security/PathSecurity.js.map +1 -0
  47. package/build/server/websocket/Websocket.js +4 -1
  48. package/build/server/websocket/Websocket.js.map +1 -1
  49. package/build/utilities/ConsoleUI.d.ts +2 -1
  50. package/build/utilities/ConsoleUI.js +2 -1
  51. package/build/utilities/ConsoleUI.js.map +1 -1
  52. package/build/utilities/DebugUI.d.ts +1 -1
  53. package/build/utilities/DebugUI.js +1 -1
  54. package/build/utilities/Encoding.d.ts +22 -0
  55. package/build/utilities/Encoding.js +26 -0
  56. package/build/utilities/Encoding.js.map +1 -0
  57. package/build/utilities/Env.js +7 -2
  58. package/build/utilities/Env.js.map +1 -1
  59. package/build/utilities/File.d.ts +10 -0
  60. package/build/utilities/File.js +19 -0
  61. package/build/utilities/File.js.map +1 -0
  62. package/build/utilities/Flatten.d.ts +18 -1
  63. package/build/utilities/Flatten.js +18 -1
  64. package/build/utilities/Flatten.js.map +1 -1
  65. package/build/utilities/Object.d.ts +16 -0
  66. package/build/utilities/Object.js +48 -0
  67. package/build/utilities/Object.js.map +1 -0
  68. package/build/utilities/Path.d.ts +31 -11
  69. package/build/utilities/Path.js +48 -15
  70. package/build/utilities/Path.js.map +1 -1
  71. package/build/utilities/Time.d.ts +21 -0
  72. package/build/utilities/Time.js +25 -0
  73. package/build/utilities/Time.js.map +1 -0
  74. package/build/utilities/Utilities.d.ts +43 -34
  75. package/build/utilities/Utilities.js +48 -38
  76. package/build/utilities/Utilities.js.map +1 -1
  77. package/changes.md +4 -0
  78. package/docs/ARCHITECTURE.md +142 -0
  79. package/global/style/template/error.css +29 -0
  80. package/global/style/template/folder.css +79 -0
  81. package/global/{Style/Template/Template.css → style/template/template.css} +60 -68
  82. package/global/template/error.vhtml +29 -0
  83. package/global/template/folder.vhtml +54 -0
  84. package/package.json +2 -2
  85. package/build/Template.d.ts +0 -46
  86. package/build/Template.js +0 -81
  87. package/build/Template.js.map +0 -1
  88. package/global/Style/Template/Error.css +0 -30
  89. package/global/Style/Template/Folder.css +0 -77
  90. package/global/Template/Error.vhtml +0 -29
  91. package/global/Template/Folder.vhtml +0 -41
  92. package/tests/Template/template.js +0 -18
  93. package/tests/Template/template.txt +0 -13
  94. package/tests/Template/template.vhtml +0 -23
  95. package/tests/config/config.js +0 -233
  96. package/tests/debug.js +0 -34
  97. package/tests/jwtManager/jwtManager.js +0 -342
  98. package/tests/router.js +0 -596
  99. package/tests/schema/schema.js +0 -368
  100. package/tests/test.env +0 -0
  101. package/tests/test.js +0 -131
  102. package/tests/test.vhtml +0 -14
  103. package/tests/utilities.js +0 -28
  104. package/tests/websocket.vhtml +0 -86
  105. /package/global/{Source/Logo_960.png → source/logo_960.png} +0 -0
  106. /package/global/{Source/Logo_SM_960.png → source/logo_SM_960.png} +0 -0
package/changes.md CHANGED
@@ -32,6 +32,10 @@
32
32
  - **(Server/WebSocket)**: Overhauled the WebSocket connection lifecycle for improved security and developer experience.
33
33
  - The `WebSocket` class no longer accepts connections in its constructor. Instead, it waits in a `pending` state.
34
34
  - Added `accept()` and `reject()` methods to give the framework full control over the connection handshake.
35
+ - **(Server/Response)**: The `send()`, `sendJson()`, `sendFile()`, `sendFolder()`, and `sendTemplate()` methods are now **async** and return `Promise<void>`. **This is a breaking change.**
36
+ - All response methods now require `await` in calling code for proper error handling.
37
+ - Added `sendReadable()` for streaming responses with backpressure support via `stream/promises`.
38
+ - HTTP range requests (206 Partial Content) are now properly handled in streaming contexts.
35
39
 
36
40
  # version (4.1.0)
37
41
  ## ➕ Added
@@ -0,0 +1,142 @@
1
+ # Vortez Architecture Guide
2
+
3
+ This document explains how Vortez works internally, how requests are processed end-to-end, and how teams can run it confidently in production.
4
+
5
+ ## Who This Is For
6
+
7
+ - Engineers evaluating Vortez for backend and real-time workloads.
8
+ - Teams onboarding to an existing Vortez codebase.
9
+ - Contributors who need to understand extension points and runtime behavior.
10
+
11
+ ## System At A Glance
12
+
13
+ ```mermaid
14
+ flowchart TD
15
+ A[Application Code] --> B[Vortez Server]
16
+ B --> C[Config]
17
+ B --> D[Router]
18
+ D --> E[HTTP Rules]
19
+ D --> F[WebSocket Rules]
20
+ E --> G[HttpMiddleware Pipeline]
21
+ F --> H[WsMiddleware Pipeline]
22
+ G --> I[Response Helpers]
23
+ H --> J[WebSocket Client]
24
+ I --> K[Template Engine]
25
+ B --> L[Logger Manager]
26
+ B --> M[Utilities]
27
+ B --> N[Beta Modules: JWT + Mail]
28
+ ```
29
+
30
+ ## Request Lifecycle (HTTP)
31
+
32
+ ```mermaid
33
+ flowchart TD
34
+ A[Incoming HTTP request] --> B[Router.requestManager]
35
+ B --> C[Build Request object]
36
+ C --> D[Build Response object]
37
+ D --> E[Routing Algorithm route]
38
+ E --> F{Rule matched}
39
+ F -->|No| G[Response.sendError 404]
40
+ F -->|Yes| H[HttpRule.exec]
41
+ H --> I[Run HTTP middleware pipeline]
42
+ I --> J{Pipeline status}
43
+ J -->|Success| K[Route action executes]
44
+ J -->|Error| L[Error middleware or default handler]
45
+ K --> M[send/sendJson/sendFile/sendFolder/sendTemplate]
46
+ L --> N[ServerError or 500 response]
47
+ ```
48
+
49
+ ### Key behavior
50
+
51
+ - Route parameters are extracted before action execution.
52
+ - Middleware is snapshot-based at rule registration time.
53
+ - If no route matches, Vortez returns a 404 error page.
54
+ - File and folder responses include path-safety checks for traversal protection.
55
+
56
+ ## Request Lifecycle (WebSocket)
57
+
58
+ ```mermaid
59
+ flowchart TD
60
+ A[Upgrade request] --> B[Router.upgradeManager]
61
+ B --> C[Build Request + WebSocket wrapper]
62
+ C --> D[Routing Algorithm route]
63
+ D --> E{Rule matched}
64
+ E -->|No| F[Reject 404]
65
+ E -->|Yes| G[WsRule.exec]
66
+ G --> H[Run WS middleware pipeline]
67
+ H --> I{Connection state}
68
+ I -->|pending and valid| J[Accept handshake]
69
+ I -->|error| K[Reject handshake]
70
+ J --> L[Route action executes]
71
+ L --> M[message/close/finish/error events]
72
+ ```
73
+
74
+ ### Key behavior
75
+
76
+ - WS routes also support middleware and error middleware.
77
+ - If middleware completes and state is pending, handshake is auto-accepted.
78
+ - Errors before accept are converted into explicit handshake rejection.
79
+
80
+ ## Routing Strategies
81
+
82
+ - FIFO
83
+ - First matching rule wins.
84
+ - Predictable registration-order behavior.
85
+ - Good default for simple APIs and deterministic route priority.
86
+ - Tree
87
+ - Segment-based navigation through static, param, and wildcard nodes.
88
+ - Better scalability for large route maps.
89
+ - Falls back to rule test checks in optional-edge cases.
90
+
91
+ ## Configuration Model
92
+
93
+ Configuration is schema-driven and normalized on startup.
94
+
95
+ - Host, port, SSL
96
+ - Routing algorithm selection
97
+ - Templates for folder and error pages
98
+ - Logging controls per channel
99
+
100
+ This gives stable defaults while preserving explicit overrides.
101
+
102
+ ## Static Files And Templates
103
+
104
+ - `sendFile` supports byte-range requests for media and binary responses.
105
+ - `sendFolder` resolves paths inside a secured base directory.
106
+ - `sendTemplate` uses Vortez template compilation with variable and block expansion.
107
+
108
+ ## Build And Test Pipeline
109
+
110
+ ```mermaid
111
+ flowchart LR
112
+ A[npm run compile] --> B[scripts/compile.sh]
113
+ B --> C[tsc build to build/]
114
+ D[npm test] --> E[scripts/test.sh]
115
+ E --> F[tsc source]
116
+ F --> G[tsc tests]
117
+ G --> H[node build-tests/test.js]
118
+ ```
119
+
120
+ ## Operational Checklist For Production
121
+
122
+ - Use HTTPS with valid key/certificate and explicit TLS termination strategy.
123
+ - Configure reverse proxy headers if deploying behind load balancers.
124
+ - Register global middleware before route registration.
125
+ - Choose `Tree` algorithm for large route sets.
126
+ - Define custom error and folder templates for consistent UX.
127
+ - Enable structured log persistence and shipping to your observability stack.
128
+ - Add health/readiness endpoints and graceful shutdown handling.
129
+ - Run CI for compile + tests on every change.
130
+
131
+ ## Recommended Documentation Map
132
+
133
+ To match industry-grade developer experience, keep docs split by user intent:
134
+
135
+ - Getting Started: first server in 5 minutes.
136
+ - Core Concepts: routing, middleware, request/response.
137
+ - Production Guide: deployment, scaling, reliability.
138
+ - Security Guide: SSL, headers, path safety, secrets.
139
+ - API Reference: exported classes and methods.
140
+ - Examples: REST API, static site, SPA/PWA, WebSocket chat.
141
+
142
+ This architecture guide is the canonical high-level reference for that set.
@@ -0,0 +1,29 @@
1
+ #error {
2
+ --color-bg: rgb(255,180,220);
3
+ --color-code: rgb(255,0,0);
4
+ --color-message: rgb(0,0,0);
5
+ --color-bg-image: rgba(255,0,0,0.1);
6
+
7
+ background: var(--color-bg);
8
+ height: 100%;
9
+ position: fixed;
10
+ width: 100%;
11
+ overflow: visible;
12
+ & > .content {
13
+ text-align: center;
14
+ width: 90%;
15
+ overflow: visible;
16
+ }
17
+ & > .code {
18
+ color: var(--color-code);
19
+ font-size: 3em;
20
+ }
21
+ & > .message {
22
+ color: var(--color-message);
23
+ font-size: 1em;
24
+ margin-bottom: 1em;
25
+ }
26
+ & > .loading {
27
+ width: 30%;
28
+ }
29
+ }
@@ -0,0 +1,79 @@
1
+ #folder {
2
+ --color-bg: rgb(255,180,220);
3
+ --color-bg-content: rgba(255,0,0,0.1);
4
+ --color-bg-back: rgba(180,220,255,0.5);
5
+ --color-bg-back-action: rgba(180,220,255,0.75);
6
+ --color-bg-search: rgba(255,180,220,0.5);
7
+ --color-bg-search-action: rgba(255,180,220,0.75);
8
+ --color-bg-item: rgba(220,255,180,0.25);
9
+ --color-bg-item-action: rgba(220,255,180,0.5);
10
+ --color-border-search-action: rgb(180,220,255);
11
+
12
+ align-items: center;
13
+ background: var(--color-bg);
14
+ height: 100%;
15
+ overflow: visible scroll;
16
+ position: fixed;
17
+ width: 100%;
18
+
19
+ & > .content {
20
+ background: var(--color-bg-content);
21
+ border-radius: 2em;
22
+ margin-top: 2em;
23
+ padding: 2em;
24
+ text-align: center;
25
+ width: 70%;
26
+
27
+ & > .options {
28
+ display: flex;
29
+ text-align: start;
30
+
31
+ & > #input-path:focus {
32
+ border: var(--color-border-search-action) 3px double;
33
+ margin: calc(0.5em - 3px);
34
+ outline: none;
35
+ }
36
+ & > #input-path:focus,
37
+ & > #input-change:hover {
38
+ background: var(--color-bg-search-action);
39
+ }
40
+ & > #input-change {
41
+ cursor: pointer;
42
+ }
43
+ & > .back,
44
+ & > #input-path,
45
+ & > #input-change {
46
+ background: var(--color-bg-back);
47
+ border-radius: 1em;
48
+ color: rgb(0,0,0);
49
+ display: inline-block;
50
+ margin: 0.5em;
51
+ padding: 1em;
52
+ text-decoration: none;
53
+ }
54
+ & > #input-path,
55
+ & > #input-change {
56
+ background: var(--color-bg-search);
57
+ border: none;
58
+ }
59
+ & > .back:hover {
60
+ background: var(--color-bg-back-action);
61
+ }
62
+ }
63
+ & > .list {
64
+ list-style: none;
65
+ & .item {
66
+ background: var(--color-bg-item);
67
+ border-radius: 1em;
68
+ color: rgb(0,0,0);
69
+ display: block;
70
+ margin: 0.25em;
71
+ padding: 1em;
72
+ text-decoration: none;
73
+ &:hover {
74
+ background: var(--color-bg-item-action);
75
+ }
76
+ }
77
+ }
78
+ }
79
+ }
@@ -1,11 +1,11 @@
1
- @import './Folder.css';
2
- @import './Error.css';
1
+ @import './folder.css';
2
+ @import './error.css';
3
3
 
4
4
  * {
5
5
  padding: 0px;
6
6
  margin: 0px;
7
7
  }
8
- .Centrar-X {
8
+ .center-X {
9
9
  align-items: center;
10
10
  display: flex;
11
11
  flex-direction: column;
@@ -14,7 +14,7 @@
14
14
  height: 100%;
15
15
  overflow: visible;
16
16
  }
17
- .Centrar-Y {
17
+ .center-Y {
18
18
  /* align-items: center; */
19
19
  display: flex;
20
20
  flex-direction: column;
@@ -23,7 +23,7 @@
23
23
  height: 100%;
24
24
  overflow: visible;
25
25
  }
26
- .Carga {
26
+ .loading {
27
27
  align-items: center;
28
28
  animation: Entrada 0.2s linear 0s 1, Fluctuar 4s linear 1s infinite;
29
29
  background: var(--Color_Fondo);
@@ -36,70 +36,62 @@
36
36
  position: relative;
37
37
  width: 40%;
38
38
  z-index: 0;
39
- }
40
- .Carga .C_Fondo,
41
- .Carga .C_Fondo2 {
42
- align-items: center;
43
- background: var(--Color_Fondo, rgb(0,0,0));
44
- border-radius: 50%;
45
- box-sizing: content-box;
46
- display: flex;
47
- height: 96%;
48
- justify-content: center;
49
- overflow: hidden;
50
- position: absolute;
51
- width: 96%;
52
- }
53
- .Carga .C_Fondo2 {
54
- height: 92%;
55
- width: 92%;
56
- }
57
- .Carga .C_Logo {
58
- /*background: var(--Color_Fondo) url('/Src/Recursos/Íconos/NetFeez-Labs/[Ícono] - SM - 960.png');
59
- background-attachment: local;
60
- background-position:center top;
61
- background-repeat: no-repeat;
62
- background-size: cover;
63
- border-radius: 50%;
64
- height: 0px;
65
- padding-bottom: 100%;*/
66
- animation: FluctuarImg 4s linear 0s infinite;
67
- border-radius: 50%;
68
- width: 100%;
69
- height: 100%;
70
- }
71
- .Carga .C_Fondo::before,
72
- .Carga .C_Fondo::after,
73
- .Carga::before,
74
- .Carga::after {
75
- animation: Girar 5s linear 0s infinite;
76
- background: linear-gradient(90deg, rgb(100,100,0), rgb(0,100,180));
77
- content: '';
78
- height: 25%;
79
- position: absolute;
80
- width: 125%;
81
- z-index: -1;
82
- }
83
- .Carga .C_Fondo::after,
84
- .Carga::after {
85
- animation-direction: reverse;
86
- animation-duration: 3s;
87
- background: linear-gradient(0deg, rgb(255,0,255), rgb(0,255,0));
88
- height: 125%;
89
- width: 25%;
90
- }
91
- .Carga .C_Fondo::before,
92
- .Carga .C_Fondo::after {
93
- background: linear-gradient(90deg, rgb(0,0,255), rgb(255,255,0));
94
- animation-duration: 4s;
95
- z-index: 0;
96
- }
97
- .Carga .C_Fondo::after {
98
- background: linear-gradient(0deg, rgb(255,0,0), rgb(0,255,255));
99
- animation-duration: 2s;
100
- z-index: 0;
101
- }
102
39
 
40
+ & > .background-1,
41
+ & > .background-2 {
42
+ align-items: center;
43
+ background: var(--Color_Fondo, rgb(0,0,0));
44
+ border-radius: 50%;
45
+ box-sizing: content-box;
46
+ display: flex;
47
+ height: 96%;
48
+ justify-content: center;
49
+ overflow: hidden;
50
+ position: absolute;
51
+ width: 96%;
52
+ }
53
+ & > .background-2 {
54
+ height: 92%;
55
+ width: 92%;
56
+ }
57
+ & > .logo {
58
+ animation: FluctuarImg 4s linear 0s infinite;
59
+ border-radius: 50%;
60
+ width: 100%;
61
+ height: 100%;
62
+ }
63
+ & > .background-1::before,
64
+ & > .background-1::after,
65
+ &::before,
66
+ &::after {
67
+ animation: Girar 5s linear 0s infinite;
68
+ background: linear-gradient(90deg, rgb(100,100,0), rgb(0,100,180));
69
+ content: '';
70
+ height: 25%;
71
+ position: absolute;
72
+ width: 125%;
73
+ z-index: -1;
74
+ }
75
+ & > .background-1::after,
76
+ &::after {
77
+ animation-direction: reverse;
78
+ animation-duration: 3s;
79
+ background: linear-gradient(0deg, rgb(255,0,255), rgb(0,255,0));
80
+ height: 125%;
81
+ width: 25%;
82
+ }
83
+ & > .background-1::before,
84
+ & > .background-1::after {
85
+ background: linear-gradient(90deg, rgb(0,0,255), rgb(255,255,0));
86
+ animation-duration: 4s;
87
+ z-index: 0;
88
+ }
89
+ & > .background-1::after {
90
+ background: linear-gradient(0deg, rgb(255,0,0), rgb(0,255,255));
91
+ animation-duration: 2s;
92
+ z-index: 0;
93
+ }
94
+ }
103
95
  @keyframes Entrada {
104
96
  0% {opacity: 0;}
105
97
  100% {opacity: 1;}
@@ -0,0 +1,29 @@
1
+ <!DOCTYPE html>
2
+ <html lang="es">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
+ <link rel="stylesheet" href="/vortez:global/style/template/template.css">
8
+ <title>[Vortez] - {{status}}</title>
9
+ </head>
10
+ <body>
11
+ <div id="error" class="center-X center-Y">
12
+ <div class="content">
13
+ <h1 class="code">Status: {{status}}</h1>
14
+ <p class="message">{{message}}</p>
15
+ <div class="center-X center-Y">
16
+ <div class="loading">
17
+ <div class="background-1"></div>
18
+ <div class="background-2"></div>
19
+ <picture>
20
+ <source srcset="/vortez:global/source/logo_SM_960.png"/>
21
+ <source srcset="/favicon.ico"/>
22
+ <img class="logo">
23
+ </picture>
24
+ </div>
25
+ </div>
26
+ </div>
27
+ </div>
28
+ </body>
29
+ </html>
@@ -0,0 +1,54 @@
1
+ <!DOCTYPE html>
2
+ <html lang="es">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
+ <link rel="stylesheet" href="/vortez:global/style/template/template.css">
8
+ <title>[Vortez] - Folder</title>
9
+ </head>
10
+ <body>
11
+ <div id="folder" class="center-X">
12
+ <div class="content">
13
+ <h1 class="path">Folder: {{Url}}</h1>
14
+ <div class="options">
15
+ <vortez-if name="Url" condition="!=" expected="/">
16
+ <a class="back" href="{{Url}}/../">Back</a>
17
+ <vortez-else />
18
+ <span class="back disabled">Back</span>
19
+ </vortez-if>
20
+ <input id="input-path" type="search" placeholder="enter the path... {{Url}}" value="{{Url}}"/>
21
+ <input id="input-change"type="button" value="change"/>
22
+ </div>
23
+ <ul class="list">
24
+ <vortez-each name="folder" value="name">
25
+ <li>
26
+ <vortez-if name="Url" condition="==" expected="/">
27
+ <a class="item" href="./{{name}}">
28
+ <vortez-if name="name" condition="==" expected="style">
29
+ <span class="folder">[Folder]</span>
30
+ </vortez-if>
31
+ {{name}}
32
+ </a>
33
+ <vortez-else />
34
+ <a class="item" href="{{Url}}/{{name}}">{{name}}</a>
35
+ </vortez-if>
36
+ </li>
37
+ </vortez-each>
38
+ </ul>
39
+ </div>
40
+ <script>
41
+ const inputChange = document.querySelector('#input-change');
42
+ const inputPath = document.querySelector('#input-path');
43
+ inputChange.addEventListener('click', () => {
44
+ window.location.href = inputPath.value;
45
+ });
46
+ inputPath.addEventListener('keydown', (event) => {
47
+ inputPath.value.length <= '{{Url}}'.length && event.key == 'Backspace'
48
+ ? event.preventDefault()
49
+ : false;
50
+ })
51
+ </script>
52
+ </div>
53
+ </body>
54
+ </html>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vortez",
3
- "version": "5.0.0-dev.19",
3
+ "version": "5.0.0",
4
4
  "description": "a module for web server creation",
5
5
  "type": "module",
6
6
  "main": "build/Vortez.js",
@@ -25,7 +25,7 @@
25
25
  "build/",
26
26
  "examples/",
27
27
  "global/",
28
- "tests/",
28
+ "docs/",
29
29
  ".gitignore",
30
30
  "changes.md",
31
31
  "LICENSE",
@@ -1,46 +0,0 @@
1
- /**
2
- * @author NetFeez <netfeez.dev@gmail.com>
3
- * @description Add the HNetFeez-Labs template engine to the Vortez.
4
- * @license Apache-2.0
5
- */
6
- export declare class Template {
7
- /** Regular expressions used for parsing and processing the template. */
8
- private static expressions;
9
- /**
10
- * Load and compile a template.
11
- * This method reads a template file from the specified path,
12
- * checks if it's a valid file, and then compiles its content
13
- * using the provided data object.
14
- *
15
- * @example `Template.load('./templates/myTemplate.html', { username: 'John Doe' });`
16
- * @param path - The path to the template file.
17
- * @param data - The data used to compile the template.
18
- * @returns The compiled template.
19
- * @throws Error if the path is not a file.
20
- * @throws Error if the file does not exist.
21
- */
22
- static load(path: string, data: Template.dataObject): Promise<string>;
23
- /**
24
- * Compile a template.
25
- * This internal method takes the raw template content and the data object
26
- * and performs the actual compilation, replacing variables and processing
27
- * object/array blocks according to the defined syntax.
28
- *
29
- * @example `Template.compile('Hello, ${name}!', { name: 'Alice' });`
30
- * @param content - The content of the template.
31
- * @param data - The data used to compile the template.
32
- * @returns The compiled template.
33
- * @throws Error if key and value names are equal in object blocks.
34
- */
35
- private static compile;
36
- }
37
- export declare namespace Template {
38
- /**
39
- * Represents the structure of the data object used for template compilation.
40
- * It is a key-value store where keys are strings and values can be of any type.
41
- */
42
- interface dataObject {
43
- [key: string]: any;
44
- }
45
- }
46
- export default Template;
package/build/Template.js DELETED
@@ -1,81 +0,0 @@
1
- /**
2
- * @author NetFeez <netfeez.dev@gmail.com>
3
- * @description Add the HNetFeez-Labs template engine to the Vortez.
4
- * @license Apache-2.0
5
- */
6
- import FS from 'fs';
7
- import Utilities from './utilities/Utilities.js';
8
- export class Template {
9
- /** Regular expressions used for parsing and processing the template. */
10
- static expressions = {
11
- /** Regular expression for matching variables (e.g., `${variableName}`). */
12
- variable: /\$\{(.+?)\}/ig,
13
- object: {
14
- /** Regular expression for matching object/array blocks (e.g., `$(objectName) { ... }`). */
15
- block: /\$ ?\((.+)\) ?\{([^]+?)\}/g,
16
- /** Regular expression for matching placeholders within object/array blocks (e.g., `%key%`, `%value%`). */
17
- replaces: /\%(.+?)%/g
18
- }
19
- };
20
- /**
21
- * Load and compile a template.
22
- * This method reads a template file from the specified path,
23
- * checks if it's a valid file, and then compiles its content
24
- * using the provided data object.
25
- *
26
- * @example `Template.load('./templates/myTemplate.html', { username: 'John Doe' });`
27
- * @param path - The path to the template file.
28
- * @param data - The data used to compile the template.
29
- * @returns The compiled template.
30
- * @throws Error if the path is not a file.
31
- * @throws Error if the file does not exist.
32
- */
33
- static async load(path, data) {
34
- path = Utilities.Path.normalize(path);
35
- const details = await FS.promises.stat(path);
36
- if (!details.isFile())
37
- throw new Error('the path is not a template file');
38
- const template = await FS.promises.readFile(path);
39
- return this.compile(template.toString('utf-8'), data);
40
- }
41
- /**
42
- * Compile a template.
43
- * This internal method takes the raw template content and the data object
44
- * and performs the actual compilation, replacing variables and processing
45
- * object/array blocks according to the defined syntax.
46
- *
47
- * @example `Template.compile('Hello, ${name}!', { name: 'Alice' });`
48
- * @param content - The content of the template.
49
- * @param data - The data used to compile the template.
50
- * @returns The compiled template.
51
- * @throws Error if key and value names are equal in object blocks.
52
- */
53
- static compile(content, data) {
54
- content = content.replace(this.expressions.variable, (text, name) => {
55
- return name && name in data ? data[name] : text;
56
- });
57
- content = content.replace(this.expressions.object.block, (block, sentence, loop) => {
58
- const [name, keyName = 'key', valueName = 'value'] = sentence.split(/, ?/gi);
59
- if (keyName === valueName)
60
- throw new Error('the key and value names must be different in block: ' + block);
61
- return name && name in data && data[name] instanceof Object ? Object.keys(data[name]).map((key) => {
62
- return loop.replace(this.expressions.object.replaces, (SubText, varName) => {
63
- if (keyName == varName)
64
- return key;
65
- else if (valueName == varName)
66
- return data[name][key];
67
- });
68
- }).join('') : block;
69
- });
70
- return content;
71
- }
72
- }
73
- export default Template;
74
- /*
75
- Variables: ${name}
76
- Objects/Arrays: $(name) { the key is %key% and value %value% }
77
- Objects/Arrays: $(name, customKeyName, customValueName) {
78
- the key is %customKeyName% and value %customValueName%
79
- }
80
- */
81
- //# sourceMappingURL=Template.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Template.js","sourceRoot":"","sources":["../src/Template.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,SAAS,MAAM,0BAA0B,CAAC;AAEjD,MAAM,OAAO,QAAQ;IACpB,wEAAwE;IAChE,MAAM,CAAC,WAAW,GAAG;QAC5B,2EAA2E;QAC3E,QAAQ,EAAE,eAAe;QACzB,MAAM,EAAE;YACP,2FAA2F;YAC3F,KAAK,EAAE,4BAA4B;YACnC,0GAA0G;YAC1G,QAAQ,EAAE,WAAW;SACrB;KACD,CAAC;IACF;;;;;;;;;;;;OAYG;IACI,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,IAAY,EAAE,IAAyB;QAC/D,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QACtC,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7C,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;YAAE,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;QAC1E,MAAM,QAAQ,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAClD,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,CAAC;IACvD,CAAC;IAED;;;;;;;;;;;OAWG;IACK,MAAM,CAAC,OAAO,CAAC,OAAe,EAAE,IAAyB;QAChE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE;YACnE,OAAO,IAAI,IAAI,IAAI,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QACjD,CAAC,CAAC,CAAC;QACH,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,KAAa,EAAE,QAAgB,EAAE,IAAY,EAAE,EAAE;YAC1G,MAAM,CAAC,IAAI,EAAE,OAAO,GAAG,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YAC7E,IAAI,OAAO,KAAK,SAAS;gBAAE,MAAM,IAAI,KAAK,CAAC,sDAAsD,GAAG,KAAK,CAAC,CAAC;YAC3G,OAAO,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,YAAY,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;gBACjG,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE;oBAC1E,IAAI,OAAO,IAAI,OAAO;wBAAE,OAAO,GAAG,CAAA;yBAC7B,IAAI,SAAS,IAAI,OAAO;wBAAE,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;gBACvD,CAAC,CAAC,CAAC;YACJ,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;QACrB,CAAC,CAAC,CAAC;QACH,OAAO,OAAO,CAAC;IAChB,CAAC;;AAaF,eAAe,QAAQ,CAAC;AACxB;;;;;;EAME"}
@@ -1,30 +0,0 @@
1
- #Error {
2
- --Color_Fondo: rgb(255,180,220);
3
- --Color_Código: rgb(255,0,0);
4
- --Color_Mensaje: rgb(0,0,0);
5
- --Color_Fondo_Imagen: rgba(255,0,0,0.1);
6
- }
7
- #Error {
8
- background: var(--Color_Fondo);
9
- height: 100%;
10
- position: fixed;
11
- width: 100%;
12
- overflow: visible;
13
- }
14
- #Error .Información {
15
- text-align: center;
16
- width: 90%;
17
- overflow: visible;
18
- }
19
- #Error .Código {
20
- color: var(--Color_Código);
21
- font-size: 3em;
22
- }
23
- #Error .Mensaje {
24
- color: var(--Color_Mensaje);
25
- font-size: 1em;
26
- margin-bottom: 1em;
27
- }
28
- #Error .Carga {
29
- width: 30%;
30
- }