baraqex 1.0.74 → 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 (185) hide show
  1. package/CHANGELOG.md +73 -0
  2. package/README.md +272 -472
  3. package/bin/baraqex.js +150 -12
  4. package/dist/browser.d.ts +1 -1
  5. package/dist/browser.d.ts.map +1 -1
  6. package/dist/browser.js +2319 -205
  7. package/dist/browser.js.map +4 -4
  8. package/dist/core/batch.d.ts +10 -0
  9. package/dist/core/batch.d.ts.map +1 -0
  10. package/dist/core/component.d.ts +69 -0
  11. package/dist/core/component.d.ts.map +1 -0
  12. package/dist/core/context.d.ts +22 -0
  13. package/dist/core/context.d.ts.map +1 -0
  14. package/dist/core/errors.d.ts +125 -0
  15. package/dist/core/errors.d.ts.map +1 -0
  16. package/dist/core/event-bus.d.ts +29 -0
  17. package/dist/core/event-bus.d.ts.map +1 -0
  18. package/dist/core/forms.d.ts +128 -0
  19. package/dist/core/forms.d.ts.map +1 -0
  20. package/dist/core/hooks.d.ts +84 -0
  21. package/dist/core/hooks.d.ts.map +1 -0
  22. package/dist/core/index.d.ts +23 -0
  23. package/dist/core/index.d.ts.map +1 -0
  24. package/dist/core/jsx-runtime.d.ts +45 -0
  25. package/dist/core/jsx-runtime.d.ts.map +1 -0
  26. package/dist/core/lifecycle-events.d.ts +71 -0
  27. package/dist/core/lifecycle-events.d.ts.map +1 -0
  28. package/dist/core/renderer.d.ts +39 -0
  29. package/dist/core/renderer.d.ts.map +1 -0
  30. package/dist/core/router.d.ts +108 -0
  31. package/dist/core/router.d.ts.map +1 -0
  32. package/dist/core/server-renderer.d.ts +26 -0
  33. package/dist/core/server-renderer.d.ts.map +1 -0
  34. package/dist/core/store.d.ts +102 -0
  35. package/dist/core/store.d.ts.map +1 -0
  36. package/dist/core/types.d.ts +66 -0
  37. package/dist/core/types.d.ts.map +1 -0
  38. package/dist/core/utils.d.ts +153 -0
  39. package/dist/core/utils.d.ts.map +1 -0
  40. package/dist/core/vdom.d.ts +29 -0
  41. package/dist/core/vdom.d.ts.map +1 -0
  42. package/dist/index.d.ts +39 -35
  43. package/dist/index.d.ts.map +1 -1
  44. package/dist/index.js +2592 -508
  45. package/dist/index.js.map +4 -4
  46. package/dist/server/auth.d.ts +8 -3
  47. package/dist/server/auth.d.ts.map +1 -1
  48. package/dist/server/index.d.ts +2 -2
  49. package/dist/server/index.d.ts.map +1 -1
  50. package/dist/server/index.js +173 -112
  51. package/dist/server/index.js.map +4 -4
  52. package/dist/server/middleware.d.ts +10 -1
  53. package/dist/server/middleware.d.ts.map +1 -1
  54. package/package.json +224 -124
  55. package/templates/basic-app/src/main.jsx +336 -0
  56. package/templates/complete-app/api/hello.js +0 -0
  57. package/templates/complete-app/client.js +58 -0
  58. package/templates/complete-app/lib/frontend-hamroun.js +182 -0
  59. package/templates/complete-app/package.json +18 -0
  60. package/templates/complete-app/pages/about.js +119 -0
  61. package/templates/complete-app/pages/about.jsx +0 -0
  62. package/templates/complete-app/pages/index.js +157 -0
  63. package/templates/complete-app/pages/index.jsx +0 -0
  64. package/templates/complete-app/pages/wasm-demo.js +290 -0
  65. package/templates/complete-app/pages/wasm-demo.jsx +0 -0
  66. package/templates/complete-app/public/client.js +89 -0
  67. package/templates/complete-app/public/index.html +118 -0
  68. package/templates/complete-app/public/styles.css +76 -0
  69. package/templates/complete-app/readme.md +188 -0
  70. package/templates/complete-app/server.js +226 -0
  71. package/templates/complete-app/server.ts +275 -0
  72. package/templates/complete-app/src/App.tsx +59 -0
  73. package/templates/complete-app/src/client.ts +61 -0
  74. package/templates/complete-app/src/client.tsx +18 -0
  75. package/templates/complete-app/src/pages/index.tsx +51 -0
  76. package/templates/complete-app/src/server.ts +218 -0
  77. package/templates/complete-app/tsconfig.json +22 -0
  78. package/templates/complete-app/tsconfig.server.json +19 -0
  79. package/templates/complete-app/vite.config.js +57 -0
  80. package/templates/complete-app/vite.config.ts +30 -0
  81. package/templates/complete-app/wasm/build.bat +0 -0
  82. package/templates/complete-app/wasm/build.sh +0 -0
  83. package/templates/complete-app/wasm/example.go +0 -0
  84. package/templates/fullstack-app/README.md +37 -0
  85. package/templates/fullstack-app/api/hello.js +11 -0
  86. package/templates/fullstack-app/api/hello.ts +18 -0
  87. package/templates/fullstack-app/api/users/[id].ts +73 -0
  88. package/templates/fullstack-app/api/users/index.ts +32 -0
  89. package/templates/fullstack-app/build/main.css +874 -0
  90. package/templates/fullstack-app/build/main.css.map +7 -0
  91. package/templates/fullstack-app/build/main.js +967 -0
  92. package/templates/fullstack-app/build/main.js.map +7 -0
  93. package/templates/fullstack-app/build.ts +210 -0
  94. package/templates/fullstack-app/index.html +36 -0
  95. package/templates/fullstack-app/package.json +35 -0
  96. package/templates/fullstack-app/postcss.config.js +6 -0
  97. package/templates/fullstack-app/process-tailwind.js +45 -0
  98. package/templates/fullstack-app/public/_redirects +1 -0
  99. package/templates/fullstack-app/public/route-handler.js +47 -0
  100. package/templates/fullstack-app/public/spa-fix.html +17 -0
  101. package/templates/fullstack-app/public/styles.css +975 -0
  102. package/templates/fullstack-app/public/tailwind.css +15 -0
  103. package/templates/fullstack-app/server.js +267 -0
  104. package/templates/fullstack-app/server.ts +474 -0
  105. package/templates/fullstack-app/src/README.md +55 -0
  106. package/templates/fullstack-app/src/client.js +87 -0
  107. package/templates/fullstack-app/src/components/ClientHome.tsx +0 -0
  108. package/templates/fullstack-app/src/components/ErrorBoundary.tsx +36 -0
  109. package/templates/fullstack-app/src/components/Layout.tsx +42 -0
  110. package/templates/fullstack-app/src/components/StateDemo.tsx +207 -0
  111. package/templates/fullstack-app/src/components/UserList.tsx +44 -0
  112. package/templates/fullstack-app/src/config.ts +42 -0
  113. package/templates/fullstack-app/src/data/api.ts +206 -0
  114. package/templates/fullstack-app/src/main.tsx +155 -0
  115. package/templates/fullstack-app/src/middleware.ts +28 -0
  116. package/templates/fullstack-app/src/pages/404.tsx +28 -0
  117. package/templates/fullstack-app/src/pages/[id].tsx +0 -0
  118. package/templates/fullstack-app/src/pages/_app.tsx +11 -0
  119. package/templates/fullstack-app/src/pages/_document.tsx +25 -0
  120. package/templates/fullstack-app/src/pages/_error.tsx +45 -0
  121. package/templates/fullstack-app/src/pages/about/index.tsx +67 -0
  122. package/templates/fullstack-app/src/pages/about.tsx +71 -0
  123. package/templates/fullstack-app/src/pages/api/users/[id].ts +73 -0
  124. package/templates/fullstack-app/src/pages/api/users/index.ts +43 -0
  125. package/templates/fullstack-app/src/pages/index.tsx +110 -0
  126. package/templates/fullstack-app/src/pages/users/[id].tsx +153 -0
  127. package/templates/fullstack-app/src/pages/users.tsx +60 -0
  128. package/templates/fullstack-app/src/pages/wasm-demo.tsx +1 -0
  129. package/templates/fullstack-app/src/router.ts +255 -0
  130. package/templates/fullstack-app/src/styles.css +5 -0
  131. package/templates/fullstack-app/tailwind.config.js +11 -0
  132. package/templates/fullstack-app/tsconfig.json +18 -0
  133. package/templates/fullstack-app/vite.config.js +87 -0
  134. package/templates/go/build.bat +36 -0
  135. package/templates/go/build.sh +43 -0
  136. package/templates/go/example.go +205 -0
  137. package/templates/go-wasm-app/README.md +38 -0
  138. package/templates/go-wasm-app/babel.config.js +21 -0
  139. package/templates/go-wasm-app/build-client.js +49 -0
  140. package/templates/go-wasm-app/build-wasm.js +237 -0
  141. package/templates/go-wasm-app/build.config.js +62 -0
  142. package/templates/go-wasm-app/build.js +218 -0
  143. package/templates/go-wasm-app/package.json +32 -0
  144. package/templates/go-wasm-app/public/index.html +128 -0
  145. package/templates/go-wasm-app/public/styles.css +197 -0
  146. package/templates/go-wasm-app/public/wasm/example.wasm +0 -0
  147. package/templates/go-wasm-app/public/wasm/wasm_exec.js +561 -0
  148. package/templates/go-wasm-app/public/wasm/wasm_exec_node.js +39 -0
  149. package/templates/go-wasm-app/server.js +70 -0
  150. package/templates/go-wasm-app/src/App.jsx +38 -0
  151. package/templates/go-wasm-app/src/app.js +173 -0
  152. package/templates/go-wasm-app/src/client.js +57 -0
  153. package/templates/go-wasm-app/src/components/Footer.jsx +13 -0
  154. package/templates/go-wasm-app/src/components/Header.jsx +19 -0
  155. package/templates/go-wasm-app/src/components/WasmDemo.jsx +120 -0
  156. package/templates/go-wasm-app/src/main.jsx +12 -0
  157. package/templates/go-wasm-app/src/wasm/example.go +75 -0
  158. package/templates/go-wasm-app/tsconfig.server.json +18 -0
  159. package/templates/go-wasm-app/vite.config.js +45 -0
  160. package/templates/ssr-template/package.json +16 -10
  161. package/templates/wasm/package.json +43 -43
  162. package/templates/wasm/src/App.tsx +2 -2
  163. package/dist/forms/index.d.ts +0 -2
  164. package/dist/forms/index.d.ts.map +0 -1
  165. package/dist/forms/types.d.ts +0 -2
  166. package/dist/forms/types.d.ts.map +0 -1
  167. package/dist/frontend/components/WasmLoader.d.ts +0 -2
  168. package/dist/frontend/components/WasmLoader.d.ts.map +0 -1
  169. package/dist/frontend/hooks/useWasm.d.ts +0 -2
  170. package/dist/frontend/hooks/useWasm.d.ts.map +0 -1
  171. package/dist/frontend/index.d.ts +0 -2
  172. package/dist/frontend/index.d.ts.map +0 -1
  173. package/dist/router/index.d.ts +0 -2
  174. package/dist/router/index.d.ts.map +0 -1
  175. package/dist/router/types.d.ts +0 -2
  176. package/dist/router/types.d.ts.map +0 -1
  177. package/dist/store/index.d.ts +0 -2
  178. package/dist/store/index.d.ts.map +0 -1
  179. package/dist/store/types.d.ts +0 -2
  180. package/dist/store/types.d.ts.map +0 -1
  181. package/templates/basic-app/package-lock.json +0 -7173
  182. package/templates/fullstack-template/package-lock.json +0 -3558
  183. package/templates/ssr-template/package-lock.json +0 -5380
  184. package/templates/wasm/package-lock.json +0 -5347
  185. package/templates/wasm/public/example.wasm +0 -0
