@mpxjs/webpack-plugin 2.8.48 → 2.8.49

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.
@@ -22,6 +22,7 @@ module.exports = function createJSONHelper ({ loaderContext, emitWarning, custom
22
22
 
23
23
  const isUrlRequest = r => isUrlRequestRaw(r, root, externals)
24
24
  const urlToRequest = r => loaderUtils.urlToRequest(r)
25
+ const isScript = ext => /\.(ts|js)$/.test(ext)
25
26
 
26
27
  const dynamicEntryMap = new Map()
27
28
 
@@ -73,7 +74,7 @@ module.exports = function createJSONHelper ({ loaderContext, emitWarning, custom
73
74
  const resourceName = path.join(parsed.dir, parsed.name)
74
75
 
75
76
  if (!outputPath) {
76
- if (ext === '.js' && resourceName.includes('node_modules') && mode !== 'web') {
77
+ if (isScript(ext) && resourceName.includes('node_modules') && mode !== 'web') {
77
78
  let root = info.descriptionFileRoot
78
79
  let name = 'nativeComponent'
79
80
  if (info.descriptionFileData) {
@@ -91,7 +92,7 @@ module.exports = function createJSONHelper ({ loaderContext, emitWarning, custom
91
92
  outputPath = getOutputPath(resourcePath, 'component')
92
93
  }
93
94
  }
94
- if (ext === '.js' && mode !== 'web') {
95
+ if (isScript(ext) && mode !== 'web') {
95
96
  resource = `!!${nativeLoaderPath}!${resource}`
96
97
  }
97
98
 
@@ -131,7 +132,7 @@ module.exports = function createJSONHelper ({ loaderContext, emitWarning, custom
131
132
  outputPath = /^(.*?)(\.[^.]*)?$/.exec(relative)[1]
132
133
  }
133
134
  }
134
- if (ext === '.js' && mode !== 'web') {
135
+ if (isScript(ext) && mode !== 'web') {
135
136
  resource = `!!${nativeLoaderPath}!${resource}`
136
137
  }
137
138
  const entry = getDynamicEntry(resource, 'page', outputPath, tarRoot, publicPath + tarRoot)
@@ -8,7 +8,7 @@ const async = require('async')
8
8
  const { matchCondition } = require('./utils/match-condition')
9
9
  const { JSON_JS_EXT } = require('./utils/const')
10
10
  const getRulesRunner = require('./platform')
11
-
11
+ // todo native-loader考虑与mpx-loader或加强复用,原生组件约等于4个区块都为src的.mpx文件
12
12
  module.exports = function (content) {
13
13
  this.cacheable()
14
14
 
@@ -44,6 +44,8 @@ module.exports = function (content) {
44
44
  scss: '.scss'
45
45
  }
46
46
 
47
+ const TS_EXT = '.ts'
48
+
47
49
  let useJSONJS = false
48
50
  let cssLang = ''
49
51
  const hasScoped = (queryObj.scoped || autoScope) && mode === 'ali'
@@ -54,7 +56,7 @@ module.exports = function (content) {
54
56
  this.resolve(parsed.dir, resourceName + extName, callback)
55
57
  }
56
58
 
57
- function checkCSSLangFiles (callback) {
59
+ function checkCSSLangFile (callback) {
58
60
  const langs = mpx.nativeConfig.cssLangs || ['less', 'stylus', 'scss', 'sass']
59
61
  const results = []
60
62
  async.eachOf(langs, function (lang, i, callback) {
@@ -89,6 +91,15 @@ module.exports = function (content) {
89
91
  })
90
92
  }
91
93
 
94
+ function checkTSFile (callback) {
95
+ checkFileExists(TS_EXT, (err, result) => {
96
+ if (!err && result) {
97
+ typeResourceMap.script = result
98
+ }
99
+ callback()
100
+ })
101
+ }
102
+
92
103
  const emitWarning = (msg) => {
93
104
  this.emitWarning(
94
105
  new Error('[native-loader][' + this.resource + ']: ' + msg)
@@ -105,15 +116,16 @@ module.exports = function (content) {
105
116
  async.waterfall([
106
117
  (callback) => {
107
118
  async.parallel([
108
- checkCSSLangFiles,
109
- checkJSONJSFile
119
+ checkCSSLangFile,
120
+ checkJSONJSFile,
121
+ checkTSFile
110
122
  ], (err) => {
111
123
  callback(err)
112
124
  })
113
125
  },
114
126
  (callback) => {
115
127
  async.forEachOf(typeExtMap, (ext, key, callback) => {
116
- // 检测到jsonjs或cssLang时跳过对应类型文件检测
128
+ // 对应资源存在预处理类型文件时跳过对应的标准文件检测
117
129
  if (typeResourceMap[key]) {
118
130
  return callback()
119
131
  }
@@ -70,6 +70,19 @@ module.exports = function getSpec ({ warn, error }) {
70
70
  return input
71
71
  }
72
72
 
73
+ // 校验输出支付宝 componentGenerics 配置的正确性
74
+ function aliComponentGenericsValidate (input) {
75
+ const componentGenerics = input.componentGenerics
76
+ if (componentGenerics && typeof componentGenerics === 'object') {
77
+ Object.keys(componentGenerics).forEach(key => {
78
+ if (!componentGenerics[key].default) {
79
+ error(`Ali environment componentGenerics need to specify a default custom component! please check the configuration of component ${key}`)
80
+ }
81
+ })
82
+ }
83
+ return input
84
+ }
85
+
73
86
  function fillGlobalComponents (input, { globalComponents }) {
74
87
  if (globalComponents) {
75
88
  Object.assign(globalComponents, input.usingComponents)
@@ -115,7 +128,7 @@ module.exports = function getSpec ({ warn, error }) {
115
128
  const componentRules = [
116
129
  {
117
130
  test: 'componentGenerics',
118
- ali: deletePath(true)
131
+ ali: aliComponentGenericsValidate
119
132
  },
120
133
  {
121
134
  test: 'componentPlaceholder',
@@ -144,20 +144,8 @@ export function inheritEvent (type, oe, detail = {}) {
144
144
  }
145
145
 
146
146
  export function getCustomEvent (type, detail = {}, target = null) {
147
- const targetInfo = {}
148
- if (target) {
149
- const targetEl = target.$el || {}
150
- const info = {
151
- id: targetEl.id || '',
152
- dataset: targetEl.dataset || {},
153
- offsetTop: targetEl.offsetTop || 0,
154
- offsetLeft: targetEl.offsetLeft || 0
155
- }
156
- Object.assign(targetInfo, {
157
- target: info,
158
- currentTarget: info
159
- })
160
- }
147
+ const targetEl = (target && target.$el) || null
148
+ const targetInfo = targetEl ? { target: targetEl, currentTarget: targetEl } : {}
161
149
  return {
162
150
  type,
163
151
  detail,
@@ -1,13 +1,13 @@
1
1
  <template>
2
- <div class="mpx-movable-scroll-content" ref="scrollContent">
3
- <div class="mpx-movable-scroll-item">
4
- <slot></slot>
5
- </div>
2
+ <div class="mpx-movable-scroll-content" ref="scrollContent">
3
+ <div class="mpx-movable-scroll-item">
4
+ <slot></slot>
6
5
  </div>
6
+ </div>
7
7
  </template>
8
8
 
9
9
  <script type="text/ecmascript-6">
10
- import {getCustomEvent} from './getInnerListeners'
10
+ import {getCustomEvent, extendEvent} from './getInnerListeners'
11
11
  import BScroll from '@better-scroll/core'
12
12
  import Movable from '@better-scroll/movable'
13
13
  import Zoom from '@better-scroll/zoom'
@@ -121,6 +121,13 @@
121
121
  newVal = 0.5
122
122
  }
123
123
  this.bs.zoomTo(newVal, 'center', 'center')
124
+ },
125
+ disabled (newVal) {
126
+ if (newVal) {
127
+ this.bs && this.bs.disable()
128
+ } else {
129
+ this.bs && this.bs.enable()
130
+ }
124
131
  }
125
132
  },
126
133
  mounted () {
@@ -204,6 +211,14 @@
204
211
  this.bs.movingDirectionY = -1
205
212
  }
206
213
  })
214
+ actionsHandlerHooks.on('start', (e) => {
215
+ extendEvent(e, { detail: Object.assign({}, e.detail) })
216
+ this.$emit('touchstart', e)
217
+ })
218
+ actionsHandlerHooks.on('end', (e) => {
219
+ extendEvent(e, { detail: Object.assign({}, e.detail) })
220
+ this.$emit('touchend', e)
221
+ })
207
222
  actionsHandlerHooks.on('move', ({ deltaX, deltaY, e }) => {
208
223
  if (this.isZooming) {
209
224
  return
@@ -215,7 +230,9 @@
215
230
  this.touchEvent = 'vtouchmove'
216
231
  }
217
232
  }
218
- this.$emit(this.touchEvent, getCustomEvent(this.touchEvent, {}, this))
233
+ extendEvent(e, { detail: Object.assign({}, e.detail), currentTarget: e.target })
234
+ this.$emit(this.touchEvent, e)
235
+ this.$emit('touchmove', e)
219
236
  this.isFirstTouch = false
220
237
  })
221
238
  if (this.inertia) { // movable-view是否带有惯性
@@ -302,7 +319,9 @@
302
319
  }
303
320
  </script>
304
321
  <style lang="stylus" rel="stylesheet/stylus" scoped>
305
- .mpx-movable-scroll-content {
306
- position: absolute
307
- }
322
+ .mpx-movable-scroll-content
323
+ position: absolute
324
+ .mpx-movable-scroll-item
325
+ width: 100%
326
+ height: 100%
308
327
  </style>
@@ -163,7 +163,7 @@
163
163
  height: 100%
164
164
  overflow: hidden
165
165
  text-align: center
166
- font-size: 14px
166
+ font-size: 16px
167
167
  position: relative
168
168
 
169
169
  &.mpx-picker-fade-enter, &.mpx-picker-fade-leave-active
@@ -264,10 +264,9 @@
264
264
  },
265
265
  initLayerComputed () {
266
266
  const wrapper = this.$refs.wrapper
267
- const wrapperWidth = wrapper.offsetWidth
268
- const wrapperHeight = wrapper.offsetHeight
269
- this.$refs.innerWrapper.style.width = `${wrapperWidth}px`
270
- this.$refs.innerWrapper.style.height = `${wrapperHeight}px`
267
+ const computedStyle = getComputedStyle(wrapper)
268
+ this.$refs.innerWrapper.style.width = `${computedStyle.clientWidth - parseInt(computedStyle.paddingLeft) - parseInt(computedStyle.paddingRight)}px`
269
+ this.$refs.innerWrapper.style.height = `${computedStyle.clientHeight - parseInt(computedStyle.paddingTop) - parseInt(computedStyle.paddingBottom)}px`
271
270
  const innerWrapper = this.$refs.innerWrapper
272
271
  const childrenArr = Array.from(innerWrapper.children)
273
272
 
@@ -146,6 +146,11 @@
146
146
  classList: ''
147
147
  }
148
148
  },
149
+ watch: {
150
+ muted (val) {
151
+ this.mutedCopy = val
152
+ }
153
+ },
149
154
  mounted () {
150
155
  this.initStyle()
151
156
  this.initEvent()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpxjs/webpack-plugin",
3
- "version": "2.8.48",
3
+ "version": "2.8.49",
4
4
  "description": "mpx compile core",
5
5
  "keywords": [
6
6
  "mpx"
@@ -29,7 +29,6 @@
29
29
  "@better-scroll/zoom": "^2.5.1",
30
30
  "acorn-walk": "^7.2.0",
31
31
  "async": "^2.6.0",
32
- "consolidate": "^0.15.1",
33
32
  "css": "^2.2.1",
34
33
  "css-selector-tokenizer": "^0.7.0",
35
34
  "cssnano": "^5.0.16",
@@ -82,5 +81,5 @@
82
81
  "engines": {
83
82
  "node": ">=14.14.0"
84
83
  },
85
- "gitHead": "4cbd364322aadc0e9727a0d852ca3ca1c8e0b1ca"
84
+ "gitHead": "b399e81951df7094fb0a494ae877bcf4e6a2985b"
86
85
  }
@@ -1,29 +0,0 @@
1
- // loader for pre-processing templates with e.g. pug
2
-
3
- const cons = require('consolidate')
4
- const loaderUtils = require('loader-utils')
5
-
6
- module.exports = function (content) {
7
- this.cacheable && this.cacheable()
8
- const callback = this.async()
9
- const opt = loaderUtils.getOptions(this) || {}
10
-
11
- if (!cons[opt.engine]) {
12
- return callback(new Error(
13
- 'Template engine \'' + opt.engine + '\' ' +
14
- 'isn\'t available in Consolidate.js'
15
- ))
16
- }
17
-
18
- const templateOption = opt.templateOption
19
-
20
- // for relative includes
21
- templateOption.filename = this.resourcePath
22
-
23
- cons[opt.engine].render(content, templateOption, function (err, html) {
24
- if (err) {
25
- return callback(err)
26
- }
27
- callback(null, html)
28
- })
29
- }