@mpxjs/webpack-plugin 2.10.5 → 2.10.6-beta.2

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 (92) hide show
  1. package/lib/dependencies/WriteVfsDependency.js +46 -0
  2. package/lib/index.js +22 -6
  3. package/lib/json-compiler/helper.js +1 -4
  4. package/lib/platform/index.js +4 -2
  5. package/lib/platform/json/wx/index.js +0 -1
  6. package/lib/platform/template/wx/component-config/button.js +1 -1
  7. package/lib/platform/template/wx/component-config/index.js +7 -3
  8. package/lib/platform/template/wx/component-config/input.js +1 -1
  9. package/lib/platform/template/wx/component-config/sticky-header.js +23 -0
  10. package/lib/platform/template/wx/component-config/sticky-section.js +23 -0
  11. package/lib/platform/template/wx/component-config/template.js +26 -1
  12. package/lib/platform/template/wx/index.js +31 -4
  13. package/lib/react/processJSON.js +7 -6
  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/mpx-button.jsx +9 -4
  18. package/lib/runtime/components/react/dist/mpx-canvas/Image.js +2 -4
  19. package/lib/runtime/components/react/dist/mpx-canvas/index.jsx +20 -17
  20. package/lib/runtime/components/react/dist/mpx-checkbox-group.jsx +7 -2
  21. package/lib/runtime/components/react/dist/mpx-checkbox.jsx +7 -2
  22. package/lib/runtime/components/react/dist/mpx-icon/index.jsx +7 -2
  23. package/lib/runtime/components/react/dist/mpx-image.jsx +9 -2
  24. package/lib/runtime/components/react/dist/mpx-input.jsx +7 -2
  25. package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.jsx +1 -1
  26. package/lib/runtime/components/react/dist/mpx-label.jsx +7 -2
  27. package/lib/runtime/components/react/dist/mpx-movable-area.jsx +8 -3
  28. package/lib/runtime/components/react/dist/mpx-movable-view.jsx +100 -62
  29. package/lib/runtime/components/react/dist/mpx-picker/index.jsx +11 -13
  30. package/lib/runtime/components/react/dist/mpx-picker-view/index.jsx +8 -7
  31. package/lib/runtime/components/react/dist/mpx-picker-view-column/index.jsx +26 -8
  32. package/lib/runtime/components/react/dist/mpx-radio-group.jsx +9 -2
  33. package/lib/runtime/components/react/dist/mpx-radio.jsx +7 -2
  34. package/lib/runtime/components/react/dist/mpx-rich-text/index.jsx +7 -2
  35. package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +30 -10
  36. package/lib/runtime/components/react/dist/mpx-sticky-header.jsx +115 -0
  37. package/lib/runtime/components/react/dist/mpx-sticky-section.jsx +45 -0
  38. package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +11 -9
  39. package/lib/runtime/components/react/dist/mpx-swiper.jsx +82 -36
  40. package/lib/runtime/components/react/dist/mpx-switch.jsx +7 -2
  41. package/lib/runtime/components/react/dist/mpx-text.jsx +7 -2
  42. package/lib/runtime/components/react/dist/mpx-video.jsx +7 -2
  43. package/lib/runtime/components/react/dist/mpx-view.jsx +2 -4
  44. package/lib/runtime/components/react/dist/mpx-web-view.jsx +13 -13
  45. package/lib/runtime/components/react/dist/utils.jsx +14 -3
  46. package/lib/runtime/components/react/mpx-button.tsx +12 -3
  47. package/lib/runtime/components/react/mpx-canvas/Image.ts +4 -4
  48. package/lib/runtime/components/react/mpx-canvas/index.tsx +24 -17
  49. package/lib/runtime/components/react/mpx-checkbox-group.tsx +9 -1
  50. package/lib/runtime/components/react/mpx-checkbox.tsx +9 -1
  51. package/lib/runtime/components/react/mpx-icon/index.tsx +9 -1
  52. package/lib/runtime/components/react/mpx-image.tsx +38 -19
  53. package/lib/runtime/components/react/mpx-input.tsx +10 -1
  54. package/lib/runtime/components/react/mpx-keyboard-avoiding-view.tsx +1 -1
  55. package/lib/runtime/components/react/mpx-label.tsx +9 -1
  56. package/lib/runtime/components/react/mpx-movable-area.tsx +8 -2
  57. package/lib/runtime/components/react/mpx-movable-view.tsx +100 -62
  58. package/lib/runtime/components/react/mpx-picker/index.tsx +18 -16
  59. package/lib/runtime/components/react/mpx-picker-view/index.tsx +22 -8
  60. package/lib/runtime/components/react/mpx-picker-view-column/index.tsx +34 -30
  61. package/lib/runtime/components/react/mpx-radio-group.tsx +20 -9
  62. package/lib/runtime/components/react/mpx-radio.tsx +9 -1
  63. package/lib/runtime/components/react/mpx-rich-text/index.tsx +10 -2
  64. package/lib/runtime/components/react/mpx-scroll-view.tsx +82 -53
  65. package/lib/runtime/components/react/mpx-sticky-header.tsx +179 -0
  66. package/lib/runtime/components/react/mpx-sticky-section.tsx +96 -0
  67. package/lib/runtime/components/react/mpx-swiper-item.tsx +11 -19
  68. package/lib/runtime/components/react/mpx-swiper.tsx +95 -38
  69. package/lib/runtime/components/react/mpx-switch.tsx +10 -2
  70. package/lib/runtime/components/react/mpx-text.tsx +10 -2
  71. package/lib/runtime/components/react/mpx-video.tsx +7 -2
  72. package/lib/runtime/components/react/mpx-view.tsx +8 -4
  73. package/lib/runtime/components/react/mpx-web-view.tsx +12 -12
  74. package/lib/runtime/components/react/utils.tsx +16 -5
  75. package/lib/runtime/components/web/mpx-scroll-view.vue +21 -4
  76. package/lib/runtime/components/web/mpx-sticky-header.vue +91 -0
  77. package/lib/runtime/components/web/mpx-sticky-section.vue +15 -0
  78. package/lib/runtime/components/web/mpx-web-view.vue +1 -1
  79. package/lib/runtime/mpxGlobal.js +1 -0
  80. package/lib/runtime/optionProcessor.d.ts +5 -0
  81. package/lib/runtime/optionProcessor.js +2 -2
  82. package/lib/template-compiler/bind-this.js +8 -7
  83. package/lib/template-compiler/compiler.js +59 -9
  84. package/lib/utils/get-template-content.js +47 -0
  85. package/lib/web/index.js +2 -0
  86. package/lib/web/processScript.js +29 -7
  87. package/lib/web/processTemplate.js +10 -4
  88. package/lib/web/template2vue.js +280 -0
  89. package/lib/web/wxml-template-loader.js +29 -0
  90. package/lib/wxs/pre-loader.js +1 -0
  91. package/package.json +4 -4
  92. package/LICENSE +0 -433
