Skip to content

Commit e6dba75

Browse files
authored
Merge branch 'dcloudio:next' into pr_1
2 parents 043ca3b + 5249587 commit e6dba75

File tree

39 files changed

+628
-481
lines changed

39 files changed

+628
-481
lines changed

packages/playground/__tests__/__snapshots__/uni_modules.spec.ts.snap

Lines changed: 122 additions & 48 deletions
Large diffs are not rendered by default.

packages/playground/__tests__/uni_modules.spec.ts

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import fs from 'fs-extra'
22
import path from 'path'
33
import execa from 'execa'
44
import { sync } from 'fast-glob'
5+
import { normalizePath } from '@dcloudio/uni-cli-shared'
56

67
const projectDir = path.resolve(__dirname, '../uni_modules')
78

@@ -57,26 +58,30 @@ describe('uni_modules playground', () => {
5758
UNI_APP_X: type === 'uni-app-x' ? 'true' : 'false',
5859
},
5960
})
61+
const files = sync('**/*', { cwd: outDir, absolute: true }).sort()
6062
sync('**/*', { cwd: outDir, absolute: true })
61-
.sort()
62-
.forEach((file) => {
63-
if (file.endsWith('.png')) {
64-
expect(path.basename(file)).toMatchSnapshot()
65-
} else {
66-
expect(
67-
fs
68-
.readFileSync(file, 'utf-8')
69-
.replace(
70-
`"compilerVersion": "${
71-
require('../../vite-plugin-uni/package.json')['uni-app'][
72-
'compilerVersion'
73-
]
74-
}"`,
75-
`"compilerVersion": "x.xx"`
76-
)
77-
).toMatchSnapshot()
78-
}
79-
})
63+
expect(
64+
files.map((file) => normalizePath(file).split('/uni-app-x/')[1])
65+
).toMatchSnapshot()
66+
files.forEach((file) => {
67+
if (file.endsWith('.png')) {
68+
expect(path.basename(file)).toMatchSnapshot()
69+
} else {
70+
expect(
71+
fs
72+
.readFileSync(file, 'utf-8')
73+
.replace(
74+
`"compilerVersion": "${
75+
require('../../vite-plugin-uni/package.json')['uni-app'][
76+
'compilerVersion'
77+
]
78+
}"`,
79+
`"compilerVersion": "x.xx"`
80+
)
81+
.replaceAll(projectDir, '')
82+
).toMatchSnapshot()
83+
}
84+
})
8085
})
8186
})
8287
})

