export type GyroscopeInterval =
	'game' |
	'ui' |
	'normal'

export type GyroscopeErrorCode =
	601 |
	602 |
	603 |
	604 |
	701 |
	702 |
	703 |
	704 |
	801 |
	802 |
	803 |
	804 |
	501 |
	502 |
	503 |
	504 |
	901

export interface IGyroscopeError extends IUniError {
	errCode : GyroscopeErrorCode
}

export type GyroscopeSuccess = {
	errMsg ?: string | null
}

export type GyroscopeFail = IGyroscopeError
export type GyroscopeSuccessCallback = (res : GyroscopeSuccess) => void
export type GyroscopeFailCallback = (res : GyroscopeFail) => void
export type GyroscopeComplete = GyroscopeSuccess | GyroscopeFail
export type GyroscopeCompleteCallback = (res : GyroscopeComplete) => void

export type StartGyroscopeOptions = {
	interval ?: GyroscopeInterval | null
	success ?: GyroscopeSuccessCallback | null
	fail ?: GyroscopeFailCallback | null
	complete ?: GyroscopeCompleteCallback | null
}

export type StopGyroscopeOptions = {
	success ?: GyroscopeSuccessCallback | null
	fail ?: GyroscopeFailCallback | null
	complete ?: GyroscopeCompleteCallback | null
}

export type OnGyroscopeChangeCallbackResult = {
	x : number
	y : number
	z : number
}

export type OnGyroscopeChangeCallback = (result : OnGyroscopeChangeCallbackResult) => void