@@ -0,0 +1,46 @@
1
+ const NullDependency = require('webpack/lib/dependencies/NullDependency')
2
+ const makeSerializable = require('webpack/lib/util/makeSerializable')
3
+
4
+ class WriteVfsDependency extends NullDependency {
5
+ constructor (filename, content) {
6
+ super()
7
+ this.filename = filename
8
+ this.content = content
9
+ }
10
+
11
+ get type () {
12
+ return 'mpx app entry'
13
+ }
14
+
15
+ mpxAction (module, compilation, callback) {
16
+ const mpx = compilation.__mpx__
17
+ const vfs = mpx.__vfs
18
+ if (vfs) {
19
+ vfs.writeModule(this.filename, this.content)
20
+ }
21
+ return callback()
22
+ }
23
+
24
+ serialize (context) {
25
+ const { write } = context
26
+ write(this.filename)
27
+ write(this.content)
28
+ super.serialize(context)
29
+ }
30
+
31
+ deserialize (context) {
32
+ const { read } = context
33
+ this.filename = read()
34
+ this.content = read()
35
+ super.deserialize(context)
36
+ }
37
+ }
38
+
39
+ WriteVfsDependency.Template = class WriteVfsDependencyTemplate {
40
+ apply () {
41
+ }
42
+ }
43
+
44
+ makeSerializable(WriteVfsDependency, '@mpxjs/webpack-plugin/lib/dependencies/WriteVfsDependency')
45
+
46
+ module.exports = WriteVfsDependency
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')
@@ -43,6 +44,7 @@ const FlagPluginDependency = require('./dependencies/FlagPluginDependency')
43
44
  const RemoveEntryDependency = require('./dependencies/RemoveEntryDependency')
