@mpxjs/webpack-plugin 2.10.4 → 2.10.5-beta.1

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 (100) hide show
  1. package/lib/index.js +10 -1
  2. package/lib/json-compiler/helper.js +1 -4
  3. package/lib/platform/json/wx/index.js +0 -1
  4. package/lib/platform/style/wx/index.js +22 -21
  5. package/lib/platform/template/wx/component-config/button.js +1 -1
  6. package/lib/platform/template/wx/component-config/index.js +5 -1
  7. package/lib/platform/template/wx/component-config/input.js +1 -1
  8. package/lib/platform/template/wx/component-config/sticky-header.js +23 -0
  9. package/lib/platform/template/wx/component-config/sticky-section.js +23 -0
  10. package/lib/platform/template/wx/index.js +21 -1
  11. package/lib/react/processJSON.js +7 -6
  12. package/lib/react/processScript.js +9 -1
  13. package/lib/react/script-helper.js +5 -1
  14. package/lib/resolver/PackageEntryPlugin.js +3 -1
  15. package/lib/runtime/components/react/context.ts +12 -3
  16. package/lib/runtime/components/react/dist/context.js +4 -1
  17. package/lib/runtime/components/react/dist/event.config.js +0 -2
  18. package/lib/runtime/components/react/dist/getInnerListeners.js +127 -153
  19. package/lib/runtime/components/react/dist/mpx-button.jsx +11 -7
  20. package/lib/runtime/components/react/dist/mpx-canvas/Image.js +2 -4
  21. package/lib/runtime/components/react/dist/mpx-canvas/index.jsx +23 -21
  22. package/lib/runtime/components/react/dist/mpx-checkbox-group.jsx +9 -4
  23. package/lib/runtime/components/react/dist/mpx-checkbox.jsx +9 -5
  24. package/lib/runtime/components/react/dist/mpx-form.jsx +2 -2
  25. package/lib/runtime/components/react/dist/mpx-icon/index.jsx +9 -4
  26. package/lib/runtime/components/react/dist/mpx-image.jsx +11 -4
  27. package/lib/runtime/components/react/dist/mpx-input.jsx +24 -13
  28. package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.jsx +23 -30
  29. package/lib/runtime/components/react/dist/mpx-label.jsx +9 -5
  30. package/lib/runtime/components/react/dist/mpx-movable-area.jsx +9 -4
  31. package/lib/runtime/components/react/dist/mpx-movable-view.jsx +77 -43
  32. package/lib/runtime/components/react/dist/mpx-navigator.jsx +11 -3
  33. package/lib/runtime/components/react/dist/mpx-picker/index.jsx +12 -14
  34. package/lib/runtime/components/react/dist/mpx-picker-view/index.jsx +10 -10
  35. package/lib/runtime/components/react/dist/mpx-picker-view-column/index.jsx +28 -10
  36. package/lib/runtime/components/react/dist/mpx-radio-group.jsx +11 -4
  37. package/lib/runtime/components/react/dist/mpx-radio.jsx +9 -5
  38. package/lib/runtime/components/react/dist/mpx-rich-text/index.jsx +9 -4
  39. package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +31 -11
  40. package/lib/runtime/components/react/dist/mpx-simple-text.jsx +3 -2
  41. package/lib/runtime/components/react/dist/mpx-simple-view.jsx +3 -3
  42. package/lib/runtime/components/react/dist/mpx-sticky-header.jsx +115 -0
  43. package/lib/runtime/components/react/dist/mpx-sticky-section.jsx +45 -0
  44. package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +15 -14
  45. package/lib/runtime/components/react/dist/mpx-swiper.jsx +86 -40
  46. package/lib/runtime/components/react/dist/mpx-switch.jsx +10 -7
  47. package/lib/runtime/components/react/dist/mpx-text.jsx +11 -9
  48. package/lib/runtime/components/react/dist/mpx-video.jsx +9 -4
  49. package/lib/runtime/components/react/dist/mpx-view.jsx +15 -10
  50. package/lib/runtime/components/react/dist/mpx-web-view.jsx +13 -13
  51. package/lib/runtime/components/react/dist/useAnimationHooks.js +27 -4
  52. package/lib/runtime/components/react/dist/utils.jsx +99 -98
  53. package/lib/runtime/components/react/event.config.ts +1 -8
  54. package/lib/runtime/components/react/getInnerListeners.ts +146 -192
  55. package/lib/runtime/components/react/mpx-button.tsx +16 -8
  56. package/lib/runtime/components/react/mpx-canvas/Image.ts +4 -4
  57. package/lib/runtime/components/react/mpx-canvas/index.tsx +47 -32
  58. package/lib/runtime/components/react/mpx-checkbox-group.tsx +13 -4
  59. package/lib/runtime/components/react/mpx-checkbox.tsx +17 -10
  60. package/lib/runtime/components/react/mpx-form.tsx +25 -19
  61. package/lib/runtime/components/react/mpx-icon/index.tsx +13 -4
  62. package/lib/runtime/components/react/mpx-image.tsx +42 -22
  63. package/lib/runtime/components/react/mpx-input.tsx +32 -16
  64. package/lib/runtime/components/react/mpx-keyboard-avoiding-view.tsx +31 -42
  65. package/lib/runtime/components/react/mpx-label.tsx +13 -6
  66. package/lib/runtime/components/react/mpx-movable-area.tsx +29 -14
  67. package/lib/runtime/components/react/mpx-movable-view.tsx +121 -81
  68. package/lib/runtime/components/react/mpx-navigator.tsx +4 -6
  69. package/lib/runtime/components/react/mpx-picker/index.tsx +24 -19
  70. package/lib/runtime/components/react/mpx-picker-view/index.tsx +39 -22
  71. package/lib/runtime/components/react/mpx-picker-view-column/index.tsx +36 -32
  72. package/lib/runtime/components/react/mpx-radio-group.tsx +24 -12
  73. package/lib/runtime/components/react/mpx-radio.tsx +17 -10
  74. package/lib/runtime/components/react/mpx-rich-text/index.tsx +25 -8
  75. package/lib/runtime/components/react/mpx-scroll-view.tsx +95 -60
  76. package/lib/runtime/components/react/mpx-simple-text.tsx +10 -3
  77. package/lib/runtime/components/react/mpx-simple-view.tsx +10 -4
  78. package/lib/runtime/components/react/mpx-sticky-header.tsx +179 -0
  79. package/lib/runtime/components/react/mpx-sticky-section.tsx +96 -0
  80. package/lib/runtime/components/react/mpx-swiper-item.tsx +42 -43
  81. package/lib/runtime/components/react/mpx-swiper.tsx +142 -79
  82. package/lib/runtime/components/react/mpx-switch.tsx +29 -16
  83. package/lib/runtime/components/react/mpx-text.tsx +26 -15
  84. package/lib/runtime/components/react/mpx-video.tsx +41 -35
  85. package/lib/runtime/components/react/mpx-view.tsx +38 -18
  86. package/lib/runtime/components/react/mpx-web-view.tsx +12 -12
  87. package/lib/runtime/components/react/types/getInnerListeners.d.ts +65 -35
  88. package/lib/runtime/components/react/useAnimationHooks.ts +30 -9
  89. package/lib/runtime/components/react/utils.tsx +107 -103
  90. package/lib/runtime/components/web/mpx-scroll-view.vue +21 -4
  91. package/lib/runtime/components/web/mpx-sticky-header.vue +91 -0
  92. package/lib/runtime/components/web/mpx-sticky-section.vue +15 -0
  93. package/lib/runtime/components/web/mpx-web-view.vue +1 -1
  94. package/lib/runtime/mpxGlobal.js +1 -0
  95. package/lib/runtime/optionProcessor.d.ts +5 -0
  96. package/lib/template-compiler/bind-this.js +8 -7
  97. package/lib/template-compiler/compiler.js +1 -1
  98. package/lib/wxs/pre-loader.js +1 -0
  99. package/package.json +3 -3
  100. package/LICENSE +0 -433
