diff --git a/README.md b/README.md deleted file mode 100644 index 5c6f8b5693c4c30bd71c14bcc690392f47b74686..0000000000000000000000000000000000000000 --- a/README.md +++ /dev/null @@ -1,8 +0,0 @@ -# Public JS API Repository - -- [Introduction](#section11660541593) - -## Introduction - -This repository is used to submit **d.ts** declaration files of JS APIs. - diff --git a/README_zh.md b/README_zh.md deleted file mode 100644 index 21846d91b8adec8fa349e614fb8dd3fb7ddfc319..0000000000000000000000000000000000000000 --- a/README_zh.md +++ /dev/null @@ -1,8 +0,0 @@ -# API声明文件公共仓 - -- [简介](#section11660541593) - -## 简介 - -JavaScript API 公共仓,用来提交 API d.ts 声明文件。 - diff --git a/api/phone/@ohos.process.d.ts b/api/phone/@ohos.process.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..c22bb4795087e3d407656e06c06fb3504456b7db --- /dev/null +++ b/api/phone/@ohos.process.d.ts @@ -0,0 +1,81 @@ +/* +* 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. +*/ + +declare namespace process { + + export interface ChildProcess { + readonly pid: number; + readonly ppid: number; + readonly exitCode: number; + readonly killed: boolean; + + wait(): Promise; + /** + * Buffer the stdout until EOF and return it as 'Uint8Array' + */ + getOutput(): Promise; + /** + * Buffer the stderr until EOF and return it as 'Uint8Array' + */ + getErrorOutput(): Promise; + /** + * close the target process + */ + close(): void; + /** + * send a signal to process + */ + kill(signo: number): void; + } + /** + * spawns a new ChildProcess to run the command + */ + function runCmd(command: string, options?: RunOptions): ChildProcess; + + function getPid(): number; + function getPpid(): number; + + /** + *abort current process + *@return void + */ + function abort(): void; + + function on(type: string, listener: EventListener): void; + function exit(code:number): void; + + /** + *get current work directory; + */ + function cwd(): string; + + /** + *change current directory + *@param dir + */ + function chdir(dir: string): void; + + function getEgid(): number; + function getEuid(): number; + + function getGid(): number; + function getUid(): number; + function uptime(): number; + + function getGroups(): number[]; + function kill(signal: number, pid: number): boolean; + function off(type: string): boolean; +} +export default process; \ No newline at end of file diff --git a/api/phone/@ohos.url.d.ts b/api/phone/@ohos.url.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..c89206f5d3846355e8f2a9145a79d93c8b423a87 --- /dev/null +++ b/api/phone/@ohos.url.d.ts @@ -0,0 +1,125 @@ +/* +* 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. +*/ + +declare class URLSearchParams { + constructor(init ? : string[][] | Record | string | URLSearchParams +}; + +/** Appends a specified key/value pair as a new search parameter. + */ +append(name: string, value : string) : void; + +/** Delete the given search parameter and its associated value, + * from the list of all search parameters. + */ +delete(name: string) : void; + +/** Returns all the values associated with a given search parameter + * as an array. + */ +getAll(name: string) : string[]; + +/** Returns an iterator allowing to go through all key/value + * pairs contained in this object. + */ +entries() : IterableIterator<[string, string]>; + +/** Allows iteration through all values contained in this object via a callback function. + */ +forEach(callbackfn: (value: string, key : string, parent : this) = > void, thisArg ? : object) : void; + +/** Returns the first value associated to the given search parameter. + */ +get(name: string) : string | null; + +/** Returns a Boolean that indicates whether a parameter with the + * specified name exists. + */ +has(name: string) : boolean; + +/**Sets the value associated with a given search parameter to the + * given value.If there were several matching values, this methods + * deletes the others. If the search parameter doesn't exist, this + * methods creates it. + */ +set(name: string, value : string) : void; + +/** Sort all key/value pairs contained in this object in place and + * return undefined. + */ +sort() : void; + +/** Returns an iterator allowing to go through all keys contained + * in this object. + */ +keys() :IterableIterator; + +/** Returns an iterator allowing to go through all values contained + * in this object. + */ +values() : IterableIterator; + + +/** Returns an iterator allowing to go through all key/value + * pairs contained in this object. + */ +[Symbol.iterator]() : IterableIterator<[string, string]>; + +/** Returns a query string suitable for use in a URL. + */ +toString() :string; +} + +/* web api URL interface */ +declare class URL { + /** constructor of URL + * url:absolute URL string or a relative URL string + * base:base URL string + */ + constructor(url: string, base ? : string | URL); + + /* methods */ + createObjectURL(object: object) : string; + revokeObjectURL(url: string) : void; + toString() : string; + toJSON() : string; + + /* fragment identifier of URL */ +hash: string; + /* domain: port of URL */ +host: string; + /* domain of URL */ +hostname: string; + /* whole URL */ +href: string; + /* contain the origin of the URL, readonly */ + readonly origin : string; + /* password specified before the domain name */ +password: string; + /* an '/' followed by the path of the URL */ +pathname: string; + /* port of the URL */ +port: string; + /* the protocol scheme of the URL, readonly */ +protocol: string; + /* indicating the parameter string of the URL */ +search: string; + /* URLSearchParams object which used to access the individual query parameters */ + readonly searchParams : URLSearchParams; + /* the username before the domain name */ +username: string; +} + +export {URL, URLSearchParams}; \ No newline at end of file diff --git a/api/phone/@ohos.util.d.ts b/api/phone/@ohos.util.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..7b3aeceaae2f37cf2cc572bbbd0b2d262f048b5c --- /dev/null +++ b/api/phone/@ohos.util.d.ts @@ -0,0 +1,82 @@ +/* +* 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. +*/ +declare namespace util { + /** return a formatted string using the first argument as a printf-like format. */ + /** %s: String will be used to convert all values except BigInt, Object and -0. BigInt values will + be represented with an n and Objects that have no user defined toString function are inspected using + util.inspect() with options { depth: 0, colors: false, compact: 3 }. + %d: Number will be used to convert all values except BigInt and Symbol. + %i: parseInt(value, 10) is used for all values except BigInt and Symbol. + %f: parseFloat(value) is used for all values except Bigint and Symbol. + %j: JSON. Replaced whith the string '[Circular]' if the argument contains circular references. + %o: Object. A string representation of an object with generic JavaScript object formatting. + Similar to 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. + 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. + %%: single percent sign ('%'). This does not consume an argument. + Returns: The formatted string */ + function printf(format: string, ...args: Object[]): string; + + /** return the string name of a system errno*/ + function getErrorString(errno: number): string; + + /** Takes an async function (or a function that returns a Promise) and returns a function following the + error-first callback style */ + function callbackWrapper(original: Function): (err: Object, value: Object) => void; + + /** Takes a function following the common error-first callback style, i.e taking an (err, value) => ... + callback as the last argument, and return a version that returns promises */ + function promiseWrapper(original: (err: Object, value: Object) => void): Object; + + /** + * encoding name: support full encoding in ICU data utf-8 utf-16 iso8859 must support in all device + */ + class TextDecoder { + /** the source encoding's name, lowercased. */ + readonly encoding: string; + /** Returns `true` if error mode is "fatal", and `false` otherwise. */ + readonly fatal: boolean; + /** Returns `true` if ignore BOM flag is set, and `false` otherwise. */ + readonly ignoreBOM = false; + constructor( + encoding?: string, + options?: { fatal?: boolean; ignoreBOM?: boolean }, + ); + /** Returns the result of running encoding's decoder. */ + decode(input?: ArrayBuffer | ArrayBufferView, options?: { stream?: false }): string; + } + /** + * TextEncoder takes a stream of code points as input and emits a stream of UTF-8 bytes. + */ + class TextEncoder { + readonly encoding = "utf-8"; + + constructor(); + + /** Returns the result of encoder. */ + encode(input?: string): Uint8Array; + + /** encode string, write the result to dest array */ + encodeInto( + input: string, + dest: Uint8Array, + ): { read: number; written: number }; + } +} + +export default util; \ No newline at end of file