44
45
  const RecordLoaderContentDependency = require('./dependencies/RecordLoaderContentDependency')
45
46
  const RecordRuntimeInfoDependency = require('./dependencies/RecordRuntimeInfoDependency')
47
+ const WriteVfsDependency = require('./dependencies/WriteVfsDependency')
46
48
  const SplitChunksPlugin = require('webpack/lib/optimize/SplitChunksPlugin')
47
49
  const fixRelative = require('./utils/fix-relative')
48
50
  const parseRequest = require('./utils/parse-request')
@@ -60,6 +62,7 @@ const templateCompilerPath = normalize.lib('template-compiler/index')
60
62
  const jsonCompilerPath = normalize.lib('json-compiler/index')
61
63
  const jsonThemeCompilerPath = normalize.lib('json-compiler/theme')
62
64
  const jsonPluginCompilerPath = normalize.lib('json-compiler/plugin')
65
+ const mpxGlobalRuntimePath = normalize.lib('runtime/mpxGlobal')
63
66
  const extractorPath = normalize.lib('extractor')
64
67
  const async = require('async')
65
68
  const { parseQuery } = require('loader-utils')
@@ -177,6 +180,7 @@ class MpxWebpackPlugin {
177
180
  options.forceProxyEventRules = options.forceProxyEventRules || {}
178
181
  options.disableRequireAsync = options.disableRequireAsync || false
179
182
  options.miniNpmPackages = options.miniNpmPackages || []
183
+ options.normalNpmPackages = options.normalNpmPackages || []
180
184
  options.fileConditionRules = options.fileConditionRules || {
181
185
  include: () => true
182
186
  }
@@ -325,6 +329,12 @@ class MpxWebpackPlugin {
325
329
  }
326
330
  }
327
331
 
