diff --git a/api/@ohos.process.d.ts b/api/@ohos.process.d.ts index c960ef96ada4a88c483e97e7f7fa58c755fd363b..575b00e27cf81f677a7591a2fbc061971c257af2 100644 --- a/api/@ohos.process.d.ts +++ b/api/@ohos.process.d.ts @@ -61,11 +61,11 @@ declare namespace process { readonly killed: boolean; /** - * return 'number' is the targer process exit code + * return 'number' is the target process exit code * @since 7 * @sysCap SystemCapability.CCRuntime * @systemapi Hide this for inner system use - * @return return the targer process exit code. + * @return return the target process exit code. */ wait(): Promise; @@ -162,11 +162,11 @@ declare namespace process { * @since 7 * @sysCap SystemCapability.CCRuntime * @systemapi Hide this for inner system use - * @return return The pid of the current child processs. + * @return return The pid of the current child process. */ const ppid: number; - - /** + + /** * Returns the tid of the current thread. * @since 8 * @sysCap SystemCapability.CCRuntime @@ -174,7 +174,7 @@ declare namespace process { */ const tid: number; - /** + /** * Returns a boolean whether the process is isolated. * @since 8 * @sysCap SystemCapability.CCRuntime @@ -199,7 +199,7 @@ declare namespace process { */ function is64Bit(): boolean; - /** + /** * Returns the uid based on the specified user name. * @since 8 * @sysCap SystemCapability.CCRuntime @@ -208,7 +208,7 @@ declare namespace process { */ function getUidForName(v: string): number; - /** + /** * Returns the thread priority based on the specified tid. * @since 8 * @sysCap SystemCapability.CCRuntime @@ -217,7 +217,7 @@ declare namespace process { */ 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 @@ -225,15 +225,15 @@ declare namespace 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[]; + 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 @@ -241,7 +241,7 @@ declare namespace process { */ function getPastCpuTime(): number; - /** + /** * Returns the system configuration at runtime. * @since 8 * @sysCap SystemCapability.CCRuntime @@ -250,7 +250,7 @@ declare namespace process { */ function getSystemConfig(name: number): number; - /** + /** * Returns the system value for environment variables. * @since 8 * @sysCap SystemCapability.CCRuntime @@ -317,7 +317,7 @@ declare namespace process { * @return Return the current work directory. */ function cwd(): string; - + /** * Change current directory * @since 7 diff --git a/api/@ohos.uri.d.ts b/api/@ohos.uri.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..06440d2617ef05ab5f182c32df86d5e0692744d2 --- /dev/null +++ b/api/@ohos.uri.d.ts @@ -0,0 +1,129 @@ +/* +* 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 uri module provides utilities for URI resolution and parsing. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @devices phone, tablet + * @import import uri from '@ohos.uri'; + * @permission N/A + */ +declare namespace uri { + class URI { + /** + * URI constructor, which is used to instantiate a URI object. + * uri: Constructs a URI by parsing a given string. + */ + constructor(uri: string); + + /** + * Returns the serialized URI as a string. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @return Returns the serialized URI as a string. + */ + toString(): string + + /** + * Tests whether this URI is equivalent to other URI objects. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param other URI object to be compared + * @return boolean Tests whether this URI is equivalent to other URI objects. + */ + equals(other: URI): boolean; + + /** + * Indicates whether this URI is an absolute URI. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @return boolean Indicates whether the URI is an absolute URI (whether the scheme component is defined). + */ + checkIsAbsolute(): boolean; + + /** + * Normalize the path of this URI. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @return URI Used to normalize the path of this URI and return a URI object whose path has been normalized. + */ + normalize(): URI; + + /** + * Gets the protocol part of the URI. + * @since 8 + * @sysCap SystemCapability.CCRuntime + */ + scheme: string; + + /** + * Obtains the user information part of the URI. + * @since 8 + * @sysCap SystemCapability.CCRuntime + */ + userinfo: string; + + /** + * Gets the hostname portion of the URI without a port. + * @since 8 + * @sysCap SystemCapability.CCRuntime + */ + host: string; + + /** + * Gets the port portion of the URI. + * @since 8 + * @sysCap SystemCapability.CCRuntime + */ + port: string; + + /** + * Gets the path portion of the URI. + * @since 8 + * @sysCap SystemCapability.CCRuntime + */ + path: string; + + /** + * Gets the query portion of the URI + * @since 8 + * @sysCap SystemCapability.CCRuntime + */ + query: string; + + /** + * Gets the fragment part of the URI. + * @since 8 + * @sysCap SystemCapability.CCRuntime + */ + fragment: string; + + /** + * Gets the decoding permission component part of this URI. + * @since 8 + * @sysCap SystemCapability.CCRuntime + */ + authority: string; + + /** + * Gets the decoding scheme-specific part of the URI. + * @since 8 + * @sysCap SystemCapability.CCRuntime + */ + ssp: string; + } +} +export default uri; \ No newline at end of file diff --git a/api/@ohos.util.d.ts b/api/@ohos.util.d.ts index b8584180af91d7f9c6400c3c85006638a8c809d0..a2e7914b17b8b81655bfa422998c568f20e634a3 100644 --- a/api/@ohos.util.d.ts +++ b/api/@ohos.util.d.ts @@ -34,7 +34,7 @@ declare namespace util { * util.inspect() with options { showHidden: true, showProxy: true}. This will show the full object including * non-enumerable properties and proxies. * %O: Object. A string representation of an object with generic JavaScript object formatting. - * %O: Object. A string representation of an object with generic JavaScript object formatting.Similar to + * %O: Object. A string representation of an object with generic JavaScript object formatting.Similar to * util.inspect() without options. This will show the full object not including non-enumerable properties and * proxies. * %c: CSS. This specifier is ignored and will skip any CSS passed in. @@ -76,28 +76,28 @@ declare namespace util { function promiseWrapper(original: (err: Object, value: Object) => void): Object; class TextDecoder { - /** + /** * the source encoding's name, lowercased. * @since 7 * @sysCap SystemCapability.CCRuntime */ readonly encoding: string; - /** + /** * Returns `true` if error mode is "fatal", and `false` otherwise. * @since 7 * @sysCap SystemCapability.CCRuntime */ readonly fatal: boolean; - /** + /** * Returns `true` if ignore BOM flag is set, and `false` otherwise. * @since 7 * @sysCap SystemCapability.CCRuntime */ readonly ignoreBOM = false; - /** + /** * the textEncoder constructor. * @param 7 * @sysCap SystemCapability.CCRuntime @@ -119,14 +119,14 @@ declare namespace util { } class TextEncoder { - /** + /** * Encoding format. * @since 7 * @sysCap SystemCapability.CCRuntime */ readonly encoding = "utf-8"; - - /** + + /** * the textEncoder constructor. * @since 7 * @sysCap SystemCapability.CCRuntime @@ -147,19 +147,19 @@ declare namespace util { * @since 7 * @sysCap SystemCapability.CCRuntime * @param input The string to be encoded. - * @param dest decoded numbers in accordance with the format + * @param dest decoded numbers in accordance with the format * @return returns Returns the object, where read represents - * the number of characters that have been encoded, and written - * represents the number of bytes occupied by the encoded characters. + * the number of characters that have been encoded, and written + * represents the number of bytes occupied by the encoded characters. */ encodeInto( input: string, dest: Uint8Array, ): { read: number; written: number }; } - - class RationalNumber​ { - /** + + class RationalNumber​ { + /** * A constructor used to create a RationalNumber instance with a given numerator and denominator. * @since 8 * @sysCap SystemCapability.CCRuntime @@ -174,7 +174,7 @@ declare namespace util { * @param String Expression of Rational Numbers * @return Returns a RationalNumber object generated based on the given string. */ - static createRationalFromString​(rationalString: string): RationalNumber​; + static createRationalFromString​(rationalString: string): RationalNumber​; /** * Compares the current RationalNumber object to the given object. * @since 8 @@ -190,14 +190,14 @@ declare namespace util { * @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; - /** + 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; + valueOf(): number; /** * Get the greatest common divisor of two integers. * @since 8 @@ -206,7 +206,7 @@ declare namespace util { * @param number2 is an integer. * @return Returns the greatest common divisor of two integers, integer type. */ - static getCommonDivisor​(number1: number, number2: number): number; + static getCommonDivisor​(number1: number, number2: number): number; /** * Gets the denominator of the current object. * @since 8 @@ -220,7 +220,7 @@ declare namespace util { * @sysCap SystemCapability.CCRuntime * @return Returns the numerator​ of the current object. */ - getNumerator​(): number; + getNumerator​(): number; /** * Checks whether the current RationalNumber object represents an infinite value. * @since 8 @@ -234,7 +234,7 @@ declare namespace util { * @sysCap SystemCapability.CCRuntime * @return If both the denominator and numerator are 0, true is returned. Otherwise, false is returned. */ - isNaN​(): boolean; + isNaN​(): boolean; /** * Checks whether the current RationalNumber object represents the value 0. * @since 8 @@ -250,13 +250,13 @@ declare namespace util { */ toString​(): string; } - - class LruBuffer { - /** + + 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. + * @param capacity Indicates the capacity to customize for the buffer. */ constructor(capacity?:number); /** @@ -265,7 +265,7 @@ declare namespace util { * @sysCap SystemCapability.CCRuntime * @param newCapacity Indicates the new capacity to set. */ - updateCapacity(newCapacity: number):void + updateCapacity(newCapacity: number):void /** *Returns a string representation of the object. * @since 8 @@ -279,20 +279,20 @@ declare namespace util { * @sysCap SystemCapability.CCRuntime * @return Returns the total number of values in the current buffer. */ - size():number + length:number /** * Obtains the capacity of the current buffer. * @since 8 * @sysCap SystemCapability.CCRuntime * @return Returns the capacity of the current buffer. */ - capacity(): number; + getCapacity(): number; /** * Clears key-value pairs from the current buffer. * @since 8 * @sysCap SystemCapability.CCRuntime */ - clear(): void; + clear(): void; /** * Obtains the number of times createDefault(Object) returned a value. * @since 8 @@ -306,7 +306,7 @@ declare namespace util { * @sysCap SystemCapability.CCRuntime * @return Returns the number of times that the queried values are not matched. */ - getMissCount(): number; + getMissCount(): number; /** * Obtains the number of times that values are evicted from the buffer. * @since 8 @@ -320,7 +320,7 @@ declare namespace util { * @sysCap SystemCapability.CCRuntime * @return Returns the number of times that the queried values are successfully matched. */ - getMatchCount(): number; + getMatchCount(): number; /** * Obtains the number of times that values are added to the buffer. * @since 8 @@ -334,7 +334,7 @@ declare namespace util { * @sysCap SystemCapability.CCRuntime * @return Returns true if the current buffer contains no value. */ - isEmpty​(): boolean; + isEmpty​(): boolean; /** * Obtains the value associated with a specified key. * @since 8 @@ -351,7 +351,7 @@ declare namespace util { * @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; + put(key: K, value: V): V; /** * Obtains a list of all values in the current buffer. * @since 8 @@ -365,12 +365,12 @@ declare namespace util { * @sysCap SystemCapability.CCRuntime * @return Returns a list of keys sorted from most recently accessed to least recently accessed. */ - keys​(): K[]; + keys​(): K[]; /** * Deletes a specified key and its associated value from the current buffer. * @since 8 * @sysCap SystemCapability.CCRuntime - * @param key key + * @param key Indicates the key to delete. * @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; @@ -381,9 +381,9 @@ declare namespace util { * @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. + * @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; + afterRemoval(isEvict: boolean, key: K, value: V, newValue: V): void; /** * Checks whether the current buffer contains a specified key. * @since 8 @@ -399,7 +399,7 @@ declare namespace util { * @param key Indicates the missed key. * @return Returns the value associated with the key. */ - createDefault​(key: K): V; + createDefault​(key: K): V; /** * Returns an array of key-value pairs of enumeratable properties of a given object. * @since 8 @@ -415,14 +415,14 @@ declare namespace util { */ [Symbol.iterator](): IterableIterator<[K, V]>; } - interface ScopeComparable { + interface ScopeComparable { /* The comparison function is used by the scope. */ compareTo(other: ScopeComparable): boolean; } - type ScopeType = ScopeComparable | number; + type ScopeType = ScopeComparable | number; - class Scope{ + class Scope{ /** * A constructor used to create a Scope instance with the lower and upper bounds specified. * @since 8 @@ -437,7 +437,7 @@ declare namespace util { * @sysCap SystemCapability.CCRuntime * @return Returns a string representation of the current range object. */ - toString​(): string; + toString​(): string; /** * Returns the intersection of a given range and the current range. * @since 8 @@ -454,7 +454,7 @@ declare namespace util { * @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; + intersect(lowerObj: ScopeType, upperObj: ScopeType): Scope; /** * Obtains the upper bound of the current range. * @since 8 @@ -468,7 +468,7 @@ declare namespace util { * @sysCap SystemCapability.CCRuntime * @return Returns the lower bound of the current range. */ - getLower(): ScopeType; + getLower(): ScopeType; /** * Creates the smallest range that includes the current range and the given lower and upper bounds. * @since 8 @@ -484,31 +484,31 @@ declare namespace util { * @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; + */ + 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. + * @return If the value is within the current range return true,otherwise return false. */ - contains(value: ScopeType): boolean; + 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. - */ + * @return If the current range is within the given range return true,otherwise return false. + */ contains(range: Scope): boolean; /** * Clamps a given value to the current range. @@ -516,11 +516,11 @@ declare namespace util { * @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{ + class Base64{ /** * Constructor for creating base64 encoding and decoding * @since 8 @@ -528,55 +528,378 @@ declare namespace util { * @param No input parameter is required. * @return No return value. */ - constructor(); + 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 Uint8Array value * @return Return the encoded new Uint8Array. - */ - encode(src: Uint8Array): Uint8Array; + */ + encodeSync(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 + * @param value A Uint8Array value * @return Return the encoded string. - */ - encodeToString(src: Uint8Array): string; + */ + encodeToStringSync(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 + * @param value A Uint8Array value or value A string value * @return Return the decoded Uint8Array. - */ - decode(src: Uint8Array | string): Uint8Array; + */ + decodeSync(src: Uint8Array | string): Uint8Array; /** - * Asynchronously encodes all bytes in the specified u8 array into the newly allocated u8 array using the Base64 encoding scheme. + * 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 + * @param value A Uint8Array value * @return Return the encodes asynchronous new Uint8Array. - */ - encodeAsync(src: Uint8Array): Promise; + */ + encode(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 + * @param value A Uint8Array value * @return Returns the encoded asynchronous string. */ - encodeToStringAsync(src: Uint8Array): Promise; + encodeToString(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 + * @param value A Uint8Array value or value A string value * @return Return the decoded asynchronous Uint8Array. - */ - decodeAsync(src: Uint8Array | string): Promise; - } + */ + decode(src: Uint8Array | string): Promise; + } + + class types{ + /** + * The types constructor + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param No input parameter is required. + * @return No return value. + */ + constructor(); + /** + * Check whether the entered value is of arraybuffer or sharedarraybuffer type. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param value A ArrayBuffer or SharedArrayBuffer value + * @Returns true if the value is a built-in ArrayBuffer or SharedArrayBuffer instance.. + */ + isAnyArrayBuffer(value: Object): boolean; + /** + * Check whether the type is included in the isAnyArrayBuffer. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param value A included in the isAnyArrayBuffer value + * @return Returns true if the value is an instance of one of the ArrayBuffer views, such as typed array objects or DataView. Equivalent to ArrayBuffer.isView(). + */ + isArrayBufferView(value: Object): boolean; + /** + * Check whether the entered value is an arguments object type. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param value A arguments value + * @return Returns true if the value is an arguments object. + */ + isArgumentsObject(value: Object): boolean; + /** + * Check whether the entered value is of arraybuffer type. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param value A arraybuffer value + * @return Returns true if the value is a built-in ArrayBuffer instance. This does not include SharedArrayBuffer instances. Usually, it is desirable to test for both; See isAnyArrayBuffer() for that. + */ + isArrayBuffer(value: Object): boolean; + /** + * Check whether the value entered is an asynchronous function type. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param value A async function value + * @return Returns true if the value is an async function. This only reports back what the JavaScript engine is seeing; in particular, the return value may not match the original source code if a transpilation tool was used. + */ + isAsyncFunction(value: Object): boolean; + /** + * Check whether the entered value is of bigint64array array type. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param value A BigInt64Array value + * @return Returns true if the value is a BigInt64Array instance. + */ + isBigInt64Array(value: Object): boolean; + /** + * Check whether the entered value is of biguint64array array array type. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param value A BigUint64Array value + * @return Returns true if the value is a BigUint64Array instance. + */ + isBigUint64Array(value: Object): boolean; + /** + * Check whether the entered value is a Boolean object type. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param value A boolean object value + * @return Returns true if the value is a boolean object, e.g. created by new Boolean(). + */ + isBooleanObject(value: Object): boolean; + /** + * Check whether the entered value is a Boolean or number or string or symbol object type. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param value A boxed primitive object value + * @return Returns true if the value is any boxed primitive object, e.g. created by new Boolean(), new String() or Object(Symbol()). + */ + isBoxedPrimitive(value: Object): boolean; + /** + * Check whether the entered value is of DataView type. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param value A DataView value + * @return Returns true if the value is a built-in DataView instance. + */ + isDataView(value: Object): boolean; + /** + * Check whether the entered value is of type date. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param value A Date value + * @return Returns true if the value is a built-in Date instance. + */ + isDate(value: Object): boolean; + /** + * Check whether the entered value is a native external value type. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param value A External value + * @return Returns true if the value is a native External value. + */ + isExternal(value: Object): boolean; + /** + * Check whether the entered value is of float32array array type. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param value A Float32Array value + * @return Returns true if the value is a built-in Float32Array instance. + */ + isFloat32Array(value: Object): boolean; + /** + * Check whether the entered value is of float64array array type. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param value A Float64Array value + * @return Returns true if the value is a built-in Float64Array instance. + */ + isFloat64Array(value: Object): boolean; + /** + * Check whether the input value is a generator function type. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param value A generator function value + * @return Returns true if the value is a generator function. This only reports back what the JavaScript engine is seeing; in particular, the return value may not match the original source code if a transpilation tool was used. + */ + isGeneratorFunction(value: Object): boolean; + /** + * Check whether the entered value is a generator object type. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param value A generator object value + * @return Returns true if the value is a generator object as returned from a built-in generator function. This only reports back what the JavaScript engine is seeing; in particular, the return value may not match the original source code if a transpilation tool was used. + */ + isGeneratorObject(value: Object): boolean; + /** + * Check whether the entered value is of int8array array type. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param value A Int8Array value + * @return Returns true if the value is a built-in Int8Array instance. + */ + isInt8Array(value: Object): boolean; + /** + * Check whether the entered value is the int16array type. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param value A Int16Array value + * @return Returns true if the value is a built-in Int16Array instance. + */ + isInt16Array(value: Object): boolean; + /** + * Check whether the entered value is the int32array array type. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param value A Int32Array value + * @return Returns true if the value is a built-in Int32Array instance. + */ + isInt32Array(value: Object): boolean; + /** + * Check whether the entered value is of map type. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param value A Map value + * @return Returns true if the value is a built-in Map instance. + */ + isMap(value: Object): boolean; + /** + * Check whether the entered value is the iterator type of map. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param value A Map iterator value + * @return Returns true if the value is an iterator returned for a built-in Map instance. + */ + isMapIterator(value: Object): boolean; + /** + * Check whether the entered value is the module namespace object object type. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param value A Module Namespace Object value + * @return Returns true if the value is an instance of a Module Namespace Object. + */ + isModuleNamespaceObject(value: Object): boolean; + /** + * Check whether the value entered is of type error. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param value A Error value + * @return Returns true if the value is an instance of a built-in Error type. + */ + isNativeError(value: Object): boolean; + /** + * Check whether the entered value is of the number object type. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param value A number object value + * @return Returns true if the value is a number object, e.g. created by new Number(). + */ + isNumberObject(value: Object): boolean; + /** + * Check whether the entered value is of promise type. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param value A Promise value + * @return Returns true if the value is a built-in Promise. + */ + isPromise(value: Object): boolean; + /** + * Check whether the value entered is of proxy type. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param value A Proxy value + * @return Returns true if the value is a Proxy instance. + */ + isProxy(value: Object): boolean; + /** + * Check whether the entered value is of type regexp. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param value A regular expression object value + * @return Returns true if the value is a regular expression object. + */ + isRegExp(value: Object): boolean; + /** + * Check whether the entered value is of type set. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param value A Set instance value + * @return Returns true if the value is a built-in Set instance. + */ + isSet(value: Object): boolean; + /** + * Check whether the entered value is the iterator type of set. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param value A Set iterator value + * @return Returns true if the value is an iterator returned for a built-in Set instance. + */ + isSetIterator(value: Object): boolean; + /** + * Check whether the entered value is of type sharedarraybuffer. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param value A SharedArrayBuffer instance value + * @return Returns true if the value is a built-in SharedArrayBuffer instance. This does not include ArrayBuffer instances. Usually, it is desirable to test for both; See isAnyArrayBuffer() for that. + */ + isSharedArrayBuffer(value: Object): boolean; + /** + * Check whether the entered value is a string object type. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param value A String object value + * @return Returns true if the value is a string object, e.g. created by new String(). + */ + isStringObject(value: Object): boolean; + /** + * Check whether the entered value is a symbol object type. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param value A symbol object value + * @return Returns true if the value is a symbol object, created by calling Object() on a Symbol primitive. + */ + isSymbolObject(value: Object): boolean; + /** + * Check whether the entered value is a type contained in typedarray. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param value A TypedArray instance value + * @return Returns true if the value is a built-in TypedArray instance. + */ + isTypedArray(value: Object): boolean; + /** + * Check whether the entered value is the uint8array array type. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param value A Uint8Array value + * @return Returns true if the value is a built-in Uint8Array instance. + */ + isUint8Array(value: Object): boolean; + /** + * Check whether the entered value is the uint8clapedarray array type. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param value A Uint8ClampedArray value + * @return Returns true if the value is a built-in Uint8ClampedArray instance. + */ + isUint8ClampedArray(value: Object): boolean; + /** + * Check whether the entered value is the uint16array array array type. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param value A Uint16Array value + * @return Returns true if the value is a built-in Uint16Array instance. + */ + isUint16Array(value: Object): boolean; + /** + * Check whether the entered value is the uint32array array type. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param value A Uint32Array value + * @return Returns true if the value is a built-in Uint32Array instance. + */ + isUint32Array(value: Object): boolean; + /** + * Check whether the entered value is of type weakmap. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param value A WeakMap value + * @return Returns true if the value is a built-in WeakMap instance. + */ + isWeakMap(value: Object): boolean; + /** + * Check whether the entered value is of type weakset. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param value A WeakSet value + * @return Returns true if the value is a built-in WeakSet instance. + */ + isWeakSet(value: Object): boolean; + } } export default util; \ No newline at end of file diff --git a/api/@ohos.worker.d.ts b/api/@ohos.worker.d.ts index 1ae39b267c033e7dd0e8d0f5e5e1bf35743026e7..e8b3582e1d24775e9252104311c1fe5cadd32d22 100644 --- a/api/@ohos.worker.d.ts +++ b/api/@ohos.worker.d.ts @@ -348,7 +348,7 @@ declare namespace worker { /** * Adds an event listener to the worker - * and removes the event listener automically after it is invoked once. + * and removes the event listener automatically after it is invoked once. * @param type Type of the event to listen for * @param listener Callback to invoke when an event of the specified type occurs * @devices phone, tablet, wearable diff --git a/api/@ohos.xml.d.ts b/api/@ohos.xml.d.ts index 641e4ea0d21134ceaed9fd5fb8c465fd09116b9d..33237bc5ec91bcdb49de223a5d3d6ebee2902564 100644 --- a/api/@ohos.xml.d.ts +++ b/api/@ohos.xml.d.ts @@ -1,223 +1,400 @@ -/* - * 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; - } -} +/* + * 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, XML generation and parsing. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @devices phone, tablet + * @import import xml from '@ohos.xml'; + * @permission N/A + */ +declare namespace xml { + 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 Inputted by user to set. + * @return Returns a JavaScript object converting from XML text. + */ + convert(xml: string, options?: ConvertOptions) : Object; + } + + class XmlSerializer { + /** + * A parameterized constructor used to create a new XmlSerializer instance. + * As the input parameter of the constructor function, init supports three types. + * The input parameter is an Arrarybuff. + * The input parameter is a DataView. + * The input parameter is an encoding format of string type. + */ + constructor(buffer: ArrayBuffer | DataView, encoding?: string); + + /** + * Write an attribute. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param name Key name of the attribute. + * @param value Values of attribute. + */ + setAttributes(name: string, value: string): void; + + /** + * Add an empty element. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param name Key name of the attribute. + * @param value Values of element. + */ + addEmptyElement(name: string): void; + + /** + * Writes xml declaration with encoding. For example: . + * @since 8 + * @sysCap SystemCapability.CCRuntime + */ + setDeclaration(): void; + + /** + * Writes a elemnet start tag with the given name. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param name name of the element. + */ + startElement(name: string): void; + + /** + * Writes end tag of the element. + * @since 8 + * @sysCap SystemCapability.CCRuntime + */ + endElement(): void; + + /** + * Writes the namespace of the current element tag. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param prefix Values name of the prefix. + * @param namespace Values of namespace. + */ + setNamespace(prefix: string, namespace: string): void; + + /** + * Writes the commnet. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param text Values of commnet. + */ + setCommnet(text: string): void; + + /** + * Writes the CDATA. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param text Values of CDATA. + */ + setCData(text: string): void; + + /** + * Writes the text. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param text Values of text. + */ + setText(text: string): void; + + /** + * Writes the DOCTYPE. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param text Values of docType. + */ + setDocType(text: string): void; + } + + enum EventType { + /** + * Start a document. + */ + START_DOCUMENT, + /** + * End a document. + */ + END_DOCUMENT, + /** + * Start a tag. + */ + START_TAG, + /** + * End a tag. + */ + END_TAG, + /** + * Character data. + */ + TEXT, + /** + * A CDATA sections. + */ + CDSECT, + /** + * An XML comment. + */ + COMMENT, + /** + * An XML document type declaration. + */ + DOCDECL, + /** + * An XML processing instruction declaration. + */ + INSTRUCTION, + /** + * An entity reference. + */ + ENTITY_REFERENCE, + /** + * a whitespace. + */ + WHITESPACE, + } + + /** The current parse info. */ + interface ParseInfo { + /** + * The current column number, starting from 1. + */ + getColumnNumber(): number; + /** + * The current depth of the element. + */ + getDepth(): number; + /** + * The current column number, starting from 1. + */ + getLineNumber(): number; + /** + * The current element name. + */ + getName(): string; + /** + * The current element's name. + */ + getNamespace(): string; + /** + * The current element's namespace. + */ + getPrefix(): string; + /** + * The text content of the current event as String. + */ + getText(): string; + /** + * Returns true if the current element is empty. + */ + isEmptyElementTag(): boolean; + /** + * Checks whether the current TEXT event contains only whitespace characters. + */ + isWhitespace(): boolean; + /** + * Returns the number of attributes of the current start tag. + */ + getAttributeCount(): number; + } + + /** parse options for XmlPullParser. */ + interface ParseOptions { + + /** + * Whether to parsing Doctype of the elements. + * @since 8 + * @sysCap SystemCapability.CCRuntime + */ + supportDoctype?: boolean; + + /** + * Whether to ignore parsing texts of the elements. + * @since 8 + * @sysCap SystemCapability.CCRuntime + */ + ignoreNameSpace?: boolean; + + /** + * tag value callback function. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param name The current tag name. + * @param value The current tag value. + * @return Returns a Boolean variable for whether parse continually. + */ + tagValueCallbackFunction?: (name: string, value: string) => boolean; + + /** + * attribute value callback function. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param name The current attribute name. + * @param value The current attribute value. + * @return Returns a Boolean variable for whether parse continually. + */ + attributeValueCallbackFunction?: (name: string, value: string) => boolean; + + /** + * token value callback function. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param eventType The current token eventtype. + * @param value The current token parseinfo. + * @return Returns a Boolean variable for whether parse continually. + */ + tokenValueCallbackFunction?: (eventType: EventType, value: ParseInfo) => boolean; + } + + class XmlPullParser { + /** + * A constructor used to create a new XmlPullParser instance. + */ + constructor(buffer: ArrayBuffer | DataView, encoding?: string); + + /** + * Starts parsing the XML file. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @param option parse options for XmlPullParser, the interface including two Boolean variables and three callback functions. + */ + parse(option: ParseOptions): void; + } +} export default xml; \ No newline at end of file