@mpxjs/webpack-plugin 2.6.115 → 2.7.0-alpha

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 (129) hide show
  1. package/LICENSE +433 -0
  2. package/README.md +1 -1
  3. package/lib/config.js +14 -0
  4. package/lib/dependencies/AddEntryDependency.js +24 -0
  5. package/lib/dependencies/AppEntryDependency.js +58 -0
  6. package/lib/dependencies/CommonJsAsyncDependency.js +51 -0
  7. package/lib/dependencies/CommonJsVariableDependency.js +81 -0
  8. package/lib/dependencies/DynamicEntryDependency.js +171 -0
  9. package/lib/dependencies/FlagPluginDependency.js +24 -0
  10. package/lib/dependencies/InjectDependency.js +43 -0
  11. package/lib/dependencies/RecordGlobalComponentsDependency.js +50 -0
  12. package/lib/dependencies/RecordIndependentDependency.js +44 -0
  13. package/lib/dependencies/RecordResourceMapDependency.js +62 -0
  14. package/lib/dependencies/RemoveEntryDependency.js +40 -0
  15. package/lib/{dependency → dependencies}/ReplaceDependency.js +19 -2
  16. package/lib/dependencies/ResolveDependency.js +88 -0
  17. package/lib/extractor.js +82 -178
  18. package/lib/file-loader.js +7 -19
  19. package/lib/helpers.js +39 -334
  20. package/lib/independent-loader.js +52 -0
  21. package/lib/index.js +889 -525
  22. package/lib/json-compiler/helper.js +156 -0
  23. package/lib/json-compiler/index.js +245 -451
  24. package/lib/json-compiler/plugin.js +150 -0
  25. package/lib/json-compiler/{theme-loader.js → theme.js} +5 -3
  26. package/lib/loader.js +178 -241
  27. package/lib/native-loader.js +71 -133
  28. package/lib/parser.js +1 -2
  29. package/lib/partial-compile/index.js +35 -0
  30. package/lib/platform/json/wx/index.js +1 -1
  31. package/lib/platform/template/normalize-component-rules.js +2 -3
  32. package/lib/platform/template/wx/component-config/button.js +14 -2
  33. package/lib/platform/template/wx/component-config/image.js +4 -0
  34. package/lib/platform/template/wx/component-config/input.js +4 -0
  35. package/lib/platform/template/wx/component-config/rich-text.js +4 -0
  36. package/lib/platform/template/wx/component-config/scroll-view.js +4 -0
  37. package/lib/platform/template/wx/component-config/switch.js +4 -0
  38. package/lib/platform/template/wx/component-config/text.js +4 -0
  39. package/lib/platform/template/wx/component-config/textarea.js +5 -0
  40. package/lib/platform/template/wx/component-config/view.js +4 -0
  41. package/lib/platform/template/wx/index.js +149 -3
  42. package/lib/record-loader.js +11 -0
  43. package/lib/resolve-loader.js +6 -0
  44. package/lib/resolver/AddEnvPlugin.js +4 -3
  45. package/lib/resolver/AddModePlugin.js +4 -3
  46. package/lib/resolver/FixDescriptionInfoPlugin.js +28 -0
  47. package/lib/resolver/PackageEntryPlugin.js +23 -36
  48. package/lib/runtime/base.styl +5 -0
  49. package/lib/runtime/components/tenon/getInnerListeners.js +317 -0
  50. package/lib/runtime/components/tenon/tenon-button.vue +305 -0
  51. package/lib/runtime/components/tenon/tenon-image.vue +61 -0
  52. package/lib/runtime/components/tenon/tenon-input.vue +99 -0
  53. package/lib/runtime/components/tenon/tenon-rich-text.vue +21 -0
  54. package/lib/runtime/components/tenon/tenon-scroll-view.vue +124 -0
  55. package/lib/runtime/components/tenon/tenon-switch.vue +91 -0
  56. package/lib/runtime/components/tenon/tenon-text-area.vue +64 -0
  57. package/lib/runtime/components/tenon/tenon-text.vue +64 -0
  58. package/lib/runtime/components/tenon/tenon-view.vue +93 -0
  59. package/lib/runtime/components/tenon/util.js +44 -0
  60. package/lib/runtime/components/web/getInnerListeners.js +1 -3
  61. package/lib/runtime/components/web/mpx-image.vue +20 -5
  62. package/lib/runtime/components/web/mpx-movable-view.vue +6 -2
  63. package/lib/runtime/components/web/mpx-swiper.vue +18 -3
  64. package/lib/runtime/i18n.wxs +31 -11
  65. package/lib/runtime/optionProcessor.js +48 -3
  66. package/lib/runtime/optionProcessor.tenon.js +386 -0
  67. package/lib/selector.js +29 -10
  68. package/lib/style-compiler/index.js +16 -24
  69. package/lib/style-compiler/load-postcss-config.js +3 -1
  70. package/lib/style-compiler/plugins/conditional-strip.js +68 -65
  71. package/lib/style-compiler/plugins/hm.js +20 -0
  72. package/lib/style-compiler/plugins/rpx.js +43 -37
  73. package/lib/style-compiler/plugins/scope-id.js +79 -72
  74. package/lib/style-compiler/plugins/trans-special.js +25 -18
  75. package/lib/style-compiler/plugins/trim.js +13 -7
  76. package/lib/style-compiler/plugins/vw.js +22 -16
  77. package/lib/template-compiler/compiler.js +106 -199
  78. package/lib/template-compiler/index.js +52 -139
  79. package/lib/template-compiler/trans-dynamic-class-expr.js +18 -13
  80. package/lib/tenon/index.js +105 -0
  81. package/lib/tenon/processJSON.js +356 -0
  82. package/lib/tenon/processScript.js +261 -0
  83. package/lib/tenon/processStyles.js +21 -0
  84. package/lib/tenon/processTemplate.js +133 -0
  85. package/lib/url-loader.js +11 -29
  86. package/lib/utils/add-query.js +1 -1
  87. package/lib/utils/const.js +10 -0
  88. package/lib/utils/emit-file.js +10 -0
  89. package/lib/utils/eval-json-js.js +31 -0
  90. package/lib/utils/get-entry-name.js +13 -0
  91. package/lib/utils/get-json-content.js +42 -0
  92. package/lib/utils/get-relative-path.js +25 -0
  93. package/lib/utils/is-url-request.js +10 -1
  94. package/lib/utils/match-condition.js +4 -1
  95. package/lib/utils/normalize.js +4 -15
  96. package/lib/utils/parse-request.js +3 -3
  97. package/lib/utils/resolve.js +13 -0
  98. package/lib/utils/set.js +47 -0
  99. package/lib/utils/stringify-loaders-resource.js +25 -0
  100. package/lib/utils/stringify-query.js +4 -0
  101. package/lib/web/processJSON.js +113 -144
  102. package/lib/web/processScript.js +47 -34
  103. package/lib/web/processTemplate.js +57 -40
  104. package/lib/wxml/{wxml-loader.js → loader.js} +21 -62
  105. package/lib/wxs/WxsModuleIdsPlugin.js +29 -0
  106. package/lib/wxs/WxsParserPlugin.js +2 -2
  107. package/lib/wxs/WxsPlugin.js +4 -8
  108. package/lib/wxs/WxsTemplatePlugin.js +46 -92
  109. package/lib/wxs/{wxs-i18n-loader.js → i18n-loader.js} +5 -4
  110. package/lib/wxs/loader.js +142 -0
  111. package/lib/wxs/{wxs-pre-loader.js → pre-loader.js} +20 -5
  112. package/lib/wxss/loader.js +31 -43
  113. package/lib/wxss/localsLoader.js +1 -5
  114. package/lib/wxss/processCss.js +107 -103
  115. package/package.json +21 -18
  116. package/lib/built-in-loader.js +0 -49
  117. package/lib/content-loader.js +0 -13
  118. package/lib/dependency/ChildCompileDependency.js +0 -24
  119. package/lib/dependency/InjectDependency.js +0 -26
  120. package/lib/dependency/RemovedModuleDependency.js +0 -23
  121. package/lib/dependency/ResolveDependency.js +0 -49
  122. package/lib/path-loader.js +0 -3
  123. package/lib/plugin-loader.js +0 -287
  124. package/lib/staticConfig.js +0 -4
  125. package/lib/utils/get-main-compilation.js +0 -6
  126. package/lib/utils/read-json-for-src.js +0 -34
  127. package/lib/utils/try-require.js +0 -16
  128. package/lib/wxs/wxs-loader.js +0 -117
  129. package/lib/wxss/getImportPrefix.js +0 -30