packages/playground/uts/unpackage/dist/dev/.sourcemap/app/uni_modules/test-uniplugin/utssdk/app-ios/index.ets.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
type ShowToast = (msg: string) => void;
2+
import { UIDevice } from 'UIKit';
3+
import { CLLocationManager, CLAuthorizationStatus } from 'CoreLocation';
4+
type GetBatteryInfoOptions = {
5+
name: string;
6+
pwd: number;
7+
success?: (res: UTSJSONObject) => void;
8+
fail?: (res: UTSJSONObject) => void;
9+
complete?: (res: UTSJSONObject) => void;
10+
};
11+
function getBatteryInfo(options: GetBatteryInfoOptions) {
12+
new UIAlertController(title = title, message = message, preferredStyle = UIAlertController.Style.alert);
13+
const res = {
14+
errMsg: 'getBatteryInfo:ok',
15+
level: UIDevice.current.batteryLevel * 100,
16+
isCharging: UIDevice.current.batteryState == UIDevice.BatteryState.charging
17+
};
18+
if (options.success != null) {
19+
options.success!(res);
20+
}
21+
if (options.complete != null) {
22+
options.complete!(res);
23+
}
24+
}
25+
function test1(callback: () => void): string {
26+
console.log({
27+
"a": "b"
28+
}, " at uni_modules/test-uniplugin/utssdk/app-ios/index.uts:33");
29+
console.log('test1', " at uni_modules/test-uniplugin/utssdk/app-ios/index.uts:34");
30+
console.log('ndef android', " at uni_modules/test-uniplugin/utssdk/app-ios/index.uts:42");
31+
console.log('ndef ios', " at uni_modules/test-uniplugin/utssdk/app-ios/index.uts:45");
32+
console.log(CLLocationManager, CLAuthorizationStatus, " at uni_modules/test-uniplugin/utssdk/app-ios/index.uts:53");
33+
const a = -3;
34+
console.log(~a, " at uni_modules/test-uniplugin/utssdk/app-ios/index.uts:55");
35+
return 'test1';
36+
}
37+
class Test1 {
38+
}
39+
class Test {
40+
constructor(){
41+
new Test1();
42+
}
43+
test(): string | null {
44+
if (UTSiOS.macros("swift(>=1)")) {
45+
console.log("swift(>=1)", " at uni_modules/test-uniplugin/utssdk/app-ios/index.uts:66");
46+
}
47+
if (UTSiOS.macros("arch(i386) || arch(arm)")) {
48+
console.log("arch(i386) || arch(arm)", " at uni_modules/test-uniplugin/utssdk/app-ios/index.uts:69");
49+
}
50+
if (UTSiOS.available("iOS 14, macOS 11.0, *")) {
51+
console.log("iOS 14, macOS 11.0, *", " at uni_modules/test-uniplugin/utssdk/app-ios/index.uts:72");
52+
} else if (UTSiOS.available("iOS 13,*")) {
53+
console.log("iOS 13,*", " at uni_modules/test-uniplugin/utssdk/app-ios/index.uts:74");
54+
} else if (UTSiOS.unavailable("tvOS 12")) {
55+
console.log("tvOS 12", " at uni_modules/test-uniplugin/utssdk/app-ios/index.uts:76");
56+
}
57+
return null;
58+
}
59+
}
60+
async function testAsync() {
61+
.showToast();
62+
.showToast();
63+
.showModel();
64+
return {
65+
a: 1
66+
};
67+
}
68+
const showToast1: ShowToast = (msg)=>{};
69+
const showToast2: ShowToast = function(msg) {};
70+
const showToast3: ShowToast = function showToast(msg) {};
71+
export { getBatteryInfo as default };
72+
export { test1 as test1 };
73+
export { Test as Test };
74+
export { testAsync as testAsync };
75+
export { showToast1 as showToast1 };
76+
export { showToast2 as showToast2 };
77+
export { showToast3 as showToast3 };
78+
import { showToast } from "";
79+
import { showModel } from "";

