@mpxjs/webpack-plugin 2.10.14-beta.1 → 2.10.14-beta.10

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 (107) hide show
  1. package/lib/dependencies/ImportDependency.js +102 -0
  2. package/lib/index.js +9 -9
  3. package/lib/platform/style/wx/index.js +7 -1
  4. package/lib/platform/template/wx/component-config/button.js +13 -4
  5. package/lib/platform/template/wx/component-config/index.js +3 -1
  6. package/lib/platform/template/wx/component-config/nav-container.js +27 -0
  7. package/lib/react/processScript.js +4 -2
  8. package/lib/react/script-helper.js +3 -3
  9. package/lib/runtime/components/ali/mpx-nav-container.mpx +3 -0
  10. package/lib/runtime/components/react/context.ts +17 -6
  11. package/lib/runtime/components/react/dist/context.d.ts +78 -0
  12. package/lib/runtime/components/react/dist/context.js +1 -0
  13. package/lib/runtime/components/react/dist/event.config.d.ts +7 -0
  14. package/lib/runtime/components/react/dist/getInnerListeners.d.ts +7 -0
  15. package/lib/runtime/components/react/dist/mpx-async-suspense.d.ts +12 -0
  16. package/lib/runtime/components/react/dist/mpx-button.d.ts +68 -0
  17. package/lib/runtime/components/react/dist/mpx-canvas/Bus.d.ts +23 -0
  18. package/lib/runtime/components/react/dist/mpx-canvas/CanvasGradient.d.ts +7 -0
  19. package/lib/runtime/components/react/dist/mpx-canvas/CanvasRenderingContext2D.d.ts +6 -0
  20. package/lib/runtime/components/react/dist/mpx-canvas/Image.d.ts +20 -0
  21. package/lib/runtime/components/react/dist/mpx-canvas/ImageData.d.ts +8 -0
  22. package/lib/runtime/components/react/dist/mpx-canvas/constructorsRegistry.d.ts +10 -0
  23. package/lib/runtime/components/react/dist/mpx-canvas/html.d.ts +2 -0
  24. package/lib/runtime/components/react/dist/mpx-canvas/index.d.ts +32 -0
  25. package/lib/runtime/components/react/dist/mpx-canvas/utils.d.ts +52 -0
  26. package/lib/runtime/components/react/dist/mpx-checkbox-group.d.ts +20 -0
  27. package/lib/runtime/components/react/dist/mpx-checkbox.d.ts +32 -0
  28. package/lib/runtime/components/react/dist/mpx-form.d.ts +27 -0
  29. package/lib/runtime/components/react/dist/mpx-icon/index.d.ts +18 -0
  30. package/lib/runtime/components/react/dist/mpx-image.d.ts +21 -0
  31. package/lib/runtime/components/react/dist/mpx-inline-text.d.ts +7 -0
  32. package/lib/runtime/components/react/dist/mpx-input.d.ts +50 -0
  33. package/lib/runtime/components/react/dist/mpx-input.jsx +36 -17
  34. package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.d.ts +12 -0
  35. package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.jsx +66 -47
  36. package/lib/runtime/components/react/dist/mpx-label.d.ts +20 -0
  37. package/lib/runtime/components/react/dist/mpx-movable-area.d.ts +20 -0
  38. package/lib/runtime/components/react/dist/mpx-movable-view.d.ts +63 -0
  39. package/lib/runtime/components/react/dist/mpx-movable-view.jsx +24 -17
  40. package/lib/runtime/components/react/dist/mpx-nav-container.d.ts +9 -0
  41. package/lib/runtime/components/react/dist/mpx-nav-container.jsx +23 -0
  42. package/lib/runtime/components/react/dist/mpx-navigator.d.ts +9 -0
  43. package/lib/runtime/components/react/dist/mpx-picker/date.d.ts +6 -0
  44. package/lib/runtime/components/react/dist/mpx-picker/dateData.d.ts +7 -0
  45. package/lib/runtime/components/react/dist/mpx-picker/index.d.ts +6 -0
  46. package/lib/runtime/components/react/dist/mpx-picker/multiSelector.d.ts +6 -0
  47. package/lib/runtime/components/react/dist/mpx-picker/region.d.ts +6 -0
  48. package/lib/runtime/components/react/dist/mpx-picker/regionData.d.ts +2 -0
  49. package/lib/runtime/components/react/dist/mpx-picker/selector.d.ts +6 -0
  50. package/lib/runtime/components/react/dist/mpx-picker/time.d.ts +6 -0
  51. package/lib/runtime/components/react/dist/mpx-picker/type.d.ts +106 -0
  52. package/lib/runtime/components/react/dist/mpx-picker-view/index.d.ts +31 -0
  53. package/lib/runtime/components/react/dist/mpx-picker-view/pickerVIewContext.d.ts +8 -0
  54. package/lib/runtime/components/react/dist/mpx-picker-view-column/index.d.ts +22 -0
  55. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.d.ts +14 -0
  56. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewFaces.d.ts +16 -0
  57. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewIndicator.d.ts +12 -0
  58. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewMask.d.ts +11 -0
  59. package/lib/runtime/components/react/dist/mpx-popup/index.d.ts +22 -0
  60. package/lib/runtime/components/react/dist/mpx-popup/popupBase.d.ts +16 -0
  61. package/lib/runtime/components/react/dist/mpx-portal/index.d.ts +15 -0
  62. package/lib/runtime/components/react/dist/mpx-portal/portal-host.d.ts +29 -0
  63. package/lib/runtime/components/react/dist/mpx-portal/portal-manager.d.ts +9 -0
  64. package/lib/runtime/components/react/dist/mpx-radio-group.d.ts +20 -0
  65. package/lib/runtime/components/react/dist/mpx-radio.d.ts +26 -0
  66. package/lib/runtime/components/react/dist/mpx-rich-text/html.d.ts +1 -0
  67. package/lib/runtime/components/react/dist/mpx-rich-text/index.d.ts +24 -0
  68. package/lib/runtime/components/react/dist/mpx-root-portal.d.ts +14 -0
  69. package/lib/runtime/components/react/dist/mpx-scroll-view.d.ts +54 -0
  70. package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +26 -8
  71. package/lib/runtime/components/react/dist/mpx-simple-text.d.ts +7 -0
  72. package/lib/runtime/components/react/dist/mpx-simple-view.d.ts +7 -0
  73. package/lib/runtime/components/react/dist/mpx-sticky-header.d.ts +17 -0
  74. package/lib/runtime/components/react/dist/mpx-sticky-section.d.ts +15 -0
  75. package/lib/runtime/components/react/dist/mpx-swiper-item.d.ts +18 -0
  76. package/lib/runtime/components/react/dist/mpx-swiper.d.ts +52 -0
  77. package/lib/runtime/components/react/dist/mpx-swiper.jsx +48 -39
  78. package/lib/runtime/components/react/dist/mpx-switch.d.ts +26 -0
  79. package/lib/runtime/components/react/dist/mpx-text.d.ts +21 -0
  80. package/lib/runtime/components/react/dist/mpx-textarea.d.ts +7 -0
  81. package/lib/runtime/components/react/dist/mpx-video.d.ts +101 -0
  82. package/lib/runtime/components/react/dist/mpx-view.d.ts +34 -0
  83. package/lib/runtime/components/react/dist/mpx-view.jsx +1 -1
  84. package/lib/runtime/components/react/dist/mpx-web-view.d.ts +22 -0
  85. package/lib/runtime/components/react/dist/nav.d.ts +8 -0
  86. package/lib/runtime/components/react/dist/nav.jsx +137 -0
  87. package/lib/runtime/components/react/dist/parser.d.ts +39 -0
  88. package/lib/runtime/components/react/dist/useAnimationHooks.d.ts +32 -0
  89. package/lib/runtime/components/react/dist/useNavShared.d.ts +2 -0
  90. package/lib/runtime/components/react/dist/useNavShared.js +6 -0
  91. package/lib/runtime/components/react/dist/useNodesRef.d.ts +11 -0
  92. package/lib/runtime/components/react/dist/utils.d.ts +122 -0
  93. package/lib/runtime/components/react/mpx-input.tsx +46 -24
  94. package/lib/runtime/components/react/mpx-keyboard-avoiding-view.tsx +75 -46
  95. package/lib/runtime/components/react/mpx-movable-view.tsx +26 -20
  96. package/lib/runtime/components/react/mpx-nav-container.tsx +33 -0
  97. package/lib/runtime/components/react/mpx-scroll-view.tsx +30 -8
  98. package/lib/runtime/components/react/mpx-swiper.tsx +48 -37
  99. package/lib/runtime/components/react/mpx-view.tsx +1 -1
  100. package/lib/runtime/components/react/nav.tsx +163 -0
  101. package/lib/runtime/components/react/types/common.d.ts +19 -0
  102. package/lib/runtime/components/react/useNavShared.ts +8 -0
  103. package/lib/runtime/components/web/mpx-nav-container.vue +13 -0
  104. package/lib/runtime/components/wx/mpx-nav-container.mpx +9 -0
  105. package/lib/utils/dom-tag-config.js +2 -2
  106. package/package.json +1 -1
  107. package/lib/dependencies/ImportDependencyTemplate.js +0 -50