@@ -1,39 +1,29 @@
1
1
  const path = require('path')
2
2
  const JSON5 = require('json5')
3
3
  const parseRequest = require('./utils/parse-request')
4
- const loaderUtils = require('loader-utils')
5
4
  const config = require('./config')
6
5
  const createHelpers = require('./helpers')
7
- const InjectDependency = require('./dependency/InjectDependency')
8
- const addQuery = require('./utils/add-query')
9
- const mpxJSON = require('./utils/mpx-json')
6
+ const getJSONContent = require('./utils/get-json-content')
10
7
  const async = require('async')
11
- const matchCondition = require('./utils/match-condition')
8
+ const { matchCondition } = require('./utils/match-condition')
12
9
  const fixUsingComponent = require('./utils/fix-using-component')
13
- const getMainCompilation = require('./utils/get-main-compilation')
10
+ const { JSON_JS_EXT } = require('./utils/const')
14
11
 
15
12
  module.exports = function (content) {
16
13
  this.cacheable()
17
14
 
18
- const mainCompilation = getMainCompilation(this._compilation)
19
- const mpx = mainCompilation.__mpx__
15
+ const mpx = this.getMpx()
20
16
  if (!mpx) {
21
17
  return content
22
18
  }
23
19
 
24
20
  const nativeCallback = this.async()
25
-
26
21
  const loaderContext = this
27
22
  const isProduction = this.minimize || process.env.NODE_ENV === 'production'
28
- const options = Object.assign({}, mpx.loaderOptions, loaderUtils.getOptions(this))
29
-
30
23
  const filePath = this.resourcePath
31
-
32
24
  const moduleId = 'm' + mpx.pathHash(filePath)
33
25
  const { resourcePath, queryObj } = parseRequest(this.resource)
34
- const projectRoot = mpx.projectRoot
35
26
  const mode = mpx.mode
36
- const defs = mpx.defs
37
27
  const globalSrcMode = mpx.srcMode
38
28
  const localSrcMode = queryObj.mode
39
29
  const packageName = queryObj.packageRoot || mpx.currentPackageRoot || 'main'
@@ -41,14 +31,12 @@ module.exports = function (content) {
41
31
  const componentsMap = mpx.componentsMap[packageName]
42
32
  const parsed = path.parse(resourcePath)
43
33
  const resourceName = path.join(parsed.dir, parsed.name)
44
- const isApp = !pagesMap[resourcePath] && !componentsMap[resourcePath]
34
+ const isApp = !(pagesMap[resourcePath] || componentsMap[resourcePath])
45
35
  const srcMode = localSrcMode || globalSrcMode
46
- const fs = this._compiler.inputFileSystem
47
36
  const typeExtMap = config[srcMode].typeExtMap
48
37
  const typeResourceMap = {}
49
38
  const autoScope = matchCondition(resourcePath, mpx.autoScopeRules)
50
39
 
51
- const EXT_MPX_JSON = '.json.js'
52
40
  const CSS_LANG_EXT_MAP = {
53
41
  less: '.less',
54
42
  stylus: '.styl',
@@ -56,40 +44,18 @@ module.exports = function (content) {
56
44
  scss: '.scss'
57
45
  }
58
46
 
59
- let useMPXJSON = false
47
+ let useJSONJS = false
60
48
  let cssLang = ''
61
49
  const hasScoped = (queryObj.scoped || autoScope) && mode === 'ali'
62
50
  const hasComment = false
63
51
  const isNative = true
64
52
 
65
- const tryEvalMPXJSON = (callback) => {
66
- const { rawResourcePath } = parseRequest(typeResourceMap['json'])
67
- const _src = rawResourcePath
68
- this.addDependency(_src)
69
- fs.readFile(_src, (err, raw) => {
70
- if (err) {
71
- callback(err)
72
- } else {
73
- try {
74
- const source = raw.toString('utf-8')
75
- const text = mpxJSON.compileMPXJSONText({ source, defs, filePath: _src })
76
- callback(null, text)
77
- } catch (e) {
78
- callback(e)
79
- }
80
- }
81
- })
82
- }
83
-
84
53
  const checkFileExists = (extName, callback) => {
85
- this.resolve(parsed.dir, resourceName + extName, (err, result) => {
86
- err = null
87
- callback(err, result)
88
- })
54
+ this.resolve(parsed.dir, resourceName + extName, callback)
89
55
  }
90
56
 
91
57
  function checkCSSLangFiles (callback) {
92
- const langs = mpx.nativeOptions.cssLangs || ['less', 'stylus', 'scss', 'sass']
58
+ const langs = mpx.nativeConfig.cssLangs || ['less', 'stylus', 'scss', 'sass']
93
59
  const results = []
94
60
  async.eachOf(langs, function (lang, i, callback) {
95
61
  if (!CSS_LANG_EXT_MAP[lang]) {
@@ -99,7 +65,7 @@ module.exports = function (content) {
99
65
  if (!err && result) {
100
66
  results[i] = result
101
67
  }
102
- callback(err)
68
+ callback()
103
69
  })
104
70
  }, function (err) {
105
71
  for (let i = 0; i < langs.length; i++) {
@@ -113,14 +79,13 @@ module.exports = function (content) {
113
79
  })
114
80
  }
115
81
 
116
- function checkMPXJSONFile (callback) {
117
- // checkFileExists(EXT_MPX_JSON, (err, result) => {
118
- checkFileExists(EXT_MPX_JSON, (err, result) => {
82
+ function checkJSONJSFile (callback) {
83
+ checkFileExists(JSON_JS_EXT, (err, result) => {
119
84
  if (!err && result) {
120
85
  typeResourceMap.json = result
121
- useMPXJSON = true
86
+ useJSONJS = true
122
87
  }
123
- callback(err)
88
+ callback()
124
89
  })
125
90
  }
126
91
 
@@ -129,138 +94,111 @@ module.exports = function (content) {
129
94
  (callback) => {
130
95
  async.parallel([
131
96
  checkCSSLangFiles,
132
- checkMPXJSONFile
97
+ checkJSONJSFile
133
98
  ], (err) => {
134
99
  callback(err)
135
100
  })
136
101
  },
137
102
  (callback) => {
138
103
  async.forEachOf(typeExtMap, (ext, key, callback) => {
139
- // 检测到mpxJson或cssLang时跳过对应类型文件检测
140
- if ((key === 'json' && useMPXJSON) || (key === 'styles' && cssLang)) {
104
+ // 检测到jsonjs或cssLang时跳过对应类型文件检测
105
+ if (typeResourceMap[key]) {
141
106
  return callback()
142
107
  }
143
108
  checkFileExists(ext, (err, result) => {
144
109
  if (!err && result) {
145
110
  typeResourceMap[key] = result
146
111
  }
147
- callback(err)
112
+ callback()
148
113
  })
149
114
  }, callback)
150
115
  },
151
116
  (callback) => {
152
- // 对原生写法增强json写法,可以用js来写json,尝试找.json.js文件,找不到用回json的内容
153
- if (useMPXJSON) {
154
- tryEvalMPXJSON(callback)
155
- } else {
156
- if (typeResourceMap['json']) {
157
- // eslint-disable-next-line handle-callback-err
158
- const { rawResourcePath } = parseRequest(typeResourceMap['json'])
159
- fs.readFile(rawResourcePath, (err, raw) => {
160
- if (err) {
161
- callback(err)
162
- } else {
163
- callback(null, raw.toString('utf-8'))
164
- }
165
- })
166
- } else {
167
- callback(null, '{}')
168
- }
169
- }
117
+ getJSONContent({
118
+ src: typeResourceMap.json,
119
+ useJSONJS
120
+ }, this, callback)
170
121
  }, (content, callback) => {
171
- let usingComponents = [].concat(Object.keys(mpx.usingComponents))
122
+ let json
172
123
  try {
173
- let ret = JSON5.parse(content)
174
- if (ret.usingComponents) {
175
- fixUsingComponent(ret.usingComponents, mode)
176
- usingComponents = usingComponents.concat(Object.keys(ret.usingComponents))
177
- }
124
+ json = JSON5.parse(content)
178
125
  } catch (e) {
126
+ return callback(e)
127
+ }
128
+ let usingComponents = Object.keys(mpx.usingComponents)
129
+ if (json.usingComponents) {
130
+ fixUsingComponent(json.usingComponents, mode)
131
+ usingComponents = usingComponents.concat(Object.keys(json.usingComponents))
179
132
  }
180
133
  const {
181
- getRequireForSrc,
182
- getNamedExportsForSrc
183
- } = createHelpers({
184
- loaderContext,
185
- options,
186
- moduleId,
187
- hasScoped,
188
- hasComment,
189
- usingComponents,
190
- srcMode,
191
- isNative,
192
- projectRoot
193
- })
194
-
195
- const getRequire = (type) => {
196
- const localQuery = Object.assign({}, queryObj)
197
- let src = typeResourceMap[type]
198
- localQuery.resourcePath = resourcePath
199
- if (type !== 'script') {
200
- this.addDependency(src)
201
- }
202
- if (type === 'template' && isApp) {
203
- return ''
204
- }
205
- if (type === 'json' && !useMPXJSON) {
206
- localQuery.__component = true
134
+ getRequire
135
+ } = createHelpers(loaderContext)
136
+
137
+ const getRequireByType = (type) => {
138
+ const src = typeResourceMap[type]
139
+ const part = { src }
140
+ const extraOptions = {
141
+ ...queryObj,
142
+ resourcePath
207
143
  }
208
- src = addQuery(src, localQuery, true)
209
- const partsOpts = { src }
210
144
 
211
- if (type === 'script') {
212
- return getNamedExportsForSrc(type, partsOpts)
145
+ switch (type) {
146
+ case 'template':
147
+ if (isApp) return ''
148
+ Object.assign(extraOptions, {
149
+ hasScoped,
150
+ hasComment,
151
+ isNative,
152
+ moduleId,
153
+ usingComponents
154
+ })
155
+ break
156
+ case 'styles':
157
+ if (cssLang) part.lang = cssLang
158
+ Object.assign(extraOptions, {
159
+ moduleId,
160
+ scoped: hasScoped
161
+ })
162
+ break
163
+ case 'json':
164
+ if (useJSONJS) part.useJSONJS = true
165
+ break
213
166
  }
214
- if (type === 'styles') {
215
- if (cssLang) {
216
- partsOpts.lang = cssLang
217
- }
218
- if (hasScoped) {
219
- return getRequireForSrc(type, partsOpts, 0, true)
220
- }
221
- }
222
- return getRequireForSrc(type, partsOpts)
167
+ return getRequire(type, part, extraOptions)
223
168
  }
224
169
 
225
170
  // 注入模块id及资源路径
226
- let globalInjectCode = `global.currentModuleId = ${JSON.stringify(moduleId)}\n`
171
+ let output = `global.currentModuleId = ${JSON.stringify(moduleId)}\n`
227
172
  if (!isProduction) {
228
- globalInjectCode += `global.currentResource = ${JSON.stringify(filePath)}\n`
173
+ output += `global.currentResource = ${JSON.stringify(filePath)}\n`
229
174
  }
230
175
 
231
176
  // 注入构造函数
232
177
  let ctor = 'App'
178
+ let ctorType = 'app'
233
179
  if (pagesMap[resourcePath]) {
234
- if (mpx.forceUsePageCtor || mode === 'ali') {
180
+ ctorType = 'page'
181
+ if (mpx.forceUsePageCtor || mode === 'ali' || mode === 'swan') {
235
182
  ctor = 'Page'
236
183
  } else {
237
184
  ctor = 'Component'
238
185
  }
239
186
  } else if (componentsMap[resourcePath]) {
240
187
  ctor = 'Component'
188
+ ctorType = 'component'
241
189
  }
242
- globalInjectCode += `global.currentCtor = ${ctor}\n`
243
- globalInjectCode += `global.currentCtorType = ${JSON.stringify(ctor.replace(/^./, (match) => {
190
+ output += `global.currentCtor = ${ctor}\n`
191
+ output += `global.currentCtorType = ${JSON.stringify(ctor.replace(/^./, (match) => {
244
192
  return match.toLowerCase()
245
193
  }))}\n`
194
+ output += `global.currentResourceType = ${JSON.stringify(ctorType)}\n`
246
195
 
247
196
  if (srcMode) {
248
- globalInjectCode += `global.currentSrcMode = ${JSON.stringify(srcMode)}\n`
197
+ output += `global.currentSrcMode = ${JSON.stringify(srcMode)}\n`
249
198
  }
250
199
 
251
- if (!mpx.forceDisableInject) {
252
- const dep = new InjectDependency({
253
- content: globalInjectCode,
254
- index: -3
255
- })
256
- this._module.addDependency(dep)
257
- }
258
-
259
- // 触发webpack global var 注入
260
- let output = 'global.currentModuleId;\n'
261
-
262
200
  for (let type in typeResourceMap) {
263
- output += `/* ${type} */\n${getRequire(type)}\n\n`
201
+ output += `/* ${type} */\n${getRequireByType(type)}\n\n`
264
202
  }
265
203
 
266
204
  callback(null, output)
package/lib/parser.js CHANGED
@@ -6,7 +6,7 @@ const SourceMapGenerator = require('source-map').SourceMapGenerator
6
6
  const splitRE = /\r?\n/g
7
7
  const emptyRE = /^(?:\/\/)?\s*$/
8
8
 
9
- module.exports = (content, { filePath, needMap, mode, defs, env }) => {
9
+ module.exports = (content, { filePath, needMap, mode, env }) => {
10
10
  // 缓存需要mode隔离,不同mode经过区块条件编译parseComponent得到的内容并不一致
11
11
  const cacheKey = hash(filePath + content + mode + env)
12
12
 
@@ -14,7 +14,6 @@ module.exports = (content, { filePath, needMap, mode, defs, env }) => {
14
14
  if (output) return JSON.parse(output)
15
15
  output = compiler.parseComponent(content, {
16
16
  mode,
17
- defs,
18
17
  filePath,
19
18
  pad: 'line',
20
19
  env
@@ -0,0 +1,35 @@
1
+ const { matchCondition } = require('../utils/match-condition')
2
+ const { parseQuery } = require('loader-utils')
3
+
4
+ class MpxPartialCompilePlugin {
5
+ constructor (condition) {
6
+ this.condition = condition
7
+ }
8
+
9
+ isResolvingPage (obj) {
10
+ // valid query should start with '?'
11
+ const query = obj.query || '?'
12
+ return parseQuery(query).isPage
13
+ }
14
+
15
+ apply (compiler) {
16
+ compiler.resolverFactory.hooks.resolver.intercept({
17
+ factory: (type, hook) => {
18
+ hook.tap('MpxPartialCompilePlugin', (resolver) => {
19
+ resolver.hooks.result.tapAsync({
20
+ name: 'MpxPartialCompilePlugin',
21
+ stage: -100
22
+ }, (obj, resolverContext, callback) => {
23
+ if (this.isResolvingPage(obj) && !matchCondition(obj.path, this.condition)) {
24
+ obj.path = false
25
+ }
26
+ callback(null, obj)
27
+ })
28
+ })
29
+ return hook
30
+ }
31
+ })
32
+ }
33
+ }
34
+
35
+ module.exports = MpxPartialCompilePlugin
@@ -246,7 +246,7 @@ module.exports = function getSpec ({ warn, error }) {
246
246
  jd: deletePath()
247
247
  },
248
248
  {
249
- test: 'navigateToMiniProgramAppIdList|networkTimeout|permission',
249
+ test: 'navigateToMiniProgramAppIdList|networkTimeout',
250
250
  ali: deletePath(),
251
251
  jd: deletePath()
252
252
  },
@@ -4,7 +4,7 @@ const runRules = require('../run-rules')
4
4
  * @desc 针对每一个组件(属性,event,指令等)执行规则判断
5
5
  * @params cfgs [{test: 'camera', props:[], event: []}] 组件配置列表
6
6
  * @params spec ../index.js中公共的spec
7
- */
7
+ */
8
8
  module.exports = function normalizeComponentRules (cfgs, spec) {
9
9
  return cfgs.map((cfg) => {
10
10
  const result = {}
@@ -25,9 +25,8 @@ module.exports = function normalizeComponentRules (cfgs, spec) {
25
25
  data
26
26
  }
27
27
  el.attrsList.forEach((attr) => {
28
- let rAttr = runRules(spec.preAttrs, attr, options)
29
28
  const meta = {}
30
- rAttr = runRules(spec.directive, rAttr, {
29
+ let rAttr = runRules(spec.directive, attr, {
31
30
  ...options,
32
31
  meta
33
32
  })
@@ -28,6 +28,8 @@ 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' })
31
33
  const qaPropLog = print({ platform: 'qa', tag: TAG_NAME, isError: false })
32
34
  const wxPropValueLog = print({ platform: 'wx', tag: TAG_NAME, isError: false, type: 'value' })
33
35
 
@@ -37,6 +39,10 @@ module.exports = function ({ print }) {
37
39
  el.isBuiltIn = true
38
40
  return 'mpx-button'
39
41
  },
42
+ tenon (tag, { el }) {
43
+ el.isBuiltIn = true
44
+ return 'tenon-button'
45
+ },
40
46
  props: [
41
47
  {
42
48
  test: 'open-type',
@@ -131,13 +137,18 @@ module.exports = function ({ print }) {
131
137
  },
132
138
  {
133
139
  test: /^(open-type|lang|session-from|send-message-title|send-message-path|send-message-img|show-message-card|app-parameter)$/,
134
- web: webPropLog
140
+ web: webPropLog,
141
+ tenon: tenonPropLog
135
142
  },
136
143
  {
137
144
  test: /^(size|type|plain|loading|form-type|hover-class|hover-stop-propagation|hover-start-time|hover-stay-time|use-built-in)$/,
138
145
  web (prop, { el }) {
139
146
  // todo 这部分能力基于内部封装实现
140
147
  el.isBuiltIn = true
148
+ },
149
+ tenon (prop, { el }) {
150
+ // todo 这部分能力基于内部封装实现
151
+ el.isBuiltIn = true
141
152
  }
142
153
  },
143
154
  {
@@ -174,7 +185,8 @@ module.exports = function ({ print }) {
174
185
  },
175
186
  {
176
187
  test: /^(getuserinfo|contact|error|launchapp|opensetting|getphonenumber)$/,
177
- web: webEventLog
188
+ web: webEventLog,
189
+ tenon: tenonEventLog
178
190
  }
179
191
  ]
180
192
  }
@@ -13,6 +13,10 @@ 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
+ },
16
20
  props: [
17
21
  {
18
22
  test: /^show-menu-by-longpress$/,
@@ -20,6 +20,10 @@ 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
+ },
23
27
  props: [
24
28
  {
25
29
  test: /^(cursor-spacing|auto-focus|adjust-position|hold-keyboard)$/,
@@ -12,6 +12,10 @@ 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
+ },
15
19
  props: [
16
20
  {
17
21
  test: /^(space)$/,
@@ -19,6 +19,10 @@ 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
+ },
22
26
  props: [
23
27
  {
24
28
  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,6 +10,10 @@ 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
+ },
13
17
  props: [
14
18
  {
15
19
  test: /^type$/,
@@ -19,6 +19,10 @@ 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
+ },
22
26
  props: [
23
27
  {
24
28
  test: /^(decode|user-select)$/,
@@ -22,6 +22,11 @@ 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
+ },
25
30
  props: [
26
31
  {
27
32
  test: /^(auto-focus|fixed|cursor-spacing|cursor|show-confirm-bar|selection-start|selection-end|adjust-position|hold-keyboard|disable-default-padding|confirm-type)$/,
@@ -21,6 +21,10 @@ 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
+ },
24
28
  qa (tag) {
25
29
  return 'div'
26
30
  },