packages/uni-api/src/service/context/canvas.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,16 @@ declare var __WEEX_DEVTOOL__: any
22
//#region import
33
import {
44
API_CREATE_CANVAS_CONTEXT,
5+
type API_TYPE_CREATE_CANVAS_CONTEXT,
56
CreateCanvasContextProtocol,
67
} from '../../protocols/context/context'
78
import {
89
API_CANVAS_GET_IMAGE_DATA,
910
API_CANVAS_PUT_IMAGE_DATA,
1011
API_CANVAS_TO_TEMP_FILE_PATH,
12+
type API_TYPE_CANVAS_GET_IMAGE_DATA,
13+
type API_TYPE_CANVAS_PUT_IMAGE_DATA,
14+
type API_TYPE_CANVAS_TO_TEMP_FILE_PATH,
1115
CanvasGetImageDataOptions,
1216
CanvasGetImageDataProtocol,
1317
CanvasPutImageDataOptions,
@@ -18,13 +22,6 @@ import {
1822

1923
import { defineAsyncApi, defineSyncApi } from '../../helpers/api'
2024

21-
import type {
22-
API_TYPE_CANVAS_GET_IMAGE_DATA,
23-
API_TYPE_CANVAS_PUT_IMAGE_DATA,
24-
API_TYPE_CANVAS_TO_TEMP_FILE_PATH,
25-
API_TYPE_CREATE_CANVAS_CONTEXT,
26-
} from '@dcloudio/uni-api'
27-
2825
import { hasOwn } from '@vue/shared'
2926

3027
import { ON_ERROR, once } from '@dcloudio/uni-shared'

packages/uni-app-plus/dist/uni-app-view.umd.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/uni-cli-shared/__tests__/uni_modules.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
findEncryptUniModules,
44
findUploadEncryptUniModulesFiles,
55
} from '../src/uni_modules'
6+
import { normalizePath } from '../src/utils'
67

78
const platforms = ['app-android', 'app-ios', 'web'] as const
89
describe('uni_modules:uni-ext-api', () => {
@@ -24,7 +25,7 @@ describe('uni_modules:uni-ext-api', () => {
2425
expect(
2526
Object.keys(modules).reduce((res: string[], id: string) => {
2627
res.push(
27-
...modules[id].map((item) => item.replace(inputDir, '').slice(1))
28+
...modules[id].map((item) => normalizePath(item).split('/src/')[1])
2829
)
2930
return res
3031
}, [])
Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
1-
import type { NodeTransform } from '@vue/compiler-core'
1+
import type { ElementNode, NodeTransform } from '@vue/compiler-core'
2+
import { ElementTypes } from '@vue/compiler-core'
23
import { checkElementNodeTag } from '../../utils'
34

45
export const transformPageHead: NodeTransform = (node, context) => {
56
// 发现是page-meta下的head,直接remove该节点
6-
checkElementNodeTag(node, 'head') &&
7-
checkElementNodeTag(context.parent, 'page-meta') &&
8-
context.removeNode(node)
7+
if (
8+
checkElementNodeTag(node, 'head') &&
9+
checkElementNodeTag(context.parent, 'page-meta')
10+
) {
11+
if (process.env.UNI_APP_X === 'true') {
12+
;(node as ElementNode).tag = 'page-meta-head'
13+
;(node as ElementNode).tagType = ElementTypes.COMPONENT
14+
} else {
15+
context.removeNode(node)
16+
}
17+
}
918
}

packages/uni-components/__tests__/useField.spec.ts

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,20 +64,44 @@ describe('test: helpers/useField.ts', () => {
6464
const mockRef = ref(null)
6565
const mockEmit = jest.fn()
6666

67+
// blank modelValue > value
6768
mockProps.modelValue = ''
6869
mockProps.value = '禁用'
6970
const { state } = useField(mockProps, mockRef, mockEmit)
7071
expect(state.value).toBe('')
7172

73+
// blank modelValue > value
74+
mockProps.modelValue = '禁用1'
75+
mockProps.value = ''
76+
const { state: state0 } = useField(mockProps, mockRef, mockEmit)
77+
expect(state0.value).toBe('禁用1')
78+
79+
// normal modelValue > value
7280
mockProps.modelValue = '禁用2'
7381
mockProps.value = '禁用'
74-
const { state: state2 } = useField(mockProps, mockRef, mockEmit)
75-
expect(state2.value).toBe('禁用2')
82+
const { state: state1 } = useField(mockProps, mockRef, mockEmit)
83+
expect(state1.value).toBe('禁用2')
7684

85+
// set modelValue not set value
7786
// @ts-expect-error
7887
mockProps.value = undefined
7988
mockProps.modelValue = '禁用3'
8089
const { state: state3 } = useField(mockProps, mockRef, mockEmit)
8190
expect(state3.value).toBe('禁用3')
91+
92+
// not set modeValue,set value
93+
mockProps.value = '禁用4'
94+
// @ts-expect-error
95+
mockProps.modelValue = undefined
96+
const { state: state4 } = useField(mockProps, mockRef, mockEmit)
97+
expect(state4.value).toBe('禁用4')
98+
99+
// 不设置
100+
// @ts-expect-error
101+
mockProps.value = undefined
102+
// @ts-expect-error
103+
mockProps.modelValue = undefined
104+
const { state: state5 } = useField(mockProps, mockRef, mockEmit)
105+
expect(state5.value).toBe('')
82106
})
83107
})
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<template>
2+
<teleport to="head">
3+
<slot />
4+
</teleport>
5+
</template>
6+
<script>
7+
export default {
8+
name: 'PageMetaHead',
9+
}
10+
</script>

0 commit comments

Comments
 (0)