@@ -0,0 +1,102 @@
1
+ const Dependency = require('webpack/lib/Dependency')
2
+ const makeSerializable = require('webpack/lib/util/makeSerializable')
3
+ const ModuleDependency = require('webpack/lib/dependencies/ModuleDependency')
4
+ const { RetryRuntimeGlobal } = require('../retry-runtime-module')
5
+
6
+ class ImportDependency extends ModuleDependency {
7
+ /**
8
+ * @param {string} request the request
9
+ * @param {[number, number]} range expression range
10
+ * @param {string[][]=} referencedExports list of referenced exports
11
+ */
12
+ constructor (request, range, referencedExports, extraOptions) {
13
+ super(request)
14
+ this.range = range
15
+ this.referencedExports = referencedExports
16
+ this.extraOptions = extraOptions
17
+ }
18
+
19
+ get type () {
20
+ return 'import()'
21
+ }
22
+
23
+ get category () {
24
+ return 'esm'
25
+ }
26
+
27
+ /**
28
+ * Returns list of exports referenced by this dependency
29
+ * @param {ModuleGraph} moduleGraph module graph
30
+ * @param {RuntimeSpec} runtime the runtime for which the module is analysed
31
+ * @returns {(string[] | ReferencedExport)[]} referenced exports
32
+ */
33
+ getReferencedExports (moduleGraph, runtime) {
34
+ return this.referencedExports
35
+ ? this.referencedExports.map((e) => ({
36
+ name: e,
37
+ canMangle: false
38
+ }))
39
+ : Dependency.EXPORTS_OBJECT_REFERENCED
40
+ }
41
+
42
+ serialize (context) {
43
+ context.write(this.range)
44
+ context.write(this.referencedExports)
45
+ context.write(this.extraOptions)
46
+ super.serialize(context)
47
+ }
48
+
49
+ deserialize (context) {
50
+ this.range = context.read()
51
+ this.referencedExports = context.read()
52
+ this.extraOptions = context.read()
53
+ super.deserialize(context)
54
+ }
55
+ }
56
+
57
+ makeSerializable(ImportDependency, '@mpxjs/webpack-plugin/lib/dependencies/ImportDependency')
58
+
59
+ ImportDependency.Template = class ImportDependencyTemplate extends (
60
+ ModuleDependency.Template
61
+ ) {
62
+ /**
63
+ * @param {Dependency} dependency the dependency for which the template should be applied
64
+ * @param {ReplaceSource} source the current replace source which can be modified
65
+ * @param {DependencyTemplateContext} templateContext the context object
66
+ * @returns {void}
67
+ */
68
+ apply (
69
+ dependency,
70
+ source,
71
+ { runtimeTemplate, module, moduleGraph, chunkGraph, runtimeRequirements }
72
+ ) {
73
+ const dep = /** @type {ImportDependency} */ (dependency)
74
+ const block = /** @type {AsyncDependenciesBlock} */ (
75
+ moduleGraph.getParentBlock(dep)
76
+ )
77
+ let content = runtimeTemplate.moduleNamespacePromise({
78
+ chunkGraph,
79
+ block: block,
80
+ module: /** @type {Module} */ (moduleGraph.getModule(dep)),
81
+ request: dep.request,
82
+ strict: /** @type {BuildMeta} */ (module.buildMeta).strictHarmonyModule,
83
+ message: 'import()',
84
+ runtimeRequirements
85
+ })
86
+ // replace fakeType by 9 to fix require.async to commonjs2 module like 'module.exports = function(){...}'
87
+ content = content.replace(/(__webpack_require__\.t\.bind\(.+,\s*)(\d+)(\s*\))/, (_, p1, p2, p3) => {
88
+ return p1 + '9' + p3
89
+ })
90
+
91
+ // require.async 的场景且配置了重试次数才注入 RetryRuntimeModule
92
+ const extraOptions = dep.extraOptions || {}
93
+ if (extraOptions.isRequireAsync && extraOptions.retryRequireAsync && extraOptions.retryRequireAsync.times > 0) {
94
+ runtimeRequirements.add(RetryRuntimeGlobal)
95
+ content = `${RetryRuntimeGlobal}(function() { return ${content} }, ${extraOptions.retryRequireAsync.times}, ${extraOptions.retryRequireAsync.interval})`
96
+ }
97
+
98
+ source.replace(dep.range[0], dep.range[1] - 1, content)
99
+ }
100
+ }
101
+
102
+ module.exports = ImportDependency
package/lib/index.js CHANGED
@@ -14,8 +14,7 @@ const EntryPlugin = require('webpack/lib/EntryPlugin')
14
14
  const JavascriptModulesPlugin = require('webpack/lib/javascript/JavascriptModulesPlugin')
