webspresso 0.0.82 → 0.0.83

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webspresso",
3
- "version": "0.0.82",
3
+ "version": "0.0.83",
4
4
  "description": "Minimal, production-ready SSR framework for Node.js with file-based routing, Nunjucks templating, built-in i18n, and CLI tooling",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -227,28 +227,36 @@ function wrapCustomPageWithLayout(page, rawComp) {
227
227
 
228
228
  return {
229
229
  oninit: function(vnode) {
230
- if (typeof rawComp.oninit === 'function') return rawComp.oninit.call(this, vnode);
230
+ vnode.state.instance = typeof rawComp === 'function' ? rawComp.call(this, vnode) : rawComp;
231
+ if (vnode.state.instance && typeof vnode.state.instance.oninit === 'function') {
232
+ return vnode.state.instance.oninit.call(this, vnode);
233
+ }
231
234
  },
232
235
  oncreate: function(vnode) {
233
- if (typeof rawComp.oncreate === 'function') return rawComp.oncreate.call(this, vnode);
236
+ const comp = vnode.state.instance || rawComp;
237
+ if (comp && typeof comp.oncreate === 'function') return comp.oncreate.call(this, vnode);
234
238
  },
235
239
  onupdate: function(vnode) {
236
- if (typeof rawComp.onupdate === 'function') return rawComp.onupdate.call(this, vnode);
240
+ const comp = vnode.state.instance || rawComp;
241
+ if (comp && typeof comp.onupdate === 'function') return comp.onupdate.call(this, vnode);
237
242
  },
238
243
  onbeforeremove: function(vnode) {
239
- if (typeof rawComp.onbeforeremove === 'function') return rawComp.onbeforeremove.call(this, vnode);
244
+ const comp = vnode.state.instance || rawComp;
245
+ if (comp && typeof comp.onbeforeremove === 'function') return comp.onbeforeremove.call(this, vnode);
240
246
  },
241
247
  onremove: function(vnode) {
242
- if (typeof rawComp.onremove === 'function') return rawComp.onremove.call(this, vnode);
248
+ const comp = vnode.state.instance || rawComp;
249
+ if (comp && typeof comp.onremove === 'function') return comp.onremove.call(this, vnode);
243
250
  },
244
251
  view: function(vnode) {
252
+ const comp = vnode.state.instance || rawComp;
245
253
  var content;
246
- if (typeof rawComp.view === 'function') {
247
- content = rawComp.view.call(this, vnode);
248
- } else if (typeof rawComp === 'function') {
249
- content = rawComp.call(this, vnode);
254
+ if (comp && typeof comp.view === 'function') {
255
+ content = comp.view.call(this, vnode);
256
+ } else if (typeof comp === 'function') {
257
+ content = comp.call(this, vnode);
250
258
  } else {
251
- content = rawComp;
259
+ content = comp;
252
260
  }
253
261
  if (content && (content.tag === Layout || (content.tag && content.tag.name === 'Layout'))) {
254
262
  return content;
@@ -265,7 +265,20 @@ function registerApiRoutes(moduleId, apiConfig, deps) {
265
265
  const useAuth = route.auth !== undefined ? route.auth : defaultAuth;
266
266
  const authMiddleware = useAuth ? requireAuth : optionalAuth;
267
267
 
268
- ctx.addRoute(method, fullPath, authMiddleware, route.handler);
268
+ const safeHandler = async (req, res, next) => {
269
+ try {
270
+ await route.handler(req, res, next);
271
+ } catch (err) {
272
+ if (typeof next === 'function') {
273
+ next(err);
274
+ } else {
275
+ throw err;
276
+ }
277
+ }
278
+ };
279
+ safeHandler._originalHandler = route.handler;
280
+
281
+ ctx.addRoute(method, fullPath, authMiddleware, safeHandler);
269
282
  }
270
283
  }
271
284
 
@@ -34,9 +34,11 @@ function generateAuditLogComponent(options = {}) {
34
34
  rows = res.data || [];
35
35
  total = (res.meta && res.meta.total) || 0;
36
36
  loading = false;
37
+ if (typeof m !== 'undefined' && m.redraw) m.redraw();
37
38
  }).catch(function(e) {
38
39
  error = e.message || String(e);
39
40
  loading = false;
41
+ if (typeof m !== 'undefined' && m.redraw) m.redraw();
40
42
  });
41
43
  }
42
44