export interface Uni {
 	/**
 	 * 开始监听陀螺仪数据。
 	 *
 	 * @tutorial https://doc.dcloud.net.cn/uni-app-x/api/gyroscope.html#startgyroscope
 	 * @tutorial_uni_app_x https://doc.dcloud.net.cn/uni-app-x/api/gyroscope.html#startgyroscope
 	 * @tutorial_uni_app https://uniapp.dcloud.net.cn/api/system/gyroscope.html#startgyroscope
 	 *
 	 * @uniPlatform {
 	 * 	"app": {
 	 * 		"android": {
 	 * 			"osVer": "5.0",
 	 * 			"uniVer": "x",
 	 * 			"unixVer": "5.08"
 	 * 		},
 	 * 		"ios": {
 	 * 			"osVer": "12.0",
 	 * 			"uniVer": "x",
 	 * 			"unixVer": "5.08"
 	 * 		},
 	 *    "harmony": {
 	 *      "osVer": "5.0.0",
 	 *      "uniVer": "x",
 	 *      "unixVer": "5.08",
 	 *      "unixvVer": "5.08"
 	 *    }
 	 * 	},
 	 *   "web": {
 	 *     "uniVer": "x",
 	 *     "unixVer": "x"
 	 *   },
 	 *  "mp":{
 	 *    "weixin": {
 	 *      "hostVer": "2.3.0",
 	 *      "uniVer": "√",
 	 *      "unixVer": "4.41"
 	 *    },
 	 *    "alipay": {
 	 *      "hostVer": "x",
 	 *      "uniVer": "x",
 	 *      "unixVer": "x"
 	 *    },
 	 *    "baidu": {
 	 *      "hostVer": "x",
 	 *      "uniVer": "x",
 	 *      "unixVer": "x"
 	 *    },
 	 *    "toutiao": {
 	 *      "hostVer": "x",
 	 *      "uniVer": "x",
 	 *      "unixVer": "x"
 	 *    },
 	 *    "lark": {
 	 *      "hostVer": "x",
 	 *      "uniVer": "x",
 	 *      "unixVer": "x"
 	 *    },
 	 *    "qq": {
 	 *      "hostVer": "x",
 	 *      "uniVer": "x",
 	 *      "unixVer": "x"
 	 *    },
 	 *    "kuaishou": {
 	 *      "hostVer": "x",
 	 *      "uniVer": "x",
 	 *      "unixVer": "x"
 	 *    },
 	 *    "jd": {
 	 *      "hostVer": "x",
 	 *      "uniVer": "x",
 	 *      "unixVer": "x"
 	 *    }
 	 *  }
 	 * }
 	 */
	startGyroscope(options ?: StartGyroscopeOptions | null) : void;
 	/**
 	 * 停止监听陀螺仪数据变化事件。
 	 *
 	 * @tutorial https://doc.dcloud.net.cn/uni-app-x/api/gyroscope.html#stopgyroscope
 	 * @tutorial_uni_app_x https://doc.dcloud.net.cn/uni-app-x/api/gyroscope.html#stopgyroscope
 	 * @tutorial_uni_app https://uniapp.dcloud.net.cn/api/system/gyroscope.html#stopgyroscope
 	 *
 	 * @uniPlatform {
 	 * 	"app": {
 	 * 		"android": {
 	 * 			"osVer": "5.0",
 	 * 			"uniVer": "x",
 	 * 			"unixVer": "5.08"
 	 * 		},
 	 * 		"ios": {
 	 * 			"osVer": "12.0",
 	 * 			"uniVer": "x",
 	 * 			"unixVer": "5.08"
 	 * 		},
 	 *    "harmony": {
 	 *      "osVer": "5.0.0",
 	 *      "uniVer": "x",
 	 *      "unixVer": "5.08",
 	 *      "unixvVer": "5.08"
 	 *    }
 	 * 	},
 	 *   "web": {
 	 *     "uniVer": "x",
 	 *     "unixVer": "x"
 	 *   },
 	 *  "mp":{
 	 *    "weixin": {
 	 *      "hostVer": "2.3.0",
 	 *      "uniVer": "√",
 	 *      "unixVer": "4.41"
 	 *    },
 	 *    "alipay": {
 	 *      "hostVer": "x",
 	 *      "uniVer": "x",
 	 *      "unixVer": "x"
 	 *    },
 	 *    "baidu": {
 	 *      "hostVer": "x",
 	 *      "uniVer": "x",
 	 *      "unixVer": "x"
 	 *    },
 	 *    "toutiao": {
 	 *      "hostVer": "x",
 	 *      "uniVer": "x",
 	 *      "unixVer": "x"
 	 *    },
 	 *    "lark": {
 	 *      "hostVer": "x",
 	 *      "uniVer": "x",
 	 *      "unixVer": "x"
 	 *    },
 	 *    "qq": {
 	 *      "hostVer": "x",
 	 *      "uniVer": "x",
 	 *      "unixVer": "x"
 	 *    },
 	 *    "kuaishou": {
 	 *      "hostVer": "x",
 	 *      "uniVer": "x",
 	 *      "unixVer": "x"
 	 *    },
 	 *    "jd": {
 	 *      "hostVer": "x",
 	 *      "uniVer": "x",
 	 *      "unixVer": "x"
 	 *    }
 	 *  }
 	 * }
 	 */
	stopGyroscope(options ?: StopGyroscopeOptions | null) : void;
 	/**
 	 * 监听陀螺仪数据变化事件
	 * 支付宝小程序频率为 500ms/次，微信小程序频率根据 uni.startGyroscope 的 interval 参数设置。事件只有在调用 uni.startGyroscope 后才会开始监听，使用 uni.stopGyroscope 可以停止监听。
 	 *
 	 * @tutorial https://doc.dcloud.net.cn/uni-app-x/api/gyroscope.html#ongyroscopechange
 	 * @tutorial_uni_app_x https://doc.dcloud.net.cn/uni-app-x/api/gyroscope.html#ongyroscopechange
 	 * @tutorial_uni_app https://uniapp.dcloud.net.cn/api/system/gyroscope.html#ongyroscopechange
 	 *
 	 * @uniPlatform {
 	 * 	"app": {
 	 * 		"android": {
 	 * 			"osVer": "5.0",
 	 * 			"uniVer": "x",
 	 * 			"unixVer": "5.08"
 	 * 		},
 	 * 		"ios": {
 	 * 			"osVer": "12.0",
 	 * 			"uniVer": "x",
 	 * 			"unixVer": "5.08"
 	 * 		},
 	 *    "harmony": {
 	 *      "osVer": "5.0.0",
 	 *      "uniVer": "x",
 	 *      "unixVer": "5.08",
 	 *      "unixvVer": "5.08"
 	 *    }
 	 * 	},
 	 *   "web": {
 	 *     "uniVer": "x",
 	 *     "unixVer": "x"
 	 *   },
 	 *  "mp":{
 	 *    "weixin": {
 	 *      "hostVer": "2.3.0",
 	 *      "uniVer": "√",
 	 *      "unixVer": "4.41"
 	 *    },
 	 *    "alipay": {
 	 *      "hostVer": "x",
 	 *      "uniVer": "x",
 	 *      "unixVer": "x"
 	 *    },
 	 *    "baidu": {
 	 *      "hostVer": "x",
 	 *      "uniVer": "x",
 	 *      "unixVer": "x"
 	 *    },
 	 *    "toutiao": {
 	 *      "hostVer": "x",
 	 *      "uniVer": "x",
 	 *      "unixVer": "x"
 	 *    },
 	 *    "lark": {
 	 *      "hostVer": "x",
 	 *      "uniVer": "x",
 	 *      "unixVer": "x"
 	 *    },
 	 *    "qq": {
 	 *      "hostVer": "x",
 	 *      "uniVer": "x",
 	 *      "unixVer": "x"
 	 *    },
 	 *    "kuaishou": {
 	 *      "hostVer": "x",
 	 *      "uniVer": "x",
 	 *      "unixVer": "x"
 	 *    },
 	 *    "jd": {
 	 *      "hostVer": "x",
 	 *      "uniVer": "x",
 	 *      "unixVer": "x"
 	 *    }
 	 *  }
 	 * }
 	 */
	onGyroscopeChange(callback : OnGyroscopeChangeCallback) : void;
 	/**
 	 * 停止监听陀螺仪数据变化事件
	 *
 	 * @tutorial https://doc.dcloud.net.cn/uni-app-x/api/gyroscope.html#offgyroscopechange
 	 * @tutorial_uni_app_x https://doc.dcloud.net.cn/uni-app-x/api/gyroscope.html#offgyroscopechange
 	 * @tutorial_uni_app https://uniapp.dcloud.net.cn/api/system/gyroscope.html#offgyroscopechange
 	 *
 	 * @uniPlatform {
 	 * 	"app": {
 	 * 		"android": {
 	 * 			"osVer": "5.0",
 	 * 			"uniVer": "x",
 	 * 			"unixVer": "5.08"
 	 * 		},
 	 * 		"ios": {
 	 * 			"osVer": "12.0",
 	 * 			"uniVer": "x",
 	 * 			"unixVer": "5.08"
 	 * 		},
 	 *    "harmony": {
 	 *      "osVer": "5.0.0",
 	 *      "uniVer": "x",
 	 *      "unixVer": "5.08",
 	 *      "unixvVer": "5.08"
 	 *    }
 	 * 	},
 	 *   "web": {
 	 *     "uniVer": "x",
 	 *     "unixVer": "x"
 	 *   },
 	 *  "mp":{
 	 *    "weixin": {
 	 *      "hostVer": "2.9.3",
 	 *      "uniVer": "√",
 	 *      "unixVer": "4.41"
 	 *    },
 	 *    "alipay": {
 	 *      "hostVer": "x",
 	 *      "uniVer": "x",
 	 *      "unixVer": "x"
 	 *    },
 	 *    "baidu": {
 	 *      "hostVer": "x",
 	 *      "uniVer": "x",
 	 *      "unixVer": "x"
 	 *    },
 	 *    "toutiao": {
 	 *      "hostVer": "x",
 	 *      "uniVer": "x",
 	 *      "unixVer": "x"
 	 *    },
 	 *    "lark": {
 	 *      "hostVer": "x",
 	 *      "uniVer": "x",
 	 *      "unixVer": "x"
 	 *    },
 	 *    "qq": {
 	 *      "hostVer": "x",
 	 *      "uniVer": "x",
 	 *      "unixVer": "x"
 	 *    },
 	 *    "kuaishou": {
 	 *      "hostVer": "x",
 	 *      "uniVer": "x",
 	 *      "unixVer": "x"
 	 *    },
 	 *    "jd": {
 	 *      "hostVer": "x",
 	 *      "uniVer": "x",
 	 *      "unixVer": "x"
 	 *    }
 	 *  }
 	 * }
 	 */
	offGyroscopeChange(callback ?: OnGyroscopeChangeCallback | null) : void;
}
