baraqex 1.0.38 → 1.0.39
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.
- package/dist/browser.d.ts +1 -1
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +771 -140
- package/dist/browser.js.map +4 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +872 -220
- package/dist/index.js.map +4 -4
- package/dist/server/index.d.ts +4 -4
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +212 -85
- package/dist/server/index.js.map +4 -4
- package/package.json +14 -10
- package/templates/ssr-template/package-lock.json +5 -5
- package/templates/ssr-template/package.json +1 -1
- package/templates/ssr-template/src/App.tsx +1 -1
package/dist/server/index.d.ts
CHANGED
|
@@ -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) =>
|
|
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) =>
|
|
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,iBAAiB,CAAC;AAG1F,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAgB,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAkB7D,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,WAAW,CAAC,EAAE,GAAG,CAAC;IAClB,EAAE,CAAC,EAAE;QACH,GAAG,EAAE,MAAM,CAAC;QACZ,IAAI,EAAE,SAAS,GAAG,OAAO,GAAG,UAAU,CAAC;KACxC,CAAC;IACF,IAAI,CAAC,EAAE;QACL,MAAM,EAAE,MAAM,CAAC;QACf,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM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M,CAWnE;AAGD,wBAAgB,YAAY,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,CAK7C;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAY7D;AAGD,eAAO,MAAM,eAAe,GAAI,WAAW,GAAG,EAAE,QAAO,GAAQ;;;;;;;;CAgB9D,CAAC;AAGF,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAG7D,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAG/B,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,EACL,aAAa,EACb,YAAY,EACZ,eAAe,EACf,SAAS,EACV,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,cAAc,EAAE,CAAC;;;;;;;;;;;;;iCArCiB,GAAG,UAAS,GAAG;;;;;;;;;;;;;;;;AAwC1D,wBAsBE"}
|
package/dist/server/index.js
CHANGED
|
@@ -15,101 +15,227 @@ 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.
|
|
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;
|
|
20
38
|
var stateIndices = /* @__PURE__ */ new Map();
|
|
21
|
-
|
|
22
|
-
var serverStates = /* @__PURE__ */ new Map();
|
|
23
|
-
function prepareRender() {
|
|
39
|
+
function prepareRender(component = null) {
|
|
24
40
|
currentRender++;
|
|
25
41
|
stateIndices.set(currentRender, 0);
|
|
26
42
|
return currentRender;
|
|
27
43
|
}
|
|
28
44
|
function finishRender() {
|
|
29
|
-
if (isServer) {
|
|
30
|
-
serverStates.delete(currentRender);
|
|
31
|
-
}
|
|
32
45
|
currentRender = 0;
|
|
33
46
|
}
|
|
34
|
-
function renderToString(
|
|
35
|
-
prepareRender();
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
47
|
+
async function renderToString(element) {
|
|
48
|
+
prepareRender(true);
|
|
49
|
+
try {
|
|
50
|
+
const html = await renderNodeToString(element);
|
|
51
|
+
return html;
|
|
52
|
+
} finally {
|
|
53
|
+
finishRender();
|
|
54
|
+
}
|
|
39
55
|
}
|
|
40
|
-
function renderNodeToString(
|
|
41
|
-
|
|
42
|
-
if (vnode === null || vnode === void 0)
|
|
43
|
-
return "";
|
|
44
|
-
if (typeof vnode === "boolean")
|
|
56
|
+
async function renderNodeToString(node) {
|
|
57
|
+
if (node == null || typeof node === "boolean") {
|
|
45
58
|
return "";
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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}`;
|
|
71
|
-
}
|
|
59
|
+
}
|
|
60
|
+
if (typeof node === "string" || typeof node === "number") {
|
|
61
|
+
return escapeHtml(String(node));
|
|
62
|
+
}
|
|
63
|
+
if (Array.isArray(node)) {
|
|
64
|
+
const results = await Promise.all(node.map((child) => renderNodeToString(child)));
|
|
65
|
+
return results.join("");
|
|
66
|
+
}
|
|
67
|
+
if (node && typeof node === "object" && "type" in node) {
|
|
68
|
+
const { type, props = {} } = node;
|
|
69
|
+
if (typeof type === "function") {
|
|
70
|
+
try {
|
|
71
|
+
const result = await type(props);
|
|
72
|
+
return await renderNodeToString(result);
|
|
73
|
+
} catch (error) {
|
|
74
|
+
console.error("Error rendering component:", error);
|
|
75
|
+
return `<!-- Error rendering component: ${error.message} -->`;
|
|
72
76
|
}
|
|
73
77
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
78
|
+
if (typeof type === "string") {
|
|
79
|
+
return await renderDOMElement(type, props);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if (typeof node === "object") {
|
|
83
|
+
return escapeHtml(JSON.stringify(node));
|
|
84
|
+
}
|
|
85
|
+
return escapeHtml(String(node));
|
|
86
|
+
}
|
|
87
|
+
async function renderDOMElement(tagName, props) {
|
|
88
|
+
const { children, ...attrs } = props;
|
|
89
|
+
const voidElements = /* @__PURE__ */ new Set([
|
|
90
|
+
"area",
|
|
91
|
+
"base",
|
|
92
|
+
"br",
|
|
93
|
+
"col",
|
|
94
|
+
"embed",
|
|
95
|
+
"hr",
|
|
96
|
+
"img",
|
|
97
|
+
"input",
|
|
98
|
+
"link",
|
|
99
|
+
"meta",
|
|
100
|
+
"param",
|
|
101
|
+
"source",
|
|
102
|
+
"track",
|
|
103
|
+
"wbr"
|
|
104
|
+
]);
|
|
105
|
+
const attributeString = Object.entries(attrs).filter(([key, value]) => {
|
|
106
|
+
if (key.startsWith("on") || key === "key" || key === "ref")
|
|
107
|
+
return false;
|
|
108
|
+
if (value == null || value === false)
|
|
109
|
+
return false;
|
|
110
|
+
return true;
|
|
111
|
+
}).map(([key, value]) => {
|
|
112
|
+
if (key === "className")
|
|
113
|
+
key = "class";
|
|
114
|
+
if (value === true)
|
|
115
|
+
return key;
|
|
116
|
+
if (key === "style" && typeof value === "object" && value !== null) {
|
|
117
|
+
const styleString = Object.entries(value).map(([prop, val]) => `${kebabCase(prop)}:${val}`).join(";");
|
|
118
|
+
return `style="${escapeHtml(styleString)}"`;
|
|
119
|
+
}
|
|
120
|
+
return `${key}="${escapeHtml(String(value))}"`;
|
|
121
|
+
}).join(" ");
|
|
122
|
+
const openTag = `<${tagName}${attributeString ? " " + attributeString : ""}>`;
|
|
123
|
+
if (voidElements.has(tagName)) {
|
|
124
|
+
return openTag.slice(0, -1) + "/>";
|
|
125
|
+
}
|
|
126
|
+
const closeTag = `</${tagName}>`;
|
|
127
|
+
if (children != null) {
|
|
128
|
+
const childrenString = await renderNodeToString(children);
|
|
129
|
+
return openTag + childrenString + closeTag;
|
|
130
|
+
}
|
|
131
|
+
return openTag + closeTag;
|
|
109
132
|
}
|
|
110
133
|
function escapeHtml(text) {
|
|
111
|
-
|
|
134
|
+
const htmlEscapes = {
|
|
135
|
+
"&": "&",
|
|
136
|
+
"<": "<",
|
|
137
|
+
">": ">",
|
|
138
|
+
'"': """,
|
|
139
|
+
"'": "'",
|
|
140
|
+
"/": "/"
|
|
141
|
+
};
|
|
142
|
+
return text.replace(/[&<>"'/]/g, (match) => htmlEscapes[match]);
|
|
112
143
|
}
|
|
144
|
+
function kebabCase(str) {
|
|
145
|
+
return str.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
|
|
146
|
+
}
|
|
147
|
+
var RouterContext = createContext({
|
|
148
|
+
location: {
|
|
149
|
+
pathname: "/",
|
|
150
|
+
search: "",
|
|
151
|
+
hash: ""
|
|
152
|
+
},
|
|
153
|
+
params: {},
|
|
154
|
+
navigate: () => {
|
|
155
|
+
},
|
|
156
|
+
match: () => false
|
|
157
|
+
});
|
|
158
|
+
function createEventBus() {
|
|
159
|
+
const events = /* @__PURE__ */ new Map();
|
|
160
|
+
const onceHandlers = /* @__PURE__ */ new WeakMap();
|
|
161
|
+
const on = (event, handler) => {
|
|
162
|
+
if (!events.has(event)) {
|
|
163
|
+
events.set(event, /* @__PURE__ */ new Set());
|
|
164
|
+
}
|
|
165
|
+
events.get(event).add(handler);
|
|
166
|
+
return () => off(event, handler);
|
|
167
|
+
};
|
|
168
|
+
const once = (event, handler) => {
|
|
169
|
+
const onceWrapper = (...args) => {
|
|
170
|
+
off(event, onceWrapper);
|
|
171
|
+
handler(...args);
|
|
172
|
+
};
|
|
173
|
+
onceHandlers.set(handler, onceWrapper);
|
|
174
|
+
return on(event, onceWrapper);
|
|
175
|
+
};
|
|
176
|
+
const off = (event, handler) => {
|
|
177
|
+
if (!handler) {
|
|
178
|
+
events.delete(event);
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
const wrappedHandler = onceHandlers.get(handler);
|
|
182
|
+
const handlerToRemove = wrappedHandler || handler;
|
|
183
|
+
if (events.has(event)) {
|
|
184
|
+
events.get(event).delete(handlerToRemove);
|
|
185
|
+
if (events.get(event).size === 0) {
|
|
186
|
+
events.delete(event);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
const emit = (event, ...args) => {
|
|
191
|
+
if (!events.has(event)) {
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
const handlers = Array.from(events.get(event));
|
|
195
|
+
for (const handler of handlers) {
|
|
196
|
+
handler(...args);
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
const clear = (event) => {
|
|
200
|
+
if (event) {
|
|
201
|
+
events.delete(event);
|
|
202
|
+
} else {
|
|
203
|
+
events.clear();
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
return { on, once, off, emit, clear };
|
|
207
|
+
}
|
|
208
|
+
var globalEventBus = createEventBus();
|
|
209
|
+
var StoreContext = createContext({
|
|
210
|
+
store: {
|
|
211
|
+
getState: () => ({}),
|
|
212
|
+
dispatch: () => {
|
|
213
|
+
},
|
|
214
|
+
subscribe: () => () => {
|
|
215
|
+
}
|
|
216
|
+
},
|
|
217
|
+
state: {}
|
|
218
|
+
});
|
|
219
|
+
var LifecycleEvents;
|
|
220
|
+
(function(LifecycleEvents2) {
|
|
221
|
+
LifecycleEvents2["APP_INIT"] = "app:init";
|
|
222
|
+
LifecycleEvents2["APP_MOUNTED"] = "app:mounted";
|
|
223
|
+
LifecycleEvents2["APP_UPDATED"] = "app:updated";
|
|
224
|
+
LifecycleEvents2["APP_ERROR"] = "app:error";
|
|
225
|
+
LifecycleEvents2["APP_DESTROYED"] = "app:destroyed";
|
|
226
|
+
LifecycleEvents2["COMPONENT_CREATED"] = "component:created";
|
|
227
|
+
LifecycleEvents2["COMPONENT_MOUNTED"] = "component:mounted";
|
|
228
|
+
LifecycleEvents2["COMPONENT_UPDATED"] = "component:updated";
|
|
229
|
+
LifecycleEvents2["COMPONENT_ERROR"] = "component:error";
|
|
230
|
+
LifecycleEvents2["COMPONENT_UNMOUNTED"] = "component:unmounted";
|
|
231
|
+
LifecycleEvents2["ROUTER_BEFORE_CHANGE"] = "router:before-change";
|
|
232
|
+
LifecycleEvents2["ROUTER_AFTER_CHANGE"] = "router:after-change";
|
|
233
|
+
LifecycleEvents2["ROUTER_ERROR"] = "router:error";
|
|
234
|
+
LifecycleEvents2["STORE_INITIALIZED"] = "store:initialized";
|
|
235
|
+
LifecycleEvents2["STORE_BEFORE_ACTION"] = "store:before-action";
|
|
236
|
+
LifecycleEvents2["STORE_AFTER_ACTION"] = "store:after-action";
|
|
237
|
+
LifecycleEvents2["STORE_ERROR"] = "store:error";
|
|
238
|
+
})(LifecycleEvents || (LifecycleEvents = {}));
|
|
113
239
|
|
|
114
240
|
// src/server/database.ts
|
|
115
241
|
var Database = class {
|
|
@@ -1145,13 +1271,14 @@ var Server = class {
|
|
|
1145
1271
|
// Could be parsed from URL
|
|
1146
1272
|
api: { serverTime: (/* @__PURE__ */ new Date()).toISOString() }
|
|
1147
1273
|
};
|
|
1148
|
-
const
|
|
1149
|
-
if (!success) {
|
|
1274
|
+
const renderResult = await renderComponent(PageComponent, initialProps);
|
|
1275
|
+
if (!renderResult.success) {
|
|
1150
1276
|
return {
|
|
1151
|
-
html: generateErrorPage(500, "Failed to render page", error instanceof Error ? error : new Error("Unknown error")),
|
|
1277
|
+
html: generateErrorPage(500, "Failed to render page", renderResult.error instanceof Error ? renderResult.error : new Error("Unknown error")),
|
|
1152
1278
|
statusCode: 500
|
|
1153
1279
|
};
|
|
1154
1280
|
}
|
|
1281
|
+
const htmlContent = renderResult.html;
|
|
1155
1282
|
let pageTitle = "My App";
|
|
1156
1283
|
try {
|
|
1157
1284
|
if (typeof PageComponent.getTitle === "function") {
|
|
@@ -1162,7 +1289,7 @@ var Server = class {
|
|
|
1162
1289
|
} catch (e) {
|
|
1163
1290
|
}
|
|
1164
1291
|
const componentName = getComponentName(pagePath, pagesDir);
|
|
1165
|
-
const fullHtml = generateDocument(
|
|
1292
|
+
const fullHtml = generateDocument(htmlContent, {
|
|
1166
1293
|
title: pageTitle,
|
|
1167
1294
|
// Get description from component if available
|
|
1168
1295
|
description: typeof PageComponent.getDescription === "function" ? PageComponent.getDescription(initialProps) : PageComponent.description || "",
|
|
@@ -1315,11 +1442,11 @@ function parseCookies(req) {
|
|
|
1315
1442
|
}
|
|
1316
1443
|
return cookies;
|
|
1317
1444
|
}
|
|
1318
|
-
var renderComponent =
|
|
1445
|
+
var renderComponent = (Component, props = {}) => {
|
|
1319
1446
|
try {
|
|
1320
1447
|
const html = renderToString(Component(props));
|
|
1321
1448
|
return {
|
|
1322
|
-
html,
|
|
1449
|
+
html: typeof html === "string" ? html : String(html),
|
|
1323
1450
|
success: true
|
|
1324
1451
|
};
|
|
1325
1452
|
} catch (error) {
|