@@ -1,3 +1,6 @@
1
+ /**
2
+ * Authentication service — JWT tokens, password hashing, Express middleware
3
+ */
1
4
  export interface AuthConfig {
2
5
  secret: string;
3
6
  expiresIn?: string | number;
@@ -12,12 +15,14 @@ export interface User {
12
15
  }
13
16
  export declare class AuthService {
14
17
  private config;
18
+ private jwtPromise;
15
19
  constructor(config: AuthConfig);
20
+ private getJwt;
16
21
  hashPassword(password: string): Promise<string>;
17
22
  comparePasswords(password: string, hashedPassword: string): Promise<boolean>;
18
- generateToken(user: Omit<User, 'password'>): string;
19
- verifyToken(token: string): any;
20
- initialize(): (req: any, res: any, next: any) => void;
23
+ generateToken(user: Omit<User, 'password'>): Promise<string>;
24
+ verifyToken(token: string): Promise<any>;
25
+ initialize(): (req: any, res: any, next: any) => Promise<void>;
21
26
  requireAuth(): (req: any, res: any, next: any) => any;
22
27
  requireRoles(roles: string[]): (req: any, res: any, next: any) => any;
23
28
  private extractToken;
@@ -1 +1 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/server/auth.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CAC7B;AAED,MAAM,WAAW,IAAI;IACnB,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,qBAAa,WAAW;IACtB,OAAO,CAAC,MAAM,CAAa;gBAEf,MAAM,EAAE,UAAU;IAOxB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAY/C,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAYlF,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,GAAG,MAAM;IAsBnD,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG;IAa/B,UAAU,KACA,KAA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AK,GAAG,EAAE,KAAK,GAAG,EAAE,MAAM,GAAG;IAQvC,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,IAClB,KAAK,GAAG,EAAE,KAAK,GAAG,EAAE,MAAM,GAAG;IAgBvC,OAAO,CAAC,YAAY;CAMrB"}
@@ -1,4 +1,4 @@
1
- import { renderToString } from 'frontend-hamroun';
1
+ import { renderToString } from '../core/server-renderer.js';
2
2
  import { Database } from './database.js';
3
3
  import { AuthService } from './auth.js';
4
4
  import { ApiRouter } from './api-router.js';
@@ -91,7 +91,7 @@ declare const _default: {
91
91
  createProductionServer: typeof createProductionServer;
92
92
  rateLimit: typeof rateLimit;
93
93
  requestLogger: import("./middleware.js").MiddlewareFunction;
94
- errorHandler: (err: Error, req: any, res: any, next: any) => void;
94
+ errorHandler: (err: Error, req: any, res: any, _next: any) => void;
95
95
  notFoundHandler: (req: any, res: any) => void;
96
96
  loadGoWasmFromFile: typeof loadGoWasmFromFile;
97
97
  templates: typeof templates;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAgD,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG1F,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAgB,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAmB7D,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SA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;;;;;;AAwC1D,wBAsBE"}
@@ -1,110 +1,149 @@
1
1
  var __defProp = Object.defineProperty;
2
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
3
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
4
- }) : x)(function(x) {
5
- if (typeof require !== "undefined")
6
- return require.apply(this, arguments);
7
- throw Error('Dynamic require of "' + x + '" is not supported');
8
- });
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9
3
  var __export = (target, all) => {
10
4
  for (var name in all)
11
5
  __defProp(target, name, { get: all[name], enumerable: true });
12
6
  };
