waibu-mpa 1.2.15 → 2.0.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/{waibu → extend/waibu}/boot.js +9 -9
- package/{waibuMpa → extend/waibuMpa}/route/wmpa.js +1 -1
- package/index.js +2 -2
- package/lib/build-routes.js +6 -5
- package/lib/class/base-factory.js +1 -0
- package/lib/collect-iconsets.js +2 -1
- package/lib/collect-themes.js +1 -1
- package/lib/collect-view-engines.js +2 -1
- package/lib/error.js +1 -1
- package/lib/load-resource.js +3 -1
- package/package.json +1 -1
- /package/{bajo → extend/bajo}/hook/dobo.wmpa-session@before-sanitize-schema.js +0 -0
- /package/{bajo → extend/bajo}/hook/waibu-mpa.theme@after-inject-scripts.js +0 -0
- /package/{bajo → extend/bajo}/hook/waibu-mpa@pre-parsing.js +0 -0
- /package/{bajo → extend/bajo}/intl/en-US.json +0 -0
- /package/{bajo → extend/bajo}/intl/id.json +0 -0
- /package/{bajoTemplate → extend/bajoTemplate}/layout/default.html +0 -0
- /package/{bajoTemplate → extend/bajoTemplate}/partial/404.html +0 -0
- /package/{bajoTemplate → extend/bajoTemplate}/partial/500.html +0 -0
- /package/{bajoTemplate → extend/bajoTemplate}/partial/tbd.html +0 -0
- /package/{bajoTemplate → extend/bajoTemplate}/partial/title.html +0 -0
- /package/{bajoTemplate → extend/bajoTemplate}/partial/welcome/title.id.md +0 -0
- /package/{bajoTemplate → extend/bajoTemplate}/partial/welcome/title.md +0 -0
- /package/{bajoTemplate → extend/bajoTemplate}/partial/welcome/warning.id.md +0 -0
- /package/{bajoTemplate → extend/bajoTemplate}/partial/welcome/warning.md +0 -0
- /package/{bajoTemplate → extend/bajoTemplate}/partial/welcome.html +0 -0
- /package/{bajoTemplate → extend/bajoTemplate}/partial/~sub-title.html +0 -0
- /package/{bajoTemplate → extend/bajoTemplate}/template/404.html +0 -0
- /package/{bajoTemplate → extend/bajoTemplate}/template/500.html +0 -0
- /package/{bajoTemplate → extend/bajoTemplate}/template/_500.html +0 -0
- /package/{bajoTemplate → extend/bajoTemplate}/template/tbd.html +0 -0
- /package/{bajoTemplate → extend/bajoTemplate}/template/welcome.html +0 -0
- /package/{bajoTemplate → extend/bajoTemplate}/template/wmpa.js +0 -0
- /package/{dobo → extend/dobo}/schema/session.json +0 -0
- /package/{waibuDb → extend/waibuDb}/schema/session.json +0 -0
- /package/{waibuMpa → extend/waibuMpa}/route/component/render.js +0 -0
- /package/{waibuMpa → extend/waibuMpa}/route/logo/@id.js +0 -0
- /package/{waibuMpa → extend/waibuMpa}/view-engine.js +0 -0
- /package/{waibuStatic → extend/waibuStatic}/virtual.json +0 -0
- /package/{plugin-method → method}/attribs/parse.js +0 -0
- /package/{plugin-method → method}/attribs/stringify.js +0 -0
- /package/{plugin-method → method}/html-tags.js +0 -0
- /package/{plugin-method → method}/iconset-mappings.js +0 -0
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import decorate from '
|
|
2
|
-
import buildRoutes from '
|
|
3
|
-
import collectViewEngines from '
|
|
4
|
-
import collectThemes from '
|
|
5
|
-
import collectIconsets from '
|
|
6
|
-
import handleSession from '
|
|
7
|
-
import subApp from '
|
|
8
|
-
import notFound from '
|
|
9
|
-
import error from '
|
|
1
|
+
import decorate from '../../lib/decorate.js'
|
|
2
|
+
import buildRoutes from '../../lib/build-routes.js'
|
|
3
|
+
import collectViewEngines from '../../lib/collect-view-engines.js'
|
|
4
|
+
import collectThemes from '../../lib/collect-themes.js'
|
|
5
|
+
import collectIconsets from '../../lib/collect-iconsets.js'
|
|
6
|
+
import handleSession from '../../lib/session/setup.js'
|
|
7
|
+
import subApp from '../../lib/sub-app.js'
|
|
8
|
+
import notFound from '../../lib/not-found.js'
|
|
9
|
+
import error from '../../lib/error.js'
|
|
10
10
|
|
|
11
11
|
const boot = {
|
|
12
12
|
level: 10,
|
|
@@ -5,7 +5,7 @@ const wmpa = {
|
|
|
5
5
|
const { get, trim } = this.lib._
|
|
6
6
|
const { getPluginPrefix } = this.app.waibu
|
|
7
7
|
const { importModule } = this.app.bajo
|
|
8
|
-
const { types: formatTypes, formats } = await importModule('bajo:/
|
|
8
|
+
const { types: formatTypes, formats } = await importModule('bajo:/lib/formats.js', { asDefaultImport: false })
|
|
9
9
|
const prefix = {
|
|
10
10
|
virtual: `/${getPluginPrefix('waibuStatic')}/${this.app.waibu.config.prefixVirtual}`,
|
|
11
11
|
asset: `/${getPluginPrefix('waibuStatic')}`,
|
package/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import minifier from 'html-minifier-terser'
|
|
|
5
5
|
async function factory (pkgName) {
|
|
6
6
|
const me = this
|
|
7
7
|
|
|
8
|
-
return class WaibuMpa extends this.lib.
|
|
8
|
+
return class WaibuMpa extends this.lib.Plugin {
|
|
9
9
|
constructor () {
|
|
10
10
|
super(pkgName, me.app)
|
|
11
11
|
this.alias = 'wmpa'
|
|
@@ -193,7 +193,7 @@ async function factory (pkgName) {
|
|
|
193
193
|
const subNses = ['layout', 'template', 'partial']
|
|
194
194
|
const { ns, path, subNs, subSubNs, qs } = this.app.bajo.breakNsPath(name)
|
|
195
195
|
const plugin = this.app.bajo.getPlugin(ns)
|
|
196
|
-
const dir = `${plugin.dir.pkg}/waibuMpa`
|
|
196
|
+
const dir = `${plugin.dir.pkg}/extend/waibuMpa`
|
|
197
197
|
if (!subNses.includes(subNs)) throw this.error('unknownResource%s', name)
|
|
198
198
|
const fullPath = subSubNs ? `${dir}/${subSubNs}/${subNs}${path}` : `${dir}/${subNs}${path}`
|
|
199
199
|
return { ns, subNs, subSubNs, path, qs, fullPath }
|
package/lib/build-routes.js
CHANGED
|
@@ -11,7 +11,7 @@ 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 url = f.slice(0, f.length - ext.length).replace(`${dir}/${pathPrefix}`, '').replaceAll('@', ':')
|
|
14
|
+
const url = f.slice(0, f.length - ext.length).replace(`${dir}/extend/${pathPrefix}`, '').replaceAll('@', ':')
|
|
15
15
|
let mod
|
|
16
16
|
if (ext === '.js') mod = await importModule(f)
|
|
17
17
|
else if (ext === '.json') mod = await readJson(f)
|
|
@@ -88,16 +88,17 @@ async function buildRoutes (ctx, prefix) {
|
|
|
88
88
|
const appCtxs = {}
|
|
89
89
|
let subRoutes = []
|
|
90
90
|
await runHook(`${this.name}:beforeBuildRoutes`, ctx)
|
|
91
|
-
await eachPlugins(async function ({ dir
|
|
91
|
+
await eachPlugins(async function ({ dir }) {
|
|
92
|
+
const { name: ns } = this
|
|
92
93
|
let appPrefix = getPluginPrefix(ns)
|
|
93
94
|
if (ns === me.ns || (ns === me.app.bajo.mainNs && cfg.mountMainAsRoot)) appPrefix = ''
|
|
94
|
-
const pattern = `${dir}/${pathPrefix}/**/*.{js,json,html,md}`
|
|
95
|
+
const pattern = `${dir}/extend/${pathPrefix}/**/*.{js,json,html,md}`
|
|
95
96
|
const files = await fastGlob(pattern)
|
|
96
97
|
// subRoutes
|
|
97
|
-
const spattern = `${dir}/waibuMpa/extend/{${me.app.bajo.pluginNames.join(',')}}/route/**/*.{js,json,html,md}`
|
|
98
|
+
const spattern = `${dir}/extend/waibuMpa/extend/{${me.app.bajo.pluginNames.join(',')}}/route/**/*.{js,json,html,md}`
|
|
98
99
|
const sfiles = await fastGlob(spattern)
|
|
99
100
|
for (const file of sfiles) {
|
|
100
|
-
const [sns] = file.replace(`${dir}/waibuMpa/extend/`, '').split('/')
|
|
101
|
+
const [sns] = file.replace(`${dir}/extend/waibuMpa/extend/`, '').split('/')
|
|
101
102
|
subRoutes.push({ file, ns: sns, sns: ns, dir })
|
|
102
103
|
}
|
|
103
104
|
if (files.length === 0) return undefined
|
|
@@ -9,6 +9,7 @@ class BaseFactory {
|
|
|
9
9
|
constructor (options = {}) {
|
|
10
10
|
this.component = options.component
|
|
11
11
|
this.plugin = this.component.plugin
|
|
12
|
+
this.app = this.plugin.app
|
|
12
13
|
this.params = options.params ?? {}
|
|
13
14
|
this.block = {}
|
|
14
15
|
this.setting = this._parseBase64Attr(this.params.attr.setting)
|
package/lib/collect-iconsets.js
CHANGED
|
@@ -13,7 +13,8 @@ async function collectIconsets (ctx) {
|
|
|
13
13
|
this.log.debug('collect%s', this.log.write('iconsets'))
|
|
14
14
|
const me = this
|
|
15
15
|
const all = []
|
|
16
|
-
await eachPlugins(async function ({ file
|
|
16
|
+
await eachPlugins(async function ({ file }) {
|
|
17
|
+
const { name: ns } = this
|
|
17
18
|
let mod = await importModule(file)
|
|
18
19
|
if (isFunction(mod)) mod = await mod.call(this, ctx)
|
|
19
20
|
if (!isArray(mod)) mod = [mod]
|
package/lib/collect-themes.js
CHANGED
|
@@ -19,7 +19,7 @@ async function loadItems (type, theme) {
|
|
|
19
19
|
|
|
20
20
|
const container = {}
|
|
21
21
|
// main
|
|
22
|
-
const files = await fastGlob(`${this.dir.pkg}/waibuMpa/theme/component/${type}/*.js`)
|
|
22
|
+
const files = await fastGlob(`${this.dir.pkg}/extend/waibuMpa/theme/component/${type}/*.js`)
|
|
23
23
|
for (const file of files) {
|
|
24
24
|
await addItem.call(this, { file, container })
|
|
25
25
|
}
|
|
@@ -6,7 +6,8 @@ async function collectViewEngines (ctx) {
|
|
|
6
6
|
this.viewEngines = []
|
|
7
7
|
this.log.debug('collect%s', 'view engines')
|
|
8
8
|
const me = this
|
|
9
|
-
await eachPlugins(async function ({ file
|
|
9
|
+
await eachPlugins(async function ({ file }) {
|
|
10
|
+
const { name: ns } = this
|
|
10
11
|
let mod = await importModule(file)
|
|
11
12
|
if (isFunction(mod)) mod = await mod.call(this, ctx)
|
|
12
13
|
if (!isArray(mod)) mod = [mod]
|
package/lib/error.js
CHANGED
|
@@ -25,7 +25,7 @@ const extHandler = async function (err, req, reply) {
|
|
|
25
25
|
} catch (err) {
|
|
26
26
|
// only getting here when there is error on view rendering
|
|
27
27
|
console.error(err)
|
|
28
|
-
const file = getPluginFile(`${this.name}:/bajoTemplate/template/_500.html`)
|
|
28
|
+
const file = getPluginFile(`${this.name}:/extend/bajoTemplate/template/_500.html`)
|
|
29
29
|
const content = fs.readFileSync(file)
|
|
30
30
|
const compiled = template(content)
|
|
31
31
|
result = compiled({ error: err })
|
package/lib/load-resource.js
CHANGED
|
@@ -9,7 +9,9 @@ async function loadResource (mod = [], item) {
|
|
|
9
9
|
for (const i in mod[item]) {
|
|
10
10
|
if (mod[item][i].startsWith('/')) items.push(mod.css[i])
|
|
11
11
|
else {
|
|
12
|
-
|
|
12
|
+
let name = mod[item][i]
|
|
13
|
+
if (['$', '^'].includes(name[0])) name = name.slice(1)
|
|
14
|
+
const { ns, path, subNs } = breakNsPath(name, undefined, false)
|
|
13
15
|
if (subNs === 'load') extItems.push({ ns, path })
|
|
14
16
|
else items.push(mod[item][i])
|
|
15
17
|
}
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|