15
15
  const FlagEntryExportAsUsedPlugin = require('webpack/lib/FlagEntryExportAsUsedPlugin')
16
16
  const FileSystemInfo = require('webpack/lib/FileSystemInfo')
17
- const ImportDependency = require('webpack/lib/dependencies/ImportDependency')
18
- const ImportDependencyTemplate = require('./dependencies/ImportDependencyTemplate')
17
+ const ImportDependency = require('./dependencies/ImportDependency')
19
18
  const AsyncDependenciesBlock = require('webpack/lib/AsyncDependenciesBlock')
20
19
  const ProvidePlugin = require('webpack/lib/ProvidePlugin')
21
20
  const normalize = require('./utils/normalize')
@@ -199,6 +198,7 @@ class MpxWebpackPlugin {
199
198
  }, options.nativeConfig)
200
199
  options.webConfig = options.webConfig || {}
201
200
  options.rnConfig = options.rnConfig || {}
201
+ options.rnConfig.supportSubpackage = options.rnConfig.supportSubpackage !== undefined ? options.rnConfig.supportSubpackage : true
202
202
  options.partialCompileRules = options.partialCompileRules || null
203
203
  options.asyncSubpackageRules = options.asyncSubpackageRules || []
204
204
  options.optimizeRenderRules = options.optimizeRenderRules ? (Array.isArray(options.optimizeRenderRules) ? options.optimizeRenderRules : [options.optimizeRenderRules]) : []
@@ -695,7 +695,8 @@ class MpxWebpackPlugin {
695
695
  compilation.dependencyFactories.set(RequireExternalDependency, new NullFactory())
696
696
  compilation.dependencyTemplates.set(RequireExternalDependency, new RequireExternalDependency.Template())
697
697
 
698
- compilation.dependencyTemplates.set(ImportDependency, new ImportDependencyTemplate())
698
+ compilation.dependencyFactories.set(ImportDependency, normalModuleFactory)
699
+ compilation.dependencyTemplates.set(ImportDependency, new ImportDependency.Template())
699
700
  })
700
701
 
701
702
  compiler.hooks.thisCompilation.tap('MpxWebpackPlugin', (compilation, { normalModuleFactory }) => {
@@ -783,7 +784,7 @@ class MpxWebpackPlugin {
783
784
  removedChunks: [],
784
785
  forceProxyEventRules: this.options.forceProxyEventRules,
785
786
  // 若配置disableRequireAsync=true, 则全平台构建不支持异步分包
786
- supportRequireAsync: !this.options.disableRequireAsync && (this.options.mode === 'wx' || this.options.mode === 'ali' || this.options.mode === 'tt' || isWeb(this.options.mode) || isReact(this.options.mode)),
787
+ supportRequireAsync: !this.options.disableRequireAsync && (this.options.mode === 'wx' || this.options.mode === 'ali' || this.options.mode === 'tt' || isWeb(this.options.mode) || (isReact(this.options.mode) && this.options.rnConfig.supportSubpackage)),
787
788
  partialCompileRules: this.options.partialCompileRules,
788
789
  collectDynamicEntryInfo: ({ resource, packageName, filename, entryType, hasAsync }) => {
789
790
  const curInfo = mpx.dynamicEntryInfo[packageName] = mpx.dynamicEntryInfo[packageName] || {
@@ -1450,10 +1451,6 @@ class MpxWebpackPlugin {
1450
1451
  if (mpx.supportRequireAsync) {
1451
1452
  if (isWeb(mpx.mode) || isReact(mpx.mode)) {
1452
1453
  if (isReact(mpx.mode)) tarRoot = transSubpackage(mpx.transSubpackageRules, tarRoot)
1453
- request = addQuery(request, {
1454
- isRequireAsync: true,
1455
- retryRequireAsync: JSON.stringify(this.options.retryRequireAsync)
1456
- })
1457
1454
  const depBlock = new AsyncDependenciesBlock(
1458
1455
  {
1459
1456
  name: tarRoot + '/index'
@@ -1461,7 +1458,10 @@ class MpxWebpackPlugin {
1461
1458
  expr.loc,
1462
1459
  request
1463
1460
  )
1464
- const dep = new ImportDependency(request, expr.range)
1461
+ const dep = new ImportDependency(request, expr.range, undefined, {
1462
+ isRequireAsync: true,
1463
+ retryRequireAsync: this.options.retryRequireAsync
1464
+ })
1465
1465
  dep.loc = expr.loc
1466
1466
  depBlock.addDependency(dep)
1467
1467
  parser.state.current.addBlock(depBlock)
@@ -315,7 +315,7 @@ module.exports = function getSpec ({ warn, error }) {
315
315
  switch (prop) {
316
316
  case bgPropMap.image: {
317
317
  // background-image 支持背景图/渐变/css var
318
- if (cssVariableExp.test(value) || urlExp.test(value) || linearExp.test(value)) {
318
+ if (cssVariableExp.test(value) || urlExp.test(value) || linearExp.test(value) || value === 'none') {
319
319
  return { prop, value }
320
320
  } else {
321
321
  error(`Value of ${prop} in ${selector} selector only support value <url()> or <linear-gradient()>, received ${value}, please check again!`)
@@ -359,6 +359,12 @@ module.exports = function getSpec ({ warn, error }) {
359
359
  error(`Property [${bgPropMap.all}] in ${selector} is abbreviated property and does not support CSS var`)
360
360
  return false
361
361
  }
362
+ if (value === 'none') {
363
+ return [
364
+ { prop: bgPropMap.image, value },
365
+ { prop: bgPropMap.color, value: 'transparent' }
366
+ ]
367
+ }
362
368
  const bgMap = []
363
369
  const values = parseValues(value)
364
370
  values.forEach(item => {
@@ -31,13 +31,16 @@ module.exports = function ({ print }) {
31
31
  const qaPropLog = print({ platform: 'qa', tag: TAG_NAME, isError: false })
32
32
  const wxPropValueLog = print({ platform: 'wx', tag: TAG_NAME, isError: false, type: 'value' })
33
33
  const iosValueLogError = print({ platform: 'ios', tag: TAG_NAME, isError: true, type: 'value' })
34
+ const iosValueLog = print({ platform: 'ios', tag: TAG_NAME, isError: false, type: 'value' })
34
35
  const iosPropLog = print({ platform: 'ios', tag: TAG_NAME, isError: false })
35
36
  const iosEventLog = print({ platform: 'ios', tag: TAG_NAME, isError: false, type: 'event' })
36
37
  const androidValueLogError = print({ platform: 'android', tag: TAG_NAME, isError: true, type: 'value' })
38
+ const androidValueLog = print({ platform: 'android', tag: TAG_NAME, isError: false, type: 'value' })
37
39
  const androidPropLog = print({ platform: 'android', tag: TAG_NAME, isError: false })
38
40
  const androidEventLog = print({ platform: 'android', tag: TAG_NAME, isError: false, type: 'event' })
39
41
 
40
42
  const harmonyValueLogError = print({ platform: 'harmony', tag: TAG_NAME, isError: true, type: 'value' })
43
+ const harmonyValueLog = print({ platform: 'harmony', tag: TAG_NAME, isError: false, type: 'value' })
41
44
  const harmonyPropLog = print({ platform: 'harmony', tag: TAG_NAME, isError: false })
42
45
  const harmonyEventLog = print({ platform: 'harmony', tag: TAG_NAME, isError: false, type: 'event' })
43
46
 
@@ -133,19 +136,25 @@ module.exports = function ({ print }) {
133
136
  ios ({ name, value }) {
134
137
  // TODO 此处open-type无其他属性支持了?
135
138
  const supported = ['share']
136
- if (!supported.includes(value)) {
139
+ if (isMustache(value)) {
140
+ iosValueLog({ name, value })
141
+ } else if (!supported.includes(value)) {
137
142
  iosValueLogError({ name, value })
138
143
  }
139
144
  },
140
145
  android ({ name, value }) {
141
146
  const supported = ['share']
142
- if (!supported.includes(value)) {
147
+ if (isMustache(value)) {
148
+ androidValueLog({ name, value })
149
+ } else if (!supported.includes(value)) {
143
150
  androidValueLogError({ name, value })
144
151
  }
145
152
  },
146
153
  harmony ({ name, value }) {
147
154
  const supported = ['share']
148
- if (!supported.includes(value)) {
155
+ if (isMustache(value)) {
156
+ harmonyValueLog({ name, value })
157
+ } else if (!supported.includes(value)) {
149
158
  harmonyValueLogError({ name, value })
150
159
  }
151
160
  }
@@ -186,7 +195,7 @@ module.exports = function ({ print }) {
186
195
  qa: qaPropLog
187
196
  },
188
197
  {
189
- test: /^(lang|from-type|hover-class|send-message-title|send-message-path|send-message-img|app-parameter|show-message-card|phone-number-no-quota-toast|bindgetuserinfo|bindcontact|createliveactivity|bindgetphonenumber|bindgetrealtimephonenumber|binderror|bindopensetting|bindlaunchapp|bindchooseavatar|bindagreeprivacyauthorization)$/,
198
+ test: /^(lang|from-type|send-message-title|send-message-path|send-message-img|app-parameter|show-message-card|phone-number-no-quota-toast|bindgetuserinfo|bindcontact|createliveactivity|bindgetphonenumber|bindgetrealtimephonenumber|binderror|bindopensetting|bindlaunchapp|bindchooseavatar|bindagreeprivacyauthorization)$/,
190
199
  ios: iosPropLog,
191
200
  android: androidPropLog,
192
201
  harmony: harmonyPropLog
@@ -44,6 +44,7 @@ const fixComponentName = require('./fix-component-name')
44
44
  const rootPortal = require('./root-portal')
45
45
  const stickyHeader = require('./sticky-header')
46
46
  const stickySection = require('./sticky-section')
47
+ const navContainer = require('./nav-container')
47
48
 
48
49
  module.exports = function getComponentConfigs ({ warn, error }) {
49
50
  /**
@@ -129,6 +130,7 @@ module.exports = function getComponentConfigs ({ warn, error }) {
129
130
  component(),
130
131
  rootPortal({ print }),
131
132
  stickyHeader({ print }),
132
- stickySection({ print })
133
+ stickySection({ print }),
134
+ navContainer({ print })
133
135
  ]
134
136
  }
@@ -0,0 +1,27 @@
1
+ const TAG_NAME = 'nav-container'
2
+
3
+ module.exports = function ({ print }) {
4
+ return {
5
+ test: TAG_NAME,
6
+ web(tag, { el }) {
7
+ el.isBuiltIn = true
8
+ return 'mpx-nav-container'
9
+ },
10
+ ios(tag, { el }) {
11
+ el.isBuiltIn = true
12
+ return 'mpx-nav-container'
13
+ },
14
+ android(tag, { el }) {
15
+ el.isBuiltIn = true
16
+ return 'mpx-nav-container'
17
+ },
18
+ harmony(tag, { el }) {
19
+ el.isBuiltIn = true
20
+ return 'mpx-nav-container'
21
+ },
22
+ wx(tag, { el }) {
23
+ el.isBuiltIn = true
24
+ return 'mpx-nav-container'
25
+ }
26
+ }
27
+ }
@@ -46,7 +46,8 @@ import { getComponent, getAsyncSuspense } from ${stringifyRequest(loaderContext,
46
46
  const componentsMap = buildComponentsMap({
47
47
  localComponentsMap,
48
48
  loaderContext,
49
- jsonConfig
49
+ jsonConfig,
50
+ rnConfig
50
51
  })
51
52
  output += buildGlobalParams({ moduleId, scriptSrcMode, loaderContext, isProduction, ctorType, jsonConfig, componentsMap, pagesMap, firstPage, hasApp })
52
53
  output += getRequireScript({ ctorType, script, loaderContext })
@@ -58,7 +59,8 @@ import { getComponent, getAsyncSuspense } from ${stringifyRequest(loaderContext,
58
59
  localComponentsMap,
59
60
  builtInComponentsMap,
60
61
  loaderContext,
61
- jsonConfig
62
+ jsonConfig,
63
+ rnConfig
62
64
  })
63
65
 
64
66
  output += buildGlobalParams({ moduleId, scriptSrcMode, loaderContext, isProduction, ctorType, jsonConfig, componentsMap, outputPath, genericsInfo, componentGenerics, hasApp })
@@ -59,7 +59,7 @@ function buildPagesMap ({ localPagesMap, loaderContext, jsonConfig, rnConfig })
59
59
  Object.keys(localPagesMap).forEach((pagePath) => {
60
60
  const pageCfg = localPagesMap[pagePath]
61
61
  const pageRequest = stringifyRequest(loaderContext, pageCfg.resource)
62
- if (pageCfg.async) {
62
+ if (pageCfg.async && rnConfig.supportSubpackage) {
63
63
  const moduleId = mpx.getModuleId(pageCfg.resource)
64
64
  const getFallback = rnConfig.asyncChunk && rnConfig.asyncChunk.fallback && getComponentGetter(getComponent(stringifyRequest(loaderContext, addQuery(rnConfig.asyncChunk.fallback, { isComponent: true })), 'PageFallback'))
65
65
  const getLoading = rnConfig.asyncChunk && rnConfig.asyncChunk.loading && getComponentGetter(getComponent(stringifyRequest(loaderContext, addQuery(rnConfig.asyncChunk.loading, { isComponent: true })), 'PageLoading'))
@@ -81,14 +81,14 @@ function buildPagesMap ({ localPagesMap, loaderContext, jsonConfig, rnConfig })
81
81
  }
82
82
  }
83
83
 
84
- function buildComponentsMap ({ localComponentsMap, builtInComponentsMap, loaderContext, jsonConfig }) {
84
+ function buildComponentsMap ({ localComponentsMap, builtInComponentsMap, loaderContext, jsonConfig, rnConfig }) {
85
85
  const componentsMap = {}
86
86
  const mpx = loaderContext.getMpx()
87
87
  if (localComponentsMap) {
88
88
  Object.keys(localComponentsMap).forEach((componentName) => {
89
89
  const componentCfg = localComponentsMap[componentName]
90
90
  const componentRequest = stringifyRequest(loaderContext, componentCfg.resource)
91
- if (componentCfg.async) {
91
+ if (componentCfg.async && rnConfig.supportSubpackage) {
92
92
  const moduleId = mpx.getModuleId(componentCfg.resource)
93
93
  const placeholder = jsonConfig.componentPlaceholder && jsonConfig.componentPlaceholder[componentName]
94
94
  let getFallback
@@ -0,0 +1,3 @@
1
+ <template>
2
+ <slot />
3
+ </template>
@@ -6,9 +6,13 @@ export type LabelContextValue = MutableRefObject<{
6
6
  triggerChange: (evt: NativeSyntheticEvent<TouchEvent>) => void
7
7
  }>
8
8
 
9
- export type KeyboardAvoidContextValue = MutableRefObject<
10
- { cursorSpacing: number, ref: MutableRefObject<any> } | null
11
- >
9
+ export type KeyboardAvoidContextValue = MutableRefObject<{
10
+ cursorSpacing: number
11
+ ref: MutableRefObject<any>
12
+ adjustPosition: boolean
13
+ keyboardHeight?: number
14
+ onKeyboardShow?: () => void
15
+ } | null>
12
16
 
13
17
  export interface GroupValue {
14
18
  [key: string]: { checked: boolean; setValue: Dispatch<SetStateAction<boolean>> }
@@ -37,13 +41,13 @@ export interface IntersectionObserver {
37
41
  }
38
42
 
39
43
  export interface PortalContextValue {
40
- mount: (children: React.ReactNode, key?: number | null, id?: number| null) => number| undefined
44
+ mount: (children: React.ReactNode, key?: number | null, id?: number | null) => number | undefined
41
45
  update: (key: number, children: React.ReactNode) => void
42
46
  unmount: (key: number) => void
43
47
  }
44
48
 
45
49
  export interface ScrollViewContextValue {
46
- gestureRef: React.RefObject<any> | null,
50
+ gestureRef: React.RefObject<any> | null
47
51
  scrollOffset: Animated.Value
48
52
  }
49
53
 
@@ -53,10 +57,15 @@ export interface RouteContextValue {
53
57
  }
54
58
 
55
59
  export interface StickyContextValue {
56
- registerStickyHeader: Function,
60
+ registerStickyHeader: Function
57
61
  unregisterStickyHeader: Function
58
62
  }
59
63
 
64
+ export interface NavSharedValue {
65
+ customNav?: React.ReactNode
66
+ setCustomNav: (value: React.ReactNode) => void
67
+ }
68
+
60
69
  export const MovableAreaContext = createContext({ width: 0, height: 0 })
61
70
 
62
71
  export const FormContext = createContext<FormContextValue | null>(null)
@@ -84,3 +93,5 @@ export const ScrollViewContext = createContext<ScrollViewContextValue>({ gesture
84
93
  export const PortalContext = createContext<PortalContextValue>(null as any)
85
94
 
86
95
  export const StickyContext = createContext<StickyContextValue>({ registerStickyHeader: noop, unregisterStickyHeader: noop })
96
+
97
+ export const NavSharedContext = createContext<NavSharedValue>(null as any)
@@ -0,0 +1,78 @@
1
+ import { Dispatch, MutableRefObject, SetStateAction } from 'react';
2
+ import { NativeSyntheticEvent, Animated } from 'react-native';
3
+ export type LabelContextValue = MutableRefObject<{
4
+ triggerChange: (evt: NativeSyntheticEvent<TouchEvent>) => void;
5
+ }>;
6
+ export type KeyboardAvoidContextValue = MutableRefObject<{
7
+ cursorSpacing: number;
8
+ ref: MutableRefObject<any>;
9
+ adjustPosition: boolean;
10
+ keyboardHeight?: number;
11
+ onKeyboardShow?: () => void;
12
+ } | null>;
13
+ export interface GroupValue {
14
+ [key: string]: {
15
+ checked: boolean;
16
+ setValue: Dispatch<SetStateAction<boolean>>;
17
+ };
18
+ }
19
+ export interface GroupContextValue {
20
+ groupValue: GroupValue;
21
+ notifyChange: (evt: NativeSyntheticEvent<TouchEvent>) => void;
22
+ }
23
+ export interface FormFieldValue {
24
+ getValue: () => any;
25
+ resetValue: ({ newVal, type }: {
26
+ newVal?: any;
27
+ type?: string;
28
+ }) => void;
29
+ }
30
+ export interface FormContextValue {
31
+ formValuesMap: Map<string, FormFieldValue>;
32
+ submit: () => void;
33
+ reset: () => void;
34
+ }
35
+ export interface IntersectionObserver {
36
+ [key: number]: {
37
+ throttleMeasure: () => void;
38
+ };
39
+ }
40
+ export interface PortalContextValue {
41
+ mount: (children: React.ReactNode, key?: number | null, id?: number | null) => number | undefined;
42
+ update: (key: number, children: React.ReactNode) => void;
43
+ unmount: (key: number) => void;
44
+ }
45
+ export interface ScrollViewContextValue {
46
+ gestureRef: React.RefObject<any> | null;
47
+ scrollOffset: Animated.Value;
48
+ }
49
+ export interface RouteContextValue {
50
+ pageId: number;
51
+ navigation: Record<string, any>;
52
+ }
53
+ export interface StickyContextValue {
54
+ registerStickyHeader: Function;
55
+ unregisterStickyHeader: Function;
56
+ }
57
+ export interface NavSharedValue {
58
+ customNav?: React.ReactNode;
59
+ setCustomNav: (value: React.ReactNode) => void;
60
+ }
61
+ export declare const MovableAreaContext: import("react").Context<{
62
+ width: number;
63
+ height: number;
64
+ }>;
65
+ export declare const FormContext: import("react").Context<FormContextValue | null>;
66
+ export declare const CheckboxGroupContext: import("react").Context<GroupContextValue | null>;
67
+ export declare const RadioGroupContext: import("react").Context<GroupContextValue | null>;
68
+ export declare const LabelContext: import("react").Context<LabelContextValue | null>;
69
+ export declare const PickerContext: import("react").Context<null>;
70
+ export declare const VarContext: import("react").Context<{}>;
71
+ export declare const IntersectionObserverContext: import("react").Context<IntersectionObserver | null>;
72
+ export declare const RouteContext: import("react").Context<RouteContextValue | null>;
73
+ export declare const SwiperContext: import("react").Context<{}>;
74
+ export declare const KeyboardAvoidContext: import("react").Context<KeyboardAvoidContextValue | null>;
75
+ export declare const ScrollViewContext: import("react").Context<ScrollViewContextValue>;
76
+ export declare const PortalContext: import("react").Context<PortalContextValue>;
77
+ export declare const StickyContext: import("react").Context<StickyContextValue>;
78
+ export declare const NavSharedContext: import("react").Context<NavSharedValue>;
@@ -15,3 +15,4 @@ export const KeyboardAvoidContext = createContext(null);
15
15
  export const ScrollViewContext = createContext({ gestureRef: null, scrollOffset: new Animated.Value(0) });
16
16
  export const PortalContext = createContext(null);
17
17
  export const StickyContext = createContext({ registerStickyHeader: noop, unregisterStickyHeader: noop });
18
+ export const NavSharedContext = createContext(null);
@@ -0,0 +1,7 @@
1
+ declare const eventConfigMap: {
2
+ [key: string]: {
3
+ bitFlag: string;
4
+ events: string[];
5
+ };
6
+ };
7
+ export default eventConfigMap;
@@ -0,0 +1,7 @@
1
+ import { Props, RawConfig, RemoveProps, LayoutRef, ExtendedNativeTouchEvent } from './types/getInnerListeners';
2
+ export declare const getCustomEvent: (type: string | undefined, oe: any, { detail, layoutRef }: {
3
+ detail?: Record<string, unknown> | undefined;
4
+ layoutRef?: LayoutRef | undefined;
5
+ }, props?: Props) => any;
6
+ declare const useInnerProps: (props?: Props, userRemoveProps?: RemoveProps, rawConfig?: RawConfig) => Record<string, (e: ExtendedNativeTouchEvent) => void> & Omit<Props, string>;
7
+ export default useInnerProps;
@@ -0,0 +1,12 @@
1
+ import { ComponentType, ReactNode } from 'react';
2
+ interface AsyncSuspenseProps {
3
+ type: 'component' | 'page';
4
+ chunkName: string;
5
+ moduleId: string;
6
+ innerProps: any;
7
+ getLoading?: () => ComponentType<unknown>;
8
+ getFallback?: () => ComponentType<unknown>;
9
+ getChildren: () => Promise<ReactNode>;
10
+ }
11
+ declare const AsyncSuspense: React.FC<AsyncSuspenseProps>;
12
+ export default AsyncSuspense;
@@ -0,0 +1,68 @@
1
+ /**
2
+ * ✔ size
3
+ * ✔ type
4
+ * ✔ plain
5
+ * ✔ disabled
6
+ * ✔ loading
7
+ * ✔ form-type
8
+ * - open-type: Partially. Only support `share`、`getUserInfo`
9
+ * ✔ hover-class: Convert hoverClass to hoverStyle.
10
+ * ✔ hover-style
11
+ * ✘ hover-stop-propagation
12
+ * ✔ hover-start-time
13
+ * ✔ hover-stay-time
14
+ * ✘ lang
15
+ * ✘ session-from
16
+ * ✘ send-message-title
17
+ * ✘ send-message-path
18
+ * ✘ send-message-img
19
+ * ✘ app-parameter
20
+ * ✘ show-message-card
21
+ * ✘ phone-number-no-quota-toast
22
+ * ✘ bindgetuserinfo
23
+ * ✘ bindcontact
24
+ * ✘ createliveactivity
25
+ * ✘ bindgetphonenumber
26
+ * ✘ bindgetphonenumber
27
+ * ✘ bindgetrealtimephonenumber
28
+ * ✘ binderror
29
+ * ✘ bindopensetting
30
+ * ✘ bindlaunchapp
31
+ * ✘ bindlaunchapp
32
+ * ✘ bindchooseavatar
33
+ * ✘ bindchooseavatar
34
+ * ✘ bindagreeprivacyauthorization
35
+ * ✔ bindtap
36
+ */
37
+ import { ReactNode } from 'react';
38
+ import { View, ViewStyle, TextStyle, NativeSyntheticEvent } from 'react-native';
39
+ import { HandlerRef } from './useNodesRef';
40
+ import type { ExtendedViewStyle } from './types/common';
41
+ export type Type = 'default' | 'primary' | 'warn';
42
+ export type OpenType = 'share' | 'getUserInfo';
43
+ export type OpenTypeEvent = 'onShareAppMessage' | 'onUserInfo';
44
+ export interface ButtonProps {
45
+ size?: string;
46
+ type?: Type;
47
+ plain?: boolean;
48
+ disabled?: boolean;
49
+ loading?: boolean;
50
+ 'hover-class'?: string;
51
+ 'hover-style'?: ExtendedViewStyle;
52
+ 'hover-start-time'?: number;
53
+ 'hover-stay-time'?: number;
54
+ 'open-type'?: OpenType;
55
+ 'form-type'?: 'submit' | 'reset';
56
+ 'enable-offset'?: boolean;
57
+ 'enable-var'?: boolean;
58
+ 'external-var-context'?: Record<string, any>;
59
+ 'parent-font-size'?: number;
60
+ 'parent-width'?: number;
61
+ 'parent-height'?: number;
62
+ style?: ViewStyle & TextStyle & Record<string, any>;
63
+ children: ReactNode;
64
+ bindgetuserinfo?: (userInfo: any) => void;
65
+ bindtap?: (evt: NativeSyntheticEvent<TouchEvent> | unknown) => void;
66
+ }
67
+ declare const Button: import("react").ForwardRefExoticComponent<ButtonProps & import("react").RefAttributes<HandlerRef<View, ButtonProps>>>;
68
+ export default Button;
@@ -0,0 +1,23 @@
1
+ /// <reference types="node" />
2
+ interface Message {
3
+ id?: string;
4
+ type: string;
5
+ payload?: any;
6
+ }
7
+ export default class Bus {
8
+ _paused: Boolean;
9
+ _messageListeners: {
10
+ [key: string]: (message: Message) => void;
11
+ };
12
+ _queue: Message[];
13
+ _send: (message: Message | Message[]) => void;
14
+ _timeoutId: NodeJS.Timeout | null;
15
+ constructor(send: (message: Message | Message[]) => void);
16
+ post(message: Message): Promise<any>;
17
+ handle(message: Message): void;
18
+ pause(): void;
19
+ resume(): void;
20
+ startBatching(): void;
21
+ clearBatchingTimeout(): void;
22
+ }
23
+ export {};
@@ -0,0 +1,7 @@
1
+ import { WebviewMessage, CanvasInstance } from './utils';
2
+ export default class CanvasGradient {
3
+ private canvas;
4
+ [key: string]: any;
5
+ constructor(canvas: CanvasInstance, noOnConstruction?: boolean);
6
+ postMessage(message: WebviewMessage): Promise<any>;
7
+ }
@@ -0,0 +1,6 @@
1
+ import { CanvasInstance, WebviewMessage } from './utils';
2
+ export default class CanvasRenderingContext2D {
3
+ canvas: CanvasInstance;
4
+ constructor(canvas: CanvasInstance);
5
+ postMessage(message: WebviewMessage): Promise<any>;
6
+ }
@@ -0,0 +1,20 @@
1
+ import { WebviewMessage, WEBVIEW_TARGET, CanvasInstance } from './utils';
2
+ export declare class Image {
3
+ [WEBVIEW_TARGET]: string;
4
+ canvas: any;
5
+ width: number;
6
+ height: number;
7
+ private _loadListener;
8
+ private _errorListener;
9
+ private _onload;
10
+ private _onerror;
11
+ [key: string]: any;
12
+ constructor(canvas: CanvasInstance, width?: number, height?: number, noOnConstruction?: boolean);
13
+ postMessage(message: WebviewMessage): any;
14
+ addEventListener(type: 'load' | 'error', callbackFn: Function): any;
15
+ set onload(callback: ((...args: any[]) => void));
16
+ get onload(): ((...args: any[]) => void);
17
+ set onerror(callback: ((...args: any[]) => void));
18
+ get onerror(): ((...args: any[]) => void);
19
+ }
20
+ export declare function createImage(canvas: CanvasInstance, width?: number, height?: number): Image;
@@ -0,0 +1,8 @@
1
+ import { WebviewMessage, CanvasInstance } from './utils';
2
+ export default class ImageData {
3
+ canvas: CanvasInstance;
4
+ [key: string]: any;
5
+ constructor(canvas: CanvasInstance, dataArray: number[], width: number, height: number, noOnConstruction?: boolean);
6
+ postMessage: (message: WebviewMessage) => Promise<any>;
7
+ }
8
+ export declare function createImageData(canvas: CanvasInstance, dataArray: number[], width: number, height: number): ImageData;
@@ -0,0 +1,10 @@
1
+ import { WebviewConstructor } from './utils';
2
+ export declare enum ConstructorType {
3
+ Image = "Image",
4
+ CanvasGradient = "CanvasGradient",
5
+ ImageData = "ImageData"
6
+ }
7
+ export declare function useConstructorsRegistry(): {
8
+ register: (registerWebviewConstructor: Function) => void;
9
+ getConstructor: (type: ConstructorType) => WebviewConstructor | undefined;
10
+ };