diff --git a/api/@ohos.process.d.ts b/api/@ohos.process.d.ts index bff59be60eeaaaa17d6d367ce1d884cca23b7114..d481c9bf4bcfaf212528c2655ccc773c6bff3e1c 100644 --- a/api/@ohos.process.d.ts +++ b/api/@ohos.process.d.ts @@ -1,17 +1,17 @@ /* -* Copyright (c) 2021 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. -*/ + * Copyright (c) 2021 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. + */ /** * The process is mainly used to obtain the relevant ID of the process, obtain and modify @@ -26,202 +26,295 @@ declare namespace process { export interface ChildProcess { /** - * return pid is the pid of the current process - * @since 7 - * @sysCap SystemCapability.CCRuntime - * @return return the pid of the current process. - */ + * return pid is the pid of the current process + * @since 7 + * @sysCap SystemCapability.CCRuntime + * @return return the pid of the current process. + */ readonly pid: number; /** - * return ppid is the pid of the current child process - * @since 7 - * @sysCap SystemCapability.CCRuntime - * @return return the pid of the current child process. - */ + * return ppid is the pid of the current child process + * @since 7 + * @sysCap SystemCapability.CCRuntime + * @return return the pid of the current child process. + */ readonly ppid: number; /** - * return exitCode is the exit code of the current child process - * @since 7 - * @sysCap SystemCapability.CCRuntime - * @return return the exit code of the current child process. - */ + * return exitCode is the exit code of the current child process + * @since 7 + * @sysCap SystemCapability.CCRuntime + * @return return the exit code of the current child process. + */ readonly exitCode: number; /** - * return boolean is whether the current process signal is sent successfully - * @since 7 - * @sysCap SystemCapability.CCRuntime - * @return return whether the current process signal is sent successfully. - */ + * return boolean is whether the current process signal is sent successfully + * @since 7 + * @sysCap SystemCapability.CCRuntime + * @return return whether the current process signal is sent successfully. + */ readonly killed: boolean; /** - * return 'number' is the targer process exit code - * @since 7 - * @sysCap SystemCapability.CCRuntime - * @return return the targer process exit code. - */ + * return 'number' is the targer process exit code + * @since 7 + * @sysCap SystemCapability.CCRuntime + * @return return the targer process exit code. + */ wait(): Promise; /** - * return it as 'Uint8Array' of the stdout until EOF - * @since 7 - * @sysCap SystemCapability.CCRuntime - * @return return subprocess standard outpute. - */ + * return it as 'Uint8Array' of the stdout until EOF + * @since 7 + * @sysCap SystemCapability.CCRuntime + * @return return subprocess standard outpute. + */ getOutput(): Promise; /** - * return it as 'Uint8Array of the stderr until EOF - * @since 7 - * @sysCap SystemCapability.CCRuntime - * @return return subprocess standard error output. - */ + * return it as 'Uint8Array of the stderr until EOF + * @since 7 + * @sysCap SystemCapability.CCRuntime + * @return return subprocess standard error output. + */ getErrorOutput(): Promise; /** - * close the target process - * @since 7 - * @sysCap SystemCapability.CCRuntime - */ + * close the target process + * @since 7 + * @sysCap SystemCapability.CCRuntime + */ close(): void; /** - * send a signal to process - * @since 7 - * @sysCap SystemCapability.CCRuntime - * @param signal number or string represents the signal sent. - */ + * send a signal to process + * @since 7 + * @sysCap SystemCapability.CCRuntime + * @param signal number or string represents the signal sent. + */ kill(signal: number | string): void; } /** - * returns the numeric valid group ID of the process - * @since 7 - * @sysCap SystemCapability.CCRuntime - * @return return the numeric valid group ID of the process. - */ + * returns the numeric valid group ID of the process + * @since 7 + * @sysCap SystemCapability.CCRuntime + * @return return the numeric valid group ID of the process. + */ readonly getEgid: number; /** - * return the numeric valid user identity of the process - * @since 7 - * @sysCap SystemCapability.CCRuntime - * @return return the numeric valid user identity of the process. - */ + * return the numeric valid user identity of the process + * @since 7 + * @sysCap SystemCapability.CCRuntime + * @return return the numeric valid user identity of the process. + */ readonly getEuid: number; /** - * returns the numeric group id of the process - * @since 7 - * @sysCap SystemCapability.CCRuntime - * @return return the numeric group if of the process. - */ + * returns the numeric group id of the process + * @since 7 + * @sysCap SystemCapability.CCRuntime + * @return return the numeric group if of the process. + */ readonly getGid: number /** - * returns the digital user id of the process - * @since 7 - * @sysCap SystemCapability.CCRuntime - * @return return the digital user id of the process. - */ + * returns the digital user id of the process + * @since 7 + * @sysCap SystemCapability.CCRuntime + * @return return the digital user id of the process. + */ readonly getUid: number; /** - * return an array with supplementary group id - * @since 7 - * @sysCap SystemCapability.CCRuntime - * @return return an array with supplementary group id. - */ + * return an array with supplementary group id + * @since 7 + * @sysCap SystemCapability.CCRuntime + * @return return an array with supplementary group id. + */ readonly getGroups: number[]; /** - * return pid is The pid of the current process - * @since 7 - * @sysCap SystemCapability.CCRuntime - * @return return The pid of the current process. - */ + * return pid is The pid of the current process + * @since 7 + * @sysCap SystemCapability.CCRuntime + * @return return The pid of the current process. + */ readonly getPid: number; /** - * return ppid is The pid of the current child process - * @since 7 - * @sysCap SystemCapability.CCRuntime - * @return return The pid of the current child processs. - */ + * return ppid is The pid of the current child process + * @since 7 + * @sysCap SystemCapability.CCRuntime + * @return return The pid of the current child processs. + */ readonly getPpid: number; + /** + * Returns the tid of the current thread. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @return return the tid of the current thread. + */ + function getTid(): number; + + /** + * Returns a boolean whether the process is isolated. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @return return boolean whether the process is isolated. + */ + function isIsolatedProcess(): boolean; + + /** + * Returns a boolean whether the specified uid belongs to a particular application. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param v An id. + * @return return a boolean whether the specified uid belongs to a particular application. + */ + function isAppUid(v: number): boolean; + + /** + * Returns a boolean whether the process is running in a 64-bit environment. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @return return a boolean whether the process is running in a 64-bit environment. + */ + function is64Bit(): boolean; + + /** + * Returns the uid based on the specified user name. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param v Process name. + * @return return the uid based on the specified user name. + */ + function getUidForName(v: string): number; + + /** + * Returns the thread priority based on the specified tid. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param v The tid of the process. + * @return Return the thread priority based on the specified tid. + */ + function getThreadPriority(v: number): number; + + /** + * Returns the elapsed real time (in milliseconds) taken from the start of the system to the start of the process. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @return Return the start of the system to the start of the process. + */ + function getStartRealtime(): number; + + /** + * Returns cpu cores available for the current process on a multi-core device. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @return Return cpu cores available for the current process on a multi-core device. + */ + function getAvailableCores​(): number[]; + + /** + * Returns the cpu time (in milliseconds) from the time when the process starts to the current time. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @return Return the cpu time (in milliseconds) from the time when the process starts to the current time. + */ + function getPastCpuTime(): number; + + /** + * Returns the system configuration at runtime. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param name Parameters defined by the system configuration. + * @return Return the system configuration at runtime. + */ + function getSystemConfig(name: number): number; + + /** + * Returns the system value for environment variables. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param name Parameters defined by the system environment variables. + * @Returns the system value for environment variables. + */ + function getEnvironmentVar(name: string): string; + type EventListener = (evt: Object) => void; /** - * Return a child process object and spawns a new ChildProcess to run the command - * @since 7 - * @sysCap SystemCapability.CCRuntime - * @param command string of the shell commands executed by the child process. - * @param options This is an object. The object contains three parameters. Timeout is the running time of the child - * process, killSignal is the signal sent when the child process reaches timeout, and maxBuffer is the size of the - * maximum buffer area for standard input and output. - * @return Return a child process object. - */ + * Return a child process object and spawns a new ChildProcess to run the command + * @since 7 + * @sysCap SystemCapability.CCRuntime + * @param command string of the shell commands executed by the child process. + * @param options This is an object. The object contains three parameters. Timeout is the running time of the child + * process, killSignal is the signal sent when the child process reaches timeout, and maxBuffer is the size of the + * maximum buffer area for standard input and output. + * @return Return a child process object. + */ function runCmd(command: string, options?: { timeout : number, killSignal : number | string, maxBuffer : number }): ChildProcess; /** - * Abort current process - * @since 7 - * @sysCap SystemCapability.CCRuntime - */ + * Abort current process + * @since 7 + * @sysCap SystemCapability.CCRuntime + */ function abort(): void; /** - * Register for an event - * @since 7 - * @sysCap SystemCapability.CCRuntime - * @param type Indicates the type of event registered. - * @param listener Represents the registered event function - */ + * Register for an event + * @since 7 + * @sysCap SystemCapability.CCRuntime + * @param type Indicates the type of event registered. + * @param listener Represents the registered event function + */ function on(type: string, listener: EventListener): void; /** - * Remove registered event - * @since 7 - * @sysCap SystemCapability.CCRuntime - * @param type Remove the type of registered event. - * @return Return removed result. - */ + * Remove registered event + * @since 7 + * @sysCap SystemCapability.CCRuntime + * @param type Remove the type of registered event. + * @return Return removed result. + */ function off(type: string): boolean; /** - * Process exit - * @since 7 - * @sysCap SystemCapability.CCRuntime - * @param code Process exit code. - */ + * Process exit + * @since 7 + * @sysCap SystemCapability.CCRuntime + * @param code Process exit code. + */ function exit(code: number): void; /** - * Return the current work directory; - * @since 7 - * @sysCap SystemCapability.CCRuntime - * @return Return the current work directory. - */ + * Return the current work directory; + * @since 7 + * @sysCap SystemCapability.CCRuntime + * @return Return the current work directory. + */ function cwd(): string; /** - * Change current directory - * @since 7 - * @sysCap SystemCapability.CCRuntime - * @param dir The path you want to change. - */ + * Change current directory + * @since 7 + * @sysCap SystemCapability.CCRuntime + * @param dir The path you want to change. + */ function chdir(dir: string): void; /** - * Returns the running time of the system - * @since 7 - * @sysCap SystemCapability.CCRuntime - * @return Return the running time of the system. - */ + * Returns the running time of the system + * @since 7 + * @sysCap SystemCapability.CCRuntime + * @return Return the running time of the system. + */ function uptime(): number; /** diff --git a/api/@ohos.url.d.ts b/api/@ohos.url.d.ts index 3bf1c4482ba0cf3ceb4c361c1e83ea8b4e954448..be47f42ebd65f9c3ca20ff2e7569a2cbd3a811cd 100644 --- a/api/@ohos.url.d.ts +++ b/api/@ohos.url.d.ts @@ -1,17 +1,17 @@ /* -* Copyright (c) 2021 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. -*/ + * Copyright (c) 2021 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. + */ /** * The url module provides utilities for URL resolution and parsing. @@ -110,10 +110,10 @@ declare namespace url { set(name: string, value: string): void; /** - * Sort all key/value pairs contained in this object in place and return undefined. - * @since 7 - * @sysCap SystemCapability.CCRuntime - */ + * Sort all key/value pairs contained in this object in place and return undefined. + * @since 7 + * @sysCap SystemCapability.CCRuntime + */ sort(): void; /** diff --git a/api/@ohos.util.d.ts b/api/@ohos.util.d.ts index 9841a835ce7312e8322fad272473b0aeffcedff3..ab23c0546dad32af90c78c3a9c61de8572973912 100644 --- a/api/@ohos.util.d.ts +++ b/api/@ohos.util.d.ts @@ -1,17 +1,17 @@ /* -* Copyright (c) 2021 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. -*/ + * Copyright (c) 2021 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. + */ /** * TextDecoder support full encoding in ICU data utf-8 utf-16 iso8859 must support in all device, TextEncoder takes a * stream of code points as input and emits a stream of UTF-8 bytes, and system help function. @@ -157,6 +157,427 @@ declare namespace util { dest: Uint8Array, ): { read: number; written: number }; } -} + + class RationalNumber​ { + /** + * A constructor used to create a RationalNumber instance with a given numerator and denominator. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param numerator An integer number + * @param denominator An integer number + */ + constructor(numerator: number, denominator: number); + /** + * Creates a RationalNumber object based on a given string. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param String Expression of Rational Numbers + * @return Returns a RationalNumber object generated based on the given string. + */ + static createRationalFromString​(rationalString: string): RationalNumber​; + /** + * Compares the current RationalNumber object to the given object. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param An object of other rational numbers + * @return Returns 0 or 1, or -1, depending on the comparison. + */ + compareTo​(another :RationalNumber): number; + /** + * Compares two objects for equality. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param An object + * @return Returns true if the given object is the same as the current object; Otherwise, false is returned. + */ + equals​(obj: Object): boolean; + /** + * Gets integer and floating-point values of a rational number object. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @return Returns the integer and floating-point values of a rational number object. + */ + value(): number; + /** + * Get the greatest common divisor of two integers. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param number1 is an integer. + * @param number2 is an integer. + * @return Returns the greatest common divisor of two integers, integer type. + */ + static getCommonDivisor​(number1: number, number2: number): number; + /** + * Gets the denominator of the current object. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @return Returns the denominator of the current object. + */ + getDenominator​(): number; + /** + * Gets the numerator​ of the current object. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @return Returns the numerator​ of the current object. + */ + getNumerator​(): number; + /** + * Checks whether the current RationalNumber object represents an infinite value. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @return If the denominator is not 0, true is returned. Otherwise, false is returned. + */ + isFinite​() : boolean; + /** + * Checks whether the current RationalNumber object represents a Not-a-Number (NaN) value. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @return If both the denominator and numerator are 0, true is returned. Otherwise, false is returned. + */ + isNaN​(): boolean; + /** + * Checks whether the current RationalNumber object represents the value 0. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @return If the value represented by the current object is 0, true is returned. Otherwise, false is returned. + */ + isZero​(): boolean; + /** + * Obtains a string representation of the current RationalNumber object. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @return Returns a string representation of the current RationalNumber object. + */ + toString​(): string; + } + + class LruBuffer { + /** + * Default constructor used to create a new LruBuffer instance with the default capacity of 64. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param capacity Indicates the capacity to customize for the buffer. + */ + constructor(capacity?:number); + /** + * Updates the buffer capacity to a specified capacity. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param newCapacity Indicates the new capacity to set. + */ + updateCapacity(newCapacity: number):void + /** + *Returns a string representation of the object. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @return Returns the string representation of the object and outputs the string representation of the object. + */ + toString():string + /** + * Obtains a list of all values in the current buffer. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @return Returns the total number of values in the current buffer. + */ + size():number + /** + * Obtains the capacity of the current buffer. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @return Returns the capacity of the current buffer. + */ + capacity(): number; + /** + * Clears key-value pairs from the current buffer. + * @since 8 + * @sysCap SystemCapability.CCRuntime + */ + clear(): void; + /** + * Obtains the number of times createDefault(Object) returned a value. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @return Returns the number of times createDefault(java.lang.Object) returned a value. + */ + getCreateCount(): number; + /** + * Obtains the number of times that the queried values are not matched. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @return Returns the number of times that the queried values are not matched. + */ + getMissCount(): number; + /** + * Obtains the number of times that values are evicted from the buffer. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @return Returns the number of times that values are evicted from the buffer. + */ + getRemovalCount(): number; + /** + * Obtains the number of times that the queried values are successfully matched. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @return Returns the number of times that the queried values are successfully matched. + */ + getMatchCount(): number; + /** + * Obtains the number of times that values are added to the buffer. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @return Returns the number of times that values are added to the buffer. + */ + getPutCount(): number; + /** + * Checks whether the current buffer is empty. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @return Returns true if the current buffer contains no value. + */ + isEmpty​(): boolean; + /** + * Obtains the value associated with a specified key. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param key Indicates the key to query. + * @return Returns the value associated with the key if the specified key is present in the buffer; returns null otherwise. + */ + get(key: K): V | undefined; + /** + * Adds a key-value pair to the buffer. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param key Indicates the key to add. + * @param value Indicates the value associated with the key to add. + * @return Returns the value associated with the added key; returns the original value if the key to add already exists. + */ + put(key: K, value: V): V; + /** + * Obtains a list of all values in the current buffer. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @return Returns the list of all values in the current buffer in ascending order, from the most recently accessed to least recently accessed. + */ + values(): V[]; + /** + * Obtains a list of keys for the values in the current buffer. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @return Returns a list of keys sorted from most recently accessed to least recently accessed. + */ + keys​(): K[]; + /** + * Deletes a specified key and its associated value from the current buffer. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param key key + * @return Returns an Optional object containing the deleted key-value pair; returns an empty Optional object if the key does not exist. + */ + remove(key: K): V | undefined; + /** + * Executes subsequent operations after a value is deleted. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param isEvict The parameter value is true if this method is called due to insufficient capacity, and the parameter value is false in other cases. + * @param key Indicates the deleted key. + * @param value Indicates the deleted value. + * @param newValue The parameter value is the new value associated if the put(java.lang.Object,java.lang.Object) method is called and the key to add already exists. The parameter value is null in other cases. + */ + afterRemoval(isEvict: boolean, key: K, value: V, newValue: V): void; + /** + * Checks whether the current buffer contains a specified key. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param key Indicates the key to check. + * @return Returns true if the buffer contains the specified key. + */ + contains​(key: K): boolean; + /** + * Executes subsequent operations if miss to compute a value for the specific key. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param key Indicates the missed key. + * @return Returns the value associated with the key. + */ + createDefault​(key: K): V; + /** + * Returns an array of key-value pairs of enumeratable properties of a given object. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @return Returns an array of key-value pairs for the enumeratable properties of the given object itself. + */ + entries(): IterableIterator<[K, V]>; + /** + * Specifies the default iterator for an object. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @return Returns a two - dimensional array in the form of key - value pairs. + */ + [Symbol.iterator](): IterableIterator<[K, V]>; + } + interface ScopeComparable { + /* The comparison function is used by the scope. */ + compareTo(other: ScopeComparable): boolean; + } + + type ScopeType = ScopeComparable | number; + class Scope{ + /** + * A constructor used to create a Scope instance with the lower and upper bounds specified. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param lowerObj A ScopeType value + * @param upperObj A ScopeType value + */ + constructor(lowerObj: ScopeType, upperObj: ScopeType); + /** + * Obtains a string representation of the current range. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @return Returns a string representation of the current range object. + */ + toString​(): string; + /** + * Returns the intersection of a given range and the current range. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param range A Scope range object + * @return Returns the intersection of a given range and the current range. + */ + intersect(range: Scope): Scope; + /** + * Returns the intersection of the current range and the range specified by the given lower and upper bounds. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param lowerObj A ScopeType value + * @param upperObj A ScopeType value + * @return Returns the intersection of the current range and the range specified by the given lower and upper bounds. + */ + intersect(lowerObj: ScopeType, upperObj: ScopeType): Scope; + /** + * Obtains the upper bound of the current range. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @return Returns the upper bound of the current range. + */ + getUpper(): ScopeType; + /** + * Obtains the lower bound of the current range. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @return Returns the lower bound of the current range. + */ + getLower(): ScopeType; + /** + * Creates the smallest range that includes the current range and the given lower and upper bounds. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param lowerObj A ScopeType value + * @param upperObj A ScopeType value + * @return Returns the smallest range that includes the current range and the given lower and upper bounds. + */ + expand(lowerObj: ScopeType, upperObj: ScopeType): Scope; + /** + * Creates the smallest range that includes the current range and a given range. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param range A Scope range object + * @return Returns the smallest range that includes the current range and a given range. + */ + expand(range: Scope): Scope; + /** + * Creates the smallest range that includes the current range and a given value. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param value A ScopeType value + * @return Returns the smallest range that includes the current range and a given value. + */ + expand(value: ScopeType): Scope; + /** + * Checks whether a given value is within the current range. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param range A ScopeType range + * @return If the value is within the current range return true,oherwise return false. + */ + contains(value: ScopeType): boolean; + /** + * Checks whether a given range is within the current range. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param value A Scope value + * @return If the current range is within the given range return true,oherwise return false. + */ + contains(range: Scope): boolean; + /** + * Clamps a given value to the current range. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param value A ScopeType value + * @return Returns a ScopeType object that a given value is clamped to the current range.. + */ + clamp(value: ScopeType): ScopeType; + } + + class Base64{ + /** + * Constructor for creating base64 encoding and decoding + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param No input parameter is required. + * @return No return value. + */ + constructor(); + /** + * Encodes all bytes from the specified u8 array into a newly-allocated u8 array using the Base64 encoding scheme. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param value A Uint8Array value + * @param value A number value + * @return Return the encoded new Uint8Array. + */ + encode(src: Uint8Array): Uint8Array; + /** + * Encodes the specified byte array into a String using the Base64 encoding scheme. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param value A Uint8Array value + * @return Return the encoded string. + */ + encodeToString(src: Uint8Array): string; + /** + * Decodes a Base64 encoded String or input u8 array into a newly-allocated u8 array using the Base64 encoding scheme. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param value A Uint8Array value or value A string value + * @return Return the decoded Uint8Array. + */ + decode(src: Uint8Array | string): Uint8Array; + /** + * Asynchronously encodes all bytes in the specified u8 array into the newly allocated u8 array using the Base64 encoding scheme. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param value A Uint8Array value + * @return Return the encodes asynchronous new Uint8Array. + */ + encodeAsync(src: Uint8Array): Promise; + /** + * Asynchronously encodes the specified byte array into a String using the Base64 encoding scheme. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param value A Uint8Array value + * @return Returns the encoded asynchronous string. + */ + encodeToStringAsync(src: Uint8Array): Promise; + /** + * Use the Base64 encoding scheme to asynchronously decode a Base64-encoded string or input u8 array into a newly allocated u8 array. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param value A Uint8Array value or value A string value + * @return Return the decoded asynchronous Uint8Array. + */ + decodeAsync(src: Uint8Array | string): Promise; + } +} export default util; \ No newline at end of file diff --git a/api/@ohos.xml.d.ts b/api/@ohos.xml.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..641e4ea0d21134ceaed9fd5fb8c465fd09116b9d --- /dev/null +++ b/api/@ohos.xml.d.ts @@ -0,0 +1,223 @@ +/* + * Copyright (c) 2021 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. + */ + +/** + * The xml module provides utilities for converting XML text to Javascript object. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @devices phone, tablet + * @import import xml from '@ohos.xml'; + * @permission N/A + */ +declare namespace xml { + class DefaultKey { + /** + * default Name of the declaration property key in the output object. + * @since 8 + * @sysCap SystemCapability.CCRuntime + */ + readonly declarationKey = "_declaration"; + /** + * default Name of the instruction property key in the output object. + * @since 8 + * @sysCap SystemCapability.CCRuntime + */ + readonly instructionKey = "_instruction"; + /** + * default Name of the attributes property key in the output object. + * @since 8 + * @sysCap SystemCapability.CCRuntime + */ + readonly attributesKey = "_attributes"; + /** + * default Name of the text property key in the output object. + * @since 8 + * @sysCap SystemCapability.CCRuntime + */ + readonly textKey = "_text"; + /** + * default Name of the cdata property key in the output object. + * @since 8 + * @sysCap SystemCapability.CCRuntime + */ + readonly cdataKey = "_cdata"; + /** + * default Name of the doctype property key in the output object. + * @since 8 + * @sysCap SystemCapability.CCRuntime + */ + readonly doctypeKey = "_doctype"; + /** + * default Name of the comment property key in the output object. + * @since 8 + * @sysCap SystemCapability.CCRuntime + */ + readonly commentKey = "_comment"; + /** + * default Name of the parent property key in the output object. + * @since 8 + * @sysCap SystemCapability.CCRuntime + */ + readonly parentKey = "_parent"; + /** + * default Name of the type property key in the output object. + * @since 8 + * @sysCap SystemCapability.CCRuntime + */ + readonly typeKey = "_type"; + /** + * default Name of the name property key in the output object. + * @since 8 + * @sysCap SystemCapability.CCRuntime + */ + readonly nameKey = "_name"; + /** + * default Name of the elements property key in the output object. + * @since 8 + * @sysCap SystemCapability.CCRuntime + */ + readonly elementsKey = "_elements"; + } + + interface ConvertOptions { + /** + * Whether to trim whitespace characters that may exist before and after the text, default false. + * @since 8 + * @sysCap SystemCapability.CCRuntime + */ + trim: boolean; + /** + * Whether to ignore writing declaration directives of xml. + * @since 8 + * @sysCap SystemCapability.CCRuntime + */ + ignoreDeclaration?: boolean; + /** + * Whether to ignore writing processing instruction of xml. + * @since 8 + * @sysCap SystemCapability.CCRuntime + */ + ignoreInstruction?: boolean; + /** + * Whether to print attributes across multiple lines and indent them. + * @since 8 + * @sysCap SystemCapability.CCRuntime + */ + ignoreAttributes?: boolean; + /** + * Whether to ignore writing comments of the elements. + * @since 8 + * @sysCap SystemCapability.CCRuntime + */ + ignoreComment?: boolean; + /** + * Whether to ignore writing CData of the elements. + * @since 8 + * @sysCap SystemCapability.CCRuntime + */ + ignoreCdata?: boolean; + /** + * Whether to ignore writing Doctype of the elements. + * @since 8 + * @sysCap SystemCapability.CCRuntime + */ + ignoreDoctype?: boolean; + /** + * Whether to ignore writing texts of the elements. + * @since 8 + * @sysCap SystemCapability.CCRuntime + */ + ignoreText?: boolean; + /** + * Name of the property key which will be used for the declaration. + * @since 8 + * @sysCap SystemCapability.CCRuntime + */ + declarationKey: string; + /** + * Name of the property key which will be used for the processing instruction. + * @since 8 + * @sysCap SystemCapability.CCRuntime + */ + instructionKey: string; + /** + * Name of the property key which will be used for the attributes. + * @since 8 + * @sysCap SystemCapability.CCRuntime + */ + attributesKey: string; + /** + * Name of the property key which will be used for the text. + * @since 8 + * @sysCap SystemCapability.CCRuntime + */ + textKey: string; + /** + * Name of the property key which will be used for the cdata. + * @since 8 + * @sysCap SystemCapability.CCRuntime + */ + cdataKey: string; + /** + * Name of the property key which will be used for the doctype. + * @since 8 + * @sysCap SystemCapability.CCRuntime + */ + doctypeKey: string; + /** + * Name of the property key which will be used for the comment. + * @since 8 + * @sysCap SystemCapability.CCRuntime + */ + commentKey: string; + /** + * Name of the property key which will be used for the parent. + * @since 8 + * @sysCap SystemCapability.CCRuntime + */ + parentKey: string; + /** + * Name of the property key which will be used for the type. + * @since 8 + * @sysCap SystemCapability.CCRuntime + */ + typeKey: string; + /** + * Name of the property key which will be used for the name. + * @since 8 + * @sysCap SystemCapability.CCRuntime + */ + nameKey: string; + /** + * Name of the property key which will be used for the elements. + * @since 8 + * @sysCap SystemCapability.CCRuntime + */ + elementsKey: string; + } + + interface ConvertXML { + /** + * To convert XML text to JavaScript object. + * @since 8 + * @sysCap SystemCapability.CCRuntime. + * @param xml The xml text to be converted. + * @param option Option Inputed by user to set. + * @return Returns a JavaScript object converting from XML text. + */ + convert(xml: string, option?: ConvertOptions) : Object; + } +} +export default xml; \ No newline at end of file