package/lib/index.js CHANGED
@@ -17,6 +17,7 @@ const FileSystemInfo = require('webpack/lib/FileSystemInfo')
17
17
  const ImportDependency = require('webpack/lib/dependencies/ImportDependency')
18
18
  const ImportDependencyTemplate = require('./dependencies/ImportDependencyTemplate')
19
19
  const AsyncDependenciesBlock = require('webpack/lib/AsyncDependenciesBlock')
20
+ const ProvidePlugin = require('webpack/lib/ProvidePlugin')
20
21
  const normalize = require('./utils/normalize')
21
22
  const toPosix = require('./utils/to-posix')
22
23
  const addQuery = require('./utils/add-query')
@@ -60,6 +61,7 @@ const templateCompilerPath = normalize.lib('template-compiler/index')
60
61
  const jsonCompilerPath = normalize.lib('json-compiler/index')
61
62
  const jsonThemeCompilerPath = normalize.lib('json-compiler/theme')
62
63
  const jsonPluginCompilerPath = normalize.lib('json-compiler/plugin')
64
+ const mpxGlobalRuntimePath = normalize.lib('runtime/mpxGlobal')
63
65
  const extractorPath = normalize.lib('extractor')
64
66
  const async = require('async')
65
67
  const { parseQuery } = require('loader-utils')
