waibu-mpa 2.17.0 → 2.18.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.
- package/lib/build-routes.js +7 -5
- package/lib/class/component.js +2 -2
- package/lib/class/widget.js +1 -0
- package/package.json +1 -1
- package/wiki/CHANGES.md +9 -0
package/lib/build-routes.js
CHANGED
|
@@ -3,7 +3,7 @@ import path from 'path'
|
|
|
3
3
|
export async function build ({ files, pathPrefix, dir, ns, cfg, parent, urlPrefix, subRoute }) {
|
|
4
4
|
const { defaultsDeep, parseObject } = this.app.lib.aneka
|
|
5
5
|
const { importModule, readJson } = this.app.bajo
|
|
6
|
-
const { isFunction, isPlainObject, pick, last, camelCase, omit } = this.app.lib._
|
|
6
|
+
const { isFunction, isPlainObject, pick, last, camelCase, omit, trimEnd } = this.app.lib._
|
|
7
7
|
const { titleize } = this.app.lib.aneka
|
|
8
8
|
const { getPluginPrefix } = this.app.waibu
|
|
9
9
|
const mergeRouteHooks = await importModule('waibu:/lib/webapp-scope/merge-route-hooks.js')
|
|
@@ -11,7 +11,9 @@ export async function build ({ files, pathPrefix, dir, ns, cfg, parent, urlPrefi
|
|
|
11
11
|
const me = this
|
|
12
12
|
for (const f of files) {
|
|
13
13
|
const ext = path.extname(f)
|
|
14
|
-
const
|
|
14
|
+
const urls = f.slice(0, f.length - ext.length).replace(`${dir}/extend/${pathPrefix}`, '').replaceAll('@', ':').split('/')
|
|
15
|
+
if (last(urls) === 'index') urls.pop()
|
|
16
|
+
const url = urls.join('/')
|
|
15
17
|
let mod
|
|
16
18
|
if (ext === '.js') mod = await importModule(f)
|
|
17
19
|
else if (ext === '.json') mod = await readJson(f)
|
|
@@ -21,11 +23,10 @@ export async function build ({ files, pathPrefix, dir, ns, cfg, parent, urlPrefi
|
|
|
21
23
|
else if (isPlainObject(mod)) mod = [mod]
|
|
22
24
|
for (let m of mod) {
|
|
23
25
|
const mhandler = m.handler // parseObject has problem with function
|
|
24
|
-
const murl = m.url
|
|
26
|
+
const murl = m.url // same as above
|
|
25
27
|
m = parseObject(omit(m, ['handler', 'url'], { parseValue: true }))
|
|
26
|
-
m.handler = mhandler
|
|
27
28
|
m.url = murl
|
|
28
|
-
|
|
29
|
+
m.handler = mhandler
|
|
29
30
|
m.url = m.url ?? url
|
|
30
31
|
if (isFunction(m.url)) m.url = await m.url.call(this)
|
|
31
32
|
if (m.redirect) {
|
|
@@ -45,6 +46,7 @@ export async function build ({ files, pathPrefix, dir, ns, cfg, parent, urlPrefi
|
|
|
45
46
|
}
|
|
46
47
|
}
|
|
47
48
|
if (urlPrefix) m.url = `/${urlPrefix}/${m.url}`
|
|
49
|
+
m.url = trimEnd(m.url, '/')
|
|
48
50
|
m.method = m.method ?? 'GET'
|
|
49
51
|
await mergeRouteHooks.call(me, m)
|
|
50
52
|
m.config = m.config ?? {}
|
package/lib/class/component.js
CHANGED
|
@@ -115,12 +115,12 @@ async function componentFactory () {
|
|
|
115
115
|
params.attr.class = without(uniq(params.attr.class), undefined, null, '')
|
|
116
116
|
if (isEmpty(params.attr.class)) delete params.attr.class
|
|
117
117
|
if (isEmpty(params.attr.style)) delete params.attr.style
|
|
118
|
-
if (isEmpty(params.html)) return await this.render(params)
|
|
118
|
+
if (isEmpty(params.html)) return await this.render(params, opts)
|
|
119
119
|
|
|
120
120
|
const merged = merge({}, params.locals, { attr: params.attr })
|
|
121
121
|
const result = await compile(params.html, merged, { ttl: this.ttlDur })
|
|
122
122
|
params.html = result
|
|
123
|
-
return await this.render(params)
|
|
123
|
+
return await this.render(params, opts)
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
/**
|
package/lib/class/widget.js
CHANGED
|
@@ -26,6 +26,7 @@ async function widgetFactory () {
|
|
|
26
26
|
this.formData = get(this, `component.locals.${this.params.attr.keyLocals ?? 'form'}`, {})
|
|
27
27
|
this.oldData = get(this, `component.locals.${this.params.attr.keyOldData ?? 'oldData'}`, {})
|
|
28
28
|
this.schema = get(this, `component.locals.${this.params.attr.keySchema ?? 'schema'}`, {})
|
|
29
|
+
if (this.schema.name) this.model = this.app.dobo.getModel(this.schema.name)
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
_parseBase64Attr = (text, defValue = {}) => {
|
package/package.json
CHANGED
package/wiki/CHANGES.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changes
|
|
2
2
|
|
|
3
|
+
## 2026-06-03
|
|
4
|
+
|
|
5
|
+
- [2.18.0] Populate ```widget.model``` if available
|
|
6
|
+
- [2.18.0] If route's url ends with ```index```, rewrite url to use it's folder instead
|
|
7
|
+
|
|
8
|
+
## 2026-06-01
|
|
9
|
+
|
|
10
|
+
- [2.17.1] Bug fix in ```component.buildTag()```
|
|
11
|
+
|
|
3
12
|
## 2026-05-28
|
|
4
13
|
|
|
5
14
|
- [2.17.0] Change hooks to be written in one ```hook.js``` file
|