@mpxjs/webpack-plugin 2.9.69 → 2.9.70-alpha.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/README.md +1 -1
- package/lib/config.js +14 -0
- package/lib/dependencies/AddEntryDependency.js +24 -0
- package/lib/dependencies/ResolveDependency.js +5 -0
- package/lib/index.js +38 -7
- package/lib/json-compiler/helper.js +3 -3
- package/lib/loader.js +53 -0
- package/lib/platform/template/wx/component-config/button.js +14 -2
- package/lib/platform/template/wx/component-config/image.js +4 -0
- package/lib/platform/template/wx/component-config/input.js +5 -1
- package/lib/platform/template/wx/component-config/rich-text.js +4 -0
- package/lib/platform/template/wx/component-config/scroll-view.js +4 -0
- package/lib/platform/template/wx/component-config/swiper.js +1 -1
- package/lib/platform/template/wx/component-config/switch.js +4 -0
- package/lib/platform/template/wx/component-config/text.js +4 -0
- package/lib/platform/template/wx/component-config/textarea.js +6 -1
- package/lib/platform/template/wx/component-config/view.js +4 -0
- package/lib/platform/template/wx/index.js +127 -1
- package/lib/react/processTemplate.js +3 -0
- package/lib/resolve-loader.js +4 -1
- package/lib/runtime/components/react/context.ts +4 -0
- package/lib/runtime/components/react/dist/context.js +1 -0
- package/lib/runtime/components/react/dist/event.config.js +24 -24
- package/lib/runtime/components/react/dist/getInnerListeners.js +183 -165
- package/lib/runtime/components/react/dist/mpx-button.jsx +35 -42
- package/lib/runtime/components/react/dist/mpx-canvas/index.jsx +30 -12
- package/lib/runtime/components/react/dist/mpx-checkbox-group.jsx +13 -19
- package/lib/runtime/components/react/dist/mpx-checkbox.jsx +29 -38
- package/lib/runtime/components/react/dist/mpx-form.jsx +16 -19
- package/lib/runtime/components/react/dist/mpx-icon.jsx +8 -16
- package/lib/runtime/components/react/dist/mpx-image.jsx +291 -0
- package/lib/runtime/components/react/dist/mpx-input.jsx +54 -27
- package/lib/runtime/components/react/dist/mpx-label.jsx +15 -22
- package/lib/runtime/components/react/dist/mpx-movable-area.jsx +13 -16
- package/lib/runtime/components/react/dist/mpx-movable-view.jsx +13 -13
- package/lib/runtime/components/react/dist/mpx-navigator.jsx +2 -4
- package/lib/runtime/components/react/dist/mpx-picker/date.jsx +6 -2
- package/lib/runtime/components/react/dist/mpx-picker/index.jsx +5 -3
- package/lib/runtime/components/react/dist/mpx-picker/multiSelector.jsx +6 -2
- package/lib/runtime/components/react/dist/mpx-picker/region.jsx +6 -2
- package/lib/runtime/components/react/dist/mpx-picker/selector.jsx +6 -2
- package/lib/runtime/components/react/dist/mpx-picker/time.jsx +10 -15
- package/lib/runtime/components/react/dist/mpx-picker-view-column-item.jsx +39 -0
- package/lib/runtime/components/react/dist/mpx-picker-view-column.jsx +110 -97
- package/lib/runtime/components/react/dist/mpx-picker-view.jsx +32 -29
- package/lib/runtime/components/react/dist/mpx-radio-group.jsx +11 -19
- package/lib/runtime/components/react/dist/mpx-radio.jsx +27 -42
- package/lib/runtime/components/react/dist/mpx-rich-text/html.js +39 -0
- package/lib/runtime/components/react/dist/mpx-rich-text/index.jsx +63 -0
- package/lib/runtime/components/react/dist/mpx-root-portal.jsx +6 -4
- package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +47 -41
- package/lib/runtime/components/react/dist/mpx-simple-text.jsx +11 -0
- package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +4 -2
- package/lib/runtime/components/react/dist/mpx-swiper.jsx +606 -0
- package/lib/runtime/components/react/dist/mpx-switch.jsx +20 -10
- package/lib/runtime/components/react/dist/mpx-text.jsx +11 -10
- package/lib/runtime/components/react/dist/mpx-textarea.jsx +8 -3
- package/lib/runtime/components/react/dist/mpx-view.jsx +29 -44
- package/lib/runtime/components/react/dist/mpx-web-view.jsx +105 -42
- package/lib/runtime/components/react/dist/pickerFaces.js +12 -6
- package/lib/runtime/components/react/dist/pickerVIewContext.js +9 -0
- package/lib/runtime/components/react/dist/pickerViewMask.jsx +18 -0
- package/lib/runtime/components/react/dist/{pickerOverlay.jsx → pickerViewOverlay.jsx} +5 -3
- package/lib/runtime/components/react/dist/useAnimationHooks.js +35 -9
- package/lib/runtime/components/react/dist/utils.jsx +20 -24
- package/lib/runtime/components/react/getInnerListeners.ts +35 -28
- package/lib/runtime/components/react/mpx-button.tsx +55 -36
- package/lib/runtime/components/react/mpx-canvas/index.tsx +2 -2
- package/lib/runtime/components/react/mpx-checkbox-group.tsx +13 -12
- package/lib/runtime/components/react/mpx-checkbox.tsx +28 -28
- package/lib/runtime/components/react/mpx-form.tsx +10 -8
- package/lib/runtime/components/react/mpx-icon.tsx +10 -15
- package/lib/runtime/components/react/mpx-image.tsx +396 -0
- package/lib/runtime/components/react/mpx-input.tsx +61 -33
- package/lib/runtime/components/react/mpx-label.tsx +14 -13
- package/lib/runtime/components/react/mpx-movable-area.tsx +8 -7
- package/lib/runtime/components/react/mpx-movable-view.tsx +1 -1
- package/lib/runtime/components/react/mpx-picker/date.tsx +5 -2
- package/lib/runtime/components/react/mpx-picker/index.tsx +3 -2
- package/lib/runtime/components/react/mpx-picker/multiSelector.tsx +5 -2
- package/lib/runtime/components/react/mpx-picker/region.tsx +5 -2
- package/lib/runtime/components/react/mpx-picker/selector.tsx +5 -2
- package/lib/runtime/components/react/mpx-picker/time.tsx +10 -15
- package/lib/runtime/components/react/mpx-picker/type.ts +48 -43
- package/lib/runtime/components/react/mpx-picker-view-column.tsx +4 -1
- package/lib/runtime/components/react/mpx-picker-view.tsx +7 -1
- package/lib/runtime/components/react/mpx-radio-group.tsx +11 -12
- package/lib/runtime/components/react/mpx-radio.tsx +26 -29
- package/lib/runtime/components/react/mpx-scroll-view.tsx +32 -30
- package/lib/runtime/components/react/mpx-simple-text.tsx +18 -0
- package/lib/runtime/components/react/mpx-swiper/carouse.tsx +4 -2
- package/lib/runtime/components/react/mpx-swiper-item.tsx +3 -2
- package/lib/runtime/components/react/mpx-switch.tsx +10 -8
- package/lib/runtime/components/react/mpx-text.tsx +6 -2
- package/lib/runtime/components/react/mpx-view.tsx +37 -45
- package/lib/runtime/components/react/mpx-web-view.tsx +25 -15
- package/lib/runtime/components/react/types/global.d.ts +1 -16
- package/lib/runtime/components/react/utils.tsx +24 -24
- package/lib/runtime/components/tenon/getInnerListeners.js +334 -0
- package/lib/runtime/components/tenon/tenon-button.vue +309 -0
- package/lib/runtime/components/tenon/tenon-image.vue +66 -0
- package/lib/runtime/components/tenon/tenon-input.vue +171 -0
- package/lib/runtime/components/tenon/tenon-rich-text.vue +26 -0
- package/lib/runtime/components/tenon/tenon-scroll-view.vue +127 -0
- package/lib/runtime/components/tenon/tenon-switch.vue +96 -0
- package/lib/runtime/components/tenon/tenon-text.vue +70 -0
- package/lib/runtime/components/tenon/tenon-textarea.vue +86 -0
- package/lib/runtime/components/tenon/tenon-view.vue +93 -0
- package/lib/runtime/components/web/getInnerListeners.js +6 -6
- package/lib/runtime/components/web/mpx-movable-view.vue +334 -344
- package/lib/runtime/components/web/mpx-picker-view-column.vue +75 -75
- package/lib/runtime/components/web/mpx-picker.vue +382 -385
- package/lib/runtime/components/web/mpx-web-view.vue +162 -162
- package/lib/runtime/optionProcessor.js +7 -16
- package/lib/runtime/optionProcessor.tenon.js +84 -0
- package/lib/runtime/utils.js +2 -0
- package/lib/style-compiler/index.js +1 -1
- package/lib/style-compiler/plugins/hm.js +20 -0
- package/lib/template-compiler/bind-this.js +7 -2
- package/lib/template-compiler/compiler.js +67 -40
- package/lib/template-compiler/gen-node-react.js +2 -2
- package/lib/tenon/index.js +117 -0
- package/lib/tenon/processJSON.js +352 -0
- package/lib/tenon/processScript.js +203 -0
- package/lib/tenon/processStyles.js +21 -0
- package/lib/tenon/processTemplate.js +126 -0
- package/lib/tenon/script-helper.js +223 -0
- package/lib/utils/env.js +6 -1
- package/lib/utils/get-relative-path.js +25 -0
- package/package.json +7 -3
- package/LICENSE +0 -433
- package/lib/runtime/components/react/dist/mpx-image/index.jsx +0 -226
- package/lib/runtime/components/react/dist/mpx-image/svg.jsx +0 -7
- package/lib/runtime/components/react/dist/mpx-swiper/carouse.jsx +0 -478
- package/lib/runtime/components/react/dist/mpx-swiper/index.jsx +0 -68
- package/lib/runtime/components/react/dist/mpx-swiper/type.js +0 -1
- package/lib/runtime/components/react/mpx-image/index.tsx +0 -345
- package/lib/runtime/components/react/mpx-image/svg.tsx +0 -22
package/README.md
CHANGED
package/lib/config.js
CHANGED
|
@@ -368,6 +368,20 @@ module.exports = {
|
|
|
368
368
|
templatePrefix: 'module.exports = \n'
|
|
369
369
|
}
|
|
370
370
|
},
|
|
371
|
+
tenon: {
|
|
372
|
+
directive: {
|
|
373
|
+
if: 'v-if',
|
|
374
|
+
elseif: 'v-else-if',
|
|
375
|
+
else: 'v-else'
|
|
376
|
+
},
|
|
377
|
+
wxs: {
|
|
378
|
+
tag: 'wxs',
|
|
379
|
+
module: 'module',
|
|
380
|
+
src: 'src',
|
|
381
|
+
ext: '.wxs',
|
|
382
|
+
templatePrefix: 'module.exports = \n'
|
|
383
|
+
}
|
|
384
|
+
},
|
|
371
385
|
qa: {
|
|
372
386
|
typeExtMap: {
|
|
373
387
|
json: '.json',
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const NullDependency = require('webpack/lib/dependencies/NullDependency')
|
|
2
|
+
|
|
3
|
+
class AddEntryDependency extends NullDependency {
|
|
4
|
+
constructor ({ context, dep, name }) {
|
|
5
|
+
super()
|
|
6
|
+
this.__addEntryParams = [context, dep, name]
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
get type () {
|
|
10
|
+
return 'mpx add entry'
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// updateHash (hash) {
|
|
14
|
+
// super.updateHash(hash)
|
|
15
|
+
// hash.update(this.childCompileEntryModule.identifier())
|
|
16
|
+
// }
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
AddEntryDependency.Template = class AddEntryDependencyTemplate {
|
|
20
|
+
apply () {
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
module.exports = AddEntryDependency
|
|
@@ -76,6 +76,11 @@ ResolveDependency.Template = class ResolveDependencyTemplate {
|
|
|
76
76
|
|
|
77
77
|
getContent (dep) {
|
|
78
78
|
const { resolved = '' } = dep
|
|
79
|
+
// for tenon
|
|
80
|
+
if (dep.compilation.__mpx__.mode === 'tenon') {
|
|
81
|
+
// 只支持所有产物在一个目录下的场景 进行相对路径跳转
|
|
82
|
+
return `'./${resolved}.js'`
|
|
83
|
+
}
|
|
79
84
|
// ?resolve 必定返回绝对路径
|
|
80
85
|
return JSON.stringify('/' + resolved)
|
|
81
86
|
}
|
package/lib/index.js
CHANGED
|
@@ -66,7 +66,7 @@ const emitFile = require('./utils/emit-file')
|
|
|
66
66
|
const { MPX_PROCESSED_FLAG, MPX_DISABLE_EXTRACTOR_CACHE, MPX_APP_MODULE_ID } = require('./utils/const')
|
|
67
67
|
const isEmptyObject = require('./utils/is-empty-object')
|
|
68
68
|
const DynamicPlugin = require('./resolver/DynamicPlugin')
|
|
69
|
-
const { isReact, isWeb } = require('./utils/env')
|
|
69
|
+
const { isReact, isWeb, isTenon } = require('./utils/env')
|
|
70
70
|
const VirtualModulesPlugin = require('webpack-virtual-modules')
|
|
71
71
|
require('./utils/check-core-version-match')
|
|
72
72
|
|
|
@@ -323,7 +323,7 @@ class MpxWebpackPlugin {
|
|
|
323
323
|
}
|
|
324
324
|
}
|
|
325
325
|
|
|
326
|
-
if (!isWeb(this.options.mode) && !isReact(this.options.mode)) {
|
|
326
|
+
if (!isWeb(this.options.mode) && !isReact(this.options.mode) && !isTenon(this.options.mode)) {
|
|
327
327
|
// 强制设置publicPath为'/'
|
|
328
328
|
if (compiler.options.output.publicPath && compiler.options.output.publicPath !== publicPath) {
|
|
329
329
|
warnings.push(`webpack options: MpxWebpackPlugin accept options.output.publicPath to be ${publicPath} only, custom options.output.publicPath will be ignored!`)
|
|
@@ -381,7 +381,7 @@ class MpxWebpackPlugin {
|
|
|
381
381
|
compiler.options.resolve.plugins.push(dynamicPlugin)
|
|
382
382
|
|
|
383
383
|
const optimization = compiler.options.optimization
|
|
384
|
-
if (!isWeb(this.options.mode) && !isReact(this.options.mode)) {
|
|
384
|
+
if (!isWeb(this.options.mode) && !isReact(this.options.mode) && !isTenon(this.options.mode)) {
|
|
385
385
|
optimization.runtimeChunk = {
|
|
386
386
|
name: (entrypoint) => {
|
|
387
387
|
for (const packageName in mpx.independentSubpackagesMap) {
|
|
@@ -397,7 +397,7 @@ class MpxWebpackPlugin {
|
|
|
397
397
|
let splitChunksOptions = null
|
|
398
398
|
let splitChunksPlugin = null
|
|
399
399
|
// 输出web ssr需要将optimization.splitChunks设置为false以关闭splitChunks
|
|
400
|
-
if (optimization.splitChunks !== false && !isReact(this.options.mode)) {
|
|
400
|
+
if (optimization.splitChunks !== false && !isReact(this.options.mode) && !isTenon(this.options.mode)) {
|
|
401
401
|
splitChunksOptions = Object.assign({
|
|
402
402
|
chunks: 'all',
|
|
403
403
|
usedExports: optimization.usedExports === true,
|
|
@@ -1482,6 +1482,27 @@ class MpxWebpackPlugin {
|
|
|
1482
1482
|
}
|
|
1483
1483
|
})
|
|
1484
1484
|
|
|
1485
|
+
// processing for tenon-store
|
|
1486
|
+
if (mpx.mode === 'tenon') {
|
|
1487
|
+
let TENON_STORE_ID = 0
|
|
1488
|
+
parser.hooks.call.for('imported var').tap('MpxWebpackPlugin', (expr) => {
|
|
1489
|
+
if (['createStore', 'createStoreWithThis'].includes(expr.callee.name)) {
|
|
1490
|
+
const current = parser.state.current
|
|
1491
|
+
const storeOptions = expr.arguments.length && expr.arguments[0]
|
|
1492
|
+
if (storeOptions) {
|
|
1493
|
+
current.addDependency(new InjectDependency({
|
|
1494
|
+
content: 'Object.assign(',
|
|
1495
|
+
index: storeOptions.range[0]
|
|
1496
|
+
}))
|
|
1497
|
+
current.addDependency(new InjectDependency({
|
|
1498
|
+
content: `, { __store_id: ${TENON_STORE_ID++} })`,
|
|
1499
|
+
index: storeOptions.range[1]
|
|
1500
|
+
}))
|
|
1501
|
+
}
|
|
1502
|
+
}
|
|
1503
|
+
})
|
|
1504
|
+
}
|
|
1505
|
+
|
|
1485
1506
|
parser.hooks.evaluate.for('NewExpression').tap('MpxWebpackPlugin', (expression) => {
|
|
1486
1507
|
if (/@intlify\/core-base/.test(parser.state.module.resource)) {
|
|
1487
1508
|
if (expression.callee.name === 'Function') {
|
|
@@ -1597,7 +1618,7 @@ class MpxWebpackPlugin {
|
|
|
1597
1618
|
name: 'MpxWebpackPlugin',
|
|
1598
1619
|
stage: compilation.PROCESS_ASSETS_STAGE_ADDITIONS
|
|
1599
1620
|
}, () => {
|
|
1600
|
-
if (isWeb(mpx.mode) || isReact(mpx.mode)) return
|
|
1621
|
+
if (isWeb(mpx.mode) || isReact(mpx.mode) || isTenon(mpx.mode)) return
|
|
1601
1622
|
|
|
1602
1623
|
if (this.options.generateBuildMap) {
|
|
1603
1624
|
const pagesMap = compilation.__mpx__.pagesMap
|
|
@@ -1838,21 +1859,31 @@ try {
|
|
|
1838
1859
|
// mpxStyleOptions 为 mpx style 文件的标识,避免 Vue 文件插入 styleCompiler 后导致 vue scoped 样式隔离失效
|
|
1839
1860
|
if (isWeb(mpx.mode) && queryObj.mpxStyleOptions) {
|
|
1840
1861
|
const firstLoader = loaders[0] ? toPosix(loaders[0].loader) : ''
|
|
1841
|
-
const isPitcherRequest = firstLoader.includes('node_modules/vue-loader/lib/loaders/pitcher')
|
|
1862
|
+
const isPitcherRequest = firstLoader.includes('node_modules/vue-loader/lib/loaders/pitcher') || firstLoader.includes('node_modules/@hummer/tenon-loader/dist/pitcher.js')
|
|
1842
1863
|
let cssLoaderIndex = -1
|
|
1843
1864
|
let vueStyleLoaderIndex = -1
|
|
1844
1865
|
let mpxStyleLoaderIndex = -1
|
|
1866
|
+
let tenonStyleLoaderIndex = -1
|
|
1845
1867
|
loaders.forEach((loader, index) => {
|
|
1846
1868
|
const currentLoader = toPosix(loader.loader)
|
|
1847
1869
|
if (currentLoader.includes('node_modules/css-loader') && cssLoaderIndex === -1) {
|
|
1848
1870
|
cssLoaderIndex = index
|
|
1849
1871
|
} else if (currentLoader.includes('node_modules/vue-loader/lib/loaders/stylePostLoader') && vueStyleLoaderIndex === -1) {
|
|
1850
1872
|
vueStyleLoaderIndex = index
|
|
1873
|
+
} else if (currentLoader.includes('@hummer/tenon-style-loader/dist/index.js') && tenonStyleLoaderIndex === -1) {
|
|
1874
|
+
tenonStyleLoaderIndex = index
|
|
1851
1875
|
} else if (currentLoader.includes(styleCompilerPath) && mpxStyleLoaderIndex === -1) {
|
|
1852
1876
|
mpxStyleLoaderIndex = index
|
|
1853
1877
|
}
|
|
1854
1878
|
})
|
|
1855
|
-
if (mpxStyleLoaderIndex === -1) {
|
|
1879
|
+
if (mpx.mode === 'tenon' && mpxStyleLoaderIndex === -1) {
|
|
1880
|
+
if (tenonStyleLoaderIndex > -1 && !isPitcherRequest) {
|
|
1881
|
+
loaders.splice(tenonStyleLoaderIndex + 1, 0, {
|
|
1882
|
+
loader: normalize.lib('style-compiler/index.js'),
|
|
1883
|
+
options: (mpxStyleOptions && JSON.parse(mpxStyleOptions)) || {}
|
|
1884
|
+
})
|
|
1885
|
+
}
|
|
1886
|
+
} else if (mpxStyleLoaderIndex === -1) {
|
|
1856
1887
|
let loaderIndex = -1
|
|
1857
1888
|
if (cssLoaderIndex > -1 && vueStyleLoaderIndex === -1) {
|
|
1858
1889
|
loaderIndex = cssLoaderIndex
|
|
@@ -7,7 +7,7 @@ const addQuery = require('../utils/add-query')
|
|
|
7
7
|
const loaderUtils = require('loader-utils')
|
|
8
8
|
const resolve = require('../utils/resolve')
|
|
9
9
|
const { matchCondition } = require('../utils/match-condition')
|
|
10
|
-
const { isWeb, isReact } = require('../utils/env')
|
|
10
|
+
const { isWeb, isReact, isTenon } = require('../utils/env')
|
|
11
11
|
|
|
12
12
|
module.exports = function createJSONHelper ({ loaderContext, emitWarning, customGetDynamicEntry }) {
|
|
13
13
|
const mpx = loaderContext.getMpx()
|
|
@@ -76,7 +76,7 @@ module.exports = function createJSONHelper ({ loaderContext, emitWarning, custom
|
|
|
76
76
|
const resourceName = path.join(parsed.dir, parsed.name)
|
|
77
77
|
|
|
78
78
|
if (!outputPath) {
|
|
79
|
-
if (isScript(ext) && resourceName.includes('node_modules') && !isWeb(mode) && !isReact(mode)) {
|
|
79
|
+
if (isScript(ext) && resourceName.includes('node_modules') && !isWeb(mode) && !isTenon(mode) && !isReact(mode)) {
|
|
80
80
|
let root = info.descriptionFileRoot
|
|
81
81
|
let name = 'nativeComponent'
|
|
82
82
|
if (info.descriptionFileData) {
|
|
@@ -139,7 +139,7 @@ module.exports = function createJSONHelper ({ loaderContext, emitWarning, custom
|
|
|
139
139
|
outputPath = /^(.*?)(\.[^.]*)?$/.exec(relative)[1]
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
|
-
if (isScript(ext) && !isWeb(mode) && !isReact(mode)) {
|
|
142
|
+
if (isScript(ext) && !isWeb(mode) && !isTenon(mode) && !isReact(mode)) {
|
|
143
143
|
resource = `!!${nativeLoaderPath}!${resource}`
|
|
144
144
|
}
|
|
145
145
|
const entry = getDynamicEntry(resource, 'page', outputPath, tarRoot, publicPath + tarRoot)
|
package/lib/loader.js
CHANGED
|
@@ -4,6 +4,8 @@ const parseRequest = require('./utils/parse-request')
|
|
|
4
4
|
const { matchCondition } = require('./utils/match-condition')
|
|
5
5
|
const addQuery = require('./utils/add-query')
|
|
6
6
|
const async = require('async')
|
|
7
|
+
const processForTenon = require('./tenon/index')
|
|
8
|
+
const getJSONContent = require('./utils/get-json-content')
|
|
7
9
|
const normalize = require('./utils/normalize')
|
|
8
10
|
const getEntryName = require('./utils/get-entry-name')
|
|
9
11
|
const AppEntryDependency = require('./dependencies/AppEntryDependency')
|
|
@@ -17,6 +19,11 @@ const path = require('path')
|
|
|
17
19
|
const processWeb = require('./web')
|
|
18
20
|
const processReact = require('./react')
|
|
19
21
|
const genMpxCustomElement = require('./runtime-render/gen-mpx-custom-element')
|
|
22
|
+
const loaderUtils = require('loader-utils')
|
|
23
|
+
|
|
24
|
+
function stringifyRequest (loaderContext, request) {
|
|
25
|
+
return loaderUtils.stringifyRequest(loaderContext, request)
|
|
26
|
+
}
|
|
20
27
|
|
|
21
28
|
module.exports = function (content) {
|
|
22
29
|
this.cacheable()
|
|
@@ -128,6 +135,52 @@ module.exports = function (content) {
|
|
|
128
135
|
const hasComment = templateAttrs && templateAttrs.comments
|
|
129
136
|
const isNative = false
|
|
130
137
|
|
|
138
|
+
|
|
139
|
+
if (mode === 'tenon') {
|
|
140
|
+
let output = ''
|
|
141
|
+
if (ctorType === 'app' && !queryObj.app) {
|
|
142
|
+
const request = addQuery(this.resource, { app: true })
|
|
143
|
+
output += `
|
|
144
|
+
import App from ${stringifyRequest(loaderContext, request)}
|
|
145
|
+
import * as Tenon from '@hummer/tenon-vue'
|
|
146
|
+
|
|
147
|
+
Tenon.render(App)\n`
|
|
148
|
+
// 直接结束loader进入parse
|
|
149
|
+
this.loaderIndex = -1
|
|
150
|
+
return callback(null, output)
|
|
151
|
+
}
|
|
152
|
+
if (ctorType === 'page' && queryObj.tenon) {
|
|
153
|
+
console.log(resourcePath)
|
|
154
|
+
const request = addQuery(resourcePath, { page: true })
|
|
155
|
+
output += `
|
|
156
|
+
import page from ${stringifyRequest(loaderContext, request)}
|
|
157
|
+
import * as Tenon from '@hummer/tenon-vue'
|
|
158
|
+
|
|
159
|
+
Tenon.render(page)\n`
|
|
160
|
+
this.loaderIndex = -1
|
|
161
|
+
return callback(null, output)
|
|
162
|
+
}
|
|
163
|
+
return processForTenon({
|
|
164
|
+
parts,
|
|
165
|
+
jsonContent,
|
|
166
|
+
loaderContext,
|
|
167
|
+
pagesMap,
|
|
168
|
+
componentsMap,
|
|
169
|
+
queryObj,
|
|
170
|
+
ctorType,
|
|
171
|
+
srcMode,
|
|
172
|
+
moduleId,
|
|
173
|
+
isProduction,
|
|
174
|
+
hasScoped,
|
|
175
|
+
hasComment,
|
|
176
|
+
isNative,
|
|
177
|
+
usingComponentsInfo: JSON.stringify(usingComponentsInfo),
|
|
178
|
+
componentGenerics,
|
|
179
|
+
autoScope,
|
|
180
|
+
callback
|
|
181
|
+
})
|
|
182
|
+
}
|
|
183
|
+
|
|
131
184
|
// 处理mode为web时输出vue格式文件
|
|
132
185
|
if (mode === 'web') {
|
|
133
186
|
return processWeb({
|
|
@@ -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
|
const iosValueLogError = print({ platform: 'ios', tag: TAG_NAME, isError: true, type: 'value' })
|
|
@@ -43,6 +45,10 @@ module.exports = function ({ print }) {
|
|
|
43
45
|
el.isBuiltIn = true
|
|
44
46
|
return 'mpx-button'
|
|
45
47
|
},
|
|
48
|
+
tenon (tag, { el }) {
|
|
49
|
+
el.isBuiltIn = true
|
|
50
|
+
return 'tenon-button'
|
|
51
|
+
},
|
|
46
52
|
ios (tag, { el }) {
|
|
47
53
|
el.isBuiltIn = true
|
|
48
54
|
return 'mpx-button'
|
|
@@ -157,13 +163,18 @@ module.exports = function ({ print }) {
|
|
|
157
163
|
},
|
|
158
164
|
{
|
|
159
165
|
test: /^(open-type|lang|session-from|send-message-title|send-message-path|send-message-img|show-message-card|app-parameter)$/,
|
|
160
|
-
web: webPropLog
|
|
166
|
+
web: webPropLog,
|
|
167
|
+
tenon: tenonPropLog
|
|
161
168
|
},
|
|
162
169
|
{
|
|
163
170
|
test: /^(size|type|plain|loading|form-type|hover-class|hover-stop-propagation|hover-start-time|hover-stay-time|use-built-in)$/,
|
|
164
171
|
web (prop, { el }) {
|
|
165
172
|
// todo 这部分能力基于内部封装实现
|
|
166
173
|
el.isBuiltIn = true
|
|
174
|
+
},
|
|
175
|
+
tenon (prop, { el }) {
|
|
176
|
+
// todo 这部分能力基于内部封装实现
|
|
177
|
+
el.isBuiltIn = true
|
|
167
178
|
}
|
|
168
179
|
},
|
|
169
180
|
{
|
|
@@ -205,7 +216,8 @@ module.exports = function ({ print }) {
|
|
|
205
216
|
},
|
|
206
217
|
{
|
|
207
218
|
test: /^(getuserinfo|contact|error|launchapp|opensetting|getphonenumber)$/,
|
|
208
|
-
web: webEventLog
|
|
219
|
+
web: webEventLog,
|
|
220
|
+
tenon: tenonEventLog
|
|
209
221
|
},
|
|
210
222
|
{
|
|
211
223
|
test: /^(getuserinfo|contact|getphonenumber|bindgetrealtimephonenumber|error|opensetting|launchapp|chooseavatar|agreeprivacyauthorization)$/,
|
|
@@ -26,6 +26,10 @@ module.exports = function ({ print }) {
|
|
|
26
26
|
el.isBuiltIn = true
|
|
27
27
|
return 'mpx-input'
|
|
28
28
|
},
|
|
29
|
+
tenon (tag, { el }) {
|
|
30
|
+
el.isBuiltIn = true
|
|
31
|
+
return 'tenon-input'
|
|
32
|
+
},
|
|
29
33
|
ios (tag, { el }) {
|
|
30
34
|
el.isBuiltIn = true
|
|
31
35
|
return 'mpx-input'
|
|
@@ -92,7 +96,7 @@ module.exports = function ({ print }) {
|
|
|
92
96
|
qa: qaPropLog
|
|
93
97
|
},
|
|
94
98
|
{
|
|
95
|
-
test: /^(placeholder-style|placeholder-class|cursor-spacing|always-embed|
|
|
99
|
+
test: /^(placeholder-style|placeholder-class|cursor-spacing|always-embed|hold-keyboard|safe-password-.+)$/,
|
|
96
100
|
ios: iosPropLog,
|
|
97
101
|
android: androidPropLog
|
|
98
102
|
}
|
|
@@ -23,6 +23,10 @@ module.exports = function ({ print }) {
|
|
|
23
23
|
el.isBuiltIn = true
|
|
24
24
|
return 'mpx-scroll-view'
|
|
25
25
|
},
|
|
26
|
+
tenon (tag, { el }) {
|
|
27
|
+
el.isBuiltIn = true
|
|
28
|
+
return 'tenon-scroll-view'
|
|
29
|
+
},
|
|
26
30
|
android (tag, { el }) {
|
|
27
31
|
el.isBuiltIn = true
|
|
28
32
|
return 'mpx-scroll-view'
|
|
@@ -28,6 +28,11 @@ module.exports = function ({ print }) {
|
|
|
28
28
|
el.isBuiltIn = true
|
|
29
29
|
return 'mpx-textarea'
|
|
30
30
|
},
|
|
31
|
+
tenon (tag, { el }) {
|
|
32
|
+
// form全量使用内建组件
|
|
33
|
+
el.isBuiltIn = true
|
|
34
|
+
return 'tenon-textarea'
|
|
35
|
+
},
|
|
31
36
|
ios (tag, { el }) {
|
|
32
37
|
el.isBuiltIn = true
|
|
33
38
|
return 'mpx-textarea'
|
|
@@ -78,7 +83,7 @@ module.exports = function ({ print }) {
|
|
|
78
83
|
}
|
|
79
84
|
},
|
|
80
85
|
{
|
|
81
|
-
test: /^(placeholder-style|placeholder-class|cursor-spacing|always-embed|
|
|
86
|
+
test: /^(placeholder-style|placeholder-class|cursor-spacing|always-embed|hold-keyboard|disable-default-padding|adjust-keyboard-to|fixed|show-confirm-bar)$/,
|
|
82
87
|
ios: iosPropLog,
|
|
83
88
|
android: androidPropLog
|
|
84
89
|
}
|
|
@@ -9,7 +9,7 @@ const { dash2hump } = require('../../../utils/hump-dash')
|
|
|
9
9
|
|
|
10
10
|
module.exports = function getSpec ({ warn, error }) {
|
|
11
11
|
const spec = {
|
|
12
|
-
supportedModes: ['ali', 'swan', 'qq', 'tt', 'web', 'qa', 'jd', 'dd', 'ios', 'android'],
|
|
12
|
+
supportedModes: ['ali', 'swan', 'qq', 'tt', 'web', 'qa', 'jd', 'dd', 'ios', 'android', 'tenon'],
|
|
13
13
|
// props预处理
|
|
14
14
|
preProps: [],
|
|
15
15
|
// props后处理
|
|
@@ -28,6 +28,15 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
28
28
|
value: parsed.result
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
+
},
|
|
32
|
+
tenon ({ name, value }) {
|
|
33
|
+
const parsed = parseMustacheWithContext(value)
|
|
34
|
+
if (parsed.hasBinding) {
|
|
35
|
+
return {
|
|
36
|
+
name: name === 'animation' ? 'v-' + name : ':' + name,
|
|
37
|
+
value: parsed.result
|
|
38
|
+
}
|
|
39
|
+
}
|
|
31
40
|
}
|
|
32
41
|
}
|
|
33
42
|
],
|
|
@@ -90,6 +99,16 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
90
99
|
name: 'v-for',
|
|
91
100
|
value: `(${itemName}, ${indexName}) in ${parsed.result}`
|
|
92
101
|
}
|
|
102
|
+
},
|
|
103
|
+
tenon ({ value }, { el }) {
|
|
104
|
+
const parsed = parseMustacheWithContext(value)
|
|
105
|
+
const attrsMap = el.attrsMap
|
|
106
|
+
const itemName = attrsMap['wx:for-item'] || 'item'
|
|
107
|
+
const indexName = attrsMap['wx:for-index'] || 'index'
|
|
108
|
+
return {
|
|
109
|
+
name: 'v-for',
|
|
110
|
+
value: `(${itemName}, ${indexName}) in ${parsed.result}`
|
|
111
|
+
}
|
|
93
112
|
}
|
|
94
113
|
},
|
|
95
114
|
{
|
|
@@ -115,6 +134,25 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
115
134
|
name: ':key',
|
|
116
135
|
value
|
|
117
136
|
}
|
|
137
|
+
},
|
|
138
|
+
tenon ({ value }, { el }) {
|
|
139
|
+
// vue的template中不能包含key,对应于小程序中的block
|
|
140
|
+
if (el.tag === 'block') return false
|
|
141
|
+
const itemName = el.attrsMap['wx:for-item'] || 'item'
|
|
142
|
+
const keyName = value
|
|
143
|
+
if (value === '*this') {
|
|
144
|
+
value = itemName
|
|
145
|
+
} else {
|
|
146
|
+
if (isValidIdentifierStr(keyName)) {
|
|
147
|
+
value = `${itemName}.${keyName}`
|
|
148
|
+
} else {
|
|
149
|
+
value = `${itemName}['${keyName}']`
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return {
|
|
153
|
+
name: ':key',
|
|
154
|
+
value
|
|
155
|
+
}
|
|
118
156
|
}
|
|
119
157
|
},
|
|
120
158
|
{
|
|
@@ -125,6 +163,9 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
125
163
|
},
|
|
126
164
|
web () {
|
|
127
165
|
return false
|
|
166
|
+
},
|
|
167
|
+
tenon () {
|
|
168
|
+
return false
|
|
128
169
|
}
|
|
129
170
|
},
|
|
130
171
|
{
|
|
@@ -167,6 +208,49 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
167
208
|
}
|
|
168
209
|
]
|
|
169
210
|
}
|
|
211
|
+
},
|
|
212
|
+
tenon ({ value }, { el }) {
|
|
213
|
+
el.hasEvent = true
|
|
214
|
+
const attrsMap = el.attrsMap
|
|
215
|
+
const tagRE = /\{\{((?:.|\n|\r)+?)\}\}(?!})/
|
|
216
|
+
const stringify = JSON.stringify
|
|
217
|
+
const match = tagRE.exec(value)
|
|
218
|
+
if (match) {
|
|
219
|
+
const modelProp = attrsMap['wx:model-prop'] || 'value'
|
|
220
|
+
const modelEvent = attrsMap['wx:model-event'] || 'input'
|
|
221
|
+
const modelValuePathRaw = attrsMap['wx:model-value-path']
|
|
222
|
+
const modelValuePath = modelValuePathRaw === undefined ? 'value' : modelValuePathRaw
|
|
223
|
+
const modelFilter = attrsMap['wx:model-filter']
|
|
224
|
+
let modelValuePathArr
|
|
225
|
+
try {
|
|
226
|
+
modelValuePathArr = JSON5.parse(modelValuePath)
|
|
227
|
+
} catch (e) {
|
|
228
|
+
if (modelValuePath === '') {
|
|
229
|
+
modelValuePathArr = []
|
|
230
|
+
} else {
|
|
231
|
+
modelValuePathArr = modelValuePath.split('.')
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
const modelValue = match[1].trim()
|
|
235
|
+
return [
|
|
236
|
+
{
|
|
237
|
+
name: ':' + modelProp,
|
|
238
|
+
value: modelValue
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
name: 'mpxModelEvent',
|
|
242
|
+
value: modelEvent
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
name: 'mpxModelEventId',
|
|
246
|
+
value: Math.random().toString(36).slice(3, 11)
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
name: '@mpxModel',
|
|
250
|
+
value: `__model(${stringifyWithResolveComputed(modelValue)}, $event, ${stringify(modelValuePathArr)}, ${stringify(modelFilter)})`
|
|
251
|
+
}
|
|
252
|
+
]
|
|
253
|
+
}
|
|
170
254
|
}
|
|
171
255
|
},
|
|
172
256
|
{
|
|
@@ -183,6 +267,12 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
183
267
|
name: 'ref',
|
|
184
268
|
value: `__mpx_ref_${value}__`
|
|
185
269
|
}
|
|
270
|
+
},
|
|
271
|
+
tenon ({ value }) {
|
|
272
|
+
return {
|
|
273
|
+
name: 'ref',
|
|
274
|
+
value: `${value}`
|
|
275
|
+
}
|
|
186
276
|
}
|
|
187
277
|
},
|
|
188
278
|
{
|
|
@@ -232,6 +322,14 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
232
322
|
value: classBinding[0]
|
|
233
323
|
}
|
|
234
324
|
}
|
|
325
|
+
},
|
|
326
|
+
tenon ({ name, value }) {
|
|
327
|
+
const dir = this.test.exec(name)[1]
|
|
328
|
+
const parsed = parseMustacheWithContext(value)
|
|
329
|
+
return {
|
|
330
|
+
name: ':' + dir,
|
|
331
|
+
value: parsed.result
|
|
332
|
+
}
|
|
235
333
|
}
|
|
236
334
|
},
|
|
237
335
|
// 通用指令
|
|
@@ -289,6 +387,17 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
289
387
|
name: 'v-' + dir,
|
|
290
388
|
value: parsed.result
|
|
291
389
|
}
|
|
390
|
+
},
|
|
391
|
+
tenon ({ name, value }) {
|
|
392
|
+
let dir = this.test.exec(name)[1]
|
|
393
|
+
const parsed = parseMustacheWithContext(value)
|
|
394
|
+
if (dir === 'elif') {
|
|
395
|
+
dir = 'else-if'
|
|
396
|
+
}
|
|
397
|
+
return {
|
|
398
|
+
name: 'v-' + dir,
|
|
399
|
+
value: parsed.result
|
|
400
|
+
}
|
|
292
401
|
}
|
|
293
402
|
},
|
|
294
403
|
// 事件
|
|
@@ -432,6 +541,23 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
432
541
|
name: rPrefix + rEventName + meta.modifierStr,
|
|
433
542
|
value
|
|
434
543
|
}
|
|
544
|
+
},
|
|
545
|
+
tenon ({ name, value }, { eventRules, el }) {
|
|
546
|
+
const match = this.test.exec(name)
|
|
547
|
+
const prefix = match[1]
|
|
548
|
+
const eventName = match[2]
|
|
549
|
+
const modifierStr = match[3] || ''
|
|
550
|
+
const meta = {
|
|
551
|
+
modifierStr
|
|
552
|
+
}
|
|
553
|
+
// 记录event监听信息用于后续判断是否需要使用内置基础组件
|
|
554
|
+
el.hasEvent = true
|
|
555
|
+
const rPrefix = runRules(spec.event.prefix, prefix, { mode: 'web', meta })
|
|
556
|
+
const rEventName = runRules(eventRules, eventName, { mode: 'web' })
|
|
557
|
+
return {
|
|
558
|
+
name: rPrefix + rEventName + meta.modifierStr,
|
|
559
|
+
value
|
|
560
|
+
}
|
|
435
561
|
}
|
|
436
562
|
},
|
|
437
563
|
// 无障碍
|
|
@@ -119,6 +119,9 @@ module.exports = function (template, {
|
|
|
119
119
|
}, meta.wxsModuleMap)
|
|
120
120
|
const bindResult = bindThis.transform(rawCode, {
|
|
121
121
|
ignoreMap
|
|
122
|
+
// customBindThis (path, t) {
|
|
123
|
+
// path.replaceWith(t.callExpression(t.identifier('getValue'), [t.stringLiteral(path.node.name)]))
|
|
124
|
+
// }
|
|
122
125
|
})
|
|
123
126
|
output += `global.currentInject.render = function (createElement, getComponent) {
|
|
124
127
|
return ${bindResult.code}
|
package/lib/resolve-loader.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
module.exports = function () {
|
|
2
|
-
return `
|
|
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)})`
|
|
3
6
|
}
|