@mpxjs/webpack-plugin 2.6.114-alpha.6 → 2.6.115

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.
Files changed (43) hide show
  1. package/README.md +1 -1
  2. package/lib/config.js +0 -14
  3. package/lib/dependency/ResolveDependency.js +0 -4
  4. package/lib/index.js +5 -57
  5. package/lib/json-compiler/index.js +0 -3
  6. package/lib/loader.js +4 -44
  7. package/lib/path-loader.js +1 -4
  8. package/lib/platform/template/wx/component-config/button.js +2 -14
  9. package/lib/platform/template/wx/component-config/image.js +0 -4
  10. package/lib/platform/template/wx/component-config/input.js +0 -4
  11. package/lib/platform/template/wx/component-config/rich-text.js +0 -4
  12. package/lib/platform/template/wx/component-config/scroll-view.js +0 -4
  13. package/lib/platform/template/wx/component-config/switch.js +0 -4
  14. package/lib/platform/template/wx/component-config/text.js +0 -4
  15. package/lib/platform/template/wx/component-config/textarea.js +0 -5
  16. package/lib/platform/template/wx/component-config/view.js +0 -4
  17. package/lib/platform/template/wx/index.js +1 -121
  18. package/lib/runtime/components/web/getInnerListeners.js +3 -1
  19. package/lib/style-compiler/index.js +1 -1
  20. package/lib/template-compiler/compiler.js +2 -11
  21. package/lib/template-compiler/trans-dynamic-class-expr.js +1 -1
  22. package/package.json +3 -8
  23. package/LICENSE +0 -433
  24. package/lib/dependency/AddEntryDependency.js +0 -24
  25. package/lib/runtime/components/tenon/getInnerListeners.js +0 -317
  26. package/lib/runtime/components/tenon/tenon-button.vue +0 -305
  27. package/lib/runtime/components/tenon/tenon-image.vue +0 -61
  28. package/lib/runtime/components/tenon/tenon-input.vue +0 -99
  29. package/lib/runtime/components/tenon/tenon-rich-text.vue +0 -21
  30. package/lib/runtime/components/tenon/tenon-scroll-view.vue +0 -124
  31. package/lib/runtime/components/tenon/tenon-switch.vue +0 -91
  32. package/lib/runtime/components/tenon/tenon-text-area.vue +0 -64
  33. package/lib/runtime/components/tenon/tenon-text.vue +0 -64
  34. package/lib/runtime/components/tenon/tenon-view.vue +0 -93
  35. package/lib/runtime/components/tenon/util.js +0 -44
  36. package/lib/runtime/optionProcessor.tenon.js +0 -386
  37. package/lib/style-compiler/plugins/hm.js +0 -20
  38. package/lib/tenon/index.js +0 -108
  39. package/lib/tenon/processJSON.js +0 -361
  40. package/lib/tenon/processScript.js +0 -260
  41. package/lib/tenon/processStyles.js +0 -21
  42. package/lib/tenon/processTemplate.js +0 -133
  43. package/lib/utils/get-relative-path.js +0 -24
package/README.md CHANGED
@@ -13,6 +13,6 @@ module.exports = {
13
13
  new mpxWebpackPlugin({
14
14
  mode: 'wx'
15
15
  })
16
- ]
16
+ ],
17
17
  }