@@ -177,6 +179,7 @@ class MpxWebpackPlugin {
177
179
  options.forceProxyEventRules = options.forceProxyEventRules || {}
178
180
  options.disableRequireAsync = options.disableRequireAsync || false
179
181
  options.miniNpmPackages = options.miniNpmPackages || []
182
+ options.normalNpmPackages = options.normalNpmPackages || []
180
183
  options.fileConditionRules = options.fileConditionRules || {
181
184
  include: () => true
182
185
  }
@@ -325,6 +328,12 @@ class MpxWebpackPlugin {
325
328
  }
326
329
  }
327
330
 
331
+ compiler.options.plugins.push(new ProvidePlugin(
332
+ {
333
+ mpxGlobal: mpxGlobalRuntimePath
334
+ }
335
+ ))
336
+
328
337
  if (!isWeb(this.options.mode) && !isReact(this.options.mode)) {
329
338
  // 强制设置publicPath为'/'
330
339
  if (compiler.options.output.publicPath && compiler.options.output.publicPath !== publicPath) {
@@ -364,7 +373,7 @@ class MpxWebpackPlugin {
364
373
  }
365
374
  const addModePlugin = new AddModePlugin('before-file', this.options.mode, addModeOptions, 'file')
366
375
  const addEnvPlugin = new AddEnvPlugin('before-file', this.options.env, this.options.fileConditionRules, 'file')
367
- const packageEntryPlugin = new PackageEntryPlugin('before-file', this.options.miniNpmPackages, 'file')
376
+ const packageEntryPlugin = new PackageEntryPlugin('before-file', this.options.miniNpmPackages, this.options.normalNpmPackages, 'file')
368
377
  const dynamicPlugin = new DynamicPlugin('result', this.options.dynamicComponentRules)
369
378
 
370
379
  if (Array.isArray(compiler.options.resolve.plugins)) {
@@ -77,12 +77,9 @@ module.exports = function createJSONHelper ({ loaderContext, emitWarning, custom
77
77
 
78
78
  if (!outputPath) {
79
79
  if (isScript(ext) && resourceName.includes('node_modules') && !isWeb(mode) && !isReact(mode)) {
80
- let root = info.descriptionFileRoot
80
+ const root = info.descriptionFileRoot
81
81
  let name = 'nativeComponent'
82
82
  if (info.descriptionFileData) {
83
- if (info.descriptionFileData.miniprogram) {
84
- root = path.join(root, info.descriptionFileData.miniprogram)
85
- }
86
83
  if (info.descriptionFileData.name) {
87
84
  // 去掉name里面的@符号,因为支付宝不支持文件路径上有@
88
85
  name = info.descriptionFileData.name.replace(/@/g, '')
@@ -354,7 +354,6 @@ module.exports = function getSpec ({ warn, error }) {
354
354
  },
355
355
  {
356
356
  test: 'preloadRule',
357
- tt: deletePath(),
358
357
  jd: deletePath()
359
358
  },
360
359
  {
@@ -184,8 +184,9 @@ module.exports = function getSpec ({ warn, error }) {
184
184
  'border-top': ['borderTopWidth', 'borderTopStyle', 'borderTopColor'],
185
185
  // 仅支持 width | style | color 这种排序
186
186
  'border-bottom': ['borderBottomWidth', 'borderBottomStyle', 'borderBottomColor'],
187
+ // 0.76 及以上版本RN支持 box-shadow,实测0.77版本drn红米note12pro Android12 不支持内阴影,其他表现和web一致
187
188
  // 仅支持 offset-x | offset-y | blur-radius | color 排序
188
- 'box-shadow': ['shadowOffset.width', 'shadowOffset.height', 'shadowRadius', 'shadowColor'],
189
+ // 'box-shadow': ['shadowOffset.width', 'shadowOffset.height', 'shadowRadius', 'shadowColor'],
189
190
  // 仅支持 text-decoration-line text-decoration-style text-decoration-color 这种格式
190
191
  'text-decoration': ['textDecorationLine', 'textDecorationStyle', 'textDecorationColor'],
191
192
  // flex-grow | flex-shrink | flex-basis
@@ -525,20 +526,20 @@ module.exports = function getSpec ({ warn, error }) {
525
526
  return { prop, value: values[0].trim() }
526
527
  }
527
528
 
528
- const formatBoxShadow = ({ prop, value, selector }, { mode }) => {
529
- value = value.trim()
530
- if (value === 'none') {
531
- return false
532
- }
533
- const cssMap = formatAbbreviation({ prop, value, selector }, { mode })
534
- if (mode === 'android' || mode === 'harmony') return cssMap
535
- // ios 阴影需要额外设置 shadowOpacity=1
536
- cssMap.push({
537
- prop: 'shadowOpacity',
538
- value: 1
539
- })
540
- return cssMap
541
- }
529
+ // const formatBoxShadow = ({ prop, value, selector }, { mode }) => {
530
+ // value = value.trim()
531
+ // if (value === 'none') {
532
+ // return false
533
+ // }
534
+ // const cssMap = formatAbbreviation({ prop, value, selector }, { mode })
535
+ // if (mode === 'android' || mode === 'harmony') return cssMap
536
+ // // ios 阴影需要额外设置 shadowOpacity=1
537
+ // cssMap.push({
538
+ // prop: 'shadowOpacity',
539
+ // value: 1
540
+ // })
541
+ // return cssMap
542
+ // }
542
543
 
543
544
  return {
544
545
  supportedModes: ['ios', 'android', 'harmony'],
@@ -579,12 +580,12 @@ module.exports = function getSpec ({ warn, error }) {
579
580
  android: formatFontFamily,
580
581
  harmony: formatFontFamily
581
582
  },
582
- {
583
- test: 'box-shadow',
584
- ios: formatBoxShadow,
585
- android: formatBoxShadow,
586
- harmony: formatBoxShadow
587
- },
583
+ // {
584
+ // test: 'box-shadow',
585
+ // ios: formatBoxShadow,
586
+ // android: formatBoxShadow,
587
+ // harmony: formatBoxShadow
588
+ // },
588
589
  // 通用的简写格式匹配
589
590
  {
590
591
  test: new RegExp('^(' + Object.keys(AbbreviationMap).join('|') + ')$'),
@@ -124,7 +124,7 @@ module.exports = function ({ print }) {
124
124
  if (isMustache(value)) {
125
125
  ttValueLog({ name, value })
126
126
  } else {
127
- const supportList = ['share', 'getPhoneNumber', 'contact', 'im', 'openSetting']
127
+ const supportList = ['share', 'getPhoneNumber', 'contact', 'im', 'openSetting', 'addShortcut']
128
128
  if (value && supportList.indexOf(value) === -1) {
129
129
  ttValueLogError({ name, value })
130
130
  }
@@ -42,6 +42,8 @@ const wxs = require('./wxs')
42
42
  const component = require('./component')
43
43
  const fixComponentName = require('./fix-component-name')
44
44
  const rootPortal = require('./root-portal')
45
+ const stickyHeader = require('./sticky-header')
46
+ const stickySection = require('./sticky-section')
45
47
 
46
48
  module.exports = function getComponentConfigs ({ warn, error }) {
47
49
  /**
@@ -125,6 +127,8 @@ module.exports = function getComponentConfigs ({ warn, error }) {
125
127
  hyphenTagName({ print }),
126
128
  label({ print }),
127
129
  component(),
128
- rootPortal({ print })
130
+ rootPortal({ print }),
131
+ stickyHeader({ print }),
132
+ stickySection({ print })
129
133
  ]
130
134
  }
@@ -51,7 +51,7 @@ module.exports = function ({ print }) {
51
51
  swan: baiduPropLog
52
52
  },
53
53
  {
54
- test: /^(placeholder-class|auto-focus|confirm-type|confirm-hold|adjust-position|hold-keyboard)$/,
54
+ test: /^(auto-focus|confirm-type|confirm-hold|adjust-position|hold-keyboard)$/,
55
55
  tt: ttPropLog
56
56
  },
57
57
  {
@@ -0,0 +1,23 @@
1
+ const TAG_NAME = 'sticky-header'
2
+
3
+ module.exports = function ({ print }) {
4
+ return {
5
+ test: TAG_NAME,
6
+ android (tag, { el }) {
7
+ el.isBuiltIn = true
8
+ return 'mpx-sticky-header'
9
+ },
10
+ ios (tag, { el }) {
11
+ el.isBuiltIn = true
12
+ return 'mpx-sticky-header'
13
+ },
14
+ harmony (tag, { el }) {
15
+ el.isBuiltIn = true
16
+ return 'mpx-sticky-header'
17
+ },
18
+ web (tag, { el }) {
19
+ el.isBuiltIn = true
20
+ return 'mpx-sticky-header'
21
+ }
22
+ }
23
+ }
@@ -0,0 +1,23 @@
1
+ const TAG_NAME = 'sticky-section'
2
+
3
+ module.exports = function ({ print }) {
4
+ return {
5
+ test: TAG_NAME,
6
+ android (tag, { el }) {
7
+ el.isBuiltIn = true
8
+ return 'mpx-sticky-section'
9
+ },
10
+ ios (tag, { el }) {
11
+ el.isBuiltIn = true
12
+ return 'mpx-sticky-section'
13
+ },
14
+ harmony (tag, { el }) {
15
+ el.isBuiltIn = true
16
+ return 'mpx-sticky-section'
17
+ },
18
+ web (tag, { el }) {
19
+ el.isBuiltIn = true
20
+ return 'mpx-sticky-section'
21
+ }
22
+ }
23
+ }
@@ -43,6 +43,23 @@ module.exports = function getSpec ({ warn, error }) {
43
43
  }
44
44
  }
45
45
 
46
+ function rnAccessibilityRulesHandle ({ name, value }) {
47
+ if (name === 'aria-role') {
48
+ return [
49
+ {
50
+ name: 'accessible',
51
+ value: true
52
+ },
53
+ {
54
+ name: 'accessibilityRole',
55
+ value: value
56
+ }
57
+ ]
58
+ } else {
59
+ return { name, value }
60
+ }
61
+ }
62
+
46
63
  const spec = {
47
64
  supportedModes: ['ali', 'swan', 'qq', 'tt', 'web', 'qa', 'jd', 'dd', 'ios', 'android', 'harmony'],
48
65
  // props预处理
@@ -433,7 +450,10 @@ module.exports = function getSpec ({ warn, error }) {
433
450
  test: /^aria-(role|label)$/,
434
451
  ali () {
435
452
  warn('Ali environment does not support aria-role|label props!')
436
- }
453
+ },
454
+ ios: rnAccessibilityRulesHandle,
455
+ android: rnAccessibilityRulesHandle,
456
+ harmony: rnAccessibilityRulesHandle
437
457
  }
438
458
  ],
439
459
  event: {
@@ -113,13 +113,14 @@ module.exports = function (jsonContent, {
113
113
  }
114
114
 
115
115
  if (ctorType === 'page') {
116
- const keysToExtract = ['navigationStyle']
116
+ // const keysToExtract = ['navigationStyle']
117
117
  const configObj = {}
118
- keysToExtract.forEach(key => {
119
- if (jsonObj[key]) {
120
- configObj[key] = jsonObj[key]
121
- }
122
- })
118
+ // 暂时先不注入数据,后续如需要使用再用
119
+ // keysToExtract.forEach(key => {
120
+ // if (jsonObj[key]) {
121
+ // configObj[key] = jsonObj[key]
122
+ // }
123
+ // })
123
124
  loaderContext._module.addPresentationalDependency(new RecordPageConfigsMapDependency(parseRequest(loaderContext.resource).resourcePath, configObj))
124
125
  }
125
126
 
@@ -16,6 +16,8 @@ module.exports = function (script, {
16
16
  componentGenerics,
17
17
  genericsInfo
18
18
  }, callback) {
19
+ const { appInfo } = loaderContext.getMpx()
20
+
19
21
  let scriptSrcMode = srcMode
20
22
  if (script) {
21
23
  scriptSrcMode = script.mode || scriptSrcMode
@@ -23,6 +25,12 @@ module.exports = function (script, {
23
25
  script = { tag: 'script' }
24
26
  }
25
27
 
28
+ let hasApp = true
29
+
30
+ if (!appInfo.name) {
31
+ hasApp = false
32
+ }
33
+
26
34
  let output = '/* script */\n'
27
35
  if (ctorType === 'app') {
28
36
  output += `
@@ -38,7 +46,7 @@ import { getComponent } from ${stringifyRequest(loaderContext, optionProcessorPa
38
46
  loaderContext,
39
47
  jsonConfig
40
48
  })
41
- output += buildGlobalParams({ moduleId, scriptSrcMode, loaderContext, isProduction, ctorType, jsonConfig, componentsMap, pagesMap, firstPage })
49
+ output += buildGlobalParams({ moduleId, scriptSrcMode, loaderContext, isProduction, ctorType, jsonConfig, componentsMap, pagesMap, firstPage, hasApp })
42
50
  output += getRequireScript({ ctorType, script, loaderContext })
43
51
  output += `export default global.__mpxOptionsMap[${JSON.stringify(moduleId)}]\n`
44
52
  } else {
@@ -90,7 +90,8 @@ function buildGlobalParams ({
90
90
  pagesMap,
91
91
  firstPage,
92
92
  outputPath,
93
- genericsInfo
93
+ genericsInfo,
94
+ hasApp
94
95
  }) {
95
96
  let content = ''
96
97
  if (ctorType === 'app') {
@@ -111,6 +112,9 @@ global.currentInject.getPages = function () {
111
112
  }
112
113
  global.currentInject.firstPage = ${JSON.stringify(firstPage)}\n`
113
114
  } else {
115
+ if (!hasApp) {
116
+ content += ' global.__mpxGenericsMap = global.__mpxGenericsMap || {}\n'
117
+ }
114
118
  if (ctorType === 'page') {
115
119
  const pageConfig = Object.assign({}, jsonConfig)
116
120
  delete pageConfig.usingComponents
@@ -2,10 +2,11 @@ const path = require('path')
2
2
  const toPosix = require('../utils/to-posix')
3
3
 
4
4
  module.exports = class PackageEntryPlugin {
5
- constructor (source, miniNpmPackages, target) {
5
+ constructor (source, miniNpmPackages, normalNpmPackages, target) {
6
6
  this.source = source
7
7
  this.target = target
8
8
  this.miniNpmPackages = miniNpmPackages
9
+ this.normalNpmPackages = normalNpmPackages
9
10
  }
10
11
 
11
12
  /**
@@ -23,6 +24,7 @@ module.exports = class PackageEntryPlugin {
23
24
 
24
25
  let { name, miniprogram } = descriptionFileData
25
26
  if (!miniprogram && this.miniNpmPackages.includes(name)) miniprogram = 'miniprogram_dist'
27
+ if (this.normalNpmPackages.includes(name)) return callback()
26
28
  if (!miniprogram) return callback()
27
29
 
28
30
  let relativePath = path.relative(descriptionFileRoot, resourcePath)
@@ -1,5 +1,6 @@
1
1
  import { createContext, Dispatch, MutableRefObject, SetStateAction } from 'react'
2
- import { NativeSyntheticEvent } from 'react-native'
2
+ import { NativeSyntheticEvent, Animated } from 'react-native'
3
+ import { noop } from '@mpxjs/utils'
3
4
 
4
5
  export type LabelContextValue = MutableRefObject<{
5
6
  triggerChange: (evt: NativeSyntheticEvent<TouchEvent>) => void
@@ -42,7 +43,8 @@ export interface PortalContextValue {
42
43
  }
43
44
 
44
45
  export interface ScrollViewContextValue {
45
- gestureRef: React.RefObject<any> | null
46
+ gestureRef: React.RefObject<any> | null,
47
+ scrollOffset: Animated.Value
46
48
  }
47
49
 
48
50
  export interface RouteContextValue {
@@ -50,6 +52,11 @@ export interface RouteContextValue {
50
52
  navigation: Record<string, any>
51
53
  }
52
54
 
55
+ export interface StickyContextValue {
56
+ registerStickyHeader: Function,
57
+ unregisterStickyHeader: Function
58
+ }
59
+
53
60
  export const MovableAreaContext = createContext({ width: 0, height: 0 })
54
61
 
55
62
  export const FormContext = createContext<FormContextValue | null>(null)
@@ -72,6 +79,8 @@ export const SwiperContext = createContext({})
72
79
 
73
80
  export const KeyboardAvoidContext = createContext<KeyboardAvoidContextValue | null>(null)
74
81
 
75
- export const ScrollViewContext = createContext<ScrollViewContextValue>({ gestureRef: null })
82
+ export const ScrollViewContext = createContext<ScrollViewContextValue>({ gestureRef: null, scrollOffset: new Animated.Value(0) })
76
83
 
77
84
  export const PortalContext = createContext<PortalContextValue>(null as any)
85
+
86
+ export const StickyContext = createContext<StickyContextValue>({ registerStickyHeader: noop, unregisterStickyHeader: noop })
@@ -1,4 +1,6 @@
1
1
  import { createContext } from 'react';
2
+ import { Animated } from 'react-native';
3
+ import { noop } from '@mpxjs/utils';
2
4
  export const MovableAreaContext = createContext({ width: 0, height: 0 });
3
5
  export const FormContext = createContext(null);
4
6
  export const CheckboxGroupContext = createContext(null);
@@ -10,5 +12,6 @@ export const IntersectionObserverContext = createContext(null);
10
12
  export const RouteContext = createContext(null);
11
13
  export const SwiperContext = createContext({});
12
14
  export const KeyboardAvoidContext = createContext(null);
13
- export const ScrollViewContext = createContext({ gestureRef: null });
15
+ export const ScrollViewContext = createContext({ gestureRef: null, scrollOffset: new Animated.Value(0) });
14
16
  export const PortalContext = createContext(null);
17
+ export const StickyContext = createContext({ registerStickyHeader: noop, unregisterStickyHeader: noop });
@@ -1,5 +1,3 @@
1
- export const TAP_EVENTS = ['bindtap', 'catchtap', 'capture-bindtap', 'capture-catchtap'];
2
- export const LONGPRESS_EVENTS = ['bindlongpress', 'catchlongpress', 'capture-bindlongpress', 'capture-catchlongpress'];
3
1
  const eventConfigMap = {
4
2
  bindtap: { bitFlag: '0', events: ['onTouchStart', 'onTouchMove', 'onTouchEnd'] },
5
3
  bindlongpress: { bitFlag: '1', events: ['onTouchStart', 'onTouchMove', 'onTouchEnd', 'onTouchCancel'] },