@mpxjs/webpack-plugin 2.9.67 → 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 +51 -15
- 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/canvas.js +8 -0
- 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/unsupported.js +1 -1
- package/lib/platform/template/wx/component-config/view.js +4 -0
- package/lib/platform/template/wx/index.js +127 -1
- package/lib/react/processStyles.js +14 -4
- package/lib/react/processTemplate.js +3 -0
- package/lib/resolve-loader.js +4 -1
- package/lib/resolver/AddModePlugin.js +8 -8
- package/lib/runtime/components/react/context.ts +6 -0
- package/lib/runtime/components/react/dist/context.js +2 -0
- package/lib/runtime/components/react/dist/event.config.js +24 -24
- package/lib/runtime/components/react/dist/getInnerListeners.js +183 -174
- package/lib/runtime/components/react/dist/mpx-button.jsx +77 -49
- package/lib/runtime/components/react/dist/mpx-canvas/Bus.js +60 -0
- package/lib/runtime/components/react/dist/mpx-canvas/CanvasGradient.js +15 -0
- package/lib/runtime/components/react/dist/mpx-canvas/CanvasRenderingContext2D.js +84 -0
- package/lib/runtime/components/react/dist/mpx-canvas/Image.js +87 -0
- package/lib/runtime/components/react/dist/mpx-canvas/ImageData.js +15 -0
- package/lib/runtime/components/react/dist/mpx-canvas/constructorsRegistry.js +28 -0
- package/lib/runtime/components/react/dist/mpx-canvas/html.js +343 -0
- package/lib/runtime/components/react/dist/mpx-canvas/index.jsx +232 -0
- package/lib/runtime/components/react/dist/mpx-canvas/utils.jsx +89 -0
- 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 +160 -88
- package/lib/runtime/components/react/dist/mpx-picker-view.jsx +80 -121
- 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 +65 -61
- package/lib/runtime/components/react/dist/mpx-web-view.jsx +112 -35
- package/lib/runtime/components/react/dist/pickerFaces.js +81 -0
- 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/pickerViewOverlay.jsx +23 -0
- package/lib/runtime/components/react/dist/useAnimationHooks.js +35 -9
- package/lib/runtime/components/react/dist/utils.jsx +70 -23
- package/lib/runtime/components/react/getInnerListeners.ts +36 -43
- package/lib/runtime/components/react/mpx-button.tsx +95 -43
- package/lib/runtime/components/react/mpx-canvas/Bus.ts +70 -0
- package/lib/runtime/components/react/mpx-canvas/CanvasGradient.ts +18 -0
- package/lib/runtime/components/react/mpx-canvas/CanvasRenderingContext2D.ts +87 -0
- package/lib/runtime/components/react/mpx-canvas/Image.ts +102 -0
- package/lib/runtime/components/react/mpx-canvas/ImageData.ts +23 -0
- package/lib/runtime/components/react/mpx-canvas/constructorsRegistry.ts +38 -0
- package/lib/runtime/components/react/mpx-canvas/html.ts +343 -0
- package/lib/runtime/components/react/mpx-canvas/index.tsx +302 -0
- package/lib/runtime/components/react/mpx-canvas/utils.tsx +150 -0
- 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 +236 -104
- package/lib/runtime/components/react/mpx-picker-view.tsx +132 -122
- 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 +81 -59
- package/lib/runtime/components/react/mpx-web-view.tsx +46 -19
- package/lib/runtime/components/react/pickerFaces.ts +104 -0
- package/lib/runtime/components/react/pickerOverlay.tsx +32 -0
- package/lib/runtime/components/react/types/common.ts +2 -0
- package/lib/runtime/components/react/types/global.d.ts +3 -16
- package/lib/runtime/components/react/utils.tsx +98 -27
- 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 +70 -42
- package/lib/template-compiler/gen-node-react.js +3 -3
- 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 +9 -4
- 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
|
@@ -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
|
// 无障碍
|
|
@@ -56,13 +56,23 @@ module.exports = function (styles, {
|
|
|
56
56
|
error
|
|
57
57
|
})
|
|
58
58
|
if (ctorType === 'app') {
|
|
59
|
-
output += `
|
|
60
|
-
|
|
59
|
+
output += `
|
|
60
|
+
let __appClassMap
|
|
61
|
+
global.__getAppClassMap = function() {
|
|
62
|
+
if(!__appClassMap) {
|
|
63
|
+
__appClassMap = ${shallowStringify(classMap)};
|
|
64
|
+
}
|
|
65
|
+
return __appClassMap;
|
|
61
66
|
};\n`
|
|
62
67
|
} else {
|
|
63
|
-
output += `
|
|
68
|
+
output += `
|
|
69
|
+
let __classMap
|
|
70
|
+
global.currentInject.injectMethods = {
|
|
64
71
|
__getClassMap: function() {
|
|
65
|
-
|
|
72
|
+
if(!__classMap) {
|
|
73
|
+
__classMap = ${shallowStringify(classMap)};
|
|
74
|
+
}
|
|
75
|
+
return __classMap;
|
|
66
76
|
}
|
|
67
77
|
};\n`
|
|
68
78
|
}
|
|
@@ -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
|
}
|
|
@@ -6,17 +6,17 @@ const addInfix = require('../utils/add-infix')
|
|
|
6
6
|
const { JSON_JS_EXT } = require('../utils/const')
|
|
7
7
|
|
|
8
8
|
module.exports = class AddModePlugin {
|
|
9
|
-
constructor (source, mode,
|
|
9
|
+
constructor (source, mode, options, target) {
|
|
10
10
|
this.source = source
|
|
11
11
|
this.target = target
|
|
12
12
|
this.mode = mode
|
|
13
|
-
this.
|
|
14
|
-
this.defaultMode = defaultMode
|
|
13
|
+
this.options = options
|
|
15
14
|
}
|
|
16
15
|
|
|
17
16
|
apply (resolver) {
|
|
18
17
|
const target = resolver.ensureHook(this.target)
|
|
19
|
-
const {
|
|
18
|
+
const { options = {}, mode } = this
|
|
19
|
+
const { defaultMode, fileConditionRules, implicitMode } = options
|
|
20
20
|
resolver.getHook(this.source).tapAsync('AddModePlugin', (request, resolveContext, callback) => {
|
|
21
21
|
if (request.mode || request.env) {
|
|
22
22
|
return callback()
|
|
@@ -32,20 +32,20 @@ module.exports = class AddModePlugin {
|
|
|
32
32
|
extname = path.extname(resourcePath)
|
|
33
33
|
}
|
|
34
34
|
// 当前资源没有后缀名或者路径不符合fileConditionRules规则时,直接返回
|
|
35
|
-
if (!extname || !matchCondition(resourcePath,
|
|
35
|
+
if (!extname || !matchCondition(resourcePath, fileConditionRules)) return callback()
|
|
36
36
|
const queryObj = parseQuery(request.query || '?')
|
|
37
37
|
const queryInfix = queryObj.infix
|
|
38
|
-
queryObj.mode = mode
|
|
38
|
+
if (!implicitMode) queryObj.mode = mode
|
|
39
39
|
queryObj.infix = `${queryInfix || ''}.${mode}`
|
|
40
40
|
obj.query = stringifyQuery(queryObj)
|
|
41
41
|
obj.path = addInfix(resourcePath, mode, extname)
|
|
42
42
|
obj.relativePath = request.relativePath && addInfix(request.relativePath, mode, extname)
|
|
43
43
|
resolver.doResolve(target, Object.assign({}, request, obj), 'add mode: ' + mode, resolveContext, (err, result) => {
|
|
44
|
-
if (
|
|
44
|
+
if (defaultMode && !result) {
|
|
45
45
|
queryObj.infix = `${queryInfix || ''}.${defaultMode}`
|
|
46
46
|
obj.query = stringifyQuery(queryObj)
|
|
47
47
|
obj.path = addInfix(resourcePath, defaultMode, extname)
|
|
48
|
-
resolver.doResolve(target, Object.assign({}, request, obj), 'add mode: ' +
|
|
48
|
+
resolver.doResolve(target, Object.assign({}, request, obj), 'add mode: ' + defaultMode, resolveContext, (err, result) => {
|
|
49
49
|
callback(err, result)
|
|
50
50
|
})
|
|
51
51
|
return
|
|
@@ -5,6 +5,8 @@ export type LabelContextValue = MutableRefObject<{
|
|
|
5
5
|
triggerChange: (evt: NativeSyntheticEvent<TouchEvent>) => void
|
|
6
6
|
}>
|
|
7
7
|
|
|
8
|
+
export type KeyboardAvoidContextValue = (enabled: boolean) => void
|
|
9
|
+
|
|
8
10
|
export interface GroupValue {
|
|
9
11
|
[key: string]: { checked: boolean; setValue: Dispatch<SetStateAction<boolean>> }
|
|
10
12
|
}
|
|
@@ -46,3 +48,7 @@ export const PickerContext = createContext(null)
|
|
|
46
48
|
export const VarContext = createContext({})
|
|
47
49
|
|
|
48
50
|
export const IntersectionObserverContext = createContext<IntersectionObserver | null>(null)
|
|
51
|
+
|
|
52
|
+
export const RouteContext = createContext<number | null>(null)
|
|
53
|
+
|
|
54
|
+
export const KeyboardAvoidContext = createContext<KeyboardAvoidContextValue | null>(null)
|
|
@@ -7,3 +7,5 @@ export const LabelContext = createContext(null);
|
|
|
7
7
|
export const PickerContext = createContext(null);
|
|
8
8
|
export const VarContext = createContext({});
|
|
9
9
|
export const IntersectionObserverContext = createContext(null);
|
|
10
|
+
export const RouteContext = createContext(null);
|
|
11
|
+
export const KeyboardAvoidContext = createContext(null);
|
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
const eventConfigMap = {
|
|
2
|
-
bindtap: ['onTouchStart', 'onTouchMove', 'onTouchEnd'],
|
|
3
|
-
bindlongpress: ['onTouchStart', 'onTouchMove', 'onTouchEnd', 'onTouchCancel'],
|
|
4
|
-
bindtouchstart: ['onTouchStart'],
|
|
5
|
-
bindtouchmove: ['onTouchMove'],
|
|
6
|
-
bindtouchend: ['onTouchEnd'],
|
|
7
|
-
bindtouchcancel: ['onTouchCancel'],
|
|
8
|
-
catchtap: ['onTouchStart', 'onTouchMove', 'onTouchEnd'],
|
|
9
|
-
catchlongpress: ['onTouchStart', 'onTouchMove', 'onTouchEnd', 'onTouchCancel'],
|
|
10
|
-
catchtouchstart: ['onTouchStart'],
|
|
11
|
-
catchtouchmove: ['onTouchMove'],
|
|
12
|
-
catchtouchend: ['onTouchEnd'],
|
|
13
|
-
catchtouchcancel: ['onTouchCancel'],
|
|
14
|
-
'capture-bindtap': ['onTouchStartCapture', 'onTouchMoveCapture', 'onTouchEndCapture'],
|
|
15
|
-
'capture-bindlongpress': ['onTouchStartCapture', 'onTouchMoveCapture', 'onTouchEndCapture', 'onTouchCancelCapture'],
|
|
16
|
-
'capture-bindtouchstart': ['onTouchStartCapture'],
|
|
17
|
-
'capture-bindtouchmove': ['onTouchMoveCapture'],
|
|
18
|
-
'capture-bindtouchend': ['onTouchEndCapture'],
|
|
19
|
-
'capture-bindtouchcancel': ['onTouchCancelCapture'],
|
|
20
|
-
'capture-catchtap': ['onTouchStartCapture', 'onTouchMoveCapture', 'onTouchEndCapture'],
|
|
21
|
-
'capture-catchlongpress': ['onTouchStartCapture', 'onTouchMoveCapture', 'onTouchEndCapture', 'onTouchCancelCapture'],
|
|
22
|
-
'capture-catchtouchstart': ['onTouchStartCapture'],
|
|
23
|
-
'capture-catchtouchmove': ['onTouchMoveCapture'],
|
|
24
|
-
'capture-catchtouchend': ['onTouchEndCapture'],
|
|
25
|
-
'capture-catchtouchcancel': ['onTouchCancelCapture']
|
|
2
|
+
bindtap: { bitFlag: '0', events: ['onTouchStart', 'onTouchMove', 'onTouchEnd'] },
|
|
3
|
+
bindlongpress: { bitFlag: '1', events: ['onTouchStart', 'onTouchMove', 'onTouchEnd', 'onTouchCancel'] },
|
|
4
|
+
bindtouchstart: { bitFlag: '2', events: ['onTouchStart'] },
|
|
5
|
+
bindtouchmove: { bitFlag: '3', events: ['onTouchMove'] },
|
|
6
|
+
bindtouchend: { bitFlag: '4', events: ['onTouchEnd'] },
|
|
7
|
+
bindtouchcancel: { bitFlag: '5', events: ['onTouchCancel'] },
|
|
8
|
+
catchtap: { bitFlag: '6', events: ['onTouchStart', 'onTouchMove', 'onTouchEnd'] },
|
|
9
|
+
catchlongpress: { bitFlag: '7', events: ['onTouchStart', 'onTouchMove', 'onTouchEnd', 'onTouchCancel'] },
|
|
10
|
+
catchtouchstart: { bitFlag: '8', events: ['onTouchStart'] },
|
|
11
|
+
catchtouchmove: { bitFlag: '9', events: ['onTouchMove'] },
|
|
12
|
+
catchtouchend: { bitFlag: 'a', events: ['onTouchEnd'] },
|
|
13
|
+
catchtouchcancel: { bitFlag: 'b', events: ['onTouchCancel'] },
|
|
14
|
+
'capture-bindtap': { bitFlag: 'c', events: ['onTouchStartCapture', 'onTouchMoveCapture', 'onTouchEndCapture'] },
|
|
15
|
+
'capture-bindlongpress': { bitFlag: 'd', events: ['onTouchStartCapture', 'onTouchMoveCapture', 'onTouchEndCapture', 'onTouchCancelCapture'] },
|
|
16
|
+
'capture-bindtouchstart': { bitFlag: 'e', events: ['onTouchStartCapture'] },
|
|
17
|
+
'capture-bindtouchmove': { bitFlag: 'f', events: ['onTouchMoveCapture'] },
|
|
18
|
+
'capture-bindtouchend': { bitFlag: 'g', events: ['onTouchEndCapture'] },
|
|
19
|
+
'capture-bindtouchcancel': { bitFlag: 'h', events: ['onTouchCancelCapture'] },
|
|
20
|
+
'capture-catchtap': { bitFlag: 'i', events: ['onTouchStartCapture', 'onTouchMoveCapture', 'onTouchEndCapture'] },
|
|
21
|
+
'capture-catchlongpress': { bitFlag: 'j', events: ['onTouchStartCapture', 'onTouchMoveCapture', 'onTouchEndCapture', 'onTouchCancelCapture'] },
|
|
22
|
+
'capture-catchtouchstart': { bitFlag: 'k', events: ['onTouchStartCapture'] },
|
|
23
|
+
'capture-catchtouchmove': { bitFlag: 'l', events: ['onTouchMoveCapture'] },
|
|
24
|
+
'capture-catchtouchend': { bitFlag: 'm', events: ['onTouchEndCapture'] },
|
|
25
|
+
'capture-catchtouchcancel': { bitFlag: 'n', events: ['onTouchCancelCapture'] }
|
|
26
26
|
};
|
|
27
27
|
export default eventConfigMap;
|