@mpxjs/api-proxy 2.9.60 → 2.9.62

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/LICENSE ADDED
@@ -0,0 +1,433 @@
1
+ Apache License
2
+
3
+ Version 2.0, January 2004
4
+
5
+ http://www.apache.org/licenses/
6
+
7
+
8
+
9
+
10
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
11
+
12
+
13
+
14
+
15
+ 1. Definitions.
16
+
17
+
18
+
19
+
20
+ "License" shall mean the terms and conditions for use, reproduction,
21
+
22
+ and distribution as defined by Sections 1 through 9 of this document.
23
+
24
+
25
+
26
+
27
+ "Licensor" shall mean the copyright owner or entity authorized by
28
+
29
+ the copyright owner that is granting the License.
30
+
31
+
32
+
33
+
34
+ "Legal Entity" shall mean the union of the acting entity and all
35
+
36
+ other entities that control, are controlled by, or are under common
37
+
38
+ control with that entity. For the purposes of this definition,
39
+
40
+ "control" means (i) the power, direct or indirect, to cause the
41
+
42
+ direction or management of such entity, whether by contract or
43
+
44
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
45
+
46
+ outstanding shares, or (iii) beneficial ownership of such entity.
47
+
48
+
49
+
50
+
51
+ "You" (or "Your") shall mean an individual or Legal Entity
52
+
53
+ exercising permissions granted by this License.
54
+
55
+
56
+
57
+
58
+ "Source" form shall mean the preferred form for making modifications,
59
+
60
+ including but not limited to software source code, documentation
61
+
62
+ source, and configuration files.
63
+
64
+
65
+
66
+
67
+ "Object" form shall mean any form resulting from mechanical
68
+
69
+ transformation or translation of a Source form, including but
70
+
71
+ not limited to compiled object code, generated documentation,
72
+
73
+ and conversions to other media types.
74
+
75
+
76
+
77
+
78
+ "Work" shall mean the work of authorship, whether in Source or
79
+
80
+ Object form, made available under the License, as indicated by a
81
+
82
+ copyright notice that is included in or attached to the work
83
+
84
+ (an example is provided in the Appendix below).
85
+
86
+
87
+
88
+
89
+ "Derivative Works" shall mean any work, whether in Source or Object
90
+
91
+ form, that is based on (or derived from) the Work and for which the
92
+
93
+ editorial revisions, annotations, elaborations, or other modifications
94
+
95
+ represent, as a whole, an original work of authorship. For the purposes
96
+
97
+ of this License, Derivative Works shall not include works that remain
98
+
99
+ separable from, or merely link (or bind by name) to the interfaces of,
100
+
101
+ the Work and Derivative Works thereof.
102
+
103
+
104
+
105
+
106
+ "Contribution" shall mean any work of authorship, including
107
+
108
+ the original version of the Work and any modifications or additions
109
+
110
+ to that Work or Derivative Works thereof, that is intentionally
111
+
112
+ submitted to Licensor for inclusion in the Work by the copyright owner
113
+
114
+ or by an individual or Legal Entity authorized to submit on behalf of
115
+
116
+ the copyright owner. For the purposes of this definition, "submitted"
117
+
118
+ means any form of electronic, verbal, or written communication sent
119
+
120
+ to the Licensor or its representatives, including but not limited to
121
+
122
+ communication on electronic mailing lists, source code control systems,
123
+
124
+ and issue tracking systems that are managed by, or on behalf of, the
125
+
126
+ Licensor for the purpose of discussing and improving the Work, but
127
+
128
+ excluding communication that is conspicuously marked or otherwise
129
+
130
+ designated in writing by the copyright owner as "Not a Contribution."
131
+
132
+
133
+
134
+
135
+ "Contributor" shall mean Licensor and any individual or Legal Entity
136
+
137
+ on behalf of whom a Contribution has been received by Licensor and
138
+
139
+ subsequently incorporated within the Work.
140
+
141
+
142
+
143
+
144
+ 2. Grant of Copyright License. Subject to the terms and conditions of
145
+
146
+ this License, each Contributor hereby grants to You a perpetual,
147
+
148
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
149
+
150
+ copyright license to reproduce, prepare Derivative Works of,
151
+
152
+ publicly display, publicly perform, sublicense, and distribute the
153
+
154
+ Work and such Derivative Works in Source or Object form.
155
+
156
+
157
+
158
+
159
+ 3. Grant of Patent License. Subject to the terms and conditions of
160
+
161
+ this License, each Contributor hereby grants to You a perpetual,
162
+
163
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
164
+
165
+ (except as stated in this section) patent license to make, have made,
166
+
167
+ use, offer to sell, sell, import, and otherwise transfer the Work,
168
+
169
+ where such license applies only to those patent claims licensable
170
+
171
+ by such Contributor that are necessarily infringed by their
172
+
173
+ Contribution(s) alone or by combination of their Contribution(s)
174
+
175
+ with the Work to which such Contribution(s) was submitted. If You
176
+
177
+ institute patent litigation against any entity (including a
178
+
179
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
180
+
181
+ or a Contribution incorporated within the Work constitutes direct
182
+
183
+ or contributory patent infringement, then any patent licenses
184
+
185
+ granted to You under this License for that Work shall terminate
186
+
187
+ as of the date such litigation is filed.
188
+
189
+
190
+
191
+
192
+ 4. Redistribution. You may reproduce and distribute copies of the
193
+
194
+ Work or Derivative Works thereof in any medium, with or without
195
+
196
+ modifications, and in Source or Object form, provided that You
197
+
198
+ meet the following conditions:
199
+
200
+
201
+
202
+
203
+ (a) You must give any other recipients of the Work or
204
+
205
+ Derivative Works a copy of this License; and
206
+
207
+
208
+
209
+
210
+ (b) You must cause any modified files to carry prominent notices
211
+
212
+ stating that You changed the files; and
213
+
214
+
215
+
216
+
217
+ (c) You must retain, in the Source form of any Derivative Works
218
+
219
+ that You distribute, all copyright, patent, trademark, and
220
+
221
+ attribution notices from the Source form of the Work,
222
+
223
+ excluding those notices that do not pertain to any part of
224
+
225
+ the Derivative Works; and
226
+
227
+
228
+
229
+
230
+ (d) If the Work includes a "NOTICE" text file as part of its
231
+
232
+ distribution, then any Derivative Works that You distribute must
233
+
234
+ include a readable copy of the attribution notices contained
235
+
236
+ within such NOTICE file, excluding those notices that do not
237
+
238
+ pertain to any part of the Derivative Works, in at least one
239
+
240
+ of the following places: within a NOTICE text file distributed
241
+
242
+ as part of the Derivative Works; within the Source form or
243
+
244
+ documentation, if provided along with the Derivative Works; or,
245
+
246
+ within a display generated by the Derivative Works, if and
247
+
248
+ wherever such third-party notices normally appear. The contents
249
+
250
+ of the NOTICE file are for informational purposes only and
251
+
252
+ do not modify the License. You may add Your own attribution
253
+
254
+ notices within Derivative Works that You distribute, alongside
255
+
256
+ or as an addendum to the NOTICE text from the Work, provided
257
+
258
+ that such additional attribution notices cannot be construed
259
+
260
+ as modifying the License.
261
+
262
+
263
+
264
+
265
+ You may add Your own copyright statement to Your modifications and
266
+
267
+ may provide additional or different license terms and conditions
268
+
269
+ for use, reproduction, or distribution of Your modifications, or
270
+
271
+ for any such Derivative Works as a whole, provided Your use,
272
+
273
+ reproduction, and distribution of the Work otherwise complies with
274
+
275
+ the conditions stated in this License.
276
+
277
+
278
+
279
+
280
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
281
+
282
+ any Contribution intentionally submitted for inclusion in the Work
283
+
284
+ by You to the Licensor shall be under the terms and conditions of
285
+
286
+ this License, without any additional terms or conditions.
287
+
288
+ Notwithstanding the above, nothing herein shall supersede or modify
289
+
290
+ the terms of any separate license agreement you may have executed
291
+
292
+ with Licensor regarding such Contributions.
293
+
294
+
295
+
296
+
297
+ 6. Trademarks. This License does not grant permission to use the trade
298
+
299
+ names, trademarks, service marks, or product names of the Licensor,
300
+
301
+ except as required for reasonable and customary use in describing the
302
+
303
+ origin of the Work and reproducing the content of the NOTICE file.
304
+
305
+
306
+
307
+
308
+ 7. Disclaimer of Warranty. Unless required by applicable law or
309
+
310
+ agreed to in writing, Licensor provides the Work (and each
311
+
312
+ Contributor provides its Contributions) on an "AS IS" BASIS,
313
+
314
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
315
+
316
+ implied, including, without limitation, any warranties or conditions
317
+
318
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
319
+
320
+ PARTICULAR PURPOSE. You are solely responsible for determining the
321
+
322
+ appropriateness of using or redistributing the Work and assume any
323
+
324
+ risks associated with Your exercise of permissions under this License.
325
+
326
+
327
+
328
+
329
+ 8. Limitation of Liability. In no event and under no legal theory,
330
+
331
+ whether in tort (including negligence), contract, or otherwise,
332
+
333
+ unless required by applicable law (such as deliberate and grossly
334
+
335
+ negligent acts) or agreed to in writing, shall any Contributor be
336
+
337
+ liable to You for damages, including any direct, indirect, special,
338
+
339
+ incidental, or consequential damages of any character arising as a
340
+
341
+ result of this License or out of the use or inability to use the
342
+
343
+ Work (including but not limited to damages for loss of goodwill,
344
+
345
+ work stoppage, computer failure or malfunction, or any and all
346
+
347
+ other commercial damages or losses), even if such Contributor
348
+
349
+ has been advised of the possibility of such damages.
350
+
351
+
352
+
353
+
354
+ 9. Accepting Warranty or Additional Liability. While redistributing
355
+
356
+ the Work or Derivative Works thereof, You may choose to offer,
357
+
358
+ and charge a fee for, acceptance of support, warranty, indemnity,
359
+
360
+ or other liability obligations and/or rights consistent with this
361
+
362
+ License. However, in accepting such obligations, You may act only
363
+
364
+ on Your own behalf and on Your sole responsibility, not on behalf
365
+
366
+ of any other Contributor, and only if You agree to indemnify,
367
+
368
+ defend, and hold each Contributor harmless for any liability
369
+
370
+ incurred by, or claims asserted against, such Contributor by reason
371
+
372
+ of your accepting any such warranty or additional liability.
373
+
374
+
375
+
376
+
377
+ END OF TERMS AND CONDITIONS
378
+
379
+
380
+
381
+
382
+ APPENDIX: How to apply the Apache License to your work.
383
+
384
+
385
+
386
+
387
+ To apply the Apache License to your work, attach the following
388
+
389
+ boilerplate notice, with the fields enclosed by brackets "{}"
390
+
391
+ replaced with your own identifying information. (Don't include
392
+
393
+ the brackets!) The text should be enclosed in the appropriate
394
+
395
+ comment syntax for the file format. We also recommend that a
396
+
397
+ file or class name and description of purpose be included on the
398
+
399
+ same "printed page" as the copyright notice for easier
400
+
401
+ identification within third-party archives.
402
+
403
+
404
+
405
+
406
+ Copyright (C) 2017 Beijing Didi Infinity Technology and Development Co.,Ltd. All rights reserved.
407
+
408
+
409
+
410
+
411
+ Licensed under the Apache License, Version 2.0 (the "License");
412
+
413
+ you may not use this file except in compliance with the License.
414
+
415
+ You may obtain a copy of the License at
416
+
417
+
418
+
419
+
420
+ http://www.apache.org/licenses/LICENSE-2.0
421
+
422
+
423
+
424
+
425
+ Unless required by applicable law or agreed to in writing, software
426
+
427
+ distributed under the License is distributed on an "AS IS" BASIS,
428
+
429
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
430
+
431
+ See the License for the specific language governing permissions and
432
+
433
+ limitations under the License.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpxjs/api-proxy",
3
- "version": "2.9.60",
3
+ "version": "2.9.62",
4
4
  "description": "convert miniprogram API at each end",
5
5
  "module": "src/index.js",
6
6
  "types": "@types/index.d.ts",
@@ -43,19 +43,18 @@
43
43
  "peerDependencies": {
44
44
  "@ant-design/react-native": "^5.1.3",
45
45
  "@react-native-async-storage/async-storage": "^1.23.1",
46
- "@react-native-clipboard/clipboard": "^1.14.0",
47
46
  "@react-native-community/netinfo": "^11.2.1",
48
47
  "expo-brightness": "~11.8.0",
48
+ "expo-clipboard": "~6.0.3",
49
49
  "react-native-device-info": "^10.13.2",
50
50
  "react-native-get-location": "^4.0.1",
51
- "react-native-safe-area-context": "^4.10.1",
52
- "react-native-webview": "^13.10.5"
51
+ "react-native-safe-area-context": "^4.10.1"
53
52
  },
54
53
  "peerDependenciesMeta": {
55
54
  "@react-native-async-storage/async-storage": {
56
55
  "optional": true
57
56
  },
58
- "@react-native-clipboard/clipboard": {
57
+ "expo-clipboard": {
59
58
  "optional": true
60
59
  },
61
60
  "@react-native-community/netinfo": {
@@ -75,9 +74,7 @@
75
74
  },
76
75
  "expo-brightness": {
77
76
  "optional": true
78
- },
79
- "react-native-webview": {
80
- "optional": true
81
77
  }
82
- }
78
+ },
79
+ "gitHead": "c31a343e7ef2c1c1585002752d8c50f016a858ae"
83
80
  }