18
18
  ```
package/lib/config.js CHANGED
@@ -356,20 +356,6 @@ module.exports = {
356
356
  templatePrefix: 'module.exports = \n'
357
357
  }
358
358
  },
359
- tenon: {
360
- directive: {
361
- if: 'v-if',
362
- elseif: 'v-else-if',
363
- else: 'v-else'
364
- },
365
- wxs: {
366
- tag: 'wxs',
367
- module: 'module',
368
- src: 'src',
369
- ext: '.wxs',
370
- templatePrefix: 'module.exports = \n'
371
- }
372
- },
373
359
  qa: {
374
360
  typeExtMap: {
375
361
  json: '.json',
@@ -42,10 +42,6 @@ ResolveDependency.Template = class ResolveDependencyTemplate {
42
42
  if (!resolved) {
43
43
  dep.compilation.errors.push(new Error(`Path ${dep.resource} is not a page/component/static resource, which is resolved from ${dep.issuerResource}!`))
44
44
  }
45
- // for tenon
46
- if (dep.compilation.__mpx__.mode === 'tenon') {
47
- return `getRelativePath(currentURL, ${JSON.stringify(resolved)}) + '.js'`
48
- }
49
45
  return JSON.stringify(dep.publicPath + resolved)
50
46
  }
51
47
  }
package/lib/index.js CHANGED
@@ -7,7 +7,6 @@ const ResolveDependency = require('./dependency/ResolveDependency')
7
7
  const InjectDependency = require('./dependency/InjectDependency')
8
8
  const ReplaceDependency = require('./dependency/ReplaceDependency')
9
9
  const ChildCompileDependency = require('./dependency/ChildCompileDependency')
10
- const AddEntryDependency = require('./dependency/AddEntryDependency')
11
10
  const NullFactory = require('webpack/lib/NullFactory')
12
11
  const normalize = require('./utils/normalize')
13
12
  const toPosix = require('./utils/to-posix')
@@ -229,7 +228,7 @@ class MpxWebpackPlugin {
229
228
  let splitChunksPlugin
230
229
  let splitChunksOptions
231
230
 
232
- if (this.options.mode !== 'web' && this.options.mode !== 'tenon') {
231
+ if (this.options.mode !== 'web') {
233
232
  compiler.options.optimization.runtimeChunk = {
234
233
  name: (entrypoint) => {
235
234
  for (let packageName in mpx.independentSubpackagesMap) {
@@ -297,9 +296,6 @@ class MpxWebpackPlugin {
297
296
  compilation.dependencyFactories.set(ChildCompileDependency, new NullFactory())
298
297
  compilation.dependencyTemplates.set(ChildCompileDependency, new ChildCompileDependency.Template())
299
298
 
300
- compilation.dependencyFactories.set(AddEntryDependency, new NullFactory())
301
- compilation.dependencyTemplates.set(AddEntryDependency, new AddEntryDependency.Template())
302
-
303
299
  compilation.dependencyFactories.set(RemovedModuleDependency, normalModuleFactory)
304
300
  compilation.dependencyTemplates.set(RemovedModuleDependency, new RemovedModuleDependency.Template())
305
301
 
@@ -594,23 +590,6 @@ class MpxWebpackPlugin {
594
590
  const rawProcessModuleDependencies = compilation.processModuleDependencies
595
591
  compilation.processModuleDependencies = (module, callback) => {
596
592
  let proxyedCallback = callback
597
- if (module.__has_tenon_entry) {
598
- let tasks = []
599
- module.dependencies.forEach(dep => {
600
- if (dep instanceof AddEntryDependency) {
601
- tasks.push(new Promise(resolve => {
602
- compilation.addEntry(...dep.__addEntryParams, (err) => {
603
- resolve(err)
604
- })
605
- }))
606
- }
607
- })
608
- proxyedCallback = (error) => {
609
- Promise.all(tasks).then(errs => {
610
- callback(errs.filter(e => !!e)[0] || error)
611
- })
612
- }
613
- }
614
593
  if (module.rawRequest === mpx.appScriptRawRequest) {
615
594
  // 避免模块request重名,只对第一次匹配到的模块进行代理
616
595
  mpx.appScriptRawRequest = ''
@@ -837,27 +816,6 @@ class MpxWebpackPlugin {
837
816
  }
838
817
  })
839
818
 
840
- // processing for tenon-store
841
- if (mpx.mode === 'tenon') {
842
- let TENON_STORE_ID = 0
843
- parser.hooks.call.for('imported var').tap('MpxWebpackPlugin', (expr) => {
844
- if (['createStore', 'createStoreWithThis'].includes(expr.callee.name)) {
845
- const current = parser.state.current
846
- const storeOptions = expr.arguments.length && expr.arguments[0]
847
- if (storeOptions) {
848
- current.addDependency(new InjectDependency({
849
- content: 'Object.assign(',
850
- index: storeOptions.range[0]
851
- }))
852
- current.addDependency(new InjectDependency({
853
- content: `, { __store_id: ${TENON_STORE_ID++} })`,
854
- index: storeOptions.range[1]
855
- }))
856
- }
857
- }
858
- })
859
- }
860
-
861
819
  if (mpx.srcMode !== mpx.mode) {
862
820
  // 全量替换未声明的wx identifier
863
821
  parser.hooks.expression.for('wx').tap('MpxWebpackPlugin', transHandler)
@@ -906,6 +864,7 @@ class MpxWebpackPlugin {
906
864
  'set',
907
865
  'remove',
908
866
  'delete: del',
867
+ 'setConvertRule',
909
868
  'getMixin',
910
869
  'getComputed',
911
870
  'implement'
@@ -946,7 +905,7 @@ class MpxWebpackPlugin {
946
905
 
947
906
  // 为了正确生成sourceMap,将该步骤由原来的compile.hooks.emit迁移到compilation.hooks.optimizeChunkAssets中来
948
907
  compilation.hooks.optimizeChunkAssets.tapAsync('MpxWebpackPlugin', (chunks, callback) => {
949
- if (mpx.mode === 'web' || mpx.mode === 'tenon') return callback()
908
+ if (mpx.mode === 'web') return callback()
950
909
  const jsonpFunction = compilation.outputOptions.jsonpFunction
951
910
 
952
911
  function getTargetFile (file) {
@@ -1125,13 +1084,11 @@ try {
1125
1084
  if (data.loaders) {
1126
1085
  const { queryObj } = parseRequest(data.request)
1127
1086
  const mpxStyleOptions = queryObj.mpxStyleOptions
1128
- // todo 本套逻辑可能需要根据mode来提前判断以做编译优化
1129
1087
  const firstLoader = (data.loaders[0] && data.loaders[0].loader) || ''
1130
- const isPitcherRequest = firstLoader.includes('vue-loader/lib/loaders/pitcher.js') || firstLoader.includes('@hummer/tenon-loader/dist/pitcher.js')
1088
+ const isPitcherRequest = firstLoader.includes('vue-loader/lib/loaders/pitcher.js')
1131
1089
  let cssLoaderIndex = -1
1132
1090
  let vueStyleLoaderIndex = -1
1133
1091
  let mpxStyleLoaderIndex = -1
1134
- let tenonStyleLoaderIndex = -1
1135
1092
  data.loaders.forEach((loader, index) => {
1136
1093
  const currentLoader = loader.loader
1137
1094
  if (currentLoader.includes('ts-loader')) {
@@ -1142,20 +1099,11 @@ try {
1142
1099
  cssLoaderIndex = index
1143
1100
  } else if (currentLoader.includes('vue-loader/lib/loaders/stylePostLoader.js')) {
1144
1101
  vueStyleLoaderIndex = index
1145
- } else if (currentLoader.includes('@hummer/tenon-style-loader/dist/index.js')) {
1146
- tenonStyleLoaderIndex = index
1147
1102
  } else if (currentLoader.includes('@mpxjs/webpack-plugin/lib/style-compiler/index.js')) {
1148
1103
  mpxStyleLoaderIndex = index
1149
1104
  }
1150
1105
  })
1151
- if (mpx.mode === 'tenon' && mpxStyleLoaderIndex === -1) {
1152
- if (tenonStyleLoaderIndex > -1 && !isPitcherRequest) {
1153
- data.loaders.splice(tenonStyleLoaderIndex + 1, 0, {
1154
- loader: normalize.lib('style-compiler/index.js'),
1155
- options: (mpxStyleOptions && JSON.parse(mpxStyleOptions)) || {}
1156
- })
1157
- }
1158
- } else if (mpxStyleLoaderIndex === -1) {
1106
+ if (mpxStyleLoaderIndex === -1) {
1159
1107
  let loaderIndex = -1
1160
1108
  if (cssLoaderIndex > -1 && vueStyleLoaderIndex === -1) {
1161
1109
  loaderIndex = cssLoaderIndex
@@ -176,9 +176,6 @@ module.exports = function (raw = '{}') {
176
176
  if (!json.usingComponents) {
177
177
  json.usingComponents = {}
178
178
  }
179
- if (!json.component && mode === 'swan') {
180
- json.component = true
181
- }
182
179
  }
183
180
  } else if (componentsMap[resourcePath]) {
184
181
  // component
package/lib/loader.js CHANGED
@@ -12,7 +12,6 @@ const processJSON = require('./web/processJSON')
12
12
  const processScript = require('./web/processScript')
13
13
  const processStyles = require('./web/processStyles')
14
14
  const processTemplate = require('./web/processTemplate')
15
- const processForTenon = require('./tenon/index')
16
15
  const readJsonForSrc = require('./utils/read-json-for-src')
17
16
  const normalize = require('./utils/normalize')
18
17
  const getMainCompilation = require('./utils/get-main-compilation')
@@ -164,56 +163,16 @@ module.exports = function (content) {
164
163
  projectRoot
165
164
  })
166
165
 
167
- if (mode === 'tenon') {
168
- if (ctorType === 'app' && !queryObj.app) {
169
- const request = addQuery(this.resource, { app: true })
170
- output += `
171
- import App from ${stringifyRequest(request)}
172
- import * as Tenon from '@hummer/tenon-vue'
173
-
174
- Tenon.render(App)\n`
175
- // 直接结束loader进入parse
176
- this.loaderIndex = -1
177
- return callback(null, output)
178
- }
179
- if (ctorType === 'page' && queryObj.tenon) {
180
- console.log(resourcePath)
181
- const request = addQuery(resourcePath, { page: true })
182
- output += `
183
- import page from ${stringifyRequest(request)}
184
- import * as Tenon from '@hummer/tenon-vue'
185
-
186
- Tenon.render(page)\n`
187
- this.loaderIndex = -1
188
- return callback(null, output)
189
- }
190
- return processForTenon({
191
- mpx,
192
- loaderContext,
193
- isProduction,
194
- queryObj,
195
- filePath,
196
- parts,
197
- ctorType,
198
- autoScope,
199
- componentsMap,
200
- projectRoot,
201
- getRequireForSrc,
202
- vueContentCache,
203
- moduleId,
204
- callback
205
- })
206
- }
207
-
208
166
  // 处理mode为web时输出vue格式文件
209
167
  if (mode === 'web') {
210
168
  if (ctorType === 'app' && !queryObj.app) {
211
169
  const request = addQuery(this.resource, { app: true })
170
+ const el = mpx.webConfig.el || '#app'
212
171
  output += `
