diff --git a/api/phone/@system.sensor.d.ts b/api/phone/@system.sensor.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b0addd5d69f76347f1206d1efb87cad53c34e555 --- /dev/null +++ b/api/phone/@system.sensor.d.ts @@ -0,0 +1,467 @@ +/* + * Copyright (c) 2020 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export interface AccelerometerResponse { + /** + * X-coordinate + * @since 3 + */ + x: number; + + /** + * Y-coordinate + * @since 3 + */ + y: number; + + /** + * Z-coordinate + * @since 3 + */ + z: number; +} + +export interface CompassResponse { + /** + * Direction of the device (in degrees). + * @since 3 + */ + direction: number; +} + +export interface LightResponse { + /** + * Light intensity, in lux. + * @since 3 + */ + intensity: number; +} + +export interface StepCounterResponse { + /** + * Number of steps counted. + * Each time the device restarts, the value is recalculated from 0. + * @since 3 + */ + steps: number; +} + +export interface BarometerResponse { + /** + * Pressure, in pascal. + * @since 3 + */ + pressure: number; +} + +export interface DeviceOrientationResponse { + /** + * alpha + * @since 6 + */ + alpha: number; + + /** + * beta + * @since 6 + */ + beta: number; + + /** + * gamma + * @since 6 + */ + gamma: number; +} + +export interface GyroscopeResponse { + /** + * X-coordinate + * @since 6 + */ + x: number; + + /** + * Y-coordinate + * @since 6 + */ + y: number; + + /** + * Z-coordinate + * @since 6 + */ + z: number; +} + +export interface GravityResponse { + /** + * X-coordinate + * @since 7 + */ + x: number; + + /** + * Y-coordinate + * @since 7 + */ + y: number; + + /** + * Z-coordinate + * @since 7 + */ + z: number; +} + +export interface MagneticResponse { + /** + * X-coordinate + * @since 7 + */ + x: number; + + /** + * Y-coordinate + * @since 7 + */ + y: number; + + /** + * Z-coordinate + * @since 7 + */ + z: number; +} + +export interface HallResponse { + /** + * Indicates the hall sensor data. + * @since 7 + */ + value: number; +} + +/** + * @Syscap SysCap.ACE.UIEngine + */ +export default class Sensor { + /** + * Listens to acceleration sensor data changes. + * If this API is called multiple times, the last call takes effect. + * @param options + */ + static subscribeAccelerometer(options: { + /** + * Execution frequency of the callback function for listening to acceleration sensor data. + * The default value is normal. + * @since 3 + */ + interval: string; + + /** + * Called when acceleration sensor data changes. + * @since 3 + */ + success: (data: AccelerometerResponse) => void; + + /** + * Called when the listening fails. + * @since 3 + */ + fail?: (data: any, code: number) => void; + }): void; + + /** + * Cancels listening to acceleration sensor data. + */ + static unsubscribeAccelerometer(): void; + + /** + * Listens to compass sensor data changes. + * If this API is called multiple times, the last call takes effect. + * @param options Options. + */ + static subscribeCompass(options: { + /** + * Called when compass sensor data changes. + * @since 3 + */ + success: (data: CompassResponse) => void; + + /** + * Called when the listening fails. + * @since 3 + */ + fail?: (data: any, code: number) => void; + }): void; + + /** + * Cancels listening to compass sensor data. + */ + static unsubscribeCompass(): void; + + /** + * Listens to distance sensor data changes. + * If this API is called multiple times, the last call takes effect. + * @param options + */ + static subscribeProximity(options: { + /** + * Called when distance sensor data changes. + * @since 3 + */ + success: (ret: { distance: number}) => void; + + /** + * Called when the listening fails. + * @since 3 + */ + fail?: (data: any, code: number) => void; + }): void; + + /** + * Cancels listening to distance sensor data. + * @param options + */ + static unsubscribeProximity(): void; + + /** + * Listens to ambient light sensor data changes. + * If this API is called multiple times, the last call takes effect. + * @param options + */ + static subscribeLight(options: { + /** + * Called when ambient light sensor data changes. + * @since 3 + */ + success: (data: LightResponse) => void; + + /** + * Called when the listening fails. + * @since 3 + */ + fail?: (data: any, code: number) => void; + }): void; + + /** + * Cancels listening to ambient light sensor data. + */ + static unsubscribeLight(): void; + + /** + * Listens to step counter sensor data changes. + * If this API is called multiple times, the last call takes effect. + * @param options + */ + static subscribeStepCounter(options: { + /** + * Called when step counter sensor data changes. + * @since 3 + */ + success: (data: StepCounterResponse) => void; + + /** + * Called when the listening fails. + * @since 3 + */ + fail?: (data: any, code: number) => void; + }): void; + + /** + * Cancels listening to step counter sensor data. + */ + static unsubscribeStepCounter(): void; + + /** + * Listens to barometer sensor data changes. + * If this API is called multiple times, the last call takes effect. + * @param options + */ + static subscribeBarometer(options: { + /** + * Called when the barometer sensor data changes. + * @since 3 + */ + success: (data: BarometerResponse) => void; + + /** + * Called when the listening fails. + * @since 3 + */ + fail?: (data: any, code: number) => void; + }): void; + + /** + * Cancels listening to barometer sensor data. + */ + static unsubscribeBarometer(): void; + + /** + * Listens to device orientation sensor data changes. + * If this API is called multiple times, the last call takes effect. + * @param options + */ + static subscribeDeviceOrientation(options: { + /** + * Execution frequency of the callback function for listening to device orientation sensor data. + * The default value is normal. + * @since 6 + */ + interval: string; + + /** + * Called when device orientation sensor data changes. + * @since 6 + */ + success: (data: DeviceOrientationResponse) => void; + + /** + * Called when the listening fails. + * @since 6 + */ + fail?: (data: any, code: number) => void; + }): void; + + /** + * Cancels listening to device orientation sensor data. + */ + static unsubscribeDeviceOrientation(): void; + + /** + * Listens to gyroscope sensor data changes. + * If this API is called multiple times, the last call takes effect. + * @param options + */ + static subscribeGyroscope(options: { + /** + * Execution frequency of the callback function for listening to gyroscope sensor data. + * The default value is normal. + * @since 6 + */ + interval: string; + + /** + * Called when gyroscope sensor data changes. + * @since 6 + */ + success: (data: GyroscopeResponse) => void; + + /** + * Called when the listening fails. + * @since 6 + */ + fail?: (data: any, code: number) => void; + }): void; + + /** + * Cancels listening to gyroscope sensor data. + */ + static unsubscribeGyroscope(): void; + + /** + * Listens to gravity sensor data changes. + * If this API is called multiple times, the last call takes effect. + * @param options + */ + static subscribeGravity(options: { + /** + * Execution frequency of the callback function for listening to gravity sensor data. + * The default value is normal. + * @since 7 + */ + interval: string; + + /** + * Called when gravity sensor data changes. + * @since 7 + */ + success: (data: GravityResponse) => void; + + /** + * Called when the listening fails. + * @since 7 + */ + fail?: (data: any, code: number) => void; + }): void; + + /** + * Cancels listening to gravity sensor data. + */ + static unsubscribeGravity(): void; + + /** + * Listens to magnetic sensor data changes. + * If this API is called multiple times, the last call takes effect. + * @param options + */ + static subscribeMagnetic(options: { + /** + * Execution frequency of the callback function for listening to magnetic sensor data. + * The default value is normal. + * @since 7 + */ + interval: string; + + /** + * Called when magnetic sensor data changes. + * @since 7 + */ + success: (data: MagneticResponse) => void; + + /** + * Called when the listening fails. + * @since 7 + */ + fail?: (data: any, code: number) => void; + }): void; + + /** + * Cancels listening to magnetic sensor data. + */ + static unsubscribeMagnetic(): void; + + /** + * Listens to hall sensor data changes. + * If this API is called multiple times, the last call takes effect. + * @param options + */ + static subscribeHall(options: { + /** + * Execution frequency of the callback function for listening to hall sensor data. + * The default value is normal. + * @since 7 + */ + interval: string; + + /** + * Called when hall sensor data changes. + * @since 7 + */ + success: (data: HallResponse) => void; + + /** + * Called when the listening fails. + * @since 7 + */ + fail?: (data: any, code: number) => void; + }): void; + + /** + * Cancels listening to hall sensor data. + */ + static unsubscribeHall(): void; +} diff --git a/api/phone/@system.storage.d.ts b/api/phone/@system.storage.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..abb07c05e327c96f4ca7923de6f918b3c519a980 --- /dev/null +++ b/api/phone/@system.storage.d.ts @@ -0,0 +1,160 @@ +/* + * Copyright (c) 2020 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export interface GetStorageOptions { + /** + * Content index. + * For liteWearable and smartVision, the value contains a maximum of 32 characters and cannot contain special characters such as \/"*+,:;<=>?[]|\x7F. + * @since 3 + */ + key: string; + + /** + * Default value returned when the key does not exist. + * If this parameter is not specified, an empty string is returned. + * @since 3 + */ + default?: string; + + /** + * Called when the stored content is read successfully. + * @since 3 + */ + success?: (data: any) => void; + + /** + * Called when the stored content fails to be read. + * @since 3 + */ + fail?: (data: string, code: number) => void; + + /** + * Called when the execution is completed. + * @since 3 + */ + complete?: () => void; +} + +export interface SetStorageOptions { + /** + * Index of the stored content to be modified. + * For liteWearable and smartVision, the value contains a maximum of 32 characters and cannot contain special characters such as \/"*+,:;<=>?[]|\x7F. + * @since 3 + */ + key: string; + + /** + * Target storage content. If the content is an empty string, the data item with the key as the index will be deleted. + * @since 3 + */ + value: string; + + /** + * Called when the stored content is modified successfully. + * @since 3 + */ + success?: () => void; + + /** + * Called when the stored content fails to be modified. + * @since 3 + */ + fail?: (data: string, code: number) => void; + + /** + * Called when the execution is completed. + * @since 3 + */ + complete?: () => void; +} + +/** + * @devices tv, phone, tablet, wearable, liteWearable, smartVision + */ +export interface ClearStorageOptions { + /** + * Called when the stored content is cleared successfully. + * @since 3 + */ + success?: () => void; + + /** + * Called when the stored content fails to be cleared. + * @since 3 + */ + fail?: (data: string, code: number) => void; + + /** + * Called when the execution is completed. + * @since 3 + */ + complete?: () => void; +} + +export interface DeleteStorageOptions { + /** + * Content index. + * For liteWearable and smartVision, the value contains a maximum of 32 characters and cannot contain special characters such as \/"*+,:;<=>?[]|\x7F. + * @since 3 + */ + key: string; + + /** + * Called when the stored content is deleted successfully. + * @since 3 + */ + success?: () => void; + + /** + * Called when the stored content fails to be deleted. + * @since 3 + */ + fail?: (data: string, code: number) => void; + + /** + * Called when the execution is completed. + * @since 3 + */ + complete?: () => void; +} + +/** + * @Syscap SysCap.ACE.UIEngine + */ +export default class Storage { + /** + * Reads the stored content. + * @param options Options. + */ + static get(options: GetStorageOptions): void; + + /** + * Modifies the stored content. + * @param options Options. + */ + static set(options: SetStorageOptions): void; + + /** + * Clears the stored content. + * @param options Options. + */ + static clear(options?: ClearStorageOptions): void; + + /** + * Deletes the stored content. + * @param options Options. + */ + static delete(options: DeleteStorageOptions): void; +} diff --git a/api/phone/@system.vibrator.d.ts b/api/phone/@system.vibrator.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..af7fd34f764f3767827282bfad5387ba93372a8f --- /dev/null +++ b/api/phone/@system.vibrator.d.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2020 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export interface VibrateOptions { + /** + * Vibration mode. The value long indicates long vibration, and short indicates short vibration. + * The default value is long. + * @since 3 + */ + mode?: "long" | "short"; +} + +/** + * @Syscap SysCap.ACE.UIEngine + */ +export default class Vibrator { + /** + * Triggers vibration. + * @param options Options. + */ + static vibrate(options?: VibrateOptions): void; +} \ No newline at end of file diff --git a/remove_internal.py b/remove_internal.py new file mode 100755 index 0000000000000000000000000000000000000000..0134a5cc1afff01b2023a574730bd5b86dfa7347 --- /dev/null +++ b/remove_internal.py @@ -0,0 +1,42 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. + +import os +import sys +import optparse +import shutil + +# d.ts directories to be deleted +remove_list = ["@internal", "common", "config", "form", "liteWearable", + "phone", "router", "smartVision", "tablet", "tv", "wearable"] + + +# traversal all fill in project folder +def copy_files(input_path, output_path): + for file in os.listdir(input_path): + src = os.path.join(input_path, file) + dst = os.path.join(output_path, file) + if os.path.isdir(src) and (not file in remove_list): + shutil.copytree(src, dst, dirs_exist_ok=True) + elif os.path.isfile(src) and (not file.startswith('@system')): + shutil.copy(src, dst) + + +def parse_args(args): + parser = optparse.OptionParser() + parser.add_option('--input', help='d.ts document input path') + parser.add_option('--output', help='d.ts document output path') + options, _ = parser.parse_args(args) + return options + + +def main(argv): + options = parse_args(argv) + if not os.path.exists(options.output): + os.makedirs(options.output) + copy_files(options.input, options.output) + + +if __name__ == "__main__": + exit(main(sys.argv)) \ No newline at end of file diff --git a/remove_internal.pydeps b/remove_internal.pydeps new file mode 100755 index 0000000000000000000000000000000000000000..f2f25eed752fbefcb1af8f77d907df887cf68495 --- /dev/null +++ b/remove_internal.pydeps @@ -0,0 +1,3 @@ +# Generated by running: +# build/print_python_deps.py --root interface/sdk-js --output interface/sdk-js/remove_internal.pydeps interface/sdk-js/remove_internal.py +remove_internal.py