hightjs 0.4.0 → 0.5.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 (125) hide show
  1. package/README.md +48 -116
  2. package/dist/bin/hightjs.js +51 -23
  3. package/dist/builder.js +139 -4
  4. package/dist/client/DefaultNotFound.d.ts +1 -1
  5. package/dist/client/DefaultNotFound.js +72 -46
  6. package/dist/client/client.d.ts +3 -0
  7. package/dist/{client.js → client/client.js} +4 -4
  8. package/dist/client/entry.client.js +39 -29
  9. package/dist/global/global.d.ts +117 -0
  10. package/dist/{auth/types.js → global/global.js} +0 -1
  11. package/dist/helpers.js +80 -2
  12. package/dist/hotReload.js +2 -2
  13. package/dist/index.js +16 -16
  14. package/dist/loaders.d.ts +1 -0
  15. package/dist/loaders.js +46 -0
  16. package/dist/renderer.js +158 -4
  17. package/dist/types.d.ts +44 -0
  18. package/package.json +36 -31
  19. package/.idea/HightJS.iml +0 -9
  20. package/.idea/copilot.data.migration.agent.xml +0 -6
  21. package/.idea/copilot.data.migration.ask.xml +0 -6
  22. package/.idea/copilot.data.migration.ask2agent.xml +0 -6
  23. package/.idea/copilot.data.migration.edit.xml +0 -6
  24. package/.idea/copilotDiffState.xml +0 -67
  25. package/.idea/inspectionProfiles/Project_Default.xml +0 -13
  26. package/.idea/libraries/test_package.xml +0 -9
  27. package/.idea/libraries/ts_commonjs_default_export.xml +0 -9
  28. package/.idea/misc.xml +0 -7
  29. package/.idea/modules.xml +0 -8
  30. package/.idea/vcs.xml +0 -6
  31. package/dist/auth/client.d.ts +0 -24
  32. package/dist/auth/client.js +0 -146
  33. package/dist/auth/components.d.ts +0 -29
  34. package/dist/auth/components.js +0 -100
  35. package/dist/auth/core.d.ts +0 -55
  36. package/dist/auth/core.js +0 -189
  37. package/dist/auth/index.d.ts +0 -7
  38. package/dist/auth/index.js +0 -45
  39. package/dist/auth/jwt.d.ts +0 -41
  40. package/dist/auth/jwt.js +0 -185
  41. package/dist/auth/providers/credentials.d.ts +0 -60
  42. package/dist/auth/providers/credentials.js +0 -97
  43. package/dist/auth/providers/discord.d.ts +0 -63
  44. package/dist/auth/providers/discord.js +0 -190
  45. package/dist/auth/providers/google.d.ts +0 -63
  46. package/dist/auth/providers/google.js +0 -186
  47. package/dist/auth/providers/index.d.ts +0 -2
  48. package/dist/auth/providers/index.js +0 -35
  49. package/dist/auth/providers.d.ts +0 -3
  50. package/dist/auth/providers.js +0 -26
  51. package/dist/auth/react/index.d.ts +0 -6
  52. package/dist/auth/react/index.js +0 -48
  53. package/dist/auth/react.d.ts +0 -22
  54. package/dist/auth/react.js +0 -199
  55. package/dist/auth/routes.d.ts +0 -16
  56. package/dist/auth/routes.js +0 -152
  57. package/dist/auth/types.d.ts +0 -76
  58. package/dist/client.d.ts +0 -3
  59. package/docs/README.md +0 -58
  60. package/docs/arquivos-especiais.md +0 -10
  61. package/docs/autenticacao.md +0 -212
  62. package/docs/checklist.md +0 -9
  63. package/docs/cli.md +0 -72
  64. package/docs/config.md +0 -216
  65. package/docs/estrutura.md +0 -20
  66. package/docs/faq.md +0 -10
  67. package/docs/hot-reload.md +0 -5
  68. package/docs/integracoes.md +0 -240
  69. package/docs/middlewares.md +0 -73
  70. package/docs/rotas-backend.md +0 -45
  71. package/docs/rotas-frontend.md +0 -66
  72. package/docs/seguranca.md +0 -8
  73. package/docs/websocket.md +0 -45
  74. package/example/certs/cert.pem +0 -20
  75. package/example/certs/key.pem +0 -27
  76. package/example/hightjs.config.ts +0 -87
  77. package/example/package-lock.json +0 -1174
  78. package/example/package.json +0 -26
  79. package/example/postcss.config.js +0 -8
  80. package/example/src/backend/auth.ts +0 -42
  81. package/example/src/backend/routes/auth.ts +0 -3
  82. package/example/src/backend/routes/version.ts +0 -13
  83. package/example/src/web/components/Home.tsx +0 -140
  84. package/example/src/web/components/LoginPage.tsx +0 -149
  85. package/example/src/web/globals.css +0 -5
  86. package/example/src/web/layout.tsx +0 -100
  87. package/example/src/web/routes/index.tsx +0 -13
  88. package/example/src/web/routes/login.tsx +0 -30
  89. package/example/tailwind.config.js +0 -12
  90. package/example/tsconfig.json +0 -15
  91. package/src/adapters/express.ts +0 -87
  92. package/src/adapters/factory.ts +0 -112
  93. package/src/adapters/fastify.ts +0 -104
  94. package/src/adapters/native.ts +0 -234
  95. package/src/api/console.ts +0 -305
  96. package/src/api/http.ts +0 -535
  97. package/src/auth/client.ts +0 -171
  98. package/src/auth/components.tsx +0 -125
  99. package/src/auth/core.ts +0 -215
  100. package/src/auth/index.ts +0 -25
  101. package/src/auth/jwt.ts +0 -210
  102. package/src/auth/providers/credentials.ts +0 -139
  103. package/src/auth/providers/discord.ts +0 -239
  104. package/src/auth/providers/google.ts +0 -234
  105. package/src/auth/providers/index.ts +0 -20
  106. package/src/auth/providers.ts +0 -20
  107. package/src/auth/react/index.ts +0 -25
  108. package/src/auth/react.tsx +0 -234
  109. package/src/auth/routes.ts +0 -183
  110. package/src/auth/types.ts +0 -108
  111. package/src/bin/hightjs.js +0 -222
  112. package/src/builder.js +0 -472
  113. package/src/client/DefaultNotFound.tsx +0 -84
  114. package/src/client/clientRouter.ts +0 -153
  115. package/src/client/entry.client.tsx +0 -511
  116. package/src/client.ts +0 -24
  117. package/src/components/Link.tsx +0 -38
  118. package/src/helpers.ts +0 -542
  119. package/src/hotReload.ts +0 -569
  120. package/src/index.ts +0 -555
  121. package/src/renderer.tsx +0 -263
  122. package/src/router.ts +0 -730
  123. package/src/types/framework.ts +0 -58
  124. package/src/types.ts +0 -207
  125. package/tsconfig.json +0 -17
