frontend-hamroun 1.2.3 → 1.2.4
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/frontend-hamroun.es.js +16 -32
- package/dist/frontend-hamroun.es.js.map +1 -1
- package/dist/frontend-hamroun.umd.js.map +1 -1
- package/package.json +3 -2
- package/templates/basic/package.json +1 -1
- package/templates/basic/vite.config.ts +60 -2
- package/templates/basic-app/package.json +5 -15
- package/templates/basic-app/vite.config.ts +60 -2
- package/templates/full-stack/package.json +2 -19
- package/templates/full-stack/vite.config.ts +79 -0
@@ -137,8 +137,7 @@ async function createElement(vnode) {
|
|
137
137
|
}
|
138
138
|
};
|
139
139
|
for (const [key, value] of Object.entries(props || {})) {
|
140
|
-
if (key === "children")
|
141
|
-
continue;
|
140
|
+
if (key === "children") continue;
|
142
141
|
if (key.startsWith("on") && typeof value === "function") {
|
143
142
|
const eventName = key.toLowerCase().slice(2);
|
144
143
|
if (!element.__events) {
|
@@ -199,8 +198,7 @@ async function createElement(vnode) {
|
|
199
198
|
}
|
200
199
|
const element = document.createElement(type);
|
201
200
|
for (const [key, value] of Object.entries(props || {})) {
|
202
|
-
if (key === "children")
|
203
|
-
continue;
|
201
|
+
if (key === "children") continue;
|
204
202
|
if (key.startsWith("on") && typeof value === "function") {
|
205
203
|
const eventName = key.toLowerCase().slice(2);
|
206
204
|
const existingHandler = (_a = element.__events) == null ? void 0 : _a[eventName];
|
@@ -280,8 +278,7 @@ class Component {
|
|
280
278
|
}
|
281
279
|
async update() {
|
282
280
|
const vdom = this.render();
|
283
|
-
if (!vdom)
|
284
|
-
return document.createTextNode("");
|
281
|
+
if (!vdom) return document.createTextNode("");
|
285
282
|
const rendered = await createElement(vdom);
|
286
283
|
if (rendered instanceof HTMLElement) {
|
287
284
|
return this._updateElement(rendered);
|
@@ -384,8 +381,7 @@ function useState(initial) {
|
|
384
381
|
const state = componentStates[index2];
|
385
382
|
const setState = (newValue) => {
|
386
383
|
const nextValue = typeof newValue === "function" ? newValue(componentStates[index2]) : newValue;
|
387
|
-
if (componentStates[index2] === nextValue)
|
388
|
-
return;
|
384
|
+
if (componentStates[index2] === nextValue) return;
|
389
385
|
componentStates[index2] = nextValue;
|
390
386
|
if (isBatching) {
|
391
387
|
batchUpdates(() => rerender(currentRender));
|
@@ -397,8 +393,7 @@ function useState(initial) {
|
|
397
393
|
return [state, setState];
|
398
394
|
}
|
399
395
|
function useEffect(callback, deps) {
|
400
|
-
if (!currentRender)
|
401
|
-
throw new Error("useEffect must be called within a render");
|
396
|
+
if (!currentRender) throw new Error("useEffect must be called within a render");
|
402
397
|
const effectIndex = stateIndices.get(currentRender);
|
403
398
|
if (!effects.has(currentRender)) {
|
404
399
|
effects.set(currentRender, []);
|
@@ -417,8 +412,7 @@ function useEffect(callback, deps) {
|
|
417
412
|
stateIndices.set(currentRender, effectIndex + 1);
|
418
413
|
}
|
419
414
|
function useMemo(factory, deps) {
|
420
|
-
if (!currentRender)
|
421
|
-
throw new Error("useMemo must be called within a render");
|
415
|
+
if (!currentRender) throw new Error("useMemo must be called within a render");
|
422
416
|
const memoIndex = stateIndices.get(currentRender);
|
423
417
|
if (!memos.has(currentRender)) {
|
424
418
|
memos.set(currentRender, []);
|
@@ -435,8 +429,7 @@ function useMemo(factory, deps) {
|
|
435
429
|
return prevMemo.value;
|
436
430
|
}
|
437
431
|
function useRef(initial) {
|
438
|
-
if (!currentRender)
|
439
|
-
throw new Error("useRef must be called within a render");
|
432
|
+
if (!currentRender) throw new Error("useRef must be called within a render");
|
440
433
|
const refIndex = stateIndices.get(currentRender);
|
441
434
|
if (!refs.has(currentRender)) {
|
442
435
|
refs.set(currentRender, []);
|
@@ -457,8 +450,7 @@ async function rerender(rendererId) {
|
|
457
450
|
const componentEffects = effects.get(rendererId);
|
458
451
|
if (componentEffects) {
|
459
452
|
componentEffects.forEach((effect) => {
|
460
|
-
if (effect.cleanup)
|
461
|
-
effect.cleanup();
|
453
|
+
if (effect.cleanup) effect.cleanup();
|
462
454
|
});
|
463
455
|
effects.set(rendererId, []);
|
464
456
|
}
|
@@ -507,10 +499,8 @@ async function renderToString(element) {
|
|
507
499
|
setRenderCallback(() => {
|
508
500
|
}, element, null);
|
509
501
|
try {
|
510
|
-
if (element == null)
|
511
|
-
|
512
|
-
if (typeof element === "boolean")
|
513
|
-
return "";
|
502
|
+
if (element == null) return "";
|
503
|
+
if (typeof element === "boolean") return "";
|
514
504
|
if (typeof element === "number" || typeof element === "string") {
|
515
505
|
return escapeHtml(String(element));
|
516
506
|
}
|
@@ -542,8 +532,7 @@ async function renderToString(element) {
|
|
542
532
|
}
|
543
533
|
let html = `<${type}`;
|
544
534
|
for (const [key, value] of Object.entries(props || {})) {
|
545
|
-
if (key === "children" || key === "key")
|
546
|
-
continue;
|
535
|
+
if (key === "children" || key === "key") continue;
|
547
536
|
if (key === "className") {
|
548
537
|
html += ` class="${escapeHtml(String(value))}"`;
|
549
538
|
} else if (key === "style" && typeof value === "object") {
|
@@ -884,8 +873,7 @@ ${Object.keys(ssrRoutes).length > 0 ? `
|
|
884
873
|
🖥️ Registered SSR Routes:
|
885
874
|
${Object.keys(ssrRoutes).map((route) => ` ${route}`).join("\n")}` : ""}
|
886
875
|
`);
|
887
|
-
if (callback)
|
888
|
-
callback();
|
876
|
+
if (callback) callback();
|
889
877
|
});
|
890
878
|
const gracefulShutdown = async (signal) => {
|
891
879
|
console.log(`${signal} signal received: closing HTTP server and cleaning up`);
|
@@ -1020,14 +1008,10 @@ function createApiRouter$1(routeConfig, options = {}) {
|
|
1020
1008
|
}
|
1021
1009
|
function apiResponse(success, data, message, error, meta) {
|
1022
1010
|
const response = { success };
|
1023
|
-
if (data !== void 0)
|
1024
|
-
|
1025
|
-
if (
|
1026
|
-
|
1027
|
-
if (error)
|
1028
|
-
response.error = error;
|
1029
|
-
if (meta)
|
1030
|
-
response.meta = meta;
|
1011
|
+
if (data !== void 0) response.data = data;
|
1012
|
+
if (message) response.message = message;
|
1013
|
+
if (error) response.error = error;
|
1014
|
+
if (meta) response.meta = meta;
|
1031
1015
|
return response;
|
1032
1016
|
}
|
1033
1017
|
function sendSuccess(res, data, message, statusCode = 200, meta) {
|