213
172
  import App from ${stringifyRequest(request)}
214
173
  import Vue from 'vue'
215
174
  new Vue({
216
- el: '#app',
175
+ el: '${el}',
217
176
  render: function(h){
218
177
  return h(App)
219
178
  }
@@ -342,7 +301,8 @@ module.exports = function (content) {
342
301
  // 注入构造函数
343
302
  let ctor = 'App'
344
303
  if (ctorType === 'page') {
345
- if (mpx.forceUsePageCtor || mode === 'ali') {
304
+ // swan也默认使用Page构造器
305
+ if (mpx.forceUsePageCtor || mode === 'ali' || mode === 'swan') {
346
306
  ctor = 'Page'
347
307
  } else {
348
308
  ctor = 'Component'
@@ -1,6 +1,3 @@
1
1
  module.exports = function () {
2
- return `
3
- var currentURL = global.currentPagePath
4
- var getRelativePath = require('@mpxjs/webpack-plugin/lib/utils/get-relative-path').getRelativePath
5
- module.exports = __mpx_resolve_path__(${JSON.stringify(this.resource)})`
2
+ return `module.exports = __mpx_resolve_path__(${JSON.stringify(this.resource)})`
6
3
  }
@@ -28,8 +28,6 @@ module.exports = function ({ print }) {
28
28
  const ttEventLog = print({ platform: 'bytedance', tag: TAG_NAME, isError: false, type: 'event' })
29
29
  const webPropLog = print({ platform: 'web', tag: TAG_NAME, isError: false })
30
30
  const webEventLog = print({ platform: 'web', tag: TAG_NAME, isError: false, type: 'event' })
31
- const tenonPropLog = print({ platform: 'tenon', tag: TAG_NAME, isError: false })
32
- const tenonEventLog = print({ platform: 'tenon', tag: TAG_NAME, isError: false, type: 'event' })
33
31
  const qaPropLog = print({ platform: 'qa', tag: TAG_NAME, isError: false })
34
32
  const wxPropValueLog = print({ platform: 'wx', tag: TAG_NAME, isError: false, type: 'value' })
35
33
 
@@ -39,10 +37,6 @@ module.exports = function ({ print }) {
39
37
  el.isBuiltIn = true
40
38
  return 'mpx-button'
41
39
  },
42
- tenon (tag, { el }) {
43
- el.isBuiltIn = true
44
- return 'tenon-button'
45
- },
46
40
  props: [
47
41
  {
48
42
  test: 'open-type',
@@ -137,18 +131,13 @@ module.exports = function ({ print }) {
137
131
  },
138
132
  {
139
133
  test: /^(open-type|lang|session-from|send-message-title|send-message-path|send-message-img|show-message-card|app-parameter)$/,
140
- web: webPropLog,
141
- tenon: tenonPropLog
134
+ web: webPropLog
142
135
  },
143
136
  {
144
137
  test: /^(size|type|plain|loading|form-type|hover-class|hover-stop-propagation|hover-start-time|hover-stay-time|use-built-in)$/,
145
138
  web (prop, { el }) {
146
139
  // todo 这部分能力基于内部封装实现
147
140
  el.isBuiltIn = true
148
- },
149
- tenon (prop, { el }) {
150
- // todo 这部分能力基于内部封装实现
151
- el.isBuiltIn = true
152
141
  }
153
142
  },
154
143
  {
@@ -185,8 +174,7 @@ module.exports = function ({ print }) {
185
174
  },
186
175
  {
187
176
  test: /^(getuserinfo|contact|error|launchapp|opensetting|getphonenumber)$/,
188
- web: webEventLog,
189
- tenon: tenonEventLog
177
+ web: webEventLog
190
178
  }
191
179
  ]
192
180
  }
@@ -13,10 +13,6 @@ module.exports = function ({ print }) {
13
13
  el.isBuiltIn = true
14
14
  return 'mpx-image'
15
15
  },
16
- tenon (tag, { el }) {
17
- el.isBuiltIn = true
18
- return 'tenon-image'
19
- },
20
16
  props: [
21
17
  {
22
18
  test: /^show-menu-by-longpress$/,
@@ -20,10 +20,6 @@ module.exports = function ({ print }) {
20
20
  el.isBuiltIn = true
21
21
  return 'mpx-input'
22
22
  },
23
- tenon (tag, { el }) {
24
- el.isBuiltIn = true
25
- return 'tenon-input'
26
- },
27
23
  props: [
28
24
  {
29
25
  test: /^(cursor-spacing|auto-focus|adjust-position|hold-keyboard)$/,
@@ -12,10 +12,6 @@ module.exports = function ({ print }) {
12
12
  el.isBuiltIn = true
13
13
  return 'mpx-rich-text'
14
14
  },
15
- tenon (tag, { el }) {
16
- el.isBuiltIn = true
17
- return 'tenon-rich-text'
18
- },
19
15
  props: [
20
16
  {
21
17
  test: /^(space)$/,
@@ -19,10 +19,6 @@ module.exports = function ({ print }) {
19
19
  el.isBuiltIn = true
20
20
  return 'mpx-scroll-view'
21
21
  },
22
- tenon (tag, { el }) {
23
- el.isBuiltIn = true
24
- return 'tenon-scroll-view'
25
- },
26
22
  props: [
27
23
  {
28
24
  test: /^(enable-flex|scroll-anchorin|refresher-enabled|refresher-threshold|refresher-default-style|refresher-background|refresher-triggered|enhanced|bounces|show-scrollbar|paging-enabled|fast-deceleratio)$/,
@@ -10,10 +10,6 @@ module.exports = function ({ print }) {
10
10
  el.isBuiltIn = true
11
11
  return 'mpx-switch'
12
12
  },
13
- tenon (tag, { el }) {
14
- el.isBuiltIn = true
15
- return 'tenon-switch'
16
- },
17
13
  props: [
18
14
  {
19
15
  test: /^type$/,
@@ -19,10 +19,6 @@ module.exports = function ({ print }) {
19
19
  return 'span'
20
20
  }
21
21
  },
22
- tenon (tag, { el }) {
23
- el.isBuiltIn = true
24
- return 'tenon-text'
25
- },
26
22
  props: [
27
23
  {
28
24
  test: /^(decode|user-select)$/,
@@ -22,11 +22,6 @@ module.exports = function ({ print }) {
22
22
  el.isBuiltIn = true
23
23
  return 'mpx-textarea'
24
24
  },
25
- tenon (tag, { el }) {
26
- // form全量使用内建组件
27
- el.isBuiltIn = true
28
- return 'tenon-textarea'
29
- },
30
25
  props: [
31
26
  {
32
27
  test: /^(auto-focus|fixed|cursor-spacing|cursor|show-confirm-bar|selection-start|selection-end|adjust-position|hold-keyboard|disable-default-padding|confirm-type)$/,
@@ -21,10 +21,6 @@ module.exports = function ({ print }) {
21
21
  return 'div'
22
22
  }
23
23
  },
24
- tenon (tag, { el }) {
25
- el.isBuiltIn = true
26
- return 'tenon-view'
27
- },
28
24
  qa (tag) {
29
25
  return 'div'
30
26
  },
@@ -10,7 +10,7 @@ const normalize = require('../../../utils/normalize')
10
10
 
11
11
  module.exports = function getSpec ({ warn, error }) {
12
12
  const spec = {
13
- supportedModes: ['ali', 'swan', 'qq', 'tt', 'web', 'qa', 'jd', 'dd', 'tenon'],
13
+ supportedModes: ['ali', 'swan', 'qq', 'tt', 'web', 'qa', 'jd', 'dd'],
14
14
  // props预处理
15
15
  preProps: [],
16
16
  // props后处理
@@ -24,15 +24,6 @@ module.exports = function getSpec ({ warn, error }) {
24
24
  value: parsed.result
25
25
  }
26
26
  }
27
- },
28
- tenon ({ name, value }) {
29
- const parsed = parseMustache(value)
30
- if (parsed.hasBinding) {
31
- return {
32
- name: name === 'animation' ? 'v-' + name : ':' + name,
33
- value: parsed.result
34
- }
35
- }
36
27
  }
37
28
  }
38
29
  ],
@@ -95,16 +86,6 @@ module.exports = function getSpec ({ warn, error }) {
95
86
  name: 'v-for',
96
87
  value: `(${itemName}, ${indexName}) in ${parsed.result}`
97
88
  }
98
- },
99
- tenon ({ value }, { el }) {
100
- const parsed = parseMustache(value)
101
- const attrsMap = el.attrsMap
102
- const itemName = attrsMap['wx:for-item'] || 'item'
103
- const indexName = attrsMap['wx:for-index'] || 'index'
104
- return {
105
- name: 'v-for',
106
- value: `(${itemName}, ${indexName}) in ${parsed.result}`
107
- }
108
89
  }
109
90
  },
110
91
  {
@@ -130,25 +111,6 @@ module.exports = function getSpec ({ warn, error }) {
130
111
  name: ':key',
131
112
  value
132
113
  }
133
- },
134
- tenon ({ value }, { el }) {
135
- // vue的template中不能包含key,对应于小程序中的block
136
- if (el.tag === 'block') return false
137
- const itemName = el.attrsMap['wx:for-item'] || 'item'
138
- const keyName = value
139
- if (value === '*this') {
140
- value = itemName
141
- } else {
142
- if (isValidIdentifierStr(keyName)) {
143
- value = `${itemName}.${keyName}`
144
- } else {
145
- value = `${itemName}['${keyName}']`
146
- }
147
- }
148
- return {
149
- name: ':key',
150
- value
151
- }
152
114
  }
153
115
  },
154
116
  {
@@ -159,9 +121,6 @@ module.exports = function getSpec ({ warn, error }) {
159
121
  },
160
122
  web () {
161
123
  return false
162
- },
163
- tenon () {
164
- return false
165
124
  }
166
125
  },
167
126
  {
@@ -204,49 +163,6 @@ module.exports = function getSpec ({ warn, error }) {
204
163
  }
205
164
  ]
206
165
  }
207
- },
208
- tenon ({ value }, { el }) {
209
- el.hasEvent = true
210
- const attrsMap = el.attrsMap
211
- const tagRE = /\{\{((?:.|\n|\r)+?)\}\}(?!})/
212
- const stringify = JSON.stringify
213
- const match = tagRE.exec(value)
214
- if (match) {
215
- const modelProp = attrsMap['wx:model-prop'] || 'value'
216
- const modelEvent = attrsMap['wx:model-event'] || 'input'
217
- const modelValuePathRaw = attrsMap['wx:model-value-path']
218
- const modelValuePath = modelValuePathRaw === undefined ? 'value' : modelValuePathRaw
219
- const modelFilter = attrsMap['wx:model-filter']
220
- let modelValuePathArr
221
- try {
222
- modelValuePathArr = JSON5.parse(modelValuePath)
223
- } catch (e) {
224
- if (modelValuePath === '') {
225
- modelValuePathArr = []
226
- } else {
227
- modelValuePathArr = modelValuePath.split('.')
228
- }
229
- }
230
- let modelValue = match[1].trim()
231
- return [
232
- {
233
- name: ':' + modelProp,
234
- value: modelValue
235
- },
236
- {
237
- name: 'mpxModelEvent',
238
- value: modelEvent
239
- },
240
- {
241
- name: 'mpxModelEventId',
242
- value: Math.random().toString(36).substr(3, 8)
243
- },
244
- {
245
- name: '@mpxModel',
246
- value: `__model(${stringifyWithResolveComputed(modelValue)}, $event, ${stringify(modelValuePathArr)}, ${stringify(modelFilter)})`
247
- }
248
- ]
249
- }
250
166
  }
251
167
  },
252
168
  {
@@ -275,14 +191,6 @@ module.exports = function getSpec ({ warn, error }) {
275
191
  name: ':' + dir,
276
192
  value: parsed.result
277
193
  }
278
- },
279
- tenon ({ name, value }) {
280
- const dir = this.test.exec(name)[1]
281
- const parsed = parseMustache(value)
282
- return {
283
- name: ':' + dir,
284
- value: parsed.result
285
- }
286
194
  }
287
195
  },
288
196
  // 通用指令
@@ -340,17 +248,6 @@ module.exports = function getSpec ({ warn, error }) {
340
248
  name: 'v-' + dir,
341
249
  value: parsed.result
342
250
  }
343
- },
344
- tenon ({ name, value }) {
345
- let dir = this.test.exec(name)[1]
346
- const parsed = parseMustache(value)
347
- if (dir === 'elif') {
348
- dir = 'else-if'
349
- }
350
- return {
351
- name: 'v-' + dir,
352
- value: parsed.result
353
- }
354
251
  }
355
252
  },
356
253
  // 事件
@@ -391,23 +288,6 @@ module.exports = function getSpec ({ warn, error }) {
391
288
  name: rPrefix + rEventName + meta.modifierStr,
392
289
  value
393
290
  }
394
- },
395
- tenon ({ name, value }, { eventRules, el }) {
396
- const match = this.test.exec(name)
397
- const prefix = match[1]
398
- const eventName = match[2]
399
- const modifierStr = match[3] || ''
400
- const meta = {
401
- modifierStr
402
- }
403
- // 记录event监听信息用于后续判断是否需要使用内置基础组件
404
- el.hasEvent = true
405
- const rPrefix = runRules(spec.event.prefix, prefix, { mode: 'web', meta })
406
- const rEventName = runRules(eventRules, eventName, { mode: 'web' })
407
- return {
408
- name: rPrefix + rEventName + meta.modifierStr,
409
- value
410
- }
411
291
  }
412
292
  },
413
293
  // 无障碍
@@ -1,5 +1,7 @@
1
1
  import { isEmptyObject } from './util'
2
- const isTouchDevice = 'ontouchstart' in document.documentElement
2
+ import { inBrowser } from '../../../utils/env'
3
+
4
+ const isTouchDevice = inBrowser && ('ontouchstart' in document.documentElement)
3
5
 
4
6
  function processModel (listeners, context) {
5
7
  // 该函数只有wx:model的情况下才调用,而且默认e.detail.value有值
@@ -29,7 +29,7 @@ module.exports = function (css, map) {
29
29
 
30
30
  const transRpxRules = transRpxRulesRaw ? (Array.isArray(transRpxRulesRaw) ? transRpxRulesRaw : [transRpxRulesRaw]) : []
31
31
 
32
- const transRpxFn = mpx.webConfig && mpx.webConfig.transRpxFn
32
+ const transRpxFn = mpx.webConfig.transRpxFn
33
33
  const testResolveRange = (include = () => true, exclude) => {
34
34
  return matchCondition(this.resourcePath, { include, exclude })
35
35
  }
@@ -2180,15 +2180,6 @@ function processElement (el, root, options, meta) {
2180
2180
  processComponentGenericsForWeb(el, options, meta)
2181
2181
  return
2182
2182
  }
2183
- if (mode === 'tenon') {
2184
- // 收集内建组件
2185
- processBuiltInComponents(el, meta)
2186
- // 预处理代码维度条件编译
2187
- processIfForWeb(el)
2188
- // processWebExternalClassesHack(el, options)
2189
- // processComponentGenericsForWeb(el, options, meta)
2190
- return
2191
- }
2192
2183
 
2193
2184
  const pass = isNative || processTemplate(el) || processingTemplate
2194
2185
 
@@ -2223,7 +2214,7 @@ function processElement (el, root, options, meta) {
2223
2214
 
2224
2215
  function closeElement (el, meta) {
2225
2216
  postProcessAtMode(el)
2226
- if (mode === 'web' || mode === 'tenon') {
2217
+ if (mode === 'web') {
2227
2218
  postProcessWxs(el, meta)
2228
2219
  // 处理代码维度条件编译移除死分支
2229
2220
  postProcessIf(el)
@@ -2330,7 +2321,7 @@ function serialize (root) {
2330
2321
  result += node.text
2331
2322
  }
2332
2323
  }
2333
- if (node.tag === 'wxs' && (mode === 'web' || mode === 'tenon')) {
2324
+ if (node.tag === 'wxs' && mode === 'web') {
2334
2325
  return result
2335
2326
  }
2336
2327
  if (node.type === 1) {
@@ -15,7 +15,7 @@ module.exports = function transDynamicClassExpr (expr, { error } = {}) {
15
15
  const propertyName = property.key.name || property.key.value
16
16
  if (/-/.test(propertyName)) {
17
17
  if (/\$/.test(propertyName)) {
18
- error && error(`Dynamic classname [${propertyName}] is not supported, which includes [-] char and [$] char at the same time.`)
18
+ error(`Dynamic classname [${propertyName}] is not supported, which includes [-] char and [$] char at the same time.`)
19
19
  } else {
20
20
  property.key = t.identifier(propertyName.replace(/-/g, '$$') + 'MpxDash')
21
21
  }