提交 c304446c 编写于 作者: fxy060608's avatar fxy060608

feat(types): add tests

上级 55e5ff94
......@@ -13,7 +13,8 @@
"size": "npm run build size-check",
"lint": "eslint packages/*/src/**/*.ts",
"format": "prettier --write --parser typescript \"packages/**/*.ts?(x)\"",
"test": "jest",
"test": "jest && tsc -p ./test-dts/tsconfig.json",
"test-dts": "tsc -p ./test-dts/tsconfig.json && tsc -p ./test-dts/tsconfig.build.json",
"preinstall": "node ./scripts/preinstall.js",
"e2e:ssr:dev": "cd packages/playground/ssr && npm run dev:ssr",
"e2e:ssr:open": "cd packages/playground/ssr && npx cypress open",
......@@ -42,6 +43,7 @@
"devDependencies": {
"@dcloudio/types": "^2.5.14",
"@dcloudio/uni-api": "3.0.0-alpha-3030120211215001",
"@dcloudio/uni-app": "3.0.0-alpha-3030120211215001",
"@jest/types": "^27.0.2",
"@microsoft/api-extractor": "^7.19.2",
"@rollup/plugin-alias": "^3.1.1",
......
......@@ -42,7 +42,7 @@ export function getRealPath(filepath: string) {
} else {
const page = getCurrentPage()
if (page) {
return wwwPath + getRealRoute(addLeadingSlash(page.route), filepath)
return wwwPath + getRealRoute(addLeadingSlash(page.route!), filepath)
}
}
}
......
......@@ -4,14 +4,11 @@ import {
ON_APP_ENTER_FOREGROUND,
ON_THEME_CHANGE,
ON_KEYBOARD_HEIGHT_CHANGE,
addLeadingSlash,
} from '@dcloudio/uni-shared'
import { $reLaunch } from '../../api/route/_reLaunch'
import {
EVENT_BACKBUTTON,
backbuttonListener,
getEnterOptions,
RedirectInfo,
parseRedirectInfo,
initEnterOptions,
} from './utils'
......@@ -91,13 +88,13 @@ export function onPlusMessage<T>(
UniServiceJSBridge.subscribe('plusMessage.' + type, callback, once)
}
function initEnterReLaunch(info: RedirectInfo) {
__uniConfig.realEntryPagePath =
__uniConfig.realEntryPagePath || __uniConfig.entryPagePath
__uniConfig.entryPagePath = info.path
__uniConfig.entryPageQuery = info.query
$reLaunch(
{ url: addLeadingSlash(info.path) + info.query },
{ resolve() {}, reject() {} }
)
}
// function initEnterReLaunch(info: RedirectInfo) {
// __uniConfig.realEntryPagePath =
// __uniConfig.realEntryPagePath || __uniConfig.entryPagePath
// __uniConfig.entryPagePath = info.path
// __uniConfig.entryPageQuery = info.query
// $reLaunch(
// { url: addLeadingSlash(info.path) + info.query },
// { resolve() {}, reject() {} }
// )
// }
......@@ -12,7 +12,9 @@ export function createNVueWebview({
webviewStyle,
}: CreateWebviewOptions) {
const curWebviewId = genWebviewId()
const curWebviewStyle = parseWebviewStyle(path, routeOptions.meta)
const curWebviewStyle = parseWebviewStyle(path, routeOptions.meta, {
id: curWebviewId + '',
})
;(curWebviewStyle as any).uniPageUrl = initUniPageUrl(path, query)
if (__DEV__) {
console.log(
......
......@@ -8,7 +8,7 @@ import { DebugRefresh, InitUniPageUrl } from '../utils'
export function parseWebviewStyle(
path: string,
routeMeta: UniApp.PageRouteMeta,
webview: PlusWebviewWebviewObject
webview: { id: string }
): PlusWebviewWebviewStyles & {
uniPageUrl?: InitUniPageUrl
debugRefresh?: DebugRefresh
......
......@@ -275,7 +275,6 @@ export default /*#__PURE__*/ defineBuiltInComponent({
src={control.iconPath}
style={control.position}
auto-size
// @ts-expect-error
onClick={() =>
control.clickable &&
trigger('controltap', {} as Event, { controlId: control.id })
......
import '@dcloudio/uni-components/style/audio.css'
import { Audio } from '@dcloudio/uni-components'
import { UniNodeJSON } from '@dcloudio/uni-shared'
import { UniComponent } from './UniComponent'
export class UniAudio extends UniComponent {
constructor(
id: number,
parentNodeId: number,
refNodeId: number,
nodeJson: Partial<UniNodeJSON>
) {
super(id, 'uni-audio', Audio, parentNodeId, refNodeId, nodeJson)
}
}
export function preventDoubleTap() {
if (String(navigator.vendor).indexOf('Apple') === 0) {
let firstEvent: MouseEvent | null = null
let timeout: number
let timeout: ReturnType<typeof setTimeout>
// 用于全局禁用 iOS 双击包含手势
document.documentElement.addEventListener('click', (event) => {
const TIME_MAX = 450
......
......@@ -85,27 +85,40 @@ const onShow = /*#__PURE__*/ createHook(uniShared.ON_SHOW);
const onHide = /*#__PURE__*/ createHook(uniShared.ON_HIDE);
const onLaunch = /*#__PURE__*/ createHook(uniShared.ON_LAUNCH);
const onError = /*#__PURE__*/ createHook(uniShared.ON_ERROR);
const onThemeChange = /*#__PURE__*/ createHook(uniShared.ON_THEME_CHANGE);
const onPageNotFound = /*#__PURE__*/ createHook(uniShared.ON_PAGE_NOT_FOUND);
const onUnhandledRejection = /*#__PURE__*/ createHook(uniShared.ON_UNHANDLE_REJECTION);
const onThemeChange =
/*#__PURE__*/ createHook(uniShared.ON_THEME_CHANGE);
const onPageNotFound =
/*#__PURE__*/ createHook(uniShared.ON_PAGE_NOT_FOUND);
const onUnhandledRejection =
/*#__PURE__*/ createHook(uniShared.ON_UNHANDLE_REJECTION);
// 小程序如果想在 setup 的 props 传递页面参数,需要定义 props,故同时暴露 onLoad 吧
const onLoad = /*#__PURE__*/ createHook(uniShared.ON_LOAD);
const onReady = /*#__PURE__*/ createHook(uniShared.ON_READY);
const onUnload = /*#__PURE__*/ createHook(uniShared.ON_UNLOAD);
const onResize = /*#__PURE__*/ createHook(uniShared.ON_RESIZE);
const onBackPress = /*#__PURE__*/ createHook(uniShared.ON_BACK_PRESS);
const onPageScroll = /*#__PURE__*/ createHook(uniShared.ON_PAGE_SCROLL);
const onTabItemTap = /*#__PURE__*/ createHook(uniShared.ON_TAB_ITEM_TAP);
const onBackPress =
/*#__PURE__*/ createHook(uniShared.ON_BACK_PRESS);
const onPageScroll =
/*#__PURE__*/ createHook(uniShared.ON_PAGE_SCROLL);
const onTabItemTap =
/*#__PURE__*/ createHook(uniShared.ON_TAB_ITEM_TAP);
const onReachBottom = /*#__PURE__*/ createHook(uniShared.ON_REACH_BOTTOM);
const onPullDownRefresh = /*#__PURE__*/ createHook(uniShared.ON_PULL_DOWN_REFRESH);
const onShareTimeline = /*#__PURE__*/ createHook(uniShared.ON_SHARE_TIMELINE);
const onAddToFavorites = /*#__PURE__*/ createHook(uniShared.ON_ADD_TO_FAVORITES);
const onShareAppMessage = /*#__PURE__*/ createHook(uniShared.ON_SHARE_APP_MESSAGE);
const onNavigationBarButtonTap = /*#__PURE__*/ createHook(uniShared.ON_NAVIGATION_BAR_BUTTON_TAP);
const onNavigationBarSearchInputChanged = /*#__PURE__*/ createHook(uniShared.ON_NAVIGATION_BAR_SEARCH_INPUT_CHANGED);
const onShareTimeline =
/*#__PURE__*/ createHook(uniShared.ON_SHARE_TIMELINE);
const onAddToFavorites =
/*#__PURE__*/ createHook(uniShared.ON_ADD_TO_FAVORITES);
const onShareAppMessage =
/*#__PURE__*/ createHook(uniShared.ON_SHARE_APP_MESSAGE);
const onNavigationBarButtonTap =
/*#__PURE__*/ createHook(uniShared.ON_NAVIGATION_BAR_BUTTON_TAP);
const onNavigationBarSearchInputChanged =
/*#__PURE__*/ createHook(uniShared.ON_NAVIGATION_BAR_SEARCH_INPUT_CHANGED);
const onNavigationBarSearchInputClicked = /*#__PURE__*/ createHook(uniShared.ON_NAVIGATION_BAR_SEARCH_INPUT_CLICKED);
const onNavigationBarSearchInputConfirmed = /*#__PURE__*/ createHook(uniShared.ON_NAVIGATION_BAR_SEARCH_INPUT_CONFIRMED);
const onNavigationBarSearchInputFocusChanged = /*#__PURE__*/ createHook(uniShared.ON_NAVIGATION_BAR_SEARCH_INPUT_FOCUS_CHANGED);
const onNavigationBarSearchInputConfirmed =
/*#__PURE__*/ createHook(uniShared.ON_NAVIGATION_BAR_SEARCH_INPUT_CONFIRMED);
const onNavigationBarSearchInputFocusChanged =
/*#__PURE__*/ createHook(uniShared.ON_NAVIGATION_BAR_SEARCH_INPUT_FOCUS_CHANGED);
exports.getSsrGlobalData = getSsrGlobalData;
exports.onAddToFavorites = onAddToFavorites;
......
......@@ -2,33 +2,109 @@ import type { ComponentInternalInstance } from '@vue/runtime-core';
import { ref } from 'vue';
import { shallowRef } from 'vue';
declare interface AddToFavoritesContent {
title?: string;
imageUrl?: string;
query?: string;
}
declare interface AddToFavoritesOption {
webviewUrl?: string;
}
declare interface BackPressOption {
from: 'backbutton' | 'navigateBack';
}
declare interface CustomShareAppMessage {
title?: string;
path?: string;
imageUrl?: string;
}
declare interface CustomShareTimeline {
title?: string;
query?: string;
imageUrl?: string;
}
export declare function getSsrGlobalData(): any;
export declare const onAddToFavorites: (hook: () => any, target?: ComponentInternalInstance | null) => any;
declare type LaunchOption = LaunchShowOption;
declare interface LaunchShowOption {
path: string;
query: Record<string, string | undefined>;
scene: number;
shareTicket: string;
referrerInfo?: ReferrerInfo;
}
declare interface NavigationBarButtonTapOption {
index: number;
}
declare interface NavigationBarSearchInputChangedOption {
text: string;
}
declare type NavigationBarSearchInputConfirmedOption = NavigationBarSearchInputChangedOption;
declare interface NavigationBarSearchInputFocusChanged {
focus: boolean;
}
export declare const onAddToFavorites: (hook: onAddToFavoritesHook, target?: ComponentInternalInstance | null) => any;
declare type onAddToFavoritesHook = (options: AddToFavoritesOption) => AddToFavoritesContent | void;
declare type onAppShowHook = (options: LaunchShowOption) => void;
export declare const onBackPress: (hook: () => any, target?: ComponentInternalInstance | null) => any;
export declare const onBackPress: (hook: onBackPressHook, target?: ComponentInternalInstance | null) => any;
export declare const onError: (hook: () => any, target?: ComponentInternalInstance | null) => any;
declare type onBackPressHook = (options: BackPressOption) => boolean | void;
export declare const onError: (hook: onErrorHook, target?: ComponentInternalInstance | null) => any;
declare type onErrorHook = (error: string) => void;
export declare const onHide: (hook: () => any, target?: ComponentInternalInstance | null) => any;
export declare const onLaunch: (hook: () => any, target?: ComponentInternalInstance | null) => any;
export declare const onLaunch: (hook: onLaunchHook, target?: ComponentInternalInstance | null) => any;
declare type onLaunchHook = (options: LaunchOption) => void;
export declare const onLoad: (hook: onLoadHook, target?: ComponentInternalInstance | null) => any;
export declare const onLoad: (hook: () => any, target?: ComponentInternalInstance | null) => any;
declare type onLoadHook = (query: Record<string, string | undefined>) => void;
export declare const onNavigationBarButtonTap: (hook: () => any, target?: ComponentInternalInstance | null) => any;
export declare const onNavigationBarButtonTap: (hook: onNavigationBarButtonTapHook, target?: ComponentInternalInstance | null) => any;
export declare const onNavigationBarSearchInputChanged: (hook: () => any, target?: ComponentInternalInstance | null) => any;
declare type onNavigationBarButtonTapHook = (options: NavigationBarButtonTapOption) => void;
export declare const onNavigationBarSearchInputChanged: (hook: onNavigationBarSearchInputChangedHook, target?: ComponentInternalInstance | null) => any;
declare type onNavigationBarSearchInputChangedHook = (options: NavigationBarSearchInputChangedOption) => void;
export declare const onNavigationBarSearchInputClicked: (hook: () => any, target?: ComponentInternalInstance | null) => any;
export declare const onNavigationBarSearchInputConfirmed: (hook: () => any, target?: ComponentInternalInstance | null) => any;
export declare const onNavigationBarSearchInputConfirmed: (hook: onNavigationBarSearchInputConfirmedHook, target?: ComponentInternalInstance | null) => any;
declare type onNavigationBarSearchInputConfirmedHook = (options: NavigationBarSearchInputConfirmedOption) => void;
export declare const onNavigationBarSearchInputFocusChanged: (hook: onNavigationBarSearchInputFocusChangedHook, target?: ComponentInternalInstance | null) => any;
export declare const onNavigationBarSearchInputFocusChanged: (hook: () => any, target?: ComponentInternalInstance | null) => any;
declare type onNavigationBarSearchInputFocusChangedHook = (options: NavigationBarSearchInputFocusChanged) => void;
export declare const onPageNotFound: (hook: () => any, target?: ComponentInternalInstance | null) => any;
export declare const onPageNotFound: (hook: onPageNotFoundHook, target?: ComponentInternalInstance | null) => any;
export declare const onPageScroll: (hook: () => any, target?: ComponentInternalInstance | null) => any;
declare type onPageNotFoundHook = (options: PageNotFoundOption) => void;
export declare const onPageScroll: (hook: onPageScrollHook, target?: ComponentInternalInstance | null) => any;
declare type onPageScrollHook = (options: PageScrollOption) => void;
declare type onPageShowHook = () => void;
export declare const onPullDownRefresh: (hook: () => any, target?: ComponentInternalInstance | null) => any;
......@@ -36,28 +112,83 @@ export declare const onReachBottom: (hook: () => any, target?: ComponentInternal
export declare const onReady: (hook: () => any, target?: ComponentInternalInstance | null) => any;
export declare const onResize: (hook: () => any, target?: ComponentInternalInstance | null) => any;
export declare const onResize: (hook: onResizeHook, target?: ComponentInternalInstance | null) => any;
declare type onResizeHook = (options: ResizeOption) => void;
export declare const onShareAppMessage: (hook: onShareAppMessageHook, target?: ComponentInternalInstance | null) => any;
declare type onShareAppMessageHook = (options: ShareAppMessageOption) => CustomShareAppMessage | void;
export declare const onShareTimeline: (hook: onShareTimelineHook, target?: ComponentInternalInstance | null) => any;
declare type onShareTimelineHook = () => CustomShareTimeline | void;
export declare const onShow: (hook: onAppShowHook | onPageShowHook, target?: ComponentInternalInstance | null) => any;
export declare const onShareAppMessage: (hook: () => any, target?: ComponentInternalInstance | null) => any;
export declare const onTabItemTap: (hook: onTabItemTapHook, target?: ComponentInternalInstance | null) => any;
export declare const onShareTimeline: (hook: () => any, target?: ComponentInternalInstance | null) => any;
declare type onTabItemTapHook = (options: TabItemTapOption) => void;
export declare const onShow: (hook: () => any, target?: ComponentInternalInstance | null) => any;
export declare const onThemeChange: (hook: onThemeChangeHook, target?: ComponentInternalInstance | null) => any;
export declare const onTabItemTap: (hook: () => any, target?: ComponentInternalInstance | null) => any;
declare type onThemeChangeHook = (options: ThemeChangeOption) => void;
export declare const onThemeChange: (hook: () => any, target?: ComponentInternalInstance | null) => any;
export declare const onUnhandledRejection: (hook: onUnhandledRejectionHook, target?: ComponentInternalInstance | null) => any;
export declare const onUnhandledRejection: (hook: () => any, target?: ComponentInternalInstance | null) => any;
declare type onUnhandledRejectionHook = (options: UnhandledRejectionOption) => void;
export declare const onUnload: (hook: () => any, target?: ComponentInternalInstance | null) => any;
declare interface PageNotFoundOption {
path: string;
query: Record<string, string | undefined>;
isEntryPage: boolean;
}
declare interface PageScrollOption {
scrollTop: number;
}
declare interface ReferrerInfo {
appId: string;
extraData?: any;
}
declare interface ResizeOption {
size: {
windowWidth: number;
windowHeight: number;
};
}
export declare function resolveEasycom(component: unknown, easycom: unknown): unknown;
export declare const shallowSsrRef: SSRRef;
declare interface ShareAppMessageOption {
from: 'button' | 'menu' | string;
target: any;
webViewUrl?: string;
}
declare type SSRRef = (value: unknown, key?: string, shallow?: boolean) => ReturnType<typeof ref> | ReturnType<typeof shallowRef>;
export declare const ssrRef: SSRRef;
declare interface TabItemTapOption {
index: string;
pagePath: string;
text: string;
}
declare interface ThemeChangeOption {
theme: 'dark' | 'light';
}
declare interface UnhandledRejectionOption {
promise: Promise<any>;
reason: string;
}
export { }
......@@ -53,26 +53,39 @@ const onShow = /*#__PURE__*/ createHook(ON_SHOW);
const onHide = /*#__PURE__*/ createHook(ON_HIDE);
const onLaunch = /*#__PURE__*/ createHook(ON_LAUNCH);
const onError = /*#__PURE__*/ createHook(ON_ERROR);
const onThemeChange = /*#__PURE__*/ createHook(ON_THEME_CHANGE);
const onPageNotFound = /*#__PURE__*/ createHook(ON_PAGE_NOT_FOUND);
const onUnhandledRejection = /*#__PURE__*/ createHook(ON_UNHANDLE_REJECTION);
const onThemeChange =
/*#__PURE__*/ createHook(ON_THEME_CHANGE);
const onPageNotFound =
/*#__PURE__*/ createHook(ON_PAGE_NOT_FOUND);
const onUnhandledRejection =
/*#__PURE__*/ createHook(ON_UNHANDLE_REJECTION);
// 小程序如果想在 setup 的 props 传递页面参数,需要定义 props,故同时暴露 onLoad 吧
const onLoad = /*#__PURE__*/ createHook(ON_LOAD);
const onReady = /*#__PURE__*/ createHook(ON_READY);
const onUnload = /*#__PURE__*/ createHook(ON_UNLOAD);
const onResize = /*#__PURE__*/ createHook(ON_RESIZE);
const onBackPress = /*#__PURE__*/ createHook(ON_BACK_PRESS);
const onPageScroll = /*#__PURE__*/ createHook(ON_PAGE_SCROLL);
const onTabItemTap = /*#__PURE__*/ createHook(ON_TAB_ITEM_TAP);
const onBackPress =
/*#__PURE__*/ createHook(ON_BACK_PRESS);
const onPageScroll =
/*#__PURE__*/ createHook(ON_PAGE_SCROLL);
const onTabItemTap =
/*#__PURE__*/ createHook(ON_TAB_ITEM_TAP);
const onReachBottom = /*#__PURE__*/ createHook(ON_REACH_BOTTOM);
const onPullDownRefresh = /*#__PURE__*/ createHook(ON_PULL_DOWN_REFRESH);
const onShareTimeline = /*#__PURE__*/ createHook(ON_SHARE_TIMELINE);
const onAddToFavorites = /*#__PURE__*/ createHook(ON_ADD_TO_FAVORITES);
const onShareAppMessage = /*#__PURE__*/ createHook(ON_SHARE_APP_MESSAGE);
const onNavigationBarButtonTap = /*#__PURE__*/ createHook(ON_NAVIGATION_BAR_BUTTON_TAP);
const onNavigationBarSearchInputChanged = /*#__PURE__*/ createHook(ON_NAVIGATION_BAR_SEARCH_INPUT_CHANGED);
const onShareTimeline =
/*#__PURE__*/ createHook(ON_SHARE_TIMELINE);
const onAddToFavorites =
/*#__PURE__*/ createHook(ON_ADD_TO_FAVORITES);
const onShareAppMessage =
/*#__PURE__*/ createHook(ON_SHARE_APP_MESSAGE);
const onNavigationBarButtonTap =
/*#__PURE__*/ createHook(ON_NAVIGATION_BAR_BUTTON_TAP);
const onNavigationBarSearchInputChanged =
/*#__PURE__*/ createHook(ON_NAVIGATION_BAR_SEARCH_INPUT_CHANGED);
const onNavigationBarSearchInputClicked = /*#__PURE__*/ createHook(ON_NAVIGATION_BAR_SEARCH_INPUT_CLICKED);
const onNavigationBarSearchInputConfirmed = /*#__PURE__*/ createHook(ON_NAVIGATION_BAR_SEARCH_INPUT_CONFIRMED);
const onNavigationBarSearchInputFocusChanged = /*#__PURE__*/ createHook(ON_NAVIGATION_BAR_SEARCH_INPUT_FOCUS_CHANGED);
const onNavigationBarSearchInputConfirmed =
/*#__PURE__*/ createHook(ON_NAVIGATION_BAR_SEARCH_INPUT_CONFIRMED);
const onNavigationBarSearchInputFocusChanged =
/*#__PURE__*/ createHook(ON_NAVIGATION_BAR_SEARCH_INPUT_FOCUS_CHANGED);
export { getSsrGlobalData, onAddToFavorites, onBackPress, onError, onHide, onLaunch, onLoad, onNavigationBarButtonTap, onNavigationBarSearchInputChanged, onNavigationBarSearchInputClicked, onNavigationBarSearchInputConfirmed, onNavigationBarSearchInputFocusChanged, onPageNotFound, onPageScroll, onPullDownRefresh, onReachBottom, onReady, onResize, onShareAppMessage, onShareTimeline, onShow, onTabItemTap, onThemeChange, onUnhandledRejection, onUnload, resolveEasycom, shallowSsrRef, ssrRef };
......@@ -18,6 +18,7 @@
},
"gitHead": "33e807d66e1fe47e2ee08ad9c59247e37b8884da",
"devDependencies": {
"@dcloudio/uni-shared": "3.0.0-alpha-3030120211215001"
"@dcloudio/uni-shared": "3.0.0-alpha-3030120211215001",
"@types/quill": "^1.3.7"
}
}
......@@ -144,7 +144,7 @@ function _activeAnimation(state: ProgerssState, props: ProgressProps) {
} else {
state.currentPercent += 1
}
}, parseFloat(props.duration as string))
}, parseFloat(props.duration as string)) as unknown as number
} else {
state.currentPercent = state.realPercent
}
......
......@@ -30,8 +30,8 @@ export const hoverProps = {
export function useHover(props: UseHoverOptions) {
const hovering = ref(false)
let hoverTouch: boolean = false
let hoverStartTimer: number
let hoverStayTimer: number
let hoverStartTimer: ReturnType<typeof setTimeout>
let hoverStayTimer: ReturnType<typeof setTimeout>
function hoverReset() {
requestAnimationFrame(() => {
clearTimeout(hoverStayTimer)
......
......@@ -2,7 +2,7 @@ import { Ref, watch } from 'vue'
import { CustomEventTrigger } from './useEvent'
import { plusReady } from '@dcloudio/uni-shared'
let resetTimer: number
let resetTimer: ReturnType<typeof setTimeout>
let isAndroid: boolean
let osVersion: string
let keyboardHeight: number
......
......@@ -18585,7 +18585,7 @@ function usePopupStyle(props2) {
const fixSize = () => {
const { windowWidth, windowHeight, windowTop } = uni.getSystemInfoSync();
popupWidth.value = windowWidth;
popupHeight.value = windowHeight + windowTop;
popupHeight.value = windowHeight + (windowTop || 0);
};
window.addEventListener("resize", fixSize);
fixSize();
......
......@@ -13,13 +13,13 @@ export function getJSONP(
var callbackKey = options.callback || 'callback'
var callbackName = '__callback' + Date.now()
var timeout = options.timeout || 30000
var timing: number
var timing: ReturnType<typeof setTimeout>
function end() {
clearTimeout(timing)
delete window[callbackName]
delete (window as any)[callbackName]
js.remove()
}
window[callbackName] = (res: any) => {
;(window as any)[callbackName] = (res: any) => {
if (typeof success === 'function') {
success(res)
}
......
......@@ -95,7 +95,7 @@ export function usePopupStyle(props: Data) {
const fixSize = () => {
const { windowWidth, windowHeight, windowTop } = uni.getSystemInfoSync()
popupWidth.value = windowWidth
popupHeight.value = windowHeight + windowTop
popupHeight.value = windowHeight + (windowTop || 0)
}
window.addEventListener('resize', fixSize)
fixSize()
......
......@@ -44,9 +44,10 @@ export const startAccelerometer = <API_TYPE_START_ACCELEROMETER>(
window.addEventListener('devicemotion', listener, false)
}
if (!listener) {
if (DeviceMotionEvent.requestPermission) {
DeviceMotionEvent.requestPermission()
.then((res) => {
if ((DeviceMotionEvent as any).requestPermission) {
;(DeviceMotionEvent as any)
.requestPermission()
.then((res: string) => {
if (res === 'granted') {
addEventListener()
resolve()
......@@ -54,7 +55,7 @@ export const startAccelerometer = <API_TYPE_START_ACCELEROMETER>(
reject(`${res}`)
}
})
.catch((error) => {
.catch((error: any) => {
reject(`${error}`)
})
return
......
......@@ -43,9 +43,10 @@ export const startCompass = <API_TYPE_START_COMPASS>(
window.addEventListener('deviceorientation', listener, false)
}
if (!listener) {
if (DeviceOrientationEvent.requestPermission) {
DeviceOrientationEvent.requestPermission()
.then((res) => {
if ((DeviceOrientationEvent as any).requestPermission) {
;(DeviceOrientationEvent as any)
.requestPermission()
.then((res: string) => {
if (res === 'granted') {
addEventListener()
resolve()
......@@ -53,7 +54,7 @@ export const startCompass = <API_TYPE_START_COMPASS>(
reject(`${res}`)
}
})
.catch((error) => {
.catch((error: any) => {
reject(`${error}`)
})
return
......
......@@ -62,7 +62,7 @@ export const downloadFile = defineTaskApi<API_TYPE_DOWNLOAD_FILE>(
{ url, header, timeout = __uniConfig.networkTimeout.downloadFile },
{ resolve, reject }
) => {
var timer: number
var timer: ReturnType<typeof setTimeout>
var xhr = new XMLHttpRequest()
var downloadTask = new DownloadTask(xhr)
xhr.open('GET', url, true)
......
......@@ -81,7 +81,7 @@ export const uploadFile = defineTaskApi<API_TYPE_UPLOAD_FILE>(
function upload(realFiles: File[]) {
var xhr = new XMLHttpRequest()
var form = new FormData()
var timer: number
var timer: ReturnType<typeof setTimeout>
Object.keys(formData).forEach((key) => {
form.append(key, formData[key])
})
......
......@@ -71,7 +71,7 @@ export const setStorage = <API_TYPE_SET_STORAGE>defineAsyncApi(
try {
setStorageSync(key, data)
resolve()
} catch (error) {
} catch (error: any) {
reject(error.message)
}
},
......@@ -114,7 +114,7 @@ export const getStorage = <API_TYPE_GET_STORAGE>defineAsyncApi(
resolve({
data,
})
} catch (error) {
} catch (error: any) {
reject(error.message)
}
},
......
......@@ -28,7 +28,7 @@ import type {
let showToastState: ToastProps
let showType: 'onShowToast' | 'onShowLoading' | '' = ''
let timeoutId: number
let timeoutId: ReturnType<typeof setTimeout>
const scope = /*#__PURE__*/ effectScope()
......
......@@ -298,7 +298,7 @@ const CHECK_RENDER_DELAY = 1000
const CHECK_RENDER_RETRY = 5
class AdRender {
private _checkTimer: number | null
private _checkTimer: ReturnType<typeof setTimeout> | null
private _pi: number = 0
private _pl: any[] = []
private _b: any = {}
......
......@@ -45,7 +45,7 @@ export default /*#__PURE__*/ defineSystemComponent({
})
if (!__NODE_JS__) {
const onMapReady: OnMapReady = inject('onMapReady') as OnMapReady
let timer: number
let timer: ReturnType<typeof setTimeout>
function compassChangeHandler(res: { direction: number }) {
state.rotate = res.direction
}
......
......@@ -370,7 +370,7 @@ function useMap(
if (context) {
try {
context.translate(data)
} catch (error) {
} catch (error: any) {
callOptions(data, `${type}:fail ${error.message}`)
}
callOptions(data, `${type}:ok`)
......
......@@ -485,7 +485,7 @@ function useSystem() {
return _system
}
let __contentVisibleDelay: number
let __contentVisibleDelay: ReturnType<typeof setTimeout>
function usePickerMethods(
props: Props,
state: State,
......
......@@ -462,7 +462,7 @@ function useControls(
function toggleControls() {
state.controlsVisible = !state.controlsVisible
}
let hideTiming: number | null
let hideTiming: ReturnType<typeof setTimeout> | null
function autoHideStart() {
hideTiming = setTimeout(() => {
state.controlsVisible = false
......
......@@ -872,7 +872,7 @@ function initCreatePage() {
}
// @ts-ignore
function initComponentProps(rawProps) {
function initComponentProps(_rawProps) {
const propertiesOptions = {
properties: {},
};
......
......@@ -28,11 +28,11 @@ declare function Component<P, D, M extends tinyapp.IComponentMethods>(
options: tinyapp.ComponentOptions<P, D, M>
): void
function initComponentProps(rawProps: Record<string, any>) {
function initComponentProps(_rawProps: Record<string, any>) {
const propertiesOptions = {
properties: {},
}
initProps(propertiesOptions, rawProps, false)
initProps(propertiesOptions)
const properties = propertiesOptions.properties as Record<string, any>
const props: Record<string, any> = {
// onVueInit
......
import {
hasOwn,
isFunction,
camelize,
isArray,
isString,
remove,
} from '@vue/shared'
import { hasOwn, isFunction, camelize, isString } from '@vue/shared'
import {
ComponentPublicInstance,
......
......@@ -776,7 +776,7 @@ function parseComponent(vueOptions, { parse, mocks, isPage, initRelation, handle
if (__VUE_OPTIONS_API__) {
applyOptions(mpComponentOptions, vueOptions, initBehavior);
}
initProps(mpComponentOptions, vueOptions.props);
initProps(mpComponentOptions);
initPropsObserver(mpComponentOptions);
initExtraOptions(mpComponentOptions, vueOptions);
initWxsCallMethods(mpComponentOptions.methods, vueOptions.wxsCallMethods);
......
......@@ -110,7 +110,7 @@ export function parseComponent(
applyOptions(mpComponentOptions, vueOptions, initBehavior)
}
initProps(mpComponentOptions, vueOptions.props, false)
initProps(mpComponentOptions)
initPropsObserver(mpComponentOptions)
......
......@@ -771,7 +771,7 @@ function parseComponent(vueOptions, { parse, mocks, isPage, initRelation, handle
if (__VUE_OPTIONS_API__) {
applyOptions(mpComponentOptions, vueOptions, initBehavior);
}
initProps(mpComponentOptions, vueOptions.props);
initProps(mpComponentOptions);
initPropsObserver(mpComponentOptions);
initExtraOptions(mpComponentOptions, vueOptions);
initWxsCallMethods(mpComponentOptions.methods, vueOptions.wxsCallMethods);
......
......@@ -736,7 +736,7 @@ function parseComponent(vueOptions, { parse, mocks, isPage, initRelation, handle
if (__VUE_OPTIONS_API__) {
applyOptions(mpComponentOptions, vueOptions, initBehavior);
}
initProps(mpComponentOptions, vueOptions.props);
initProps(mpComponentOptions);
initPropsObserver(mpComponentOptions);
initExtraOptions(mpComponentOptions, vueOptions);
initWxsCallMethods(mpComponentOptions.methods, vueOptions.wxsCallMethods);
......
......@@ -725,7 +725,7 @@ function parseComponent(vueOptions, { parse, mocks, isPage, initRelation, handle
if (__VUE_OPTIONS_API__) {
applyOptions(mpComponentOptions, vueOptions, initBehavior);
}
initProps(mpComponentOptions, vueOptions.props);
initProps(mpComponentOptions);
initPropsObserver(mpComponentOptions);
initExtraOptions(mpComponentOptions, vueOptions);
initWxsCallMethods(mpComponentOptions.methods, vueOptions.wxsCallMethods);
......
......@@ -736,7 +736,7 @@ function parseComponent(vueOptions, { parse, mocks, isPage, initRelation, handle
if (__VUE_OPTIONS_API__) {
applyOptions(mpComponentOptions, vueOptions, initBehavior);
}
initProps(mpComponentOptions, vueOptions.props);
initProps(mpComponentOptions);
initPropsObserver(mpComponentOptions);
initExtraOptions(mpComponentOptions, vueOptions);
initWxsCallMethods(mpComponentOptions.methods, vueOptions.wxsCallMethods);
......
......@@ -597,7 +597,7 @@ function parseComponent(vueOptions, { parse, mocks, isPage, initRelation, handle
if (__VUE_OPTIONS_API__) {
applyOptions(mpComponentOptions, vueOptions, initBehavior);
}
initProps(mpComponentOptions, vueOptions.props);
initProps(mpComponentOptions);
initPropsObserver(mpComponentOptions);
initExtraOptions(mpComponentOptions, vueOptions);
initWxsCallMethods(mpComponentOptions.methods, vueOptions.wxsCallMethods);
......
......@@ -714,7 +714,7 @@ function parseComponent(vueOptions, { parse, mocks, isPage, initRelation, handle
if (__VUE_OPTIONS_API__) {
applyOptions(mpComponentOptions, vueOptions, initBehavior);
}
initProps(mpComponentOptions, vueOptions.props);
initProps(mpComponentOptions);
initPropsObserver(mpComponentOptions);
initExtraOptions(mpComponentOptions, vueOptions);
initWxsCallMethods(mpComponentOptions.methods, vueOptions.wxsCallMethods);
......
......@@ -6,6 +6,7 @@ importers:
specifiers:
'@dcloudio/types': ^2.5.14
'@dcloudio/uni-api': 3.0.0-alpha-3030120211215001
'@dcloudio/uni-app': 3.0.0-alpha-3030120211215001
'@jest/types': ^27.0.2
'@microsoft/api-extractor': ^7.19.2
'@rollup/plugin-alias': ^3.1.1
......@@ -52,6 +53,7 @@ importers:
devDependencies:
'@dcloudio/types': 2.5.14
'@dcloudio/uni-api': link:packages/uni-api
'@dcloudio/uni-app': link:packages/uni-app
'@jest/types': 27.4.2
'@microsoft/api-extractor': 7.19.2
'@rollup/plugin-alias': 3.1.8_rollup@2.60.2
......@@ -449,8 +451,10 @@ importers:
packages/uni-components:
specifiers:
'@dcloudio/uni-shared': 3.0.0-alpha-3030120211215001
'@types/quill': ^1.3.7
devDependencies:
'@dcloudio/uni-shared': link:../uni-shared
'@types/quill': 1.3.10
packages/uni-core:
specifiers:
......@@ -2737,6 +2741,12 @@ packages:
resolution: {integrity: sha512-FGa1F62FT09qcrueBA6qYTrJPVDzah9a+493+o2PCXsesWHIn27G98TsSMs3WPNbZIEj4+VJf6saSFpvD+3Zsw==}
dev: true
/@types/quill/1.3.10:
resolution: {integrity: sha512-IhW3fPW+bkt9MLNlycw8u8fWb7oO7W5URC9MfZYHBlA24rex9rs23D5DETChu1zvgVdc5ka64ICjJOgQMr6Shw==}
dependencies:
parchment: 1.1.4
dev: true
/@types/range-parser/1.2.4:
resolution: {integrity: sha512-EEhsLsD6UsDM1yFhAvy0Cjr6VwmpMWqFBCb9w07wVugF7w9nfajxLuVmngTIpgS6svCnm6Vaw+MZhoDCKnOfsw==}
dev: true
......@@ -7135,6 +7145,10 @@ packages:
resolution: {integrity: sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==}
dev: true
/parchment/1.1.4:
resolution: {integrity: sha512-J5FBQt/pM2inLzg4hEWmzQx/8h8D0CiDxaG3vyp9rKrQRSDgBlhjdP5jQGgosEajXPSQouXGHOmVdgo7QmJuOg==}
dev: true
/parent-module/1.0.1:
resolution: {integrity: sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==}
engines: {node: '>=6'}
......
......@@ -68,6 +68,9 @@ async function main() {
step('\nBuilding all packages...')
if (!skipBuild && !isDryRun) {
await run('pnpm', ['run', 'build'])
// test generated dts files
step('\nVerifying type declarations...')
await run('pnpm', ['run', 'test-dts'])
} else {
console.log(`(skipped)`)
}
......
export * from '@dcloudio/uni-app'
export function expectType<T>(value: T): void
{
"compilerOptions": {
"noEmit": true,
"jsx": "preserve",
"module": "esnext",
"strict": true,
"moduleResolution": "node",
"lib": ["esnext", "dom"]
},
"include": ["./*"]
}
{
"extends": "../tsconfig.json",
"compilerOptions": {
"noEmit": true,
"declaration": true
},
"exclude": ["../packages/*/__tests__"]
}
import {
onShow,
onLoad,
onLaunch,
onError,
onThemeChange,
onPageNotFound,
onUnhandledRejection,
onAddToFavorites,
onBackPress,
onNavigationBarButtonTap,
onNavigationBarSearchInputChanged,
onNavigationBarSearchInputConfirmed,
onNavigationBarSearchInputFocusChanged,
onPageScroll,
onResize,
onShareAppMessage,
onShareTimeline,
onTabItemTap,
} from '@dcloudio/uni-app'
import { expectType } from './'
describe('apiLifecycle', () => {
onLaunch(({ path, query, scene }) => {
expectType<string>(path)
expectType<Record<string, string | undefined>>(query)
expectType<number>(scene)
})
onError((err) => {
expectType<string>(err)
})
onThemeChange(({ theme }) => {
expectType<'dark' | 'light'>(theme)
})
onPageNotFound(({ path, query }) => {
expectType<string>(path)
expectType<Record<string, string | undefined>>(query)
})
onUnhandledRejection(({ promise, reason }) => {
expectType<Promise<any>>(promise)
expectType<string>(reason)
})
onShow(({ path }) => {
expectType<string>(path)
})
onLoad((options) => {
expectType<string | undefined>(options.a)
})
onResize(({ size: { windowHeight, windowWidth } }) => {
expectType<number>(windowHeight)
expectType<number>(windowWidth)
})
onBackPress(({ from }) => {
expectType<'backbutton' | 'navigateBack'>(from)
})
onPageScroll(({ scrollTop }) => {
expectType<number>(scrollTop)
})
onTabItemTap(({ index, pagePath, text }) => {
expectType<string>(index)
expectType<string>(pagePath)
expectType<string>(text)
})
onShareTimeline(() => {})
onShareTimeline(() => {
return {
title: '',
query: '',
imageUrl: '',
}
})
onAddToFavorites(() => {})
onAddToFavorites(({ webviewUrl }) => {
expectType<string | undefined>(webviewUrl)
return {
title: '',
query: '',
imageUrl: '',
}
})
onShareAppMessage(() => {})
onShareAppMessage(({ from, target, webViewUrl }) => {
expectType<string>(from)
expectType<any>(target)
expectType<string | undefined>(webViewUrl)
return {
title: '',
path: '',
imageUrl: '',
}
})
onNavigationBarButtonTap(({ index }) => {
expectType<number>(index)
})
onNavigationBarSearchInputChanged(({ text }) => {
expectType<string>(text)
})
onNavigationBarSearchInputConfirmed(({ text }) => {
expectType<string>(text)
})
onNavigationBarSearchInputFocusChanged(({ focus }) => {
expectType<boolean>(focus)
})
})
......@@ -16,7 +16,7 @@
"skipLibCheck": true,
"jsx": "preserve",
"lib": ["esnext", "dom"],
"types": ["jest", "node", "@dcloudio/types", "miniprogram-api-typings"],
"types": ["jest", "@dcloudio/types", "miniprogram-api-typings"],
"rootDir": ".",
"paths": {
"types/alias": ["packages/uni-cli-shared/types/alias.d.ts"],
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册