@tarojs/runtime-rn 3.6.0-beta.2 → 3.6.0-beta.4
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/dist/compute.js +5 -1
- package/dist/compute.js.map +1 -1
- package/package.json +3 -3
- package/src/compute.ts +7 -2
- package/src/types/index.d.ts +9 -9
- package/src/utils.ts +1 -1
package/dist/compute.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Dimensions } from 'react-native';
|
|
2
|
+
import { isFunction } from './utils';
|
|
2
3
|
const globalAny = global;
|
|
3
4
|
const defaultWidth = 750;
|
|
4
5
|
const defaultRadio = {
|
|
@@ -11,7 +12,10 @@ export function pxTransform(size) {
|
|
|
11
12
|
const deviceWidthDp = Dimensions.get('window').width;
|
|
12
13
|
const uiWidthPx = 375;
|
|
13
14
|
const config = ((_a = globalAny.__taroAppConfig) === null || _a === void 0 ? void 0 : _a.appConfig) || {};
|
|
14
|
-
const
|
|
15
|
+
const deviceRatio = config.deviceRatio || defaultRadio;
|
|
16
|
+
const designWidth = (((input = 0) => isFunction(config.designWidth)
|
|
17
|
+
? config.designWidth(input)
|
|
18
|
+
: config.designWidth || defaultWidth))(size);
|
|
15
19
|
if (!(designWidth in deviceRatio)) {
|
|
16
20
|
throw new Error(`deviceRatio 配置中不存在 ${designWidth} 的设置!`);
|
|
17
21
|
}
|
package/dist/compute.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compute.js","sourceRoot":"","sources":["../src/compute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"compute.js","sourceRoot":"","sources":["../src/compute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAIpC,MAAM,SAAS,GAAQ,MAAM,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|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"react-native-root-siblings": "^4.1.1",
|
|
24
|
-
"@tarojs/components-rn": "3.6.0-beta.
|
|
25
|
-
"@tarojs/router-rn": "3.6.0-beta.
|
|
24
|
+
"@tarojs/components-rn": "3.6.0-beta.4",
|
|
25
|
+
"@tarojs/router-rn": "3.6.0-beta.4"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@types/react-native": "^0.69.8"
|
package/src/compute.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Dimensions } from 'react-native'
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { isFunction } from './utils'
|
|
4
|
+
|
|
5
|
+
import type { AppConfig } from './types/index'
|
|
4
6
|
|
|
5
7
|
const globalAny: any = global
|
|
6
8
|
const defaultWidth = 750
|
|
@@ -14,7 +16,10 @@ export function pxTransform (size: number): number {
|
|
|
14
16
|
const deviceWidthDp = Dimensions.get('window').width
|
|
15
17
|
const uiWidthPx = 375
|
|
16
18
|
const config: AppConfig = globalAny.__taroAppConfig?.appConfig || {}
|
|
17
|
-
const
|
|
19
|
+
const deviceRatio = config.deviceRatio || defaultRadio
|
|
20
|
+
const designWidth = (((input = 0) => isFunction(config.designWidth)
|
|
21
|
+
? config.designWidth(input)
|
|
22
|
+
: config.designWidth || defaultWidth))(size)
|
|
18
23
|
if (!(designWidth in deviceRatio)) {
|
|
19
24
|
throw new Error(`deviceRatio 配置中不存在 ${designWidth} 的设置!`)
|
|
20
25
|
}
|
package/src/types/index.d.ts
CHANGED
|
@@ -154,16 +154,16 @@ export interface WindowConfig extends CommonConfig {
|
|
|
154
154
|
allowsBounceVertical?: 'YES' | 'NO'
|
|
155
155
|
}
|
|
156
156
|
export interface AppConfig {
|
|
157
|
-
pages: string[]
|
|
158
|
-
window?: WindowConfig
|
|
159
|
-
tabBar?: TabBar
|
|
157
|
+
pages: string[]
|
|
158
|
+
window?: WindowConfig
|
|
159
|
+
tabBar?: TabBar
|
|
160
160
|
subPackages?: SubPackage[]
|
|
161
|
-
subpackages?: SubPackage[]
|
|
162
|
-
designWidth: number
|
|
163
|
-
deviceRatio: Record<
|
|
164
|
-
linkPrefix: string[]
|
|
165
|
-
rn?: any
|
|
166
|
-
entryPagePath?: string
|
|
161
|
+
subpackages?: SubPackage[]
|
|
162
|
+
designWidth: number | ((size: number) => number)
|
|
163
|
+
deviceRatio: Record<string, number>
|
|
164
|
+
linkPrefix: string[]
|
|
165
|
+
rn?: any
|
|
166
|
+
entryPagePath?: string
|
|
167
167
|
}
|
|
168
168
|
|
|
169
169
|
export interface RNAppConfig {
|