7
+ var __publicField = (obj, key, value) => {
8
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
9
+ return value;
10
+ };
13
11
 
14
12
  // src/server/index.ts
15
13
  import path4 from "path";
16
14
  import fs4 from "fs";
17
15
 
18
- // node_modules/frontend-hamroun/dist/index.mjs
19
- var currentRender = 0;
20
- var stateIndices = /* @__PURE__ */ new Map();
21
- var isServer = typeof window === "undefined";
22
- var serverStates = /* @__PURE__ */ new Map();
23
- function prepareRender() {
24
- currentRender++;
25
- stateIndices.set(currentRender, 0);
26
- return currentRender;
16
+ // src/core/hooks.ts
17
+ var currentRoot = null;
18
+ var currentComponentId = null;
19
+ var hookIndex = 0;
20
+ function prepareRender(root, componentId) {
21
+ if (root) {
22
+ currentRoot = root;
23
+ }
24
+ if (componentId !== void 0) {
25
+ currentComponentId = componentId;
26
+ } else if (currentRoot) {
27
+ currentComponentId = ++currentRoot.nextComponentId;
28
+ }
29
+ hookIndex = 0;
30
+ return currentComponentId || 0;
27
31
  }
28
32
  function finishRender() {
29
- if (isServer) {
30
- serverStates.delete(currentRender);
31
- }
32
- currentRender = 0;
33
+ currentComponentId = null;
33
34
  }
35
+
36
+ // src/core/server-renderer.ts
37
+ var VOID_ELEMENTS = /* @__PURE__ */ new Set([
38
+ "area",
39
+ "base",
40
+ "br",
41
+ "col",
42
+ "embed",
43
+ "hr",
44
+ "img",
45
+ "input",
46
+ "link",
47
+ "meta",
48
+ "param",
49
+ "source",
50
+ "track",
51
+ "wbr"
52
+ ]);
34
53
  function renderToString(vnode) {
35
54
  prepareRender();
36
- const html = renderNodeToString(vnode);
37
- finishRender();
38
- return html;
55
+ try {
56
+ return renderNodeToString(vnode);
57
+ } finally {
58
+ finishRender();
59
+ }
39
60
  }
40
61
  function renderNodeToString(vnode) {
41
- var _a, _b, _c;
42
62
  if (vnode === null || vnode === void 0)
43
63
  return "";
44
64
  if (typeof vnode === "boolean")
45
65
  return "";
46
66
  if (typeof vnode === "number" || typeof vnode === "string")
47
67
  return escapeHtml(String(vnode));
48
- if (typeof vnode.type === "function") {
49
- const Component2 = vnode.type;
50
- const renderedNode = Component2(vnode.props || {});
51
- return renderNodeToString(renderedNode);
68
+ if (Array.isArray(vnode)) {
69
+ return vnode.map((child) => renderNodeToString(child)).join("");
70
+ }
71
+ if (typeof vnode !== "object" || vnode.type === void 0) {
72
+ return escapeHtml(String(vnode));
73
+ }
74
+ const { type, props } = vnode;
75
+ if (typeof type === "function") {
76
+ if (type.name === "Fragment" || type === Symbol.for("react.fragment")) {
77
+ const children = props?.children;
78
+ if (children == null)
79
+ return "";
80
+ return Array.isArray(children) ? children.map((child) => renderNodeToString(child)).join("") : renderNodeToString(children);
81
+ }
82
+ const Component = type;
83
+ try {
84
+ const renderedNode = Component(props || {});
85
+ return renderNodeToString(renderedNode);
86
+ } catch (error) {
87
+ console.error("Error rendering component:", error);
88
+ return `<!-- Error rendering component: ${escapeHtml(String(error))} -->`;
89
+ }
52
90
  }
53
- if (typeof vnode.type === "string") {
54
- const tag = vnode.type;
91
+ if (typeof type === "string") {
92
+ const tag = type;
55
93
  let attrs = "";
56
- let children = "";
57
- if (vnode.props) {
58
- for (const [key, value] of Object.entries(vnode.props)) {
94
+ if (props) {
95
+ for (const [key, value] of Object.entries(props)) {
59
96
  if (key === "children")
60
97
  continue;
61
- if (key.startsWith("on"))
98
+ if (key === "dangerouslySetInnerHTML")
62
99
  continue;
63
- if (key === "className") {
64
- attrs += ` class="${escapeHtml(value)}"`;
100
+ if (key === "ref")
65
101
  continue;
102
+ if (value === void 0 || value === null || value === false)
103
+ continue;
104
+ let attrName = key;
105
+ let attrValue = value;
106
+ if (key === "className")
107
+ attrName = "class";
108
+ else if (key === "htmlFor")
109
+ attrName = "for";
110
+ else if (key === "tabIndex")
111
+ attrName = "tabindex";
112
+ if (attrName.startsWith("on") && typeof value === "function")
113
+ continue;
114
+ if (attrName === "style" && typeof value === "object") {
115
+ attrValue = Object.entries(value).map(([prop, val]) => {
116
+ const cssProperty = prop.replace(/([A-Z])/g, "-$1").toLowerCase();
117
+ return `${cssProperty}: ${val}`;
118
+ }).join("; ");
66
119
  }
67
- if (typeof value === "string" || typeof value === "number") {
68
- attrs += ` ${key}="${escapeHtml(String(value))}"`;
69
- } else if (value === true) {
70
- attrs += ` ${key}`;
120
+ if (value === true) {
121
+ attrs += ` ${attrName}`;
122
+ } else {
123
+ attrs += ` ${attrName}="${escapeHtml(String(attrValue))}"`;
71
124
  }
72
125
  }
73
126
  }
74
- const childrenArray = ((_a = vnode.props) == null ? void 0 : _a.children) ? Array.isArray(vnode.props.children) ? vnode.props.children : [vnode.props.children] : [];
127
+ if (VOID_ELEMENTS.has(tag)) {
128
+ return `<${tag}${attrs} />`;
129
+ }
130
+ if (props?.dangerouslySetInnerHTML?.__html) {
131
+ return `<${tag}${attrs}>${props.dangerouslySetInnerHTML.__html}</${tag}>`;
132
+ }
133
+ let children = "";
134
+ const childrenArray = props?.children ? Array.isArray(props.children) ? props.children : [props.children] : [];
75
135
  for (const child of childrenArray) {
76
136
  children += renderNodeToString(child);
77
137
  }
78
- const selfClosing = [
79
- "area",
80
- "base",
81
- "br",
82
- "col",
83
- "embed",
84
- "hr",
85
- "img",
86
- "input",
87
- "link",
88
- "meta",
89
- "param",
90
- "source",
91
- "track",
92
- "wbr"
93
- ];
94
- if (selfClosing.includes(tag)) {
95
- return `<${tag}${attrs}/>`;
96
- }
97
138
  return `<${tag}${attrs}>${children}</${tag}>`;
98
139
  }
99
- if (vnode.type === Symbol.for("react.fragment")) {
100
- let fragmentOutput = "";
101
- const children = Array.isArray((_b = vnode.props) == null ? void 0 : _b.children) ? vnode.props.children : ((_c = vnode.props) == null ? void 0 : _c.children) ? [vnode.props.children] : [];
102
- for (const child of children) {
103
- fragmentOutput += renderNodeToString(child);
104
- }
105
- return fragmentOutput;
140
+ if (type === Symbol.for("react.fragment")) {
141
+ const children = props?.children;
142
+ if (children == null)
143
+ return "";
144
+ return Array.isArray(children) ? children.map((child) => renderNodeToString(child)).join("") : renderNodeToString(children);
106
145
  }
107
- console.warn("Unknown vnode type:", vnode.type);
146
+ console.warn("Unknown vnode type:", type);
108
147
  return "";
109
148
  }
110
149
  function escapeHtml(text) {
@@ -114,10 +153,11 @@ function escapeHtml(text) {
114
153
  // src/server/database.ts
115
154
  var Database = class {
116
155
  constructor(config) {
117
- this.mongoClient = null;
118
- this.mongoDb = null;
119
- this.mysqlPool = null;
120
- this.pgPool = null;
156
+ __publicField(this, "config");
157
+ __publicField(this, "mongoClient", null);
158
+ __publicField(this, "mongoDb", null);
159
+ __publicField(this, "mysqlPool", null);
160
+ __publicField(this, "pgPool", null);
121
161
  this.config = config;
122
162
  }
123
163
  async connect() {
@@ -228,11 +268,27 @@ var Database = class {
228
268
  // src/server/auth.ts
229
269
  var AuthService = class {
230
270
  constructor(config) {
271
+ __publicField(this, "config");
272
+ __publicField(this, "jwtPromise", null);
231
273
  this.config = {
232
274
  expiresIn: "24h",
233
275
  ...config
234
276
  };
235
277
  }
278
+ async getJwt() {
279
+ if (!this.jwtPromise) {
280
+ this.jwtPromise = import("jsonwebtoken").catch((error) => {
281
+ this.jwtPromise = null;
282
+ if (error.code === "MODULE_NOT_FOUND") {
283
+ throw new Error(
284
+ "jsonwebtoken not installed. Run: npm install jsonwebtoken @types/jsonwebtoken"
285
+ );
286
+ }
287
+ throw error;
288
+ });
289
+ }
290
+ return this.jwtPromise;
291
+ }
236
292
  async hashPassword(password) {
237
293
  try {
238
294
  const bcrypt = await import("bcryptjs");
@@ -255,42 +311,31 @@ var AuthService = class {
255
311
  throw error;
256
312
  }
257
313
  }
258
- generateToken(user) {
259
- try {
260
- const jwt = __require("jsonwebtoken");
261
- const options = {};
262
- if (this.config.expiresIn) {
263
- options.expiresIn = this.config.expiresIn;
264
- }
265
- return jwt.sign(
266
- { id: user.id, username: user.username, roles: user.roles || [] },
267
- this.config.secret,
268
- options
269
- );
270
- } catch (error) {
271
- if (error.code === "MODULE_NOT_FOUND") {
272
- throw new Error("jsonwebtoken not installed. Run: npm install jsonwebtoken @types/jsonwebtoken");
273
- }
274
- throw error;
314
+ async generateToken(user) {
315
+ const jwt = await this.getJwt();
316
+ const options = {};
317
+ if (this.config.expiresIn) {
318
+ options.expiresIn = this.config.expiresIn;
275
319
  }
320
+ return jwt.sign(
321
+ { id: user.id, username: user.username, roles: user.roles || [] },
322
+ this.config.secret,
323
+ options
324
+ );
276
325
  }
277
- verifyToken(token) {
326
+ async verifyToken(token) {
278
327
  try {
279
- const jwt = __require("jsonwebtoken");
328
+ const jwt = await this.getJwt();
280
329
  return jwt.verify(token, this.config.secret);
281
- } catch (error) {
282
- if (error.code === "MODULE_NOT_FOUND") {
283
- throw new Error("jsonwebtoken not installed. Run: npm install jsonwebtoken @types/jsonwebtoken");
284
- }
330
+ } catch {
285
331
  return null;
286
332
  }
287
333
  }
288
- // Express middleware for authentication
289
334
  initialize() {
290
- return (req, res, next) => {
335
+ return async (req, res, next) => {
291
336
  const token = this.extractToken(req);
292
337
  if (token) {
293
- const decoded = this.verifyToken(token);
338
+ const decoded = await this.verifyToken(token);
294
339
  if (decoded) {
295
340
  req.user = decoded;
296
341
  }
@@ -298,7 +343,6 @@ var AuthService = class {
298
343
  next();
299
344
  };
300
345
  }
301
- // Express middleware for requiring authentication
302
346
  requireAuth() {
303
347
  return (req, res, next) => {
304
348
  if (!req.user) {
@@ -307,7 +351,6 @@ var AuthService = class {
307
351
  return next();
308
352
  };
309
353
  }
310
- // Express middleware for requiring specific roles
311
354
  requireRoles(roles) {
312
355
  return (req, res, next) => {
313
356
  if (!req.user) {
@@ -335,8 +378,10 @@ import fs from "fs";
335
378
  import { pathToFileURL } from "url";
336
379
  var ApiRouter = class {
337
380
  constructor(apiDir, auth = null) {
338
- this.router = null;
339
- this.initialized = false;
381
+ __publicField(this, "router", null);
382
+ __publicField(this, "apiDir");
383
+ __publicField(this, "auth");
384
+ __publicField(this, "initialized", false);
340
385
  this.apiDir = path.resolve(process.cwd(), apiDir);
341
386
  this.auth = auth;
342
387
  }
@@ -442,7 +487,7 @@ var requestLogger = (req, res, next) => {
442
487
  console.log(`${(/* @__PURE__ */ new Date()).toISOString()} - ${req.method} ${req.url}`);
443
488
  next();
444
489
  };
445
- var errorHandler = (err, req, res, next) => {
490
+ var errorHandler = (err, req, res, _next) => {
446
491
  console.error(err.stack);
447
492
  res.status(500).json({
448
493
  error: {
@@ -460,8 +505,22 @@ var notFoundHandler = (req, res) => {
460
505
  };
461
506
  function rateLimit(options) {
462
507
  const requests = /* @__PURE__ */ new Map();
508
+ const cleanupInterval = setInterval(() => {
509
+ const now = Date.now();
510
+ for (const [ip, times] of requests) {
511
+ const valid = times.filter((t) => now - t < options.windowMs);
512
+ if (valid.length === 0) {
513
+ requests.delete(ip);
514
+ } else {
515
+ requests.set(ip, valid);
516
+ }
517
+ }
518
+ }, options.windowMs);
519
+ if (cleanupInterval.unref) {
520
+ cleanupInterval.unref();
521
+ }
463
522
  return (req, res, next) => {
464
- const ip = req.ip || req.socket.remoteAddress || "unknown";
523
+ const ip = req.ip || req.socket?.remoteAddress || "unknown";
465
524
  const now = Date.now();
466
525
  const reqTimes = (requests.get(ip) || []).filter((time) => now - time < options.windowMs);
467
526
  reqTimes.push(now);
@@ -615,7 +674,7 @@ __export(templates_exports, {
615
674
  });
616
675
  function generateDocument(content, options = {}) {
617
676
  const {
618
- title = "Frontend Hamroun App",
677
+ title = "Baraqex App",
619
678
  description = "",
620
679
  lang = "en",
621
680
  charset = "UTF-8",
@@ -877,7 +936,7 @@ async function loadGoWasmFromFile(wasmFilePath, options = {}) {
877
936
  const GoRuntime = await loadGoRuntime(options.goWasmPath);
878
937
  const go = new GoRuntime();
879
938
  const wasmBuffer = await fs3.readFile(wasmFilePath);
880
- const wasmModule = await WebAssembly.compile(wasmBuffer);
939
+ const wasmModule = await WebAssembly.compile(new Uint8Array(wasmBuffer));
881
940
  const baseImports = go.importObject;
882
941
  const finalImportObject = {
883
942
  ...baseImports,
@@ -958,10 +1017,12 @@ function getComponentName(filePath, pagesDir) {
958
1017
  }
959
1018
  var Server = class {
960
1019
  constructor(config = {}) {
961
- this.server = null;
962
- this.db = null;
963
- this.auth = null;
964
- this.initialized = false;
1020
+ __publicField(this, "app");
1021
+ __publicField(this, "server", null);
1022
+ __publicField(this, "config");
1023
+ __publicField(this, "db", null);
1024
+ __publicField(this, "auth", null);
1025
+ __publicField(this, "initialized", false);
965
1026
  this.config = {
966
1027
  port: 3e3,
967
1028
  apiDir: "./api",
@@ -1240,8 +1301,8 @@ var Server = class {
1240
1301
  if (!fs4.existsSync(clientJsPath)) {
1241
1302
  const clientJsContent = `
1242
1303
  // Auto-generated hydration script
1243
- import { hydrate } from 'frontend-hamroun';
1244
-
1304
+ import { hydrate } from 'baraqex';
1305
+
1245
1306
  // Find SSR content and hydrate it
1246
1307
  document.addEventListener('DOMContentLoaded', () => {
1247
1308
  const ssrRoots = document.querySelectorAll('[data-ssr-root]');