@@ -1,58 +0,0 @@
1
- /*
2
- * This file is part of the HightJS Project.
3
- * Copyright (c) 2025 itsmuzin
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
- // Tipos genéricos para abstrair diferentes frameworks web
18
- export interface GenericRequest {
19
- method: string;
20
- url: string;
21
- headers: Record<string, string | string[]>;
22
- body?: any;
23
- query?: Record<string, any>;
24
- params?: Record<string, string>;
25
- cookies?: Record<string, string>;
26
- raw?: any; // Requisição original do framework
27
- }
28
-
29
- export interface GenericResponse {
30
- status(code: number): GenericResponse;
31
- header(name: string, value: string): GenericResponse;
32
- cookie(name: string, value: string, options?: CookieOptions): GenericResponse;
33
- clearCookie(name: string, options?: CookieOptions): GenericResponse;
34
- json(data: any): void;
35
- text(data: string): void;
36
- send(data: any): void;
37
- redirect(url: string): void;
38
- raw?: any; // Resposta original do framework
39
- }
40
-
41
- export interface CookieOptions {
42
- domain?: string;
43
- expires?: Date;
44
- httpOnly?: boolean;
45
- maxAge?: number;
46
- path?: string;
47
- secure?: boolean;
48
- signed?: boolean;
49
- sameSite?: boolean | 'lax' | 'strict' | 'none';
50
- }
51
-
52
- export type FrameworkType = 'express' | 'fastify' | 'native';
53
-
54
- export interface FrameworkAdapter {
55
- type: FrameworkType;
56
- parseRequest(req: any): GenericRequest;
57
- createResponse(res: any): GenericResponse;
58
- }
package/src/types.ts DELETED
@@ -1,207 +0,0 @@
1
- /*
2
- * This file is part of the HightJS Project.
3
- * Copyright (c) 2025 itsmuzin
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
- import type { ComponentType } from 'react';
18
- import type { GenericRequest } from './types/framework';
19
- import {HightJSRequest, HightJSResponse} from "./api/http";
20
- import { WebSocket } from 'ws';
21
- import { IncomingMessage } from 'http';
22
-
23
- // Interface do contexto WebSocket simplificada
24
- export interface WebSocketContext {
25
- ws: WebSocket;
26
- req: IncomingMessage;
27
- hightReq: HightJSRequest;
28
- url: URL;
29
- params: Record<string, string>;
30
- query: Record<string, string>;
31
- send: (data: any) => void;
32
- close: (code?: number, reason?: string) => void;
33
- broadcast: (data: any, exclude?: WebSocket[]) => void;
34
- }
35
-
36
- // --- Tipos do Frontend (sem alteração) ---
37
- export interface HightJSOptions {
38
- dev?: boolean;
39
- hostname?: string;
40
- port?: number;
41
- dir?: string;
42
- framework?: 'express' | 'fastify' | 'native';
43
- ssl?: {
44
- redirectPort: number;
45
- key: string;
46
- cert: string;
47
- ca?: string;
48
- };
49
- }
50
-
51
- // --- Tipos de Configuração ---
52
-
53
- /**
54
- * Interface para as configurações avançadas do servidor HightJS.
55
- * Essas configurações podem ser definidas no arquivo hightjs.config.js
56
- */
57
- export interface HightConfig {
58
- /**
59
- * Limita o número máximo de headers HTTP permitidos por requisição.
60
- * Padrão: 100
61
- */
62
- maxHeadersCount?: number;
63
-
64
- /**
65
- * Timeout em milissegundos para receber os headers HTTP.
66
- * Padrão: 60000 (60 segundos)
67
- */
68
- headersTimeout?: number;
69
-
70
- /**
71
- * Timeout em milissegundos para uma requisição completa.
72
- * Padrão: 30000 (30 segundos)
73
- */
74
- requestTimeout?: number;
75
-
76
- /**
77
- * Timeout geral do servidor em milissegundos.
78
- * Padrão: 35000 (35 segundos)
79
- */
80
- serverTimeout?: number;
81
-
82
- /**
83
- * Timeout por requisição individual em milissegundos.
84
- * Padrão: 30000 (30 segundos)
85
- */
86
- individualRequestTimeout?: number;
87
-
88
- /**
89
- * Tamanho máximo permitido para a URL em caracteres.
90
- * Padrão: 2048
91
- */
92
- maxUrlLength?: number;
93
-
94
- /**
95
- * Habilita o log de acesso HTTP (ex: GET /api/users 200 15ms).
96
- * Padrão: false
97
- */
98
- accessLogging?: boolean;
99
- }
100
-
101
- /**
102
- * Tipo da função de configuração que pode ser exportada no hightjs.config.js
103
- */
104
- export type HightConfigFunction = (
105
- phase: string,
106
- context: { defaultConfig: HightConfig }
107
- ) => HightConfig | Promise<HightConfig>;
108
-
109
- export interface Metadata {
110
- // Basic metadata
111
- title?: string;
112
- description?: string;
113
- keywords?: string | string[];
114
- author?: string;
115
- favicon?: string;
116
-
117
- // Viewport and mobile
118
- viewport?: string;
119
- themeColor?: string;
120
-
121
- // SEO
122
- canonical?: string;
123
- robots?: string;
124
-
125
- // Open Graph (Facebook, LinkedIn, etc.)
126
- openGraph?: {
127
- title?: string;
128
- description?: string;
129
- type?: string;
130
- url?: string;
131
- image?: string | {
132
- url: string;
133
- width?: number;
134
- height?: number;
135
- alt?: string;
136
- };
137
- siteName?: string;
138
- locale?: string;
139
- };
140
-
141
- // Twitter Card
142
- twitter?: {
143
- card?: 'summary' | 'summary_large_image' | 'app' | 'player';
144
- site?: string;
145
- creator?: string;
146
- title?: string;
147
- description?: string;
148
- image?: string;
149
- imageAlt?: string;
150
- };
151
-
152
- // Additional metadata
153
- language?: string;
154
- charset?: string;
155
- appleTouchIcon?: string;
156
- manifest?: string;
157
-
158
- // Custom meta tags
159
- other?: Record<string, string>;
160
- }
161
-
162
-
163
- export interface RouteConfig {
164
- pattern: string;
165
- component: ComponentType<any>;
166
- generateMetadata?: (params: any, req: GenericRequest) => Promise<Metadata> | Metadata;
167
- }
168
- export type RequestHandler = (req: any, res: any) => Promise<void>;
169
-
170
- // --- NOVO: Tipos do Backend ---
171
-
172
- /**
173
- * Define o formato de uma função que manipula uma rota da API.
174
- */
175
- export type BackendHandler = (
176
- request: HightJSRequest, // HWebRequest será importado onde necessário
177
- params: { [key: string]: string }
178
- ) => Promise<HightJSResponse> | HightJSResponse; // HWebResponse será importado onde necessário
179
-
180
-
181
-
182
- export type HightMiddleware = (
183
- request: HightJSRequest, // HWebRequest será importado onde necessário
184
- params: { [key: string]: string },
185
- next: () => Promise<HightJSResponse>
186
- ) => Promise<HightJSResponse> | HightJSResponse; // HWebResponse será importado onde necessário
187
-
188
-
189
- /**
190
- * Define o formato de uma função que manipula uma rota WebSocket.
191
- */
192
- export type WebSocketHandler = (
193
- context: WebSocketContext
194
- ) => Promise<void> | void;
195
-
196
- /**
197
- * Define a estrutura de cada rota da API, com suporte para métodos HTTP e WebSocket.
198
- */
199
- export interface BackendRouteConfig {
200
- pattern: string;
201
- GET?: BackendHandler;
202
- POST?: BackendHandler;
203
- PUT?: BackendHandler;
204
- DELETE?: BackendHandler;
205
- WS?: WebSocketHandler; // Suporte para WebSocket
206
- middleware?: HightMiddleware[]; // Permite adicionar middlewares específicos à rota
207
- }
package/tsconfig.json DELETED
@@ -1,17 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2020",
4
- "module": "CommonJS",
5
- "rootDir": "./src",
6
- "outDir": "./dist",
7
- "declaration": true,
8
- "strict": true,
9
- "esModuleInterop": true,
10
- "skipLibCheck": true,
11
- "jsx": "react-jsx",
12
- "moduleResolution": "node",
13
- "allowJs": true,
14
- },
15
- "include": ["src"],
16
- "exclude": ["node_modules"]
17
- }