332
+ compiler.options.plugins.push(new ProvidePlugin(
333
+ {
334
+ mpxGlobal: mpxGlobalRuntimePath
335
+ }
336
+ ))
337
+
328
338
  if (!isWeb(this.options.mode) && !isReact(this.options.mode)) {
329
339
  // 强制设置publicPath为'/'
330
340
  if (compiler.options.output.publicPath && compiler.options.output.publicPath !== publicPath) {
@@ -364,7 +374,7 @@ class MpxWebpackPlugin {
364
374
  }
365
375
  const addModePlugin = new AddModePlugin('before-file', this.options.mode, addModeOptions, 'file')
366
376
  const addEnvPlugin = new AddEnvPlugin('before-file', this.options.env, this.options.fileConditionRules, 'file')
367
- const packageEntryPlugin = new PackageEntryPlugin('before-file', this.options.miniNpmPackages, 'file')
377
+ const packageEntryPlugin = new PackageEntryPlugin('before-file', this.options.miniNpmPackages, this.options.normalNpmPackages, 'file')
368
378
  const dynamicPlugin = new DynamicPlugin('result', this.options.dynamicComponentRules)
369
379
 
370
380
  if (Array.isArray(compiler.options.resolve.plugins)) {
@@ -645,6 +655,9 @@ class MpxWebpackPlugin {
645
655
  compilation.dependencyFactories.set(RecordRuntimeInfoDependency, new NullFactory())
646
656
  compilation.dependencyTemplates.set(RecordRuntimeInfoDependency, new RecordRuntimeInfoDependency.Template())
647
657
 
658
+ compilation.dependencyFactories.set(WriteVfsDependency, new NullFactory())
659
+ compilation.dependencyTemplates.set(WriteVfsDependency, new WriteVfsDependency.Template())
660
+
648
661
  compilation.dependencyTemplates.set(ImportDependency, new ImportDependencyTemplate())
649
662
  })
650
663
 
@@ -668,6 +681,8 @@ class MpxWebpackPlugin {
668
681
  componentsMap: {
669
682
  main: {}
670
683
  },
684
+ // 用于template模版获取父组件引用的自定义组件,目前仅输出web时下支持使用
685
+ parentLocalComponentsMap: {},
671
686
  // 静态资源(图片,字体,独立样式)等,依照所属包进行记录
672
687
  staticResourcesMap: {
673
688
  main: {}
@@ -1806,11 +1821,9 @@ try {
1806
1821
  normalModuleFactory.hooks.afterResolve.tap('MpxWebpackPlugin', ({ createData }) => {
1807
1822
  const { queryObj } = parseRequest(createData.request)
1808
1823
  const loaders = createData.loaders
1809
- if (queryObj.mpx && queryObj.mpx !== MPX_PROCESSED_FLAG) {
1810
- const type = queryObj.type
1811
- const extract = queryObj.extract
1812
-
1813
- if (type === 'styles') {
1824
+ const type = queryObj.type
1825
+ if ((queryObj.mpx && queryObj.mpx !== MPX_PROCESSED_FLAG) || queryObj.vue) {
1826
+ if (type === 'styles' || type === 'style') {
1814
1827
  let insertBeforeIndex = -1
1815
1828
  // 单次遍历收集所有索引
1816
1829
  loaders.forEach((loader, index) => {
@@ -1825,7 +1838,10 @@ try {
1825
1838
  }
1826
1839
  loaders.push({ loader: styleStripConditionalPath })
1827
1840
  }
1841
+ }
1828
1842
 
1843
+ if (queryObj.mpx && queryObj.mpx !== MPX_PROCESSED_FLAG) {
1844
+ const extract = queryObj.extract
1829
1845
  switch (type) {
1830
1846
  case 'styles':
1831
1847
  case 'template': {
@@ -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, '')
@@ -9,6 +9,7 @@ module.exports = function getRulesRunner ({
9
9
  testKey,
10
10
  mainKey,
11
11
  waterfall,
12
+ moduleId,
12
13
  warn,
13
14
  error
14
15
  }) {
@@ -23,13 +24,14 @@ module.exports = function getRulesRunner ({
23
24
  wx: require('./json/wx')
24
25
  }
25
26
  }
26
- const spec = specMap[type] && specMap[type][srcMode] && specMap[type][srcMode]({ warn, error })
27
+ const spec = specMap[type] && specMap[type][srcMode] && specMap[type][srcMode]({ warn, error, moduleId })
27
28
  if (spec && spec.supportedModes.indexOf(mode) > -1) {
28
29
  const normalizeTest = spec.normalizeTest
29
30
  const mainRules = mainKey ? spec[mainKey] : spec
30
31
  if (mainRules) {
31
32
  return function (input) {
32
- return runRules(mainRules, input, { mode, data, meta, testKey, waterfall, normalizeTest })
33
+ const a = runRules(mainRules, input, { mode, data, meta, testKey, waterfall, normalizeTest })
34
+ return a
33
35
  }
34
36
  }
35
37
  }
@@ -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
  {
@@ -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,8 +42,10 @@ 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
- module.exports = function getComponentConfigs ({ warn, error }) {
48
+ module.exports = function getComponentConfigs ({ warn, error, moduleId }) {
47
49
  /**
48
50
  * universal print for detail component warn or error
49
51
  * @param {object} config
@@ -114,7 +116,7 @@ module.exports = function getComponentConfigs ({ warn, error }) {
114
116
  map({ print }),
115
117
  canvas({ print }),
116
118
  wxs({ print }),
117
- template(),
119
+ template({ moduleId }),
118
120
  block(),
119
121
  icon(),
120
122
  webView({ print }),
@@ -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
+ }
@@ -1,8 +1,13 @@
1
1
  const TAG_NAME = 'template'
2
2
 
3
- module.exports = function () {
3
+ module.exports = function ({ moduleId }) {
4
4
  return {
5
5
  test: TAG_NAME,
6
+ web (tag, { el }) {
7
+ if (el.attrsMap[':is']) {
8
+ return 'component'
9
+ }
10
+ },
6
11
  props: [
7
12
  {
8
13
  test: 'data',
@@ -11,6 +16,26 @@ module.exports = function () {
11
16
  name,
12
17
  value: `{${value}}`
13
18
  }
19
+ },
20
+ web ({ value }) {
21
+ let bindValue = value
22
+ if (moduleId) {
23
+ const lastIndex = value.lastIndexOf('}}')
24
+ bindValue = value ? value.slice(0, lastIndex) + `, _data_v_id: '${moduleId}'}}` : `{{ _data_v_id: '${moduleId}' }}`
25
+ }
26
+ return {
27
+ name: 'v-bind',
28
+ value: bindValue
29
+ }
30
+ }
31
+ },
32
+ {
33
+ test: 'is',
34
+ web ({ value }) {
35
+ return {
36
+ name: ':is',
37
+ value: `'${value}'`
38
+ }
14
39
  }
15
40
  }
16
41
  ]
@@ -3,11 +3,11 @@ const JSON5 = require('json5')
3
3
  const getComponentConfigs = require('./component-config')
4
4
  const normalizeComponentRules = require('../normalize-component-rules')
5
5
  const isValidIdentifierStr = require('../../../utils/is-valid-identifier-str')
6
- const { parseMustacheWithContext, stringifyWithResolveComputed } = require('../../../template-compiler/compiler')
6
+ const { vbindMustache, parseMustacheWithContext, stringifyWithResolveComputed } = require('../../../template-compiler/compiler')
7
7
  const normalize = require('../../../utils/normalize')
8
8
  const { dash2hump } = require('../../../utils/hump-dash')
9
9
 
10
- module.exports = function getSpec ({ warn, error }) {
10
+ module.exports = function getSpec ({ warn, error, moduleId }) {
11
11
  function getRnDirectiveEventHandle (mode) {
12
12
  return function ({ name, value }, { eventRules, el }) {
13
13
  const match = this.test.exec(name)
@@ -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预处理
@@ -51,6 +68,13 @@ module.exports = function getSpec ({ warn, error }) {
51
68
  postProps: [
52
69
  {
53
70
  web ({ name, value }) {
71
+ if (name === 'v-bind') {
72
+ const vbindValue = vbindMustache(value)
73
+ return {
74
+ name,
75
+ value: vbindValue
76
+ }
77
+ }
54
78
  const parsed = parseMustacheWithContext(value)
55
79
  if (name.startsWith('data-')) {
56
80
  return {
@@ -433,7 +457,10 @@ module.exports = function getSpec ({ warn, error }) {
433
457
  test: /^aria-(role|label)$/,
434
458
  ali () {
435
459
  warn('Ali environment does not support aria-role|label props!')
436
- }
460
+ },
461
+ ios: rnAccessibilityRulesHandle,
462
+ android: rnAccessibilityRulesHandle,
463
+ harmony: rnAccessibilityRulesHandle
437
464
  }
438
465
  ],
439
466
  event: {
@@ -547,6 +574,6 @@ module.exports = function getSpec ({ warn, error }) {
547
574
  ]
548
575
  }
549
576
  }
550
- spec.rules = normalizeComponentRules(getComponentConfigs({ warn, error }).concat({}), spec)
577
+ spec.rules = normalizeComponentRules(getComponentConfigs({ warn, error, moduleId }).concat({}), spec)
551
578
  return spec
552
579
  }
@@ -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
 
@@ -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 });
@@ -35,13 +35,14 @@
35
35
  * ✔ bindtap
36
36
  */
37
37
  import { createElement, useEffect, useRef, forwardRef, useContext } from 'react';
38
- import { View, StyleSheet, Animated, Easing } from 'react-native';
38
+ import { View, StyleSheet, Animated, Easing, useAnimatedValue } from 'react-native';
39
39
  import { warn } from '@mpxjs/utils';
40
40
  import { GestureDetector } from 'react-native-gesture-handler';
41
41
  import { getCurrentPage, splitProps, splitStyle, useLayout, useTransformStyle, wrapChildren, extendObject, useHover } from './utils';
42
42
  import useInnerProps, { getCustomEvent } from './getInnerListeners';
43
43
  import useNodesRef from './useNodesRef';
44
44
  import { RouteContext, FormContext } from './context';
45
+ import Portal from './mpx-portal';
45
46
  const LOADING_IMAGE_URI = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAYAAABw4pVUAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAB8hJREFUeJztnVtsFFUch6ltUYrEAi0Qo40xChGM+oAGI0EEKl4QfDVI9AkqqQZ4IVA1RSIvJlwUWwqJUokGKMVYwHJTq4mGuA+SxpJYggJSSgMpVFOtvbh+J84mk+3smXN2znZm2fNLvoQH5uQ/v4+Z2Z3dHUaNsrGxsbGxsbGxsbGxsbGxsTGSrq6uUqiHqw7iz6Vhz5WzofwYxJP4Mey5cjIUX+4hI0F52PPlXCi9WiKkOuz5ci5WiMFcvHhxOXRCHPpgLdyis4ZJITtqagtgPfRBHH6HV3XWyNpQ/DxHRDJbddYxLKTGEZHMLK2dy8ZQ/O4UQgQzVdcxJYTSZ6aQIfggrZ3MplD6CYmQmOo6BoXEJEK+TGsnsymUXicRIlimso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CAt/UjHyca4jXrRKt/83GlBARiq/xkPEn3KOzTtaG8p+FLkfEX7AOtL6bZVhIAbwJ/zgyLkFkP2KOZEwKsTEQKyRi0b39bjMCofhTHjI8n/1uMwI5rvERro2NjY2NjY2NjY2NjY2NjY1+/gNWA2LIOT/TRAAAAABJRU5ErkJggg==';
46
47
  const TypeColorMap = {
47
48
  default: ['#F8F8F8', '#DEDEDE', '35,35,35', '#F7F7F7'],
@@ -103,7 +104,7 @@ const timer = (data, time = 3000) => new Promise((resolve) => {
103
104
  }, time);
104
105
  });
105
106
  const Loading = ({ alone = false }) => {
106
- const image = useRef(new Animated.Value(0)).current;
107
+ const image = useAnimatedValue(0);
107
108
  const rotate = image.interpolate({
108
109
  inputRange: [0, 1],
109
110
  outputRange: ['0deg', '360deg']
@@ -167,7 +168,7 @@ const Button = forwardRef((buttonProps, ref) => {
167
168
  const defaultTextStyle = extendObject({}, styles.text, isMiniSize ? styles.textMini : {}, { color: plain ? plainTextColor : normalTextColor });
168
169
  const defaultStyle = extendObject({}, defaultViewStyle, defaultTextStyle);
169
170
  const styleObj = extendObject({}, defaultStyle, style, isHover ? hoverStyle : {});
170
- const { hasSelfPercent, normalStyle, hasVarDec, varContextRef, setWidth, setHeight } = useTransformStyle(styleObj, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
171
+ const { hasPositionFixed, hasSelfPercent, normalStyle, hasVarDec, varContextRef, setWidth, setHeight } = useTransformStyle(styleObj, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
171
172
  const nodeRef = useRef(null);
172
173
  useNodesRef(props, ref, nodeRef, { style: normalStyle });
173
174
  const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef });
@@ -262,9 +263,13 @@ const Button = forwardRef((buttonProps, ref) => {
262
263
  textStyle,
263
264
  textProps
264
265
  }));
265
- return enableHover
266
+ const finalComponent = enableHover
266
267
  ? createElement(GestureDetector, { gesture: gesture }, baseButton)
267
268
  : baseButton;
269
+ if (hasPositionFixed) {
270
+ return createElement(Portal, null, finalComponent);
271
+ }
272
+ return finalComponent;
268
273
  });
269
274
  Button.displayName = 'MpxButton';
270
275
  export default Button;
@@ -1,4 +1,5 @@
1
1
  import { WEBVIEW_TARGET, registerWebviewProperties } from './utils';
2
+ import { extendObject } from '../utils';
2
3
  const PROPERTIES = {
3
4
  crossOrigin: undefined,
4
5
  height: undefined,
@@ -50,10 +51,7 @@ export class Image {
50
51
  this[key] = value;
51
52
  }
52
53
  }
53
- callbackFn({
54
- ...message.payload,
55
- target: this
56
- });
54
+ callbackFn(extendObject({}, message.payload, { target: this }));
57
55
  }
58
56
  });
59
57
  }