baraqex 1.0.38 → 1.0.40

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.
@@ -66,7 +66,7 @@ export declare function createDevServer(options?: {
66
66
  export declare function createProductionServer(config: ServerConfig): Server;
67
67
  export declare function getRequestIp(req: any): string;
68
68
  export declare function parseCookies(req: any): Record<string, string>;
69
- export declare const renderComponent: (Component: any, props?: any) => Promise<{
69
+ export declare const renderComponent: (Component: any, props?: any) => {
70
70
  html: string;
71
71
  success: boolean;
72
72
  error?: undefined;
@@ -74,7 +74,7 @@ export declare const renderComponent: (Component: any, props?: any) => Promise<{
74
74
  html: string;
75
75
  success: boolean;
76
76
  error: unknown;
77
- }>;
77
+ };
78
78
  export { initNodeWasm, loadGoWasmFromFile } from './wasm.js';
79
79
  export * from './utils.js';
80
80
  export * from './templates.js';
@@ -95,7 +95,7 @@ declare const _default: {
95
95
  loadGoWasmFromFile: typeof loadGoWasmFromFile;
96
96
  templates: typeof templates;
97
97
  utils: typeof utils;
98
- renderComponent: (Component: any, props?: any) => Promise<{
98
+ renderComponent: (Component: any, props?: any) => {
99
99
  html: string;
100
100
  success: boolean;
101
101
  error?: undefined;
@@ -103,7 +103,7 @@ declare const _default: {
103
103
  html: string;
104
104
  success: boolean;
105
105
  error: unknown;
106
- }>;
106
+ };
107
107
  renderToString: typeof renderToString;
108
108
  getRequestIp: typeof getRequestIp;
109
109
  parseCookies: typeof parseCookies;
@@ -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,iB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,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EACL,aAAa,EACb,YAAY,EACZ,eAAe,EACf,SAAS,EACV,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,cAAc,EAAE,CAAC;;;;;;;;;;;;;iCArCiB,GAAG,UAAS,GAAG;;;;;;;;;;;;;;;;AAwC1D,wBAsBE"}
@@ -15,101 +15,236 @@ var __export = (target, all) => {
15
15
  import path4 from "path";
16
16
  import fs4 from "fs";
17
17
 
18
- // node_modules/frontend-hamroun/dist/index.mjs
18
+ // node_modules/frontend-hamroun/dist/index.js
19
+ var contexts = /* @__PURE__ */ new Map();
20
+ function createContext(defaultValue) {
21
+ const contextId = Symbol("context");
22
+ const Provider = ({ value, children }) => {
23
+ contexts.set(contextId, value);
24
+ return children;
25
+ };
26
+ const Consumer = ({ children }) => {
27
+ const value = contexts.get(contextId) ?? defaultValue;
28
+ return children(value);
29
+ };
30
+ const context = {
31
+ Provider,
32
+ Consumer,
33
+ displayName: "Context"
34
+ };
35
+ return context;
36
+ }
19
37
  var currentRender = 0;
38
+ var isSSR = false;
39
+ var states = /* @__PURE__ */ new Map();
20
40
  var stateIndices = /* @__PURE__ */ new Map();
21
- var isServer = typeof window === "undefined";
22
- var serverStates = /* @__PURE__ */ new Map();
23
- function prepareRender() {
41
+ function prepareRender(component = null, isServerSideRender = false) {
24
42
  currentRender++;
43
+ isSSR = isServerSideRender;
25
44
  stateIndices.set(currentRender, 0);
45
+ if (!states.has(currentRender)) {
46
+ states.set(currentRender, []);
47
+ }
26
48
  return currentRender;
27
49
  }
28
50
  function finishRender() {
29
- if (isServer) {
30
- serverStates.delete(currentRender);
31
- }
32
- currentRender = 0;
33
51
  }
34
- function renderToString(vnode) {
35
- prepareRender();
36
- const html = renderNodeToString(vnode);
37
- finishRender();
38
- return html;
52
+ async function renderToString(element) {
53
+ prepareRender(element);
54
+ try {
55
+ const html = await renderNodeToString(element);
56
+ return html;
57
+ } finally {
58
+ }
39
59
  }
40
- function renderNodeToString(vnode) {
41
- var _a, _b, _c;
42
- if (vnode === null || vnode === void 0)
43
- return "";
44
- if (typeof vnode === "boolean")
60
+ async function renderNodeToString(node) {
61
+ if (node == null || typeof node === "boolean") {
45
62
  return "";
46
- if (typeof vnode === "number" || typeof vnode === "string")
47
- 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);
52
- }
53
- if (typeof vnode.type === "string") {
54
- const tag = vnode.type;
55
- let attrs = "";
56
- let children = "";
57
- if (vnode.props) {
58
- for (const [key, value] of Object.entries(vnode.props)) {
59
- if (key === "children")
60
- continue;
61
- if (key.startsWith("on"))
62
- continue;
63
- if (key === "className") {
64
- attrs += ` class="${escapeHtml(value)}"`;
65
- continue;
66
- }
67
- if (typeof value === "string" || typeof value === "number") {
68
- attrs += ` ${key}="${escapeHtml(String(value))}"`;
69
- } else if (value === true) {
70
- attrs += ` ${key}`;
63
+ }
64
+ if (typeof node === "string" || typeof node === "number") {
65
+ return escapeHtml(String(node));
66
+ }
67
+ if (Array.isArray(node)) {
68
+ const results = await Promise.all(node.map((child) => renderNodeToString(child)));
69
+ return results.join("");
70
+ }
71
+ if (node && typeof node === "object" && "type" in node) {
72
+ const { type, props = {} } = node;
73
+ if (typeof type === "function") {
74
+ try {
75
+ const componentRenderId = prepareRender(type);
76
+ try {
77
+ const result = await type(props);
78
+ return await renderNodeToString(result);
79
+ } finally {
80
+ finishRender();
71
81
  }
82
+ } catch (error) {
83
+ console.error("Error rendering component:", error);
84
+ return `<!-- Error rendering component: ${error.message} -->`;
72
85
  }
73
86
  }
74
- const childrenArray = ((_a = vnode.props) == null ? void 0 : _a.children) ? Array.isArray(vnode.props.children) ? vnode.props.children : [vnode.props.children] : [];
75
- for (const child of childrenArray) {
76
- children += renderNodeToString(child);
77
- }
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
- return `<${tag}${attrs}>${children}</${tag}>`;
98
- }
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;
106
- }
107
- console.warn("Unknown vnode type:", vnode.type);
108
- return "";
87
+ if (typeof type === "string") {
88
+ return await renderDOMElement(type, props);
89
+ }
90
+ }
91
+ if (typeof node === "object") {
92
+ return escapeHtml(JSON.stringify(node));
93
+ }
94
+ return escapeHtml(String(node));
95
+ }
96
+ async function renderDOMElement(tagName, props) {
97
+ const { children, ...attrs } = props;
98
+ const voidElements = /* @__PURE__ */ new Set([
99
+ "area",
100
+ "base",
101
+ "br",
102
+ "col",
103
+ "embed",
104
+ "hr",
105
+ "img",
106
+ "input",
107
+ "link",
108
+ "meta",
109
+ "param",
110
+ "source",
111
+ "track",
112
+ "wbr"
113
+ ]);
114
+ const attributeString = Object.entries(attrs).filter(([key, value]) => {
115
+ if (key.startsWith("on") || key === "key" || key === "ref")
116
+ return false;
117
+ if (value == null || value === false)
118
+ return false;
119
+ return true;
120
+ }).map(([key, value]) => {
121
+ if (key === "className")
122
+ key = "class";
123
+ if (value === true)
124
+ return key;
125
+ if (key === "style" && typeof value === "object" && value !== null) {
126
+ const styleString = Object.entries(value).map(([prop, val]) => `${kebabCase(prop)}:${val}`).join(";");
127
+ return `style="${escapeHtml(styleString)}"`;
128
+ }
129
+ return `${key}="${escapeHtml(String(value))}"`;
130
+ }).join(" ");
131
+ const openTag = `<${tagName}${attributeString ? " " + attributeString : ""}>`;
132
+ if (voidElements.has(tagName)) {
133
+ return openTag.slice(0, -1) + "/>";
134
+ }
135
+ const closeTag = `</${tagName}>`;
136
+ if (children != null) {
137
+ const childrenString = await renderNodeToString(children);
138
+ return openTag + childrenString + closeTag;
139
+ }
140
+ return openTag + closeTag;
109
141
  }
110
142
  function escapeHtml(text) {
111
- return text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
143
+ const htmlEscapes = {
144
+ "&": "&amp;",
145
+ "<": "&lt;",
146
+ ">": "&gt;",
147
+ '"': "&quot;",
148
+ "'": "&#x27;",
149
+ "/": "&#x2F;"
150
+ };
151
+ return text.replace(/[&<>"'/]/g, (match) => htmlEscapes[match]);
152
+ }
153
+ function kebabCase(str) {
154
+ return str.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
155
+ }
156
+ var RouterContext = createContext({
157
+ location: {
158
+ pathname: "/",
159
+ search: "",
160
+ hash: ""
161
+ },
162
+ params: {},
163
+ navigate: () => {
164
+ },
165
+ match: () => false
166
+ });
167
+ function createEventBus() {
168
+ const events = /* @__PURE__ */ new Map();
169
+ const onceHandlers = /* @__PURE__ */ new WeakMap();
170
+ const on = (event, handler) => {
171
+ if (!events.has(event)) {
172
+ events.set(event, /* @__PURE__ */ new Set());
173
+ }
174
+ events.get(event).add(handler);
175
+ return () => off(event, handler);
176
+ };
177
+ const once = (event, handler) => {
178
+ const onceWrapper = (...args) => {
179
+ off(event, onceWrapper);
180
+ handler(...args);
181
+ };
182
+ onceHandlers.set(handler, onceWrapper);
183
+ return on(event, onceWrapper);
184
+ };
185
+ const off = (event, handler) => {
186
+ if (!handler) {
187
+ events.delete(event);
188
+ return;
189
+ }
190
+ const wrappedHandler = onceHandlers.get(handler);
191
+ const handlerToRemove = wrappedHandler || handler;
192
+ if (events.has(event)) {
193
+ events.get(event).delete(handlerToRemove);
194
+ if (events.get(event).size === 0) {
195
+ events.delete(event);
196
+ }
197
+ }
198
+ };
199
+ const emit = (event, ...args) => {
200
+ if (!events.has(event)) {
201
+ return;
202
+ }
203
+ const handlers = Array.from(events.get(event));
204
+ for (const handler of handlers) {
205
+ handler(...args);
206
+ }
207
+ };
208
+ const clear = (event) => {
209
+ if (event) {
210
+ events.delete(event);
211
+ } else {
212
+ events.clear();
213
+ }
214
+ };
215
+ return { on, once, off, emit, clear };
112
216
  }
217
+ var globalEventBus = createEventBus();
218
+ var StoreContext = createContext({
219
+ store: {
220
+ getState: () => ({}),
221
+ dispatch: () => {
222
+ },
223
+ subscribe: () => () => {
224
+ }
225
+ },
226
+ state: {}
227
+ });
228
+ var LifecycleEvents;
229
+ (function(LifecycleEvents2) {
230
+ LifecycleEvents2["APP_INIT"] = "app:init";
231
+ LifecycleEvents2["APP_MOUNTED"] = "app:mounted";
232
+ LifecycleEvents2["APP_UPDATED"] = "app:updated";
233
+ LifecycleEvents2["APP_ERROR"] = "app:error";
234
+ LifecycleEvents2["APP_DESTROYED"] = "app:destroyed";
235
+ LifecycleEvents2["COMPONENT_CREATED"] = "component:created";
236
+ LifecycleEvents2["COMPONENT_MOUNTED"] = "component:mounted";
237
+ LifecycleEvents2["COMPONENT_UPDATED"] = "component:updated";
238
+ LifecycleEvents2["COMPONENT_ERROR"] = "component:error";
239
+ LifecycleEvents2["COMPONENT_UNMOUNTED"] = "component:unmounted";
240
+ LifecycleEvents2["ROUTER_BEFORE_CHANGE"] = "router:before-change";
241
+ LifecycleEvents2["ROUTER_AFTER_CHANGE"] = "router:after-change";
242
+ LifecycleEvents2["ROUTER_ERROR"] = "router:error";
243
+ LifecycleEvents2["STORE_INITIALIZED"] = "store:initialized";
244
+ LifecycleEvents2["STORE_BEFORE_ACTION"] = "store:before-action";
245
+ LifecycleEvents2["STORE_AFTER_ACTION"] = "store:after-action";
246
+ LifecycleEvents2["STORE_ERROR"] = "store:error";
247
+ })(LifecycleEvents || (LifecycleEvents = {}));
113
248
 
114
249
  // src/server/database.ts
115
250
  var Database = class {
@@ -1145,13 +1280,14 @@ var Server = class {
1145
1280
  // Could be parsed from URL
1146
1281
  api: { serverTime: (/* @__PURE__ */ new Date()).toISOString() }
1147
1282
  };
1148
- const { html, success, error } = await renderComponent(PageComponent, initialProps);
1149
- if (!success) {
1283
+ const renderResult = await renderComponent(PageComponent, initialProps);
1284
+ if (!renderResult.success) {
1150
1285
  return {
1151
- html: generateErrorPage(500, "Failed to render page", error instanceof Error ? error : new Error("Unknown error")),
1286
+ html: generateErrorPage(500, "Failed to render page", renderResult.error instanceof Error ? renderResult.error : new Error("Unknown error")),
1152
1287
  statusCode: 500
1153
1288
  };
1154
1289
  }
1290
+ const htmlContent = renderResult.html;
1155
1291
  let pageTitle = "My App";
1156
1292
  try {
1157
1293
  if (typeof PageComponent.getTitle === "function") {
@@ -1162,7 +1298,7 @@ var Server = class {
1162
1298
  } catch (e) {
1163
1299
  }
1164
1300
  const componentName = getComponentName(pagePath, pagesDir);
1165
- const fullHtml = generateDocument(html, {
1301
+ const fullHtml = generateDocument(htmlContent, {
1166
1302
  title: pageTitle,
1167
1303
  // Get description from component if available
1168
1304
  description: typeof PageComponent.getDescription === "function" ? PageComponent.getDescription(initialProps) : PageComponent.description || "",
@@ -1315,11 +1451,11 @@ function parseCookies(req) {
1315
1451
  }
1316
1452
  return cookies;
1317
1453
  }
1318
- var renderComponent = async (Component, props = {}) => {
1454
+ var renderComponent = (Component, props = {}) => {
1319
1455
  try {
1320
1456
  const html = renderToString(Component(props));
1321
1457
  return {
1322
- html,
1458
+ html: typeof html === "string" ? html : String(html),
1323
1459
  success: true
1324
1460
  };
1325
1461
  } catch (error) {