waibu-mpa 1.1.21 → 1.1.23

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.
@@ -43,7 +43,7 @@ class Wmpa {
43
43
  },
44
44
  nautical: {
45
45
  speedFn: (val) => val / 1.852,
46
- speedUnit: 'nmh',
46
+ speedUnit: 'knot',
47
47
  distanceFn: (val) => val / 1.852,
48
48
  distanceUnit: 'nm',
49
49
  areaFn: (val) => val / 2.92,
package/lib/build-page.js CHANGED
@@ -13,10 +13,18 @@ function alert (text, message, opts = {}) {
13
13
  return `${text}\n${error}`
14
14
  }
15
15
 
16
+ const reqAsset = {}
17
+
16
18
  async function buildPage ({ text, locals = {}, opts = {} } = {}) {
17
19
  const { find, cloneDeep } = this.lib._
18
20
  const { runHook } = this.app.bajo
19
21
  const { req, reply } = opts
22
+ if (!reqAsset[req.id]) {
23
+ reqAsset[req.id] = {
24
+ scriptBlock: { root: [] },
25
+ styleBlock: { root: [] }
26
+ }
27
+ }
20
28
  const theme = find(this.themes, { name: opts.theme })
21
29
  if (!theme) text = alert.call(this, text, req.t('unknownTheme%s', req.theme), opts)
22
30
  const iconset = find(this.iconsets, { name: opts.iconset })
@@ -26,7 +34,7 @@ async function buildPage ({ text, locals = {}, opts = {} } = {}) {
26
34
  if (partial) $('c\\:page-start, c\\:page-end').remove()
27
35
  await runHook(`${this.name}:beforeBuildPage${partial ? 'Partial' : ''}`, { $, theme, iconset, req, reply, locals, ns, text })
28
36
  await attrsMutation.call(this, { $, el: $.root(), req })
29
- const cmp = await theme.createComponent({ $, iconset, req, reply, locals: cloneDeep(locals) })
37
+ const cmp = await theme.createComponent({ $, iconset, req, reply, locals: cloneDeep(locals), scriptBlock: reqAsset[req.id].scriptBlock, styleBlock: reqAsset[req.id].styleBlock })
30
38
  await replaceTag.call(this, { el: $.root(), cmp, opts })
31
39
  text = applyInclude.call(this, $)
32
40
  if (!opts.partial) {
@@ -36,6 +44,7 @@ async function buildPage ({ text, locals = {}, opts = {} } = {}) {
36
44
  await concatResources.call(this, { $, theme, iconset, req })
37
45
  await runHook(`${this.name}:afterBuildPage`, { $, theme, iconset, req, reply, locals, ns, text })
38
46
  text = $.root().html()
47
+ delete reqAsset[req.id]
39
48
  }
40
49
  return text
41
50
  }
@@ -16,7 +16,7 @@ class Component {
16
16
  * @param {Object} options.reply - The reply object.
17
17
  * @param {Object} options.req - The request object.
18
18
  */
19
- constructor ({ plugin, $, theme, iconset, locals, reply, req } = {}) {
19
+ constructor ({ plugin, $, theme, iconset, locals, reply, req, scriptBlock, styleBlock } = {}) {
20
20
  const { get } = plugin.app.bajo.lib._
21
21
  this.baseFactory = baseFactory
22
22
  this.plugin = plugin
@@ -29,8 +29,8 @@ class Component {
29
29
  this.cacheMaxAge = get(plugin, 'app.waibuMpa.config.theme.component.cacheMaxAgeDur', 0)
30
30
  this.namespace = 'c:'
31
31
  this.noTags = []
32
- this.scriptBlock = { root: [] }
33
- this.styleBlock = { root: [] }
32
+ this.scriptBlock = scriptBlock
33
+ this.styleBlock = styleBlock
34
34
  this.factory = {}
35
35
  }
36
36
 
@@ -18,7 +18,7 @@ class Theme {
18
18
  return find(this.plugin.app.waibuMpa.themes, { name: this.framework })
19
19
  }
20
20
 
21
- createComponent = async ($) => {}
21
+ createComponent = async (options) => {}
22
22
  }
23
23
 
24
24
  export default Theme
@@ -40,8 +40,8 @@ async function build (mod, fw) {
40
40
  Object.assign(theme, omit(mod, ['name']))
41
41
  await loadItems.call(mod.plugin, 'factory', theme)
42
42
  await loadItems.call(mod.plugin, 'method', theme)
43
- theme.createComponent = async function ({ $, iconset, req, reply, locals }) {
44
- const cmp = new Component({ plugin: fw ? fw.plugin : mod.plugin, $, theme, iconset, req, reply, locals })
43
+ theme.createComponent = async function ({ $, iconset, req, reply, locals, scriptBlock, styleBlock }) {
44
+ const cmp = new Component({ plugin: fw ? fw.plugin : mod.plugin, $, theme, iconset, req, reply, locals, scriptBlock, styleBlock })
45
45
  await cmp.loadBaseFactories()
46
46
  const framework = theme.framework ? find(me.themes, { name: theme.framework }) : undefined
47
47
  merge(cmp.factory, framework ? framework.factory : theme.factory)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "waibu-mpa",
3
- "version": "1.1.21",
3
+ "version": "1.1.23",
4
4
  "description": "MPA support for Waibu Framework",
5
5
  "main": "index.js",
6
6
  "scripts": {