@@ -87,6 +87,14 @@ function failHandle (result, fail, complete) {
87
87
  typeof complete === 'function' && complete(result)
88
88
  }
89
89
 
90
+ function getFocusedNavigation () {
91
+ for (const key in global.__mpxPagesMap) {
92
+ const navigation = global.__mpxPagesMap[key]?.[1]
93
+ if (navigation && navigation.isFocused()) {
94
+ return navigation
95
+ }
96
+ }
97
+ }
90
98
  const ENV_OBJ = getEnvObj()
91
99
 
92
100
  export {
@@ -100,5 +108,6 @@ export {
100
108
  ENV_OBJ,
101
109
  defineUnsupportedProps,
102
110
  successHandle,
103
- failHandle
111
+ failHandle,
112
+ getFocusedNavigation
104
113
  }
@@ -1,7 +1,7 @@
1
1
  import { View, TouchableHighlight, Text, StyleSheet, Button, Animated } from 'react-native'
2
2
  import { successHandle, failHandle } from '../../../common/js'
3
3
  import { Portal } from '@ant-design/react-native'
4
- function showActionSheet (options) {
4
+ function showActionSheet (options = {}) {
5
5
  const { alertText, itemList = [], itemColor = '#000000', success, fail, complete } = options
6
6
  let actionSheetKey
7
7
  const slideAnim = new Animated.Value(500)
@@ -1,7 +1,10 @@
1
1
  import { fromByteArray, toByteArray } from './base64'
2
2
 
3
3
  function base64ToArrayBuffer (base64) {
4
- return toByteArray(base64)?.buffer
4
+ if (__mpx_mode__ === 'web') {
5
+ return toByteArray(base64)?.buffer
6
+ }
7
+ return toByteArray(base64)
5
8
  }
6
9
 
7
10
  function arrayBufferToBase64 (arrayBuffer) {
@@ -1,7 +1,8 @@
1
- import Clipboard from '@react-native-clipboard/clipboard'
2
1
  import { successHandle, failHandle } from '../../../common/js'
3
2
  import { type } from '@mpxjs/utils'
4
- const setClipboardData = function (options) {
3
+ import { getStringAsync, setStringAsync } from 'expo-clipboard'
4
+
5
+ const setClipboardData = function (options = {}) {
5
6
  const { data, success, fail, complete } = options
6
7
  if (!data || type(data) !== 'String') {
7
8
  const errStr = !data ? 'parameter.data should be String instead of Undefined;' : `parameter.data should be String instead of ${type(data)};`
@@ -12,24 +13,30 @@ const setClipboardData = function (options) {
12
13
  failHandle(result, fail, complete)
13
14
  return
14
15
  }
15
- Clipboard.setString(data)
16
- const result = {
17
- errMsg: 'setClipboardData:ok'
18
- }
19
- successHandle(result, success, complete)
16
+ setStringAsync(data).then(() => {
17
+ const result = {
18
+ errMsg: 'setClipboardData:ok'
19
+ }
20
+ successHandle(result, success, complete)
21
+ }).catch((e) => {
22
+ const result = {
23
+ errMsg: `setClipboardData:fail ${e}`
24
+ }
25
+ failHandle(result, fail, complete)
26
+ })
20
27
  }
21
28
 
22
- const getClipboardData = function (options) {
29
+ const getClipboardData = function (options = {}) {
23
30
  const { success, fail, complete } = options
24
- Clipboard.getString().then((data) => {
31
+ getStringAsync().then((data) => {
25
32
  const result = {
26
33
  data,
27
34
  errMsg: 'getClipboardData:ok'
28
35
  }
29
36
  successHandle(result, success, complete)
30
- }).catch(() => {
37
+ }).catch((e) => {
31
38
  const result = {
32
- errMsg: 'setClipboardData:fail'
39
+ errMsg: `getClipboardData:fail ${e}`
33
40
  }
34
41
  failHandle(result, fail, complete)
35
42
  })
@@ -28,6 +28,12 @@ export default class SelectorQuery {
28
28
  if (!this._component) {
29
29
  warn('Please use SelectorQuery.in method to set context')
30
30
  }
31
+ selector = selector.trim()
32
+ // 后续如果要支持这种复杂的选择器,需要按场景拆分这些判断逻辑
33
+ if (/>|,|>>>|\+|~|\s+/.test(selector)) {
34
+ warn('SelectQuery.select don\'t support combinator selector, it only supports selector like #a or .a or .a.b now.')
35
+ return new NodeRef([], this, !all)
36
+ }
31
37
  const refs = this._component && this._component.__selectRef(selector, 'node', all)
32
38
  return new NodeRef(refs, this, !all)
33
39
  }
@@ -13,7 +13,7 @@ const getConnectionType = function (connectionInfo) {
13
13
  return type
14
14
  }
15
15
 
16
- const getNetworkType = function (options) {
16
+ const getNetworkType = function (options = {}) {
17
17
  const { success, fail, complete } = options
18
18
  NetInfo.fetch().then((connectionInfo) => {
19
19
  const result = {
@@ -0,0 +1,23 @@
1
+ import { changeOpts, ENV_OBJ, envError } from '../../../common/js'
2
+
3
+ const getExtConfig = function (options = {}) {
4
+ const cacheSuc = options.success
5
+ options.success = function (res) {
6
+ const sucRes = changeOpts(res, {
7
+ data: 'extConfig'
8
+ })
9
+ cacheSuc.call(this, sucRes)
10
+ }
11
+ if (ENV_OBJ.getExtConfig) {
12
+ ENV_OBJ.getExtConfig(options)
13
+ } else {
14
+ envError('getExtConfig')
15
+ }
16
+ }
17
+
18
+ const getExtConfigSync = ENV_OBJ.getExtConfigSync || envError('getExtConfigSync')
19
+
20
+ export {
21
+ getExtConfig,
22
+ getExtConfigSync
23
+ }
@@ -0,0 +1,10 @@
1
+ import { ENV_OBJ, envError } from '../../../common/js'
2
+
3
+ const getExtConfig = ENV_OBJ.getExtConfig || envError('getExtConfig')
4
+
5
+ const getExtConfigSync = ENV_OBJ.getExtConfigSync || envError('getExtConfigSync')
6
+
7
+ export {
8
+ getExtConfig,
9
+ getExtConfigSync
10
+ }
@@ -1,7 +1,7 @@
1
1
  import GetLocation from 'react-native-get-location'
2
2
  import { envError, successHandle, failHandle, defineUnsupportedProps } from '../../../common/js'
3
3
 
4
- const getLocation = function (options) {
4
+ const getLocation = function (options = {}) {
5
5
  const { isHighAccuracy = false, success, fail, complete } = options
6
6
  GetLocation.getCurrentPosition({
7
7
  enableHighAccuracy: isHighAccuracy
@@ -1,6 +1,6 @@
1
1
  import { envError, successHandle, failHandle, defineUnsupportedProps } from '../../../common/js'
2
2
 
3
- const getLocation = function (options) {
3
+ const getLocation = function (options = {}) {
4
4
  const { isHighAccuracy = false, success, fail, complete } = options
5
5
  if (navigator.geolocation.getCurrentPosition) {
6
6
  navigator.geolocation.getCurrentPosition((res = {}) => {
@@ -1,7 +1,7 @@
1
1
  import { successHandle, failHandle } from '../../../common/js'
2
2
  import { Linking } from 'react-native'
3
3
 
4
- const makePhoneCall = function (options) {
4
+ const makePhoneCall = function (options = {}) {
5
5
  const {
6
6
  phoneNumber = '',
7
7
  success = null,
@@ -1,8 +1,8 @@
1
- import { View, Dimensions, Text, StyleSheet, TouchableOpacity, ScrollView } from 'react-native'
1
+ import { View, Dimensions, Text, StyleSheet, TouchableOpacity, ScrollView, TextInput } from 'react-native'
2
2
  import { successHandle, failHandle } from '../../../common/js'
3
3
  import { Portal } from '@ant-design/react-native'
4
4
  const { width, height } = Dimensions.get('window')
5
- const showModal = function (options) {
5
+ const showModal = function (options = {}) {
6
6
  const {
7
7
  title,
8
8
  content,
@@ -10,9 +10,9 @@ const showModal = function (options) {
10
10
  cancelText = '取消',
11
11
  cancelColor = '#000000',
12
12
  confirmText = '确定',
13
- confirmColor = '#576B95',
14
13
  editable = false,
15
- placeholderText,
14
+ placeholderText = '',
15
+ confirmColor = '#576B95',
16
16
  success,
17
17
  fail,
18
18
  complete
@@ -82,12 +82,17 @@ const showModal = function (options) {
82
82
  let ModalView
83
83
  let modalTitle = []
84
84
  let modalContent = []
85
+ let editableContent = []
85
86
  let modalButton = [{
86
87
  text: confirmText,
87
88
  confirmColor,
88
89
  type: 'confirm',
89
90
  color: 'rgb(87, 107, 149)'
90
91
  }]
92
+ let contentText = content
93
+ const onChangeText = function (text) {
94
+ contentText = text
95
+ }
91
96
  const closeModal = function (buttonInfo) {
92
97
  Portal.remove(modalKey)
93
98
  modalKey = null
@@ -98,7 +103,7 @@ const showModal = function (options) {
98
103
  Object.assign(result, {
99
104
  confirm: true,
100
105
  cancel: false,
101
- content: null
106
+ content: editable ? contentText : null
102
107
  })
103
108
  } else {
104
109
  Object.assign(result, {
@@ -114,6 +119,9 @@ const showModal = function (options) {
114
119
  if (!editable && content) {
115
120
  modalContent.push(content)
116
121
  }
122
+ if (editable) {
123
+ editableContent.push(placeholderText)
124
+ }
117
125
  if (showCancel) {
118
126
  modalButton.unshift({
119
127
  text: cancelText,
@@ -123,17 +131,27 @@ const showModal = function (options) {
123
131
  color: '#000000'
124
132
  })
125
133
  }
126
- if (!editable) {
127
- ModalView = <View style={styles.modalTask}>
128
- <View style={styles.modalContent}>
129
- {modalTitle.map((item, index) => <View key={index}><Text style={styles.modalTitleText}>{item}</Text></View>)}
130
- {modalContent.map((item, index) => <ScrollView key={index} style={styles.contentBox}><Text style={styles.modalContentText}>{item}</Text></ScrollView>)}
131
- <View style={styles.modalBtnBox}>
132
- {modalButton.map((item, index) => <TouchableOpacity key={index} style={[ styles.modalBtn, item.style ]} onPress={() => closeModal(item)}><Text style={[styles.modalButton, { color: item.color }]}>{item.text}</Text></TouchableOpacity>)}
133
- </View>
134
+ ModalView = <View style={styles.modalTask}>
135
+ <View style={styles.modalContent}>
136
+ {modalTitle.map((item, index) => <View key={index}><Text style={styles.modalTitleText}>{item}</Text></View>)}
137
+ {modalContent.map((item, index) => <ScrollView key={index} style={styles.contentBox}><Text style={styles.modalContentText}>{item}</Text></ScrollView>)}
138
+ {editableContent.map((item, index) => <View key={index} style={{
139
+ width: '100%',
140
+ paddingLeft: 25,
141
+ paddingRight: 25,
142
+ marginTop: 5
143
+ }}><TextInput placeholder={item} style={{
144
+ height: 40,
145
+ backgroundColor: '#eeeeee',
146
+ width: '100%',
147
+ paddingLeft: 10,
148
+ paddingRight: 10
149
+ }} onChangeText={text => onChangeText(text)} defaultValue={content}></TextInput></View>)}
150
+ <View style={styles.modalBtnBox}>
151
+ {modalButton.map((item, index) => <TouchableOpacity key={index} style={[ styles.modalBtn, item.style ]} onPress={() => closeModal(item)}><Text style={[styles.modalButton, { color: item.color }]}>{item.text}</Text></TouchableOpacity>)}
134
152
  </View>
135
153
  </View>
136
- }
154
+ </View>
137
155
  try {
138
156
  modalKey = Portal.add(ModalView)
139
157
  } catch (e) {
@@ -1,7 +1,7 @@
1
1
  import { successHandle, failHandle, isBrowser, throwSSRWarning } from '../../../common/js'
2
2
  import { nextTick } from '../next-tick'
3
3
 
4
- export function pageScrollTo (options) {
4
+ export function pageScrollTo (options = {}) {
5
5
  if (!isBrowser) {
6
6
  throwSSRWarning('pageScrollTo API is running in non browser environments')
7
7
  return
@@ -12,7 +12,7 @@ function request (options = { url: '' }) {
12
12
  method = 'GET',
13
13
  dataType = 'json',
14
14
  responseType = 'text',
15
- timeout = 60 * 1000,
15
+ timeout = global.__networkTimeout || 60 * 1000,
16
16
  header = {},
17
17
  success = null,
18
18
  fail = null,
@@ -87,13 +87,13 @@ function request (options = { url: '' }) {
87
87
  } catch (e) {
88
88
  }
89
89
  }
90
- const result = {
90
+
91
+ const result = Object.assign({}, res, {
91
92
  errMsg: 'request:ok',
92
93
  data,
93
94
  statusCode: res.status,
94
- header: res.headers,
95
- ...res
96
- }
95
+ header: res.headers
96
+ })
97
97
  defineUnsupportedProps(result, ['cookies', 'profile', 'exception'])
98
98
  successHandle(result, success, complete)
99
99
  return result
@@ -1,50 +1,35 @@
1
- // import * as Brightness from 'expo-brightness'
1
+ import * as Brightness from 'expo-brightness'
2
2
  import { successHandle, failHandle } from '../../../common/js'
3
- //
4
- // function getScreenBrightness (options) {
5
- // const { success, fail, complete } = options
6
- // Brightness.getBrightnessAsync().then(value => {
7
- // const result = {
8
- // errMsg: 'getScreenBrightness:ok',
9
- // value
10
- // }
11
- // successHandle(result, success, complete)
12
- // }).catch(() => {
13
- // const result = {
14
- // errMsg: 'getScreenBrightness:fail'
15
- // }
16
- // failHandle(result, fail, complete)
17
- // })
18
- // }
19
- //
20
- // function setScreenBrightness (options) {
21
- // const { value, success, fail, complete } = options
22
- // Brightness.setBrightnessAsync(value).then(() => {
23
- // const result = {
24
- // errMsg: 'setScreenBrightness:ok'
25
- // }
26
- // successHandle(result, success, complete)
27
- // }).catch(() => {
28
- // const result = {
29
- // errMsg: 'setScreenBrightness:fail'
30
- // }
31
- // failHandle(result, fail, complete)
32
- // })
33
- // }
34
3
 
35
- function getScreenBrightness (options) {
36
- const { success, complete } = options
37
- const result = {
38
- errMsg: 'getScreenBrightness:ok'
39
- }
40
- successHandle(result, success, complete)
4
+ function getScreenBrightness (options = {}) {
5
+ const { success, fail, complete } = options
6
+ Brightness.getBrightnessAsync().then(value => {
7
+ const result = {
8
+ errMsg: 'getScreenBrightness:ok',
9
+ value
10
+ }
11
+ successHandle(result, success, complete)
12
+ }).catch(() => {
13
+ const result = {
14
+ errMsg: 'getScreenBrightness:fail'
15
+ }
16
+ failHandle(result, fail, complete)
17
+ })
41
18
  }
42
- function setScreenBrightness (options) {
43
- const { fail, complete } = options
44
- const result = {
45
- errMsg: 'setScreenBrightness:fail'
46
- }
47
- failHandle(result, fail, complete)
19
+
20
+ function setScreenBrightness (options = {}) {
21
+ const { value, success, fail, complete } = options
22
+ Brightness.setBrightnessAsync(value).then(() => {
23
+ const result = {
24
+ errMsg: 'setScreenBrightness:ok'
25
+ }
26
+ successHandle(result, success, complete)
27
+ }).catch(() => {
28
+ const result = {
29
+ errMsg: 'setScreenBrightness:fail'
30
+ }
31
+ failHandle(result, fail, complete)
32
+ })
48
33
  }
49
34
 
50
35
  export {
@@ -1,13 +1,5 @@
1
- import { successHandle, failHandle } from '../../../common/js'
1
+ import { successHandle, failHandle, getFocusedNavigation } from '../../../common/js'
2
2
 
3
- function getFocusedNavigation () {
4
- for (const key in global.__mpxPagesMap) {
5
- const navigation = global.__mpxPagesMap[key]?.[1]
6
- if (navigation && navigation.isFocused()) {
7
- return navigation
8
- }
9
- }
10
- }
11
3
  function setNavigationBarTitle (options = {}) {
12
4
  const { title = '', success, fail, complete } = options
13
5
  const navigation = getFocusedNavigation()
@@ -40,7 +40,7 @@ class SocketTask {
40
40
  return this._socket.readyState
41
41
  }
42
42
 
43
- send (options) {
43
+ send (options = {}) {
44
44
  const { data = '', success, fail, complete } = options
45
45
  if (typeof data !== 'string' || type(data) !== 'ArrayBuffer') {
46
46
  const res = { errMsg: 'sendSocketMessage:fail Unsupported data type' }
@@ -1,7 +1,7 @@
1
1
  import AsyncStorage from '@react-native-async-storage/async-storage'
2
2
  import { envError, successHandle, failHandle, defineUnsupportedProps } from '../../../common/js'
3
3
  import { hasOwn } from '@mpxjs/utils'
4
- function setStorage (options) {
4
+ function setStorage (options = {}) {
5
5
  const { key, data, success, fail, complete } = options
6
6
  let obj = {}
7
7
  if (typeof data === 'symbol') {
@@ -26,7 +26,7 @@ function setStorage (options) {
26
26
 
27
27
  const setStorageSync = envError('setStorageSync')
28
28
 
29
- function getStorage (options) {
29
+ function getStorage (options = {}) {
30
30
  const { key, success, fail, complete } = options
31
31
  if (!key) {
32
32
  const result = {
@@ -62,7 +62,7 @@ function getStorage (options) {
62
62
 
63
63
  const getStorageSync = envError('getStorageSync')
64
64
 
65
- function getStorageInfo (options) {
65
+ function getStorageInfo (options = {}) {
66
66
  const { success, fail, complete } = options
67
67
  AsyncStorage.getAllKeys((err, keys) => {
68
68
  if (err) {
@@ -83,7 +83,7 @@ function getStorageInfo (options) {
83
83
 
84
84
  const getStorageInfoSync = envError('getStorageInfoSync')
85
85
 
86
- function removeStorage (options) {
86
+ function removeStorage (options = {}) {
87
87
  const { key, success, fail, complete } = options
88
88
  AsyncStorage.removeItem(key, (err) => {
89
89
  if (err) {
@@ -104,7 +104,7 @@ function removeStorageSync (key) {
104
104
  AsyncStorage.removeItem(key)
105
105
  }
106
106
 
107
- function clearStorage (options) {
107
+ function clearStorage (options = {}) {
108
108
  const { success, fail, complete } = options
109
109
  AsyncStorage.clear((err) => {
110
110
  if (err) {
@@ -1,56 +1,62 @@
1
1
  import DeviceInfo from 'react-native-device-info'
2
2
  import { Platform, PixelRatio, Dimensions, StatusBar } from 'react-native'
3
3
  import { initialWindowMetrics } from 'react-native-safe-area-context'
4
- import { successHandle, failHandle, defineUnsupportedProps } from '../../../common/js'
4
+ import { successHandle, failHandle, defineUnsupportedProps, getFocusedNavigation } from '../../../common/js'
5
5
 
6
6
  const getWindowInfo = function () {
7
- const dimensionsWindow = Dimensions.get('window')
8
7
  const dimensionsScreen = Dimensions.get('screen')
9
- const result = {
10
- pixelRatio: PixelRatio.get(),
11
- windowWidth: dimensionsWindow.width,
12
- windowHeight: dimensionsWindow.height,
13
- screenWidth: dimensionsScreen.width,
14
- screenHeight: dimensionsScreen.height
8
+ const navigation = getFocusedNavigation() || {}
9
+ const insets = {
10
+ ...(initialWindowMetrics?.insets || {}),
11
+ ...(navigation.insets || {})
15
12
  }
16
- defineUnsupportedProps(result, ['screenTop'])
17
- return result
18
- }
19
-
20
- const getSystemInfoSync = function () {
21
- const windowInfo = getWindowInfo()
22
- const { screenWidth, screenHeight } = windowInfo
23
13
  let safeArea = {}
24
- let { top = 0, bottom = 0 } = initialWindowMetrics?.insets || {}
14
+ let { top = 0, bottom = 0, left = 0, right = 0 } = insets
25
15
  if (Platform.OS === 'android') {
26
16
  top = StatusBar.currentHeight || 0
27
17
  }
28
- const iosRes = {}
29
-
18
+ const screenHeight = dimensionsScreen.height
19
+ const screenWidth = dimensionsScreen.width
20
+ const layout = navigation.layout || {}
21
+ const layoutHeight = layout.height || 0
22
+ const layoutWidth = layout.width || 0
23
+ const windowHeight = layoutHeight || screenHeight
30
24
  try {
31
- const width = Math.min(screenWidth, screenHeight)
32
- const height = Math.max(screenWidth, screenHeight)
33
25
  safeArea = {
34
- left: 0,
35
- right: width,
26
+ left,
27
+ right: screenWidth - right,
36
28
  top,
37
- bottom: height - bottom,
38
- height: height - bottom - top,
39
- width
29
+ bottom: screenHeight - bottom,
30
+ height: screenHeight - top - bottom,
31
+ width: screenWidth - left - right
40
32
  }
41
33
  } catch (error) {
42
34
  }
35
+ const result = {
36
+ pixelRatio: PixelRatio.get(),
37
+ windowWidth: layoutWidth || screenWidth,
38
+ windowHeight, // 取不到layout的时候有个兜底
39
+ screenWidth: screenWidth,
40
+ screenHeight: screenHeight,
41
+ screenTop: screenHeight - windowHeight,
42
+ safeArea
43
+ }
44
+ return result
45
+ }
46
+
47
+ const getSystemInfoSync = function () {
48
+ const windowInfo = getWindowInfo()
49
+ const { screenWidth, screenHeight, safeArea } = windowInfo
50
+
43
51
  const result = {
44
52
  brand: DeviceInfo.getBrand(),
45
53
  model: DeviceInfo.getModel(),
46
54
  system: `${DeviceInfo.getSystemName()} ${DeviceInfo.getSystemVersion()}`,
47
55
  platform: DeviceInfo.isEmulatorSync() ? 'emulator' : DeviceInfo.getSystemName(),
48
56
  deviceOrientation: screenWidth > screenHeight ? 'portrait' : 'landscape',
49
- statusBarHeight: top,
57
+ statusBarHeight: safeArea.top,
50
58
  fontSizeSetting: PixelRatio.getFontScale(),
51
- safeArea,
52
- ...windowInfo,
53
- ...iosRes
59
+ ...windowInfo
54
60
  }
55
61
  defineUnsupportedProps(result, [
56
62
  'language',
@@ -77,7 +83,7 @@ const getSystemInfoSync = function () {
77
83
  return result
78
84
  }
79
85
 
80
- const getSystemInfo = function (options) {
86
+ const getSystemInfo = function (options = {}) {
81
87
  const { success, fail, complete } = options
82
88
  try {
83
89
  const systemInfo = getSystemInfoSync()
@@ -1,8 +1,6 @@
1
1
  import { View, Text, Image, StyleSheet, ActivityIndicator } from 'react-native'
2
2
  import { successHandle, failHandle } from '../../../common/js'
3
3
  import { Portal } from '@ant-design/react-native'
4
- import successPng from './success.png'
5
- import errorPng from './error.png'
6
4
 
7
5
  let toastKey
8
6
  let isLoadingShow
@@ -49,12 +47,14 @@ const styles = StyleSheet.create({
49
47
  overflow: 'hidden'
50
48
  }
51
49
  })
52
- function showToast (options) {
50
+ function showToast (options = {}) {
53
51
  const { title, icon = 'success', image, duration = 1500, mask = false, success, fail, complete, isLoading } = options
54
52
  let ToastView
53
+ const successPng = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFwAAABcAgMAAACegTrLAAAADFBMVEUAAAD////R0dHj4+PcME2AAAAAAXRSTlMAQObYZgAAANNJREFUSMft1FEKwkAMBNBGyBFyH4/gR8f+ehSPLtiyQ+wM2C8Rmp+WQN90N8tOZ/1/4SbbYfpp+sBVMqafgGQKs+FvkjF8GR6aj4M8NB+GT8OX5i+GT8OX4aH5MHwZHpoPw+c3fA0xGl/zYBrP92o8vwVwF3NO8tySjXmINQLAs/WX9S8bP9UGJUZSi8MAuUqsj75payPxuWn1BmrjewCCfAvA4Fmjvx8HQL4HiJEHeRmg5k2+B8gTFeRFwL7NzREB/sCKwsG7KN2VSb7XMp31i3oBatNdEForTOoAAAAASUVORK5CYII='
54
+ const errorPng = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFwAAABcCAYAAADj79JYAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAAB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11JdlAZuen+Nrcbm16spN+VY2oIA58jrd70xdLJ0RPkOdCnZzsd6eonWvN5O+fRlJn/3wjXKaczkWNhJZ8egM0UA3IXj99DqTgeBt5P407LCQeN3B9ttKMiJY3zO3JzlzQvA/n5mYZnXQYErEKAL9vuohWKZwMtigZbvNtoCbEEPZsEDNgFuIcLTwaLsdaS4g8c+oxvFHhz2DP/hX3KmL0cxH1iD+yimmHUL8uAZgS9F6TF6VR46gKcHRVYJvNMX4EeRHjvaNFNMo504r6stic36h/0GHxa6nCGA15eSHoGhcfRal30CtjmFL43ja3mcdS3AO/AAv5jXm5AelrAOLUEx7BJONWPUFH32PbD9/0QBrzH1KqS/XX8KafI0grx/c2UfmZZsJ5AmLZ+iIyj9SwIg9BjwtS6yDK1B96AWWoF0APRnJ3ON2Pz7I4R+iLiCBPgcaqNvkCYvF5iIxV5JpBt3q/WS4homB2EBbRci3V8o4Hov012rAq77swfi38oQZ7JEIBFIBBKBRCARSAQSgUQgEUgEEoFEICCBfwDKNlghU/F3VgAAAABJRU5ErkJggg=='
55
55
  const iconImg = {
56
56
  success: successPng,
57
- fail: errorPng
57
+ error: errorPng
58
58
  }
59
59
  const pointerEvents = mask ? 'auto' : 'none'
60
60
  isLoadingShow = isLoading
@@ -65,7 +65,7 @@ function showToast (options) {
65
65
  if (image || icon === 'success' || icon === 'error') {
66
66
  ToastView = <View style={styles.toastWrap} pointerEvents={pointerEvents}>
67
67
  <View style={styles.toastContent}>
68
- <Image source={image || iconImg[icon]} style={styles.toastImg}></Image>
68
+ <Image style={ styles.toastImg } source={{uri: image || iconImg[icon]}}></Image>
69
69
  <Text style={styles.toastText}>{title}</Text>
70
70
  </View>
71
71
  </View>
@@ -113,7 +113,7 @@ function showToast (options) {
113
113
  }
114
114
  }
115
115
 
116
- function hideToast(options) {
116
+ function hideToast(options = {}) {
117
117
  const { noConflict = false, success, fail, complete } = options
118
118
 
119
119
  if (isLoadingShow && noConflict) {
@@ -136,7 +136,7 @@ function hideToast(options) {
136
136
  }
137
137
  }
138
138
 
139
- function showLoading (options) {
139
+ function showLoading (options = {}) {
140
140
  const { title, mask, success, fail, complete } = options
141
141
  showToast({
142
142
  title,
@@ -158,7 +158,7 @@ function showLoading (options) {
158
158
  })
159
159
  }
160
160
 
161
- function hideLoading (options) {
161
+ function hideLoading (options = {}) {
162
162
  const { noConflict = false, success, fail, complete } = options
163
163
  if (!isLoadingShow && noConflict) {
164
164
  return
@@ -110,3 +110,6 @@ export * from './api/lifecycle'
110
110
 
111
111
  // getLocation, openLocation, chooseLocation
112
112
  export * from './api/location'
113
+
114
+ // getExtConfig, getExtConfigSync
115
+ export * from './api/ext'
Binary file
Binary file