Switch component name from ts_js_lang_library to ets_utils for js_api_module,js_util_module,js_sys_module,js_worker_module

Related Issue
https://gitee.com/openharmony/manifest/issues/I5HDQT

Description
Switch component name from ts_js_lang_library to ets_utils for js_api_module,js_util_module,js_sys_module,js_worker_module

Signed-off-by: lengchangjing <lengchangjing@huawei.com>
This commit is contained in:
lengchangjing
2022-07-20 15:53:10 +08:00
parent a9a470b3c6
commit 1956f2e85d
62 changed files with 4558 additions and 5282 deletions
View File
+2210
View File
File diff suppressed because it is too large Load Diff
+2211
View File
File diff suppressed because it is too large Load Diff
+68
View File
@@ -0,0 +1,68 @@
{
"name": "@ohos/js_api_module",
"version": "",
"description": "commonlibrary_ets_utils, contains of 4 submodules:js_api_module,js_util_module,js_sys_module,js_worker_module",
"homePage": "https://gitee.com/openharmony",
"license": "Apache V2",
"repository": "https://gitee.com/openharmony/js_api_module",
"domain": "os",
"language": "",
"publishAs": "code-segment",
"private": false,
"scripts": {},
"tags": [
"js"
],
"keywords": [
"ets",
"utils"
],
"envs": {},
"dirs": {},
"author": {
"name": "",
"email": "",
"url": ""
},
"contributors": [
{
"name": "",
"email": "",
"url": ""
}
],
"segment": {
"destPath": "commonlibrary/ets_utils"
},
"component": {
"name": "ets_utils",
"subsystem": "commonlibrary",
"syscap": [],
"features": [],
"adapted_system_type": [],
"rom": "",
"ram": "",
"deps": {
"components": [],
"third_party": []
},
"build": {
"sub_component": [
"//commonlibrary/ets_utils/js_api_module/uri:uri_packages",
"//commonlibrary/ets_utils/js_api_module/url:url_packages",
"//commonlibrary/ets_utils/js_api_module/convertxml:convertxml_packages",
"//commonlibrary/ets_utils/js_api_module/xml:xml_packages",
"//commonlibrary/ets_utils/js_sys_module/process:process_packages",
"//commonlibrary/ets_utils/js_sys_module/dfx:dfx_packages",
"//commonlibrary/ets_utils/js_util_module/util:util_packages",
"//commonlibrary/ets_utils/js_util_module/container:container_packages",
"//commonlibrary/ets_utils/js_worker_module:jsapi_packages"
],
"inner_kits": [],
"test": [
"//commonlibrary/ets_utils/js_api_module/test_uri/unittest:unittest",
"//commonlibrary/ets_utils/js_api_module/test_xml/unittest:unittest"
]
}
}
}
-177
View File
@@ -1,177 +0,0 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
-457
View File
@@ -1,457 +0,0 @@
# js_api_module Subsystem/Component
- [Introduction](#Introduction)
- [Contents](#Contents)
- [Illustrate](#Illustrate)
- [Interface Description](#Interface Description)
- [Instructions for use](#Instructions for use)
- [Related warehouse](#Related warehouse)
## Introduction
The interface of URL is used to parse, construct, normalize, and encode URLs. The constructor of URL creates a new URL object. In order to make changes to the resolved components of the URL or to the URL. The URLSearchParams interface defines some practical methods to process URL query strings.
URI Represents a Uniform Resource Identifier (URI) reference.
XML representation refers to extensible markup language.
The XmlSerializer interface is used to generate an xml file. The constructor of XmlSerializer creates a new XmlSerializer object, and calls the method of the XmlSerializer object to generate an xml file. The XmlPullParser interface is used to parse the existing xml file. The constructor of XmlPullParser creates a new XmlPullParser object, and calls the method of the XmlPullParser object to parse the xml file.
## Contents
```
base/compileruntime/js_api_module/
├── Class:URL # URL class
│ ├── new URL(input[, base]) # Create URL object
│ ├── hash # hash attribute
│ ├── host # host attribute
│ ├── hostname # hostname attribute
│ ├── href # href attribute
│ ├── origin # origin attribute
│ ├── password # password attribute
│ ├── pathname # pathname attribute
│ ├── port # port attribute
│ ├── protocol # protocol attribute
│ ├── search # search attribute
│ ├── searchParams # searchParams attribute
│ ├── username # username attribute
│ ├── toString() # toString method
│ └── toJSON() # toJSON method
├── Class: URLSearchParams # URLSearchParams class
│ ├── new URLSearchParams() # Create URLSearchParams object
│ ├── new URLSearchParams(string) # Create URLSearchParams object
│ ├── new URLSearchParams(obj) # Create URLSearchParams object
│ ├── new URLSearchParams(iterable) # Create URLSearchParams object
│ ├── append(name, value) # append method
│ ├── delete(name) # delete method
│ ├── entries() # entries method
│ ├── forEach(fn[, thisArg]) # forEach method
│ ├── get(name) # get method
│ ├── getAll(name) # getAll method
│ ├── has(name) # has method
│ ├── keys() # keys method
│ ├── set(name, value) # set method
│ ├── sort() # sort method
│ ├── toString() # toString method
│ ├── values() # values method
│ └── urlSearchParams[Symbol.iterator]() # Create URLSearchParams object
├── Class:URI # URI class
│ ├── URI(str: string) # Create URI object
│ ├── scheme # scheme attribute
│ ├── authority # authority attribute
│ ├── ssp # ssp attribute
│ ├── userinfo # userinfo attribute
│ ├── host # host attribute
│ ├── port # port attribute
│ ├── query # query attribute
│ ├── fragment # fragment attribute
│ ├── path # path method
│ ├── equals(ob: Object) # equals method
│ ├── normalize() # normalize method
│ ├── checkIsAbsolute() # checkIsAbsolute method
│ ├── normalize() # normalize method
│ ├── toString() # toString method
├── Class:ConvertXml # ConvertXml class
│ ├── ConvertXml() # Create convertxml class object
│ └── convert(xml: string, options: Object) # convert method
├── Class:XmlSerializer # XmlSerializer class
│ ├── new XmlSerializer(buffer: ArrayBuffer | DataView, encoding?: string) # Create XmlSerializer class object
│ ├── setAttributes(name: string, value: string) # Set Attributes method
│ ├── addEmptyElement(name: string) # Add an empty element method
│ ├── setDeclaration() # Set the Declaration method
│ ├── startElement(name: string) # Set the start element method
│ ├── endElement() # Set the end element method
│ ├── setNamespace(prefix: string, namespace: string) # Namespace method
│ ├── setCommnet(text: string) # Set up Commnet method
│ ├── setCData(text: string) # Set the CData method
│ ├── setText(text: string) # Set the Text method
│ ├── setDocType(text: string) # Set DocType method
└── Class: XmlPullParser # XmlPullParser class
├── new (buffer: ArrayBuffer | DataView, encoding?: string) # Create XmlPullParser object
└── parse(option: ParseOptions) # parse method
```
## Illustrate
### Interface Description
| Interface name | Illustrate |
| -------- | -------- |
| new URL(url: string,base?:string \| URL) | Create and return a URL object that references the URL specified by the absolute URL string, the relative URL string, and the basic URL string. |
| tostring():string | The stringification method returns a USVString containing the complete URL. It is equivalent to the read-only URL.href. |
| toJSON():string | This method returns a USVString, which contains a serialized URL version. |
| new URLSearchParams() | The URLSearchParams() constructor has no parameters. This method creates and returns a new URLSearchParams object. The beginning'?' character will be ignored. |
| new URLSearchParams(string) | The input parameter of URLSearchParams(string) constructor is string data type. This method creates and returns a new URLSearchParams object. The beginning'?' character will be ignored. |
| new URLSearchParams(obj) | URLSearchParams(obj) The input parameter of the constructor is the obj data type. This method creates and returns a new URLSearchParams object. The beginning'?' character will be ignored. |
| new URLSearchParams(iterable) | URLSearchParams(iterable) The input parameter of the constructor is the iterable data type. This method creates and returns a new URLSearchParams object. The beginning'?' character will be ignored. |
| has(name: string): boolean | Retrieve whether the searchParams object contains name. If yes, it returns true, otherwise it returns false. |
| set(name: string, value string): void | Retrieve whether the searchParams object contains a key-value pair whose key is name. If not, add the key-value pair, if any, modify the value corresponding to the first key in the object, and delete the remaining key-value pairs whose key is name. |
| sort(): void | According to the Unicode code point of the key, sort all key/value pairs contained in this object and return undefined. |
| toString(): string | According to the searchParams object, the query string applicable in the URL is returned. |
| keys(): iterableIterator\<string> | Return an iterator, which allows iterating through all the key values contained in the object. |
| values(): iterableIterator\<string> | Returns an iterator, which allows iterating over all the value values contained in the object. |
| append(name: string, value: string): void | Insert the name, value key-value pair in the searchParams object. |
| delete(name: string): void | Traverse the searchParams object, find all the names, and delete the corresponding key-value pairs. |
| get(name: string): string | Retrieve the first name in the searchParams object and return the value corresponding to the name key. |
| getAll(name: string): string[] | Retrieve all names in the searchParams object and return all the values corresponding to the name key. |
| entries(): iterableIterator<[string, string]> | Returns an iterator that allows iterating through all key/value pairs contained in the searchParams object. |
| forEach(): void | Through the callback function to traverse the key-value pairs on the URLSearchParams instance object. |
| urlSearchParams\[Symbol.iterator]() | Returns an ES6 iterator for each name-value pair in the query string. Each item of the iterator is a JavaScript array. |
| URI(str: string) | Construct the URI by parsing the given input parameter (String str). This constructor parses the given string strictly in accordance with the grammatical provisions in RFC 2396 Appendix A. |
| getScheme() | Return the scheme component of this URI, or null if the scheme is not defined. |
| getAuthority() | Returns the decoded authority component of this URI, or null if authority is not defined. The string returned by this method is the same as the string returned by the getRawAuthority method, except that all escaped octet sequences are decoded. |
| getSchemeSpecificPart() | Returns the decoding scheme-specific part of this URI. The string returned by this method is the same as the string returned by the getRawSchemeSpecificPart method, except that all escaped octet sequences are decoded. |
| getUserInfo() | Returns the decoded userinfo component of this URI. The userinfo component of the URI (if defined) only contains characters in unreserved, punctuation, escape, and other categories. |
| getHost() | Return the host component of this URI, or null if host is not defined. |
| getPort() | Return the port of this URI, or -1 if the port is not defined. The port component of the URI (if defined) is a non-negative integer. |
| getQuery() | Returns the decoded query component of this URI, or null if the query is not defined. The string returned by this method is the same as the string returned by the getRawQuery method, except that all escaped octet sequences are decoded. |
| getFragment() | Returns the decoded fragment component of this URI, or null if the fragment is not defined. The string returned by this method is the same as the string returned by the getRawFragment method, except that all escaped octet sequences are decoded. |
| getPath() | Returns the decoded path component of this URI, or null if path is not defined. The string returned by this method is the same as the string returned by the getRawPath method, except that all escaped octet sequences are decoded. |
| equals(ob: Object) | Test whether this URI is equal to another object. If the given object is not a URI, this method immediately returns false. |
| normalize() | Normalize the path of this URI. If this URI is opaque, or its path is already in normal form, then this URI is returned. Otherwise, a new URI identical to this URI will be constructed. |
| checkIsAbsolute() | Determine whether this URI is absolute. If and only if it has a scheme component, the URI is absolute and the return value is true, otherwise the return value is false. |
| toString() | Return the content of this URI as a string. |
| ConvertXml() | The constructor used to construct the convertxml class object. This constructor does not need to pass in parameters. |
| convert(xml: string, options: Object) | Returns a JavaScript object that converts an XML string as required by the option. |
| XmlSerializer(buffer: ArrayBuffer \| DataView, encoding?: string) | Create and return an XmlSerializer object. The XmlSerializer object passes two parameters. The first parameter is ArrayBuffer or DataView, and the second parameter is the file format (UTF-8 by default). |
| setAttributes(name: string, value: string): void | Write the Attributes attribute to the xml file. |
| addEmptyElement(name: string): void | Write an empty element. |
| setDeclaration(): void | Set the Declaration to use the encoding to write the xml declaration. For example: <? xml version="1.0" encoding="utf-8"> |
| startElement(name: string): void | Write the elemnet start tag with the given name.|
| endElement(): void | Write the end tag of the element. |
| setNamespace(prefix: string, namespace: string): void | Write the namespace of the current element tag. |
| setCommnet(text: string): void | Write the comment attribute. |
| setCData(text: string): void | Write the CData attribute. |
| setText(text: string): void | Write the Text property. |
| setDocType(text: string): void | Write the DocType attribute. |
| XmlPullParser(buffer: ArrayBuffer \| DataView, encoding?: string) | Create and return an XmlPullParser object. The XmlPullParser object passes two parameters. The first parameter is ArrayBuffer or DataView, and the second parameter is the file format (default is UTF-8). |
| parse(option: ParseOptions): void | This interface is used to parse xml. The ParseOptions parameter is an interface containing five optional parameters {supportDoctype?: boolea ignoreNameSpace?: boolean tagValueCallbackFunction?: (name: string, value: string) => boolean attributeValueCallbackFunction?: (name: string, value: string) => boolean) tokenValueCallbackFunction?: (eventType: EventType, value: ParseInfo) => boolean }. The input parameter 1 of the tokenValueCallbackFunction callback function is the event type, and the input parameter 2 is the info interface containing get attributes such as getColumnNumber and getDepth. The user can obtain the depth and other information in the current parsing process through methods such as info.getDepth(). |
### Instructions for use
The usage of each interface is as follows:
1、new URL(url: string,base?:string|URL)
```
let b = new URL('https://developer.mozilla.org'); // => 'https://developer.mozilla.org/'
let a = new URL( 'sca/./path/path/../scasa/text', 'http://www.example.com');
// => 'http://www.example.com/sca/path/scasa/text'
```
2、tostring():string
```
const url = new URL('http://10.0xFF.O400.235:8080/directory/file?query#fragment');
url.toString() // => 'http://10.0xff.o400.235:8080/directory/file?query#fragment'
const url = new URL("http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html");
url.toString() // => 'http://[fedc:ba98:7654:3210:fedc:ba98:7654:3210]/index.html'
const url = new URL("http://username:password@host:8080/directory/file?query#fragment");
url.toString() // => 'http://username:password@host:8080/directory/file?query#fragment'
```
3、toJSON():string
```
const url = new URL("https://developer.mozilla.org/en-US/docs/Web/API/URL/toString");
url.toJSON(); // => 'https://developer.mozilla.org/en-US/docs/Web/API/URL/toString'
```
4、new URLSearchParams()
```
let params = new URLSearchParams('foo=1&bar=2');
```
5、new URLSearchParams(string)
```
params = new URLSearchParams('user=abc&query=xyz');
console.log(params.get('user'));
// Prints 'abc'
```
6、new URLSearchParams(obj)
```
const params = new URLSearchParams({
user: 'abc',
query: ['first', 'second']
});
console.log(params.getAll('query'));
// Prints [ 'first,second' ]
```
7、new URLSearchParams(iterable)
```
let params;
// Using an array
params = new URLSearchParams([
['user', 'abc'],
['query', 'first'],
['query', 'second'],
]);
console.log(params.toString());
// Prints 'user = abc & query = first&query = second'
```
8、has(name: string): boolean
```
console.log(params.has('bar')); // =>true
```
9、set(name: string, value string): void
```
params.set('baz', 3);
```
10、sort(): void
```
params .sort();
```
11、toString(): string
```
console.log(params .toString()); // =>bar=2&baz=3&foo=1'
```
12、keys(): iterableIterator\<string>
```
for(var key of params.keys()) {
console.log(key);
} // =>bar baz foo
```
13、values(): iterableIterator\<string>
```
for(var value of params.values()) {
console.log(value);
} // =>2 3 1
```
14、append(name: string, value: string): void
```
params.append('foo', 3); // =>bar=2&baz=3&foo=1&foo=3
```
15、delete(name: string): void
```
params.delete('baz'); // => bar=2&foo=1&foo=3
```
16、get(name: string): string
```
params.get('foo'); // => 1
```
17、getAll(name: string): string[]
```
params.getAll('foo'); // =>[ '1', '3' ]
```
18、entries(): iterableIterator<[string, string]>
```
for(var pair of searchParams.entries()) {
console.log(pair[0]+ ', '+ pair[1]);
} // => bar, 2 foo, 1 foo, 3
```
19、forEach(): void
```
url.searchParams.forEach((value, name, searchParams) => {
console.log(name, value, url.searchParams === searchParams);
});
// => foo 1 true
// => bar 2 true
```
20、urlSearchParams[Symbol.iterator] ()
```
const params = new URLSearchParams('foo=bar&xyz=baz');
for (const [name, value] of params) {
console.log(name, value);
}
// Prints:
// foo bar
// xyz bar
```
21、URI(String str)
```
let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
```
22、scheme
```
let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
gaogao.scheme // => "http";
```
23、authority
```
let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
gaogao.authority // => "gg:gaogao@www.baidu.com:99";
```
24、ssp
```
let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
gaogao.ssp " // => gg:gaogao@www.baidu.com:99/path/path?query";
```
25、userinfo
```
let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
gaogao.userinfo // => "gg:gaogao";
```
26、host
```
let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
gaogao.host // => "www.baidu.com";
```
27、port
```
let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
gaogao.port // => "99";
```
28、query
```
let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
gaogao.query // => "query";
```
29、fragment
```
let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
gaogao.fragment // => "fagment";
```
30、path
```
let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
gaogao.path // => "/path/path";
```
31、equals(Object ob)
```
let gaogao = new Uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/path1?query#fagment');
let gaogao1 = gaogao;
let res = gaogao.equals(gaogao1);
console.log(res); // => true;
```
32、normalize()
```
let gaogao = new Uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/path/66./../././mm/.././path1?query#fagment');
let res = gaogao.normalize();
console.log(res.path); // => "/path/path1"
console.log(res.toString()); // => "http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/path/path1?query#fagment"
```
33、checkIsAbsolute()
```
let gaogao = new Uri.URI('f/tp://username:password@www.baidu.com:88/path?query#fagment');
let res = gaogao.checkIsAbsolute();
console.log(res); //=> false;
```
34、toString()
```
let gaogao = new Uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/../../path/.././../aa/bb/cc?query#fagment');
let res = gaogao.toString();
console.log(res.toString()); // => 'http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/../../path/.././../aa/bb/cc?query#fagment';
```
35、ConvertXml()
```
var convertml = new convertXml.ConvertXml();
```
36、convert(xml: string, options: Object)
```
var result = convertml.convert(xml, {compact: false, spaces: 4});
```
37、new XmlSerializer(buffer: ArrayBuffer | DataView, encoding?: string)
```
var arrayBuffer = new ArrayBuffer(1024);
var bufView = new DataView(arrayBuffer);
var thatSer = new xml.XmlSerializer(bufView);
```
38、setDeclaration()void
```
var thatSer = new xml.XmlSerializer(bufView);
thatSer.setDeclaration() // => <?xml version="1.0" encoding="utf-8"?>;
```
39、setCommnet(text: string):void
```
var thatSer = new xml.XmlSerializer(bufView);
thatSer.setCommnet("Hello, World!"); // => <!--Hello, World!-->;
```
40、setCData(text: string) :void
```
var thatSer = new xml.XmlSerializer(bufView);
thatSer.setDocType('root SYSTEM "http://www.test.org/test.dtd"'); // => <![CDATA[root SYSTEM \“http://www.test.org/test.dtd\”]]>
```
41、setDocType(text: string):void
```
var thatSer = new xml.XmlSerializer(bufView);
thatSer.setDocType("foo"); // => <!DOCTYPE foo>
```
42、setNamespace(prefix: string, namespace: string): void
43、startElement(name: string): void
44、setAttributes(name: string, value: string): void
45、endElement(): void
46、setText(text: string): void
```
var thatSer = new xml.XmlSerializer(bufView);
thatSer.setNamespace("h", "http://www.w3.org/TR/html4/");
thatSer.startElement("table");
thatSer.setAttributes("importance", "high");
thatSer.setText("Happy");
endElement(); // => <h:table importance="high" xmlns:h="http://www.w3.org/TR/html4/">Happy</h:table>
```
47、addEmptyElement(name: string): void
```
var thatSer = new xml.XmlSerializer(bufView);
thatSer.addEmptyElement("b"); // => <b/>
```
48、new (buffer: ArrayBuffer | DataView, encoding?: string)
```
var strXml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
' <title>Happy</title>' +
'</note>';
var arrayBuffer = new ArrayBuffer(strXml.length*2);
var bufView = new Uint8Array(arrayBuffer);
var strLen = strXml.length;
for (var i = 0; i < strLen; ++i) {
bufView[i] = strXml.charCodeAt(i);//设置arraybuffer 方式
}
var that = new xml.XmlPullParser(arrayBuffer);
```
49、parse(option: ParseOptions): void
```
var strXml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
' <title>Happy</title>' +
'</note>';
var arrayBuffer = new ArrayBuffer(strXml.length*2);
var bufView = new Uint8Array(arrayBuffer);
var strLen = strXml.length;
for (var i = 0; i < strLen; ++i) {
bufView[i] = strXml.charCodeAt(i);
}
var that = new xml.XmlPullParser(arrayBuffer);
var arrTag = {};
arrTag[0] = '132';
var i = 1;
function func(key, value){
arrTag[i] = 'key:'+key+' value:'+ value.getDepth();
i++;
return true;
}
var options = {supportDoctype:true, ignoreNameSpace:true, tokenValueCallbackFunction:func};
that.parse(options);
```
## Related warehouse
[js_api_module Subsystem](base/compileruntime/js_api_module-readme.md)
## License
URL is available under [Mozilla license](https://www.mozilla.org/en-US/MPL/), and the documentation is detailed in [documentation](https://gitee.com/openharmony/js_api_module/blob/master/mozilla_docs.txt). See [LICENSE](https://gitee.com/openharmony/js_api_module/blob/master/LICENSE) for the full license text.
-456
View File
@@ -1,456 +0,0 @@
# js_api_module子系统/组件
- [简介](#简介)
- [目录](#目录)
- [说明](#说明)
- [接口说明](#接口说明)
- [使用说明](#使用说明)
- [相关仓](#相关仓)
## 简介
URL接口用于解析,构造,规范化和编码 URLs。 URL的构造函数创建新的URL对象。 以便对URL的已解析组成部分或对URL进行更改。URLSearchParams 接口定义了一些实用的方法来处理 URL 的查询字符串。
URI表示统一资源标识符引用。
xml表示指可扩展标记语言。
XmlSerializer接口用于生成一个xml文件。 XmlSerializer的构造函数创建新的XmlSerializer对象,调用XmlSerializer对象的方法生成一个xml文件。XmlPullParser 接口用于解析已有的xml文件,XmlPullParser的构造函数创建新的XmlPullParser对象,调用XmlPullParser对象的方法解析xml。
## 目录
```
base/compileruntime/js_api_module/
├── Class:URL # URL类
│ ├── new URL(input[, base]) # 创建URL对象
│ ├── hash # hash属性
│ ├── host # host属性
│ ├── hostname # hostname属性
│ ├── href # href属性
│ ├── origin # origin属性
│ ├── password # password属性
│ ├── pathname # pathname属性
│ ├── port # port属性
│ ├── protocol # protocol属性
│ ├── search # search属性
│ ├── searchParams # searchParams属性
│ ├── username # username属性
│ ├── toString() # toString方法
│ └── toJSON() # toJSON方法
├── Class: URLSearchParams # URLSearchParams类
│ ├── new URLSearchParams() # 创建URLSearchParams对象
│ ├── new URLSearchParams(string) # 创建URLSearchParams对象
│ ├── new URLSearchParams(obj) # 创建URLSearchParams对象
│ ├── new URLSearchParams(iterable) # 创建URLSearchParams对象
│ ├── append(name, value) # append方法
│ ├── delete(name) # delete方法
│ ├── entries() # entries方法
│ ├── forEach(fn[, thisArg]) # forEach方法
│ ├── get(name) # get方法
│ ├── getAll(name) # getAll方法
│ ├── has(name) # has方法
│ ├── keys() # keys方法
│ ├── set(name, value) # set方法
│ ├── sort() # sort方法
│ ├── toString() # toString方法
│ ├── values() # values方法
│ └── urlSearchParams[Symbol.iterator]() # 创建URLSearchParams对象
├── Class:URI # URI类
│ ├── URI(str: string) # 创建URI对象
│ ├── scheme # scheme属性
│ ├── authority # authority属性
│ ├── ssp # ssp属性
│ ├── userinfo # userinfo属性
│ ├── host # host属性
│ ├── port # port属性
│ ├── query # query属性
│ ├── fragment # fragment属性
│ ├── path # path属性
│ ├── equals(ob: Object) # equals方法
│ ├── normalize() # normalize方法
│ ├── checkIsAbsolute() # checkIsAbsolute方法
│ ├── normalize() # normalize方法
│ └── toString() # toString方法
├── Class:ConvertXml # ConvertXml类
│ ├── ConvertXml() # 创建ConvertXml类对象
│ └── convert(xml: string, options: Object) # convert方法
├── Class:XmlSerializer # XmlSerializer类
│ ├── new XmlSerializer(buffer: ArrayBuffer | DataView, encoding?: string) # 创建XmlSerializer类对象
│ ├── setAttributes(name: string, value: string) # 设置Attributes方法
│ ├── addEmptyElement(name: string) # 添加一个空元素方法
│ ├── setDeclaration() # 设置Declaration方法
│ ├── startElement(name: string) # 设置开始元素方法
│ ├── endElement() # 设置结束元素方法
│ ├── setNamespace(prefix: string, namespace: string) # 设置命名空间方法
│ ├── setCommnet(text: string) # 设置Commnet方法
│ ├── setCData(text: string) # 设置CData方法
│ ├── setText(text: string) # 设置Text方法
│ └── setDocType(text: string) # 设置DocType方法
└── Class: XmlPullParser # XmlPullParser类
├── new (buffer: ArrayBuffer | DataView, encoding?: string) # 创建XmlPullParser对象
└── parse(option: ParseOptions) # parse方法
```
## 说明
### 接口说明
| 接口名 | 说明 |
| -------- | -------- |
| URL(url: string,base?:string \| URL) | 创建并返回一个URL对象,该URL对象引用使用绝对URL字符串,相对URL字符串和基本URL字符串指定的URL。 |
| tostring():string | 该字符串化方法返回一个包含完整 URL 的 USVString。它的作用等同于只读的 URL.href。 |
| toJSON():string | 该方法返回一个USVString,其中包含一个序列化的URL版本。 |
| new URLSearchParams() | URLSearchParams() 构造器无入参,该方法创建并返回一个新的URLSearchParams 对象。 开头的'?' 字符会被忽略。 |
| new URLSearchParams(string) | URLSearchParams(string) 构造器的入参为string数据类型,该方法创建并返回一个新的URLSearchParams 对象。 开头的'?' 字符会被忽略。 |
| new URLSearchParams(obj) | URLSearchParams(obj) 构造器的入参为obj数据类型,该方法创建并返回一个新的URLSearchParams 对象。 开头的'?' 字符会被忽略。 |
| new URLSearchParams(iterable) | URLSearchParams(iterable) 构造器的入参为iterable数据类型,该方法创建并返回一个新的URLSearchParams 对象。 开头的'?' 字符会被忽略。 |
| has(name: string): boolean | 检索searchParams对象中是否含有name。有则返回true,否则返回false。 |
| set(name: string, value string): void | 检索searchParams对象中是否含有key为name的键值对。没有的话则添加该键值对,有的话则修改对象中第一个key所对应的value,并删除键为name的其余键值对。 |
| sort(): void | 根据键的Unicode代码点,对包含在此对象中的所有键/值对进行排序,并返回undefined。 |
| toString(): string | 根据searchParams对象,返回适用在URL中的查询字符串。 |
| keys(): iterableIterator\<string> | 返回一个iterator,遍历器允许遍历对象中包含的所有key值。 |
| values(): iterableIterator\<string> | 返回一个iterator,遍历器允许遍历对象中包含的所有value值。 |
| append(name: string, value: string): void | 在searchParams对象中插入name, value键值对。 |
| delete(name: string): void | 遍历searchParams对象,查找所有的name,删除对应的键值对。 |
| get(name: string): string | 检索searchParams对象中第一个name,返回name键对应的值。 |
| getAll(name: string): string[] | 检索searchParams对象中所有name,返回name键对应的所有值。 |
| entries(): iterableIterator<[string, string]> | 返回一个iterator,允许遍历searchParams对象中包含的所有键/值对。 |
| forEach(): void | 通过回调函数来遍历URLSearchParams实例对象上的键值对。 |
| urlSearchParams\[Symbol.iterator]() | 返回查询字符串中每个名称-值对的ES6迭代器。迭代器的每个项都是一个JavaScript数组。 |
| URI(str: string) | 通过解析给定入参(String str)来构造URI。此构造函数严格按照RFC 2396附录A中的语法规定解析给定字符串。 |
| scheme | 返回此 URI 的scheme部分,如果scheme未定义,则返回 null |
| authority | 返回此 URI 的解码authority部分,如果authority未定义,则返回 null。 |
| ssp | 返回此 URI 的解码scheme-specific部分。 |
| userinfo | 返回此 URI 的解码userinfo部分。包含passworld和username。 |
| host | 返回此 URI 的host部分,如果host未定义,则返回 null。 |
| port | 返回此 URI 的port部分,如果port未定义,则返回 -1。URI 的port组件(如果已定义)是一个非负整数。 |
| query | 返回此 URI 的query部分,如果query未定义,则返回 null。 |
| fragment | 返回此 URI 的解码fragment组件,如果fragment未定义,则返回 null。|
| path | 返回此 URI 的解码path组件,如果path未定义,则返回 null。 |
| equals(ob: Object) | 测试此 URI 是否与另一个对象相等。如果给定的对象不是 URI,则此方法立即返回 false。 |
| normalize() | 规范化这个 URI 的路径。如果这个 URI 的path不规范,将规范后构造一个新 URI对象返回。 |
| checkIsAbsolute() | 判断这个 URI 是否是绝对的。当且仅当它具有scheme部分时,URI 是绝对的,返回值为true,否则返回值为false。 |
| ConvertXml() | 用于构造ConvertXml类对象的构造函数。此构造函数无需传入参数。 |
| convert(xml: string, options: Object) | 返回按选项要求转化xml字符串的JavaScrip对象。 |
| XmlSerializer(buffer: ArrayBuffer \| DataView, encoding?: string) | 创建并返回一个XmlSerializer对象,该XmlSerializer对象传参两个第一参数是ArrayBuffer或DataView一段内存,第二个参数为文件格式(默认为UTF-8)。 |
| setAttributes(name: string, value: string): void | 给xml文件中写入属性Attributes属性。 |
| addEmptyElement(name: string): void | 写入一个空元素。 |
| setDeclaration(): void | 设置Declaration使用编码写入xml声明。例如:<xml version=“1.0”encoding=“utf-8”> |
| startElement(name: string): void | 写入具有给定名称的elemnet开始标记。|
| endElement(): void | 写入元素的结束标记。 |
| setNamespace(prefix: string, namespace: string): void | 写入当前元素标记的命名空间。 |
| setCommnet(text: string): void | 写入comment属性。 |
| setCData(text: string): void | 写入CData属性。 |
| setText(text: string): void | 写入Text属性。 |
| setDocType(text: string): void | 写入DocType属性。 |
| XmlPullParser(buffer: ArrayBuffer \| DataView, encoding?: string) | 创建并返回一个XmlPullParser对象,该XmlPullParser对象传参两个第一参数是ArrayBuffer或DataView一段内存,第二个参数为文件格式(默认为UTF-8)。 |
| parse(option: ParseOptions): void | 该接口用于解析xmlParseOptions参数为一个接口包含五个可选参{supportDoctype?: boolea ignoreNameSpace?: boolean tagValueCallbackFunction?: (name: string, value: string) => boolean attributeValueCallbackFunction?: (name: string, value: string) => boolean tokenValueCallbackFunction?: (eventType: EventType, value: ParseInfo) => boolean }。其中tokenValueCallbackFunction回调函数的入参1是事件类型,入参2是包含getColumnNumber、getDepth等get属性的info接口,用户可通过info.getDepth()等方法来获取当前解析过程中的depth等信息。 |
### 使用说明
各接口使用方法如下:
1、new URL(url: string,base?:string|URL)
```
let b = new URL('https://developer.mozilla.org'); // => 'https://developer.mozilla.org/'
let a = new URL( 'sca/./path/path/../scasa/text', 'http://www.example.com');
// => 'http://www.example.com/sca/path/scasa/text'
```
2、tostring():string
```
const url = new URL('http://10.0xFF.O400.235:8080/directory/file?query#fragment');
url.toString() // => 'http://10.0xff.o400.235:8080/directory/file?query#fragment'
const url = new URL("http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html");
url.toString() // => 'http://[fedc:ba98:7654:3210:fedc:ba98:7654:3210]/index.html'
const url = new URL("http://username:password@host:8080/directory/file?query#fragment");
url.toString() // => 'http://username:password@host:8080/directory/file?query#fragment'
```
3、toJSON():string
```
const url = new URL("https://developer.mozilla.org/en-US/docs/Web/API/URL/toString");
url.toJSON(); // => 'https://developer.mozilla.org/en-US/docs/Web/API/URL/toString'
```
4、new URLSearchParams()
```
let params = new URLSearchParams('foo=1&bar=2');
```
5、new URLSearchParams(string)
```
params = new URLSearchParams('user=abc&query=xyz');
console.log(params.get('user'));
// Prints 'abc'
```
6、new URLSearchParams(obj)
```
const params = new URLSearchParams({
user: 'abc',
query: ['first', 'second']
});
console.log(params.getAll('query'));
// Prints [ 'first,second' ]
```
7、new URLSearchParams(iterable)
```
let params;
// Using an array
params = new URLSearchParams([
['user', 'abc'],
['query', 'first'],
['query', 'second'],
]);
console.log(params.toString());
// Prints 'user = abc & query = first&query = second'
```
8、has(name: string): boolean
```
console.log(params.has('bar')); // =>true
```
9、set(name: string, value string): void
```
params.set('baz', 3);
```
10、sort(): void
```
params .sort();
```
11、toString(): string
```
console.log(params .toString()); // =>bar=2&baz=3&foo=1'
```
12、keys(): iterableIterator\<string>
```
for(var key of params.keys()) {
console.log(key);
} // =>bar baz foo
```
13、values(): iterableIterator\<string>
```
for(var value of params.values()) {
console.log(value);
} // =>2 3 1
```
14、append(name: string, value: string): void
```
params.append('foo', 3); // =>bar=2&baz=3&foo=1&foo=3
```
15、delete(name: string): void
```
params.delete('baz'); // => bar=2&foo=1&foo=3
```
16、get(name: string): string
```
params.get('foo'); // => 1
```
17、getAll(name: string): string[]
```
params.getAll('foo'); // =>[ '1', '3' ]
```
18、entries(): iterableIterator<[string, string]>
```
for(var pair of searchParams.entries()) {
console.log(pair[0]+ ', '+ pair[1]);
} // => bar, 2 foo, 1 foo, 3
```
19、forEach(): void
```
url.searchParams.forEach((value, name, searchParams) => {
console.log(name, value, url.searchParams === searchParams);
});
// => foo 1 true
// => bar 2 true
```
20、urlSearchParams[Symbol.iterator] ()
```
const params = new URLSearchParams('foo=bar&xyz=baz');
for (const [name, value] of params) {
console.log(name, value);
}
// Prints:
// foo bar
// xyz bar
```
21、URI(str: string)
```
let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
```
22、scheme
```
let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
gaogao.scheme // => "http";
```
23、authority
```
let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
gaogao.authority // => "gg:gaogao@www.baidu.com:99";
```
24、ssp
```
let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
gaogao.ssp " // => gg:gaogao@www.baidu.com:99/path/path?query";
```
25、userinfo
```
let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
gaogao.userinfo // => "gg:gaogao";
```
26、host
```
let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
gaogao.host // => "www.baidu.com";
```
27、port
```
let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
gaogao.port // => "99";
```
28、query
```
let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
gaogao.query // => "query";
```
29、fragment
```
let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
gaogao.fragment // => "fagment";
```
30、path
```
let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
gaogao.path // => "/path/path";
```
31、equals(ob: Object)
```
let gaogao = new Uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/path1?query#fagment');
let gaogao1 = gaogao;
let res = gaogao.equals(gaogao1);
console.log(res); // => true;
```
32、normalize()
```
let gaogao = new Uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/path/66./../././mm/.././path1?query#fagment');
let res = gaogao.normalize();
console.log(res.path); // => "/path/path1"
console.log(res.toString()); // => "http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/path/path1?query#fagment"
```
33、checkIsAbsolute()
```
let gaogao = new Uri.URI('f/tp://username:password@www.baidu.com:88/path?query#fagment');
let res = gaogao.checkIsAbsolute();
console.log(res); //=> false;
```
34、toString()
```
let gaogao = new Uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/../../path/.././../aa/bb/cc?query#fagment');
let res = gaogao.toString();
console.log(res.toString()); // => 'http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/../../path/.././../aa/bb/cc?query#fagment';
```
35、ConvertXml()
```
var convertml = new convertXml.ConvertXml();
```
36、convert(xml: string, options: Object)
```
var result = convertml.convert(xml, {compact: false, spaces: 4});
```
37、new XmlSerializer(buffer: ArrayBuffer | DataView, encoding?: string)
```
var arrayBuffer = new ArrayBuffer(1024);
var bufView = new DataView(arrayBuffer);
var thatSer = new xml.XmlSerializer(bufView);
```
38、setDeclaration()void
```
var thatSer = new xml.XmlSerializer(bufView);
thatSer.setDeclaration() // => <?xml version="1.0" encoding="utf-8"?>;
```
39、setCommnet(text: string):void
```
var thatSer = new xml.XmlSerializer(bufView);
thatSer.setCommnet("Hello, World!"); // => <!--Hello, World!-->;
```
40、setCData(text: string) :void
```
var thatSer = new xml.XmlSerializer(bufView);
thatSer.setDocType('root SYSTEM "http://www.test.org/test.dtd"'); // => <![CDATA[root SYSTEM \“http://www.test.org/test.dtd\”]]>
```
41、setDocType(text: string):void
```
var thatSer = new xml.XmlSerializer(bufView);
thatSer.setDocType("foo"); // => <!DOCTYPE foo>
```
42、setNamespace(prefix: string, namespace: string): void
43、startElement(name: string): void
44、setAttributes(name: string, value: string): void
45、endElement(): void
46、setText(text: string): void
```
var thatSer = new xml.XmlSerializer(bufView);
thatSer.setNamespace("h", "http://www.w3.org/TR/html4/");
thatSer.startElement("table");
thatSer.setAttributes("importance", "high");
thatSer.setText("Happy");
endElement(); // => <h:table importance="high" xmlns:h="http://www.w3.org/TR/html4/">Happy</h:table>
```
47、addEmptyElement(name: string): void
```
var thatSer = new xml.XmlSerializer(bufView);
thatSer.addEmptyElement("b"); // => <b/>
```
48、new (buffer: ArrayBuffer | DataView, encoding?: string)
```
var strXml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
' <title>Happy</title>' +
'</note>';
var arrayBuffer = new ArrayBuffer(strXml.length*2);
var bufView = new Uint8Array(arrayBuffer);
var strLen = strXml.length;
for (var i = 0; i < strLen; ++i) {
bufView[i] = strXml.charCodeAt(i);//设置arraybuffer 方式
}
var that = new xml.XmlPullParser(arrayBuffer);
```
49、parse(option: ParseOptions): void
```
var strXml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
' <title>Happy</title>' +
'</note>';
var arrayBuffer = new ArrayBuffer(strXml.length*2);
var bufView = new Uint8Array(arrayBuffer);
var strLen = strXml.length;
for (var i = 0; i < strLen; ++i) {
bufView[i] = strXml.charCodeAt(i);
}
var that = new xml.XmlPullParser(arrayBuffer);
var arrTag = {};
arrTag[0] = '132';
var i = 1;
function func(key, value){
arrTag[i] = 'key:'+key+' value:'+ value.getDepth();
i++;
return true;
}
var options = {supportDoctype:true, ignoreNameSpace:true, tokenValueCallbackFunction:func}
that.parse(options);
```
## 相关仓
[js_api_module子系统](base/compileruntime/js_api_module/readme.md)
### 许可证
URL在[Mozilla许可证](https://www.mozilla.org/en-US/MPL/)下可用,说明文档详见[说明文档](https://gitee.com/openharmony/js_api_module/blob/master/mozilla_docs.txt)。有关完整的许可证文本,有关完整的许可证文本,请参见[许可证](https://gitee.com/openharmony/js_api_module/blob/master/LICENSE)
-64
View File
@@ -1,64 +0,0 @@
{
"name": "@ohos/js_api_module",
"version": "",
"description": "js_api_module, used to store the basic class library JSAPI, such as url, uri, etc.| 用于存放基础类库JSAPI,比如url、uri等",
"homePage": "https://gitee.com/openharmony",
"license": "Apache V2",
"repository": "https://gitee.com/openharmony/js_api_module",
"domain": "os",
"language": "",
"publishAs": "code-segment",
"private": false,
"scripts": {},
"tags": [
"js"
],
"keywords": [
"js",
"api",
"module"
],
"envs": {},
"dirs": {},
"author": {
"name": "",
"email": "",
"url": ""
},
"contributors": [
{
"name": "",
"email": "",
"url": ""
}
],
"segment": {
"destPath": "base/compileruntime/js_api_module"
},
"component": {
"name": "jsapi_api",
"subsystem": "utils",
"syscap": [],
"features": [],
"adapted_system_type": [],
"rom": "",
"ram": "",
"deps": {
"components": [],
"third_party": []
},
"build": {
"sub_component": [
"//base/compileruntime/js_api_module/uri:uri_packages",
"//base/compileruntime/js_api_module/url:url_packages",
"//base/compileruntime/js_api_module/convertxml:convertxml_packages",
"//base/compileruntime/js_api_module/xml:xml_packages"
],
"inner_kits": [],
"test": [
"//base/compileruntime/js_api_module/test_uri/unittest:unittest",
"//base/compileruntime/js_api_module/test_xml/unittest:unittest"
]
}
}
}
+6 -6
View File
@@ -18,12 +18,12 @@ import("//foundation/arkui/ace_engine/ace_config.gni")
# compile .ts to .js.
action("build_ts_js") {
script = "//base/compileruntime/js_api_module/build_ts_js.py"
script = "//commonlibrary/ets_utils/js_api_module/build_ts_js.py"
args = [
"--dst-file",
rebase_path(target_out_dir + "/js_convertxml.js"),
"--module-path",
rebase_path("/base/compileruntime/js_api_module/convertxml"),
rebase_path("/commonlibrary/ets_utils/js_api_module/convertxml"),
"--out-file",
rebase_path("./out/js_convertxml.js"),
"--relative-path",
@@ -81,7 +81,7 @@ ohos_shared_library("convertxml") {
"//third_party/node/src",
"//third_party/libxml2/include",
"//foundation/arkui/napi/interfaces/kits",
"//base/compileruntime/js_api_module/convertxml",
"//commonlibrary/ets_utils/js_api_module/convertxml",
]
sources = [
@@ -92,7 +92,7 @@ ohos_shared_library("convertxml") {
deps = [
":convertxml_abc",
":js_convertxml",
"//base/compileruntime/js_api_module/convertxml/:js_convertxml",
"//commonlibrary/ets_utils/js_api_module/convertxml/:js_convertxml",
"//foundation/arkui/napi/:ace_napi",
"//foundation/arkui/napi/:ace_napi_quickjs",
"//third_party/icu/icu4c:static_icuuc",
@@ -105,8 +105,8 @@ ohos_shared_library("convertxml") {
} else {
external_deps = [ "hilog:libhilog" ]
}
subsystem_name = "utils"
part_name = "jsapi_api"
subsystem_name = "commonlibrary"
part_name = "ets_utils"
relative_install_dir = "module"
}
View File
View File
View File
+2 -2
View File
@@ -22,7 +22,7 @@ ohos_unittest("test_uri_unittest") {
configs = [ "//arkcompiler/ets_runtime:ark_jsruntime_public_config" ]
include_dirs = [
"//base/compileruntime/js_api_module/uri",
"//commonlibrary/ets_utils/js_api_module/uri",
"//arkcompiler/ets_runtime",
"//foundation/arkui/napi",
"//foundation/arkui/napi/interfaces/kits",
@@ -42,7 +42,7 @@ ohos_unittest("test_uri_unittest") {
deps = [
"//arkcompiler/ets_runtime:libark_jsruntime",
"//base/compileruntime/js_api_module/uri:uri_packages",
"//commonlibrary/ets_utils/js_api_module/uri:uri_packages",
"//foundation/arkui/napi/:ace_napi",
"//foundation/arkui/napi/:ace_napi_ark",
"//third_party/bounds_checking_function:libsec_static",
View File
View File
+2 -2
View File
@@ -22,7 +22,7 @@ ohos_unittest("test_xml_unittest") {
configs = [ "//arkcompiler/ets_runtime:ark_jsruntime_public_config" ]
include_dirs = [
"//base/compileruntime/js_api_module/xml",
"//commonlibrary/ets_utils/js_api_module/xml",
"//arkcompiler/ets_runtime",
"//foundation/arkui/napi",
"//foundation/arkui/napi/interfaces/kits",
@@ -42,7 +42,7 @@ ohos_unittest("test_xml_unittest") {
deps = [
"//arkcompiler/ets_runtime:libark_jsruntime",
"//base/compileruntime/js_api_module/xml:xml_packages",
"//commonlibrary/ets_utils/js_api_module/xml:xml_packages",
"//foundation/arkui/napi/:ace_napi",
"//foundation/arkui/napi/:ace_napi_ark",
"//third_party/bounds_checking_function:libsec_static",
Executable → Regular
+6 -6
View File
@@ -17,12 +17,12 @@ import("//foundation/arkui/ace_engine/ace_config.gni")
# compile .ts to .js.
action("build_ts_js") {
script = "//base/compileruntime/js_api_module/build_ts_js.py"
script = "//commonlibrary/ets_utils/js_api_module/build_ts_js.py"
args = [
"--dst-file",
rebase_path(target_out_dir + "/js_uri.js"),
"--module-path",
rebase_path("/base/compileruntime/js_api_module/uri"),
rebase_path("/commonlibrary/ets_utils/js_api_module/uri"),
"--out-file",
rebase_path("./out/js_uri.js"),
"--relative-path",
@@ -79,7 +79,7 @@ ohos_shared_library("uri") {
"//third_party/icu/icu4c/source/common",
"//third_party/node/src",
"//foundation/arkui/napi/interfaces/kits",
"//base/compileruntime/js_api_module/uri",
"//commonlibrary/ets_utils/js_api_module/uri",
]
sources = [
@@ -90,7 +90,7 @@ ohos_shared_library("uri") {
deps = [
":js_uri",
":uri_abc",
"//base/compileruntime/js_api_module/uri/:js_uri",
"//commonlibrary/ets_utils/js_api_module/uri/:js_uri",
"//foundation/arkui/napi/:ace_napi",
"//foundation/arkui/napi/:ace_napi_quickjs",
"//third_party/icu/icu4c:static_icuuc",
@@ -102,8 +102,8 @@ ohos_shared_library("uri") {
} else {
external_deps = [ "hilog:libhilog" ]
}
subsystem_name = "utils"
part_name = "jsapi_api"
subsystem_name = "commonlibrary"
part_name = "ets_utils"
relative_install_dir = "module"
}
Executable → Regular
View File
Executable → Regular
View File
View File
Executable → Regular
+6 -6
View File
@@ -17,12 +17,12 @@ import("//foundation/arkui/ace_engine/ace_config.gni")
# compile .ts to .js.
action("build_ts_js") {
script = "//base/compileruntime/js_api_module/build_ts_js.py"
script = "//commonlibrary/ets_utils/js_api_module/build_ts_js.py"
args = [
"--dst-file",
rebase_path(target_out_dir + "/js_url.js"),
"--module-path",
rebase_path("/base/compileruntime/js_api_module/url"),
rebase_path("/commonlibrary/ets_utils/js_api_module/url"),
"--out-file",
rebase_path("./out/js_url.js"),
"--relative-path",
@@ -79,7 +79,7 @@ ohos_shared_library("url") {
"//third_party/icu/icu4c/source/common",
"//third_party/node/src",
"//foundation/arkui/napi/interfaces/kits",
"//base/compileruntime/js_api_module/url",
"//commonlibrary/ets_utils/js_api_module/url",
]
sources = [
@@ -90,7 +90,7 @@ ohos_shared_library("url") {
deps = [
":js_url",
":url_abc",
"//base/compileruntime/js_api_module/url/:js_url",
"//commonlibrary/ets_utils/js_api_module/url/:js_url",
"//foundation/arkui/napi/:ace_napi",
"//foundation/arkui/napi/:ace_napi_quickjs",
"//third_party/icu/icu4c:static_icuuc",
@@ -102,8 +102,8 @@ ohos_shared_library("url") {
} else {
external_deps = [ "hilog:libhilog" ]
}
subsystem_name = "utils"
part_name = "jsapi_api"
subsystem_name = "commonlibrary"
part_name = "ets_utils"
relative_install_dir = "module"
}
Executable → Regular
View File
Executable → Regular
View File
View File
+6 -6
View File
@@ -18,13 +18,13 @@ import("//foundation/arkui/ace_engine/ace_config.gni")
# compile .ts to .js.
action("build_ts_js") {
script = "//base/compileruntime/js_api_module/build_ts_js.py"
script = "//commonlibrary/ets_utils/js_api_module/build_ts_js.py"
args = [
"--dst-file",
rebase_path(target_out_dir + "/js_xml.js"),
"--module-path",
rebase_path("/base/compileruntime/js_api_module/xml"),
rebase_path("/commonlibrary/ets_utils/js_api_module/xml"),
"--out-file",
rebase_path("./out/js_xml.js"),
"--relative-path",
@@ -82,7 +82,7 @@ ohos_shared_library("xml") {
"//third_party/icu/icu4c/source/common",
"//third_party/node/src",
"//foundation/arkui/napi/interfaces/kits",
"//base/compileruntime/js_api_module/xml",
"//commonlibrary/ets_utils/js_api_module/xml",
]
sources = [
@@ -93,7 +93,7 @@ ohos_shared_library("xml") {
deps = [
":js_xml",
":xml_abc",
"//base/compileruntime/js_api_module/xml/:js_xml",
"//commonlibrary/ets_utils/js_api_module/xml/:js_xml",
"//foundation/arkui/napi/:ace_napi",
"//foundation/arkui/napi/:ace_napi_quickjs",
"//third_party/icu/icu4c:static_icuuc",
@@ -105,8 +105,8 @@ ohos_shared_library("xml") {
} else {
external_deps = [ "hilog:libhilog" ]
}
subsystem_name = "utils"
part_name = "jsapi_api"
subsystem_name = "commonlibrary"
part_name = "ets_utils"
relative_install_dir = "module"
}
-365
View File
@@ -1,365 +0,0 @@
# js_sys_module Subsystems/Components
- [Introduction](#Introduction)
- [Directory](#Directory)
- [Description](#Description)
- [Interface description](#Interface description)
- [Interface instructions](#Interface instructions)
- [Related warehouse](#Related warehouse])
## Introduction
Process is mainly used to obtain the relevant ID of the process, obtain and modify the working directory of the process, exit and close the process. The childprocess object can be used to create a new process. The main process can obtain the standard input and output of the child process, send signals and close the child process.
## Directory
```
base/compileruntime/js_sys_module/
├── Class:PROCESS # class of PROCESS
├── Uid # attribute of Uid
├── Gid # attribute of Gid
├── EUid # attribute of EUid
├── EGid # attribute of EGid
├── Groups # attribute of Groups
├── Pid # attribute of Pid
├── Ppid # attribute of Ppid
├── chdir() # method of chdir
├── uptime() # method of uptime
├── kill() # method of kill
├── abort() # method of abort
├── on() # method of on
├── tid # method of tid
├── getStartRealtime() # method of getStartRealtime
├── getAvailableCores() # method of getAvailableCores
├── getPastCputime() # method of getPastCputime
├── isIsolatedProcess() # method of isIsolatedProcess
├── is64Bit() # method of is64Bit
├── isAppUid() # method of isAppUid
├── getUidForName() # method of getUidForName
├── getThreadPriority() # method of getThreadPriority
├── getSystemConfig() # method of getSystemConfig
├── getEnvironmentVar() # method of getEnvironmentVar
├── exit() # method of exit
├── cwd() # method of cwd
├── off() # method of off
├── runCmd() # method of runCmd
└─── Class:CHILDPROCESS # class of CHILDPROCESS
├── close() # method of close
├── kill() # method of kill
├── getOutput() # method of getOutput
├── getErrorOutput() # method of getErrorOutput
├── wait() # method of wait
├── killed # attribute of killed
├── pid # attribute of pid
├── ppid # attribute of ppid
└── exitCode # attribute of exitCode
```
## Description
### Interface description
| Interface name | description |
| -------- | -------- |
| const uid :number | returns the digital user ID of the process. |
| const gid :number | returns the numeric group ID of the process. |
| const euid :number | returns the numeric valid user identity of the process. |
| const egid :number | returns the numeric valid group ID of the node.js process. |
| const groups :number[] | returns an array with supplementary group ID. |
| const pid :number | returns the PID of the process. |
| const ppid :number | returns the PID of the parent process of the current process. |
| chdir(dir:string) :void | change the current working directory of the node.js process. |
| uptime() :number | returns the number of seconds the current system has been running. |
| Kill(pid:number, signal:number) :boolean | send the signal to the identified process PID, and true means the sending is successful. |
| abort() :void | cause the node.js process to exit immediately and generate a core file. |
| on(type:string ,listener:EventListener) :void | used to store events triggered by users. |
| exit(code:number):void | cause the node.js process to exit immediately. |
| cwd():string | returns the current working directory of the node.js process. |
| off(type: string): boolean | clear the events stored by the user. True means the clearing is successful. |
| runCmd(command: string, options?: { timeout : number, killSignal : number \| string, maxBuffer : number }): ChildProcess |through runcmd, you can fork a new process to run a shell and return the childprocess object. The first parameter command refers to the shell to be run, and the second parameter options refers to some running parameters of the child process. These parameters mainly refer to timeout, killsignal and maxbuffer. If timeout is set, the child process will send a signal killsignal after timeout is exceeded. Maxbuffer is used to limit the maximum stdout and stderr sizes that can be received. |
| wait() Promise\<number> | is used to wait for the child process to run and return the promise object, whose value is the exit code of the child process. |
| getOutput(): Promise\<Uint8Array> | used to get the standard output of the child process. |
| getErrorOutput(): Promise\<Uint8Array> | used to get the standard error output of the child process. |
| const tid:number | Returns the TID of the process. |
| getStartRealtime() :number | Gets the real time elapsed (in milliseconds) from system startup to process startup. |
| getAvailableCores() :number[] | Gets the CPU kernel available to the current process on the multi-core device. |
| getPastCputime() :number | Gets the CPU time (in milliseconds) from the start of the process to the current time. |
| isIsolatedProcess(): boolean | Check if the process is quarantined. |
| is64Bit(): boolean | Check whether the process is running in a 64 bit environment. |
| isAppUid(v:number): boolean | Checks whether the specified uid belongs to a specific application. |
| getUidForName(v:string): number | Obtain the user group ID to which the user belongs according to the user name |
| getThreadPriority(v:number): number | Gets the thread priority based on the specified TID. |
| getSystemConfig(name:number): number | Gets the configuration of the system according to the specified system configuration name. |
| getEnvironmentVar(name:string): string | Obtain the corresponding value according to the name of the environment variable. |
| close(): void | used to close the running child process. |
| kill(signal: number \| string): void | used to send signals to child processes. |
| readonly killed: boolean | indicates whether the signal is sent successfully, and true indicates that the signal is sent successfully. |
| readonly exitCode: number | indicates the exit code of the child process. |
| readonly pid: number | represents the child process ID. |
| readonly ppid: number | represents the main process ID. |
### Interface instructions
Example of using interface
1.uid()
```
uid(){
var res = Process.uid;
}
```
2.gid()
```
gid(){
var result = Process.gid;
}
```
3.euid()
```
euid(){
var and = Process.euid;
}
```
4.egid()
```
egid(){
var resb = Process.egid;
}
```
5.groups()
```
groups(){
var answer = Process.groups;
}
```
6.pid()
```
pid(){
var result = Process.pid;
}
```
7.ppid()
```
ppid(){
var result = Process.ppid;
}
```
8.chdir()
```
chdir(){
Process.chdir("123456");
}
```
9.uptime()
```
uptime(){
var num = Process.uptime();
}
```
10.kill()
```
kill(){
var ansu = Process.kill(5,23);
}
```
11.abort()
```
abort(){
Process.abort();
}
```
12.on()
```
on(){
function add(num){
var value = num + 5;
return value;
}
Process.on("add",add);
}
```
13.exit()
```
exit(){
Process.exit(15);
}
```
14.Cwd()
```
Cwd(){
var result = Process.cwd();
}
```
15.off()
```
off(){
var result = Process.off("add");
}
```
16.runCmd()
```
runCmd(){
var child = process.runCmd('echo abc')
// killSignal can be a number or a string
var child = process.runCmd('echo abc;', {killSignal : 'SIGKILL'});
var child = process.runCmd('sleep 5; echo abc;', {timeout : 1, killSignal : 9, maxBuffer : 2})
}
```
17.wait()
```
wait()
{
var child = process.runCmd('ls')
var status = child.wait();
status.then(val => {
console.log(val);
})
}
```
18.getOutput()
```
getOutput(){
var child = process.runCmd('echo bcd;');
var res = child.getOutput();
child.wait();
res.then(val => {
console.log(val);
})
}
```
19.getErrorOutput()
```
getErrorOutput(){
var child = process.runCmd('makdir 1.txt'); // execute an error command
var res = child.getErrorOutput();
child.wait();
res.then(val => {
console.log(val);
})
}
```
20.close()
```
close(){
var child = process.runCmd('ls; sleep 5s;')
var result = child.close()
}
```
21.kill()
```
kill(){
var child = process.runCmd('ls; sleep 5s;')
var result = child.kill('SIGHUP');
child.wait();
var temp = child.killed;
}
```
22.killed
```
{
var child = process.runCmd('ls; sleep 5;')
child.kill(3);
var killed_ = child.killed;
child.wait();
}
```
23.exitCode
```
{
var child = process.runCmd('ls; sleep 5;')
child.kill(9);
child.wait();
var exitCode_ = child.exitCode;
}
```
24.pid
```
pid
{
var child = process.runCmd('ls; sleep 5;')
var pid_ = child.pid;
child.wait();
}
```
25.ppid
```
ppid
{
var child = process.runCmd('ls; sleep 5;')
var ppid_ = child.ppid;
child.wait();
}
```
26.tid
```
tid(){
var ansu = Process.tid;
}
```
27.isIsolatedProcess()
```
isIsolatedProcess(){
var ansu = Process.isIsolatedProcess()();
}
```
28.isAppUid()
```
isAppUid(){
var ansu = Process.isAppUid(10000);
}
```
29.is64Bit()
```
is64Bit(){
var ansu = Process.is64Bit();
}
```
30.getUidForName()
```
getUidForName(){
var buf = "root";
var ansu = Process.getUidForName(buf);
}
```
31.getEnvironmentVar()
```
getEnvironmentVar(){
var ansu = Process.getEnvironmentVar('USER');
}
```
32.getAvailableCores()
```
getAvailableCores(){
var ansu = Process.getAvailableCores();
}
```
33.getThreadPriority()
```
getThreadPriority(){
var result = Process.getTid();
var ansu = getThreadPriority(result);
}
```
34.getStartRealtime()
```
getStartRealtime(){
var ansu = Process.getStartRealtime();
}
```
35.getPastCputime()
```
getPastCputime(){
var ansu = Process.getPastCputime();
}
```
36.getSystemConfig()
```
getSystemConfig(){
var _SC_ARG_MAX = 0;
var ansu = Process.getSystemConfig(_SC_ARG_MAX)
}
```
## Related warehouse
[js_sys_module](base/compileruntime/js_sys_module/readme.md)
### License
SYS is available under [Mozilla license](https://www.mozilla.org/en-US/MPL/), and the documentation is detailed in [documentation](https://gitee.com/openharmony/js_sys_module/blob/master/mozilla_docs.txt). See [LICENSE](https://gitee.com/openharmony/js_sys_module/blob/master/LICENSE) for the full license text.
-366
View File
@@ -1,366 +0,0 @@
# js_sys_module子系统/组件
- [简介](#简介)
- [目录](#目录)
- [说明](#说明)
- [接口说明](#接口说明)
- [使用说明](#使用说明)
- [相关仓](#相关仓])
## 简介
进程主要用于获取进程的相关ID,获取和修改进程的工作目录,退出和关闭进程。 childprocess 对象可用于创建新进程。 主进程可以获取子进程的标准输入输出,发送信号,关闭子进程。
## 目录
```
base/compileruntime/js_sys_module/
├── Class:PROCESS # PROCESS类
├── Uid # Uid属性
├── Gid # Gid属性
├── EUid # EUid属性
├── EGid # EGid属性
├── Groups # Groups属性
├── Pid # Pid属性
├── Ppid # Ppid属性
├── chdir() # chdir方法
├── uptime() # uptime方法
├── kill() # kill方法
├── abort() # abort方法
├── on() # on方法
├── tid # tid方法
├── getStartRealtime() # getStartRealtime方法
├── getAvailableCores() # getAvailableCores方法
├── getPastCputime() # getPastCputime方法
├── isIsolatedProcess() # isIsolatedProcess方法
├── is64Bit() # is64Bit方法
├── isAppUid() # isAppUid方法
├── getUidForName() # getUidForName方法
├── getThreadPriority() # getThreadPriority方法
├── getSystemConfig() # getSystemConfig方法
├── getEnvironmentVar() # getEnvironmentVar方法
├── exit() # exit方法
├── cwd() # cwd方法
├── off() # off方法
├── runCmd() # runCmd方法
└─── Class:CHILDPROCESS # class of CHILDPROCESS类
├── close() # close方法
├── kill() # kill方法
├── getOutput() # getOutput方法
├── getErrorOutput() # getErrorOutput方法
├── wait() # wait方法
├── killed # killed属性
├── pid # pid属性
├── ppid # ppid属性
└── exitCode # exitCode属性
```
## 说明
### 接口说明
| 接口名 | 说明 |
| -------- | -------- |
| const uid :number | 返回进程的数字用户 ID。 |
| const gid :number | 返回进程的数字组 ID。 |
| const euid :number | 返回进程的数字有效用户身份。 |
| const egid :number | 返回 node.js 进程的数字有效组 ID。 |
| const groups :number[] | 返回具有补充组 ID 的数组。 |
| const pid :number | 返回进程的PID。 |
| const ppid :number | 返回当前进程的父进程的PID。 |
| chdir(dir:string) :void | 更改 node.js 进程的当前工作目录。 |
| uptime() :number | 返回当前系统已经运行的秒数。 |
| Kill(pid:number, signal:number) :boolean | 将信号发送到识别的进程PID,true表示发送成功。 |
| abort() :void | 导致 node.js 进程立即退出并生成核心文件。 |
| on(type:string ,listener:EventListener) :void | 用于存储用户触发的事件。 |
| exit(code:number):void | 导致 node.js 进程立即退出。 |
| cwd():string | 返回 node.js 进程的当前工作目录。 |
| off(type: string): boolean | 清除用户存储的事件。 True 表示清算成功。 |
| runCmd(command: string, options?: { timeout : number, killSignal : number \| string, maxBuffer : number }): ChildProcess |通过runcmd,你可以fork一个新进程来运行一个shell并返回childprocess对象。 第一个参数command指的是要运行的shell,第二个参数options指的是子进程的一些运行参数。 这些参数主要是指 timeout、killsignal 和 maxbuffer。 如果设置了timeout,则子进程会在超时后发送killsignal信号。 Maxbuffer 用于限制可以接收的最大 stdout 和 stderr 大小。 |
| wait() Promise\<number> | 用于等待子进程运行并返回promise对象,其值为子进程的退出码。 |
| getOutput(): Promise\<Uint8Array> | 用于获取子进程的标准输出。 |
| getErrorOutput(): Promise\<Uint8Array> | 用于获取子进程的标准错误输出。 |
| const tid:number | 返回进程的 TID。 |
| getStartRealtime() :number | 获取从系统启动到进程启动所经过的实时时间(以毫秒为单位)。 |
| getAvailableCores() :number[] | 获取多核设备上当前进程可用的 CPU 内核。 |
| getPastCputime() :number | 获取从进程开始到当前时间的 CPU 时间(以毫秒为单位)。 |
| isIsolatedProcess(): boolean | 检查进程是否被隔离。 |
| is64Bit(): boolean | 检查进程是否在 64 位环境中运行。 |
| isAppUid(v:number): boolean | 检查指定的 uid 是否属于特定应用程序。 |
| getUidForName(v:string): number | 根据用户名获取用户所属的用户组ID |
| getThreadPriority(v:number): number | 根据指定的 TID 获取线程优先级。 |
| getSystemConfig(name:number): number | 根据指定的系统配置名称获取系统的配置。 |
| getEnvironmentVar(name:string): string | 根据环境变量的名称获取对应的值。 |
| close(): void | 用于关闭正在运行的子进程。 |
| kill(signal: number \| string): void | 用于向子进程发送信号。 |
| readonly killed: boolean | 表示信号是否发送成功,true表示信号发送成功。 |
| readonly exitCode: number | 表示子进程的退出代码。 |
| readonly pid: number | 表示子进程ID。 |
| readonly ppid: number | 代表主进程ID。 |
### 使用说明
各接口使用方法如下:
1.uid()
```
uid(){
var res = Process.uid;
}
```
2.gid()
```
gid(){
var result = Process.gid;
}
```
3.euid()
```
euid(){
var and = Process.euid;
}
```
4.egid()
```
egid(){
var resb = Process.egid;
}
```
5.groups()
```
groups(){
var answer = Process.groups;
}
```
6.pid()
```
pid(){
var result = Process.pid;
}
```
7.ppid()
```
ppid(){
var result = Process.ppid;
}
```
8.chdir()
```
chdir(){
Process.chdir("123456");
}
```
9.uptime()
```
uptime(){
var num = Process.uptime();
}
```
10.kill()
```
kill(){
var ansu = Process.kill(5,23);
}
```
11.abort()
```
abort(){
Process.abort();
}
```
12.on()
```
on(){
function add(num){
var value = num + 5;
return value;
}
Process.on("add",add);
}
```
13.exit()
```
exit(){
Process.exit(15);
}
```
14.Cwd()
```
Cwd(){
var result = Process.cwd();
}
```
15.off()
```
off(){
var result = Process.off("add");
}
```
16.runCmd()
```
runCmd(){
var child = process.runCmd('echo abc')
// killSignal can be a number or a string
var child = process.runCmd('echo abc;', {killSignal : 'SIGKILL'});
var child = process.runCmd('sleep 5; echo abc;', {timeout : 1, killSignal : 9, maxBuffer : 2})
}
```
17.wait()
```
wait()
{
var child = process.runCmd('ls')
var status = child.wait();
status.then(val => {
console.log(val);
})
}
```
18.getOutput()
```
getOutput(){
var child = process.runCmd('echo bcd;');
var res = child.getOutput();
child.wait();
res.then(val => {
console.log(val);
})
}
```
19.getErrorOutput()
```
getErrorOutput(){
var child = process.runCmd('makdir 1.txt'); // execute an error command
var res = child.getErrorOutput();
child.wait();
res.then(val => {
console.log(val);
})
}
```
20.close()
```
close(){
var child = process.runCmd('ls; sleep 5s;')
var result = child.close()
}
```
21.kill()
```
kill(){
var child = process.runCmd('ls; sleep 5s;')
var result = child.kill('SIGHUP');
child.wait();
var temp = child.killed;
}
```
22.killed
```
{
var child = process.runCmd('ls; sleep 5;')
child.kill(3);
var killed_ = child.killed;
child.wait();
}
```
23.exitCode
```
{
var child = process.runCmd('ls; sleep 5;')
child.kill(9);
child.wait();
var exitCode_ = child.exitCode;
}
```
24.pid
```
pid
{
var child = process.runCmd('ls; sleep 5;')
var pid_ = child.pid;
child.wait();
}
```
25.ppid
```
ppid
{
var child = process.runCmd('ls; sleep 5;')
var ppid_ = child.ppid;
child.wait();
}
```
26.tid
```
tid(){
var ansu = Process.tid;
}
```
27.isIsolatedProcess()
```
isIsolatedProcess(){
var ansu = Process.isIsolatedProcess()();
}
```
28.isAppUid()
```
isAppUid(){
var ansu = Process.isAppUid(10000);
}
```
29.is64Bit()
```
is64Bit(){
var ansu = Process.is64Bit();
}
```
30.getUidForName()
```
getUidForName(){
var buf = "root";
var ansu = Process.getUidForName(buf);
}
```
31.getEnvironmentVar()
```
getEnvironmentVar(){
var ansu = Process.getEnvironmentVar('USER');
}
```
32.getAvailableCores()
```
getAvailableCores(){
var ansu = Process.getAvailableCores();
}
```
33.getThreadPriority()
```
getThreadPriority(){
var result = Process.getTid();
var ansu = getThreadPriority(result);
}
```
34.getStartRealtime()
```
getStartRealtime(){
var ansu = Process.getStartRealtime();
}
```
35.getPastCputime()
```
getPastCputime(){
var ansu = Process.getPastCputime();
}
```
36.getSystemConfig()
```
getSystemConfig(){
var _SC_ARG_MAX = 0;
var ansu = Process.getSystemConfig(_SC_ARG_MAX)
}
```
## 相关仓
[js_sys_module](base/compileruntime/js_sys_module/readme.md)
### 许可证
SYS在[Mozilla许可证](https://www.mozilla.org/en-US/MPL/)下可用,说明文档详见[说明文档](https://gitee.com/openharmony/js_sys_module/blob/master/mozilla_docs.txt)。有关完整的许可证文本,有关完整的许可证文本,请参见[许可证](https://gitee.com/openharmony/js_sys_module/blob/master/LICENSE)
-59
View File
@@ -1,59 +0,0 @@
{
"name": "@ohos/js_sys_module",
"version": "",
"description": "Provide system basic ability query API, including process information, CPU load information, etc. | js_sys_module, 提供系统基础能力查询API,包括进程信息,CPU负载信息等",
"homePage": "https://gitee.com/openharmony",
"license": "Apache V2",
"repository": "https://gitee.com/openharmony/js_sys_module",
"domain": "os",
"language": "",
"publishAs": "code-segment",
"private": false,
"scripts": {},
"tags": [
"js"
],
"keywords": [
"js",
"sys",
"module"
],
"envs": {},
"dirs": {},
"author": {
"name": "",
"email": "",
"url": ""
},
"contributors": [
{
"name": "",
"email": "",
"url": ""
}
],
"segment": {
"destPath": "base/compileruntime/js_sys_module"
},
"component": {
"name": "jsapi_sys",
"subsystem": "utils",
"syscap": [],
"features": [],
"adapted_system_type": [],
"rom": "",
"ram": "",
"deps": {
"components": [],
"third_party": []
},
"build": {
"sub_component": [
"//base/compileruntime/js_sys_module/process:process_packages",
"//base/compileruntime/js_sys_module/dfx:dfx_packages"
],
"inner_kits": [],
"test": []
}
}
}
+3 -3
View File
@@ -20,7 +20,7 @@ ohos_shared_library("dfx") {
"//third_party/icu/icu4c/source/common",
"//third_party/node/src",
"//foundation/arkui/napi/interfaces/kits",
"//base/compileruntime/js_api_module/dfx",
"//commonlibrary/ets_utils/js_api_module/dfx",
]
sources = [ "native_module_dfx.cpp" ]
@@ -37,8 +37,8 @@ ohos_shared_library("dfx") {
} else {
external_deps = [ "hilog:libhilog" ]
}
subsystem_name = "utils"
part_name = "jsapi_sys"
subsystem_name = "commonlibrary"
part_name = "ets_utils"
relative_install_dir = "module"
}
+3 -3
View File
@@ -18,7 +18,7 @@ ohos_shared_library("process") {
"//third_party/icu/icu4c/source/common",
"//third_party/node/src",
"//foundation/arkui/napi/interfaces/kits",
"//base/compileruntime/js_sys_module/process",
"//commonlibrary/ets_utils/js_sys_module/process",
]
sources = [
@@ -39,8 +39,8 @@ ohos_shared_library("process") {
} else {
external_deps = [ "hilog:libhilog" ]
}
subsystem_name = "utils"
part_name = "jsapi_sys"
subsystem_name = "commonlibrary"
part_name = "ets_utils"
relative_install_dir = "module"
}
+2 -2
View File
@@ -22,7 +22,7 @@ ohos_unittest("test_process_unittest") {
configs = [ "//arkcompiler/ets_runtime:ark_jsruntime_public_config" ]
include_dirs = [
"//base/compileruntime/js_sys_module/process",
"//commonlibrary/ets_utils/js_sys_module/process",
"//arkcompiler/ets_runtime",
"//foundation/arkui/napi",
"//foundation/arkui/napi/interfaces/kits",
@@ -42,7 +42,7 @@ ohos_unittest("test_process_unittest") {
deps = [
"//arkcompiler/ets_runtime:libark_jsruntime",
"//base/compileruntime/js_sys_module/process:process_packages",
"//commonlibrary/ets_utils/js_sys_module/process:process_packages",
"//foundation/arkui/napi/:ace_napi",
"//foundation/arkui/napi/:ace_napi_ark",
"//third_party/bounds_checking_function:libsec_static",
View File
View File
-177
View File
@@ -1,177 +0,0 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
-59
View File
@@ -1,59 +0,0 @@
{
"name": "@ohos/js_util_module",
"version": "",
"description": "js_util_module, used to store some helper functions, such as string encoding and decoding, function callback, promise, Base | js_util_module, 用于存放一些帮助类函数,比如字符串编解码,函数callback化、promise化,Base64编解码,Lru缓存等",
"homePage": "https://gitee.com/openharmony",
"license": "Apache V2",
"repository": "https://gitee.com/openharmony/js_util_module",
"domain": "os",
"language": "",
"publishAs": "code-segment",
"private": false,
"scripts": {},
"tags": [
"js"
],
"keywords": [
"js",
"util",
"module"
],
"envs": {},
"dirs": {},
"author": {
"name": "",
"email": "",
"url": ""
},
"contributors": [
{
"name": "",
"email": "",
"url": ""
}
],
"segment": {
"destPath": "base/compileruntime/js_util_module"
},
"component": {
"name": "jsapi_util",
"subsystem": "utils",
"syscap": [],
"features": [],
"adapted_system_type": [],
"rom": "",
"ram": "",
"deps": {
"components": [],
"third_party": []
},
"build": {
"sub_component": [
"//base/compileruntime/js_util_module/util:util_packages",
"//base/compileruntime/js_util_module/container:container_packages"
],
"inner_kits": [],
"test": []
}
}
}
+5 -5
View File
@@ -36,7 +36,7 @@ container_names = [
# compile .ts to .js.
action("build_js_ts") {
script = "//base/compileruntime/js_util_module/container/build_ts_js.py"
script = "//commonlibrary/ets_utils/js_util_module/container/build_ts_js.py"
args = [
"--dst-file",
rebase_path(target_out_dir + "/"),
@@ -104,7 +104,7 @@ template("container_lib") {
include_dirs = [
"//third_party/node/src",
"//foundation/arkui/napi/interfaces/kits",
"//base/compileruntime/js_util_module/container/" + name,
"//commonlibrary/ets_utils/js_util_module/container/" + name,
]
sources = [ name + "/native_module_" + name + ".cpp" ]
@@ -112,7 +112,7 @@ template("container_lib") {
dep_abc = ":" + name + "_abc"
dep_js = ":js_" + name
deps = [
"//base/compileruntime/js_util_module/container/:js_" + name,
"//commonlibrary/ets_utils/js_util_module/container/:js_" + name,
"//foundation/arkui/napi/:ace_napi",
"//utils/native/base:utils",
]
@@ -124,8 +124,8 @@ template("container_lib") {
} else {
external_deps = [ "hilog:libhilog" ]
}
subsystem_name = "utils"
part_name = "jsapi_util"
subsystem_name = "commonlibrary"
part_name = "ets_utils"
relative_install_dir = "module/util"
}
+1 -1
View File
@@ -35,7 +35,7 @@ if __name__ == '__main__':
input_arguments = parser.parse_args()
build_path = os.path.abspath(os.path.join(os.getcwd(), input_arguments.relative_path))
os.chdir("%s/base/compileruntime/js_util_module/container/" % build_path)
os.chdir("%s/commonlibrary/ets_utils/js_util_module/container/" % build_path)
NODE_PATH = '../../../../prebuilts/build-tools/common/nodejs/\
Executable → Regular
+6 -6
View File
@@ -18,12 +18,12 @@ import("//foundation/arkui/ace_engine/ace_config.gni")
# compile .ts to .js.
action("build_ts_js") {
script = "//base/compileruntime/js_util_module/build_ts_js.py"
script = "//commonlibrary/ets_utils/js_util_module/build_ts_js.py"
args = [
"--dst-file",
rebase_path(target_out_dir + "/util_js.js"),
"--module-path",
rebase_path("/base/compileruntime/js_util_module/util"),
rebase_path("/commonlibrary/ets_utils/js_util_module/util"),
"--out-file",
rebase_path("./out/util_js.js"),
"--relative-path",
@@ -83,7 +83,7 @@ ohos_shared_library("util") {
"//third_party/icu/icu4c/source",
"//third_party/node/src",
"//foundation/arkui/napi/interfaces/kits",
"//base/compileruntime/js_util_module/util",
"//commonlibrary/ets_utils/js_util_module/util",
]
sources = [
@@ -97,7 +97,7 @@ ohos_shared_library("util") {
deps = [
":util_abc",
":util_js",
"//base/compileruntime/js_util_module/util/:util_js",
"//commonlibrary/ets_utils/js_util_module/util/:util_js",
"//foundation/arkui/napi/:ace_napi",
"//foundation/arkui/napi/:ace_napi_quickjs",
"//third_party/icu/icu4c:static_icuuc",
@@ -109,8 +109,8 @@ ohos_shared_library("util") {
} else {
external_deps = [ "hilog:libhilog" ]
}
subsystem_name = "utils"
part_name = "jsapi_util"
subsystem_name = "commonlibrary"
part_name = "ets_utils"
relative_install_dir = "module"
}
View File
Executable → Regular
View File
View File
View File
View File
View File
View File
+5 -5
View File
@@ -15,9 +15,9 @@ import("//build/ohos.gni")
ohos_shared_library("worker") {
include_dirs = [
"//base/compileruntime/js_worker_module/worker",
"//base/compileruntime/js_worker_module/helper",
"//base/compileruntime/js_worker_module/plugin",
"//commonlibrary/ets_utils/js_worker_module/worker",
"//commonlibrary/ets_utils/js_worker_module/helper",
"//commonlibrary/ets_utils/js_worker_module/plugin",
]
sources = [
@@ -38,8 +38,8 @@ ohos_shared_library("worker") {
external_deps = [ "hilog:libhilog" ]
}
subsystem_name = "utils"
part_name = "jsapi_worker"
subsystem_name = "commonlibrary"
part_name = "ets_utils"
relative_install_dir = "module"
}
-177
View File
@@ -1,177 +0,0 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
-367
View File
@@ -1,367 +0,0 @@
# js_worker_module
### Introduction
Worker enables JS to have the ability of multithreading, and completes the communication between worker thread and host thread through PostMessage.
### Interface description
For interface implementation, see: js_worker_module/jsapi/worker
#### Worker object description
The object object used by the host thread to communicate with the worker thread.
##### Interface
1.
- name
|constructor(scriptURL:string, options? WorkerOptions) | worker constructor to Creates a worker instance |
|---|---|
- example
```
import worker from "@ohos.worker"
const worker = new worker.Worker("workers/worker.js");
```
2.
- name
| postMessage(message:Object, options?:PostMessageOptions) | Sends a message to the worker thread |
|---|---|
| postMessage(message:Object, transfer:ArrayBuffer[]) | Sends a message to the worker thread |
- example
```
// example 1
import worker from "@ohos.worker"
const worker = new worker.Worker("workers/worker.js");
worker.postMessage("hello world");
// example 2
import worker from "@ohos.worker"
const worker = new worker.Worker("workers/worker.js");
var buffer = new ArrayBuffer(8);
worker.postMessage(buffer, [buffer]);
```
3.
- name
| on(type:string, listener:EventListener) | Adds an event listener to the worker |
|---|---|
- example
```
import worker from "@ohos.worker"
const worker = new worker.Worker("workers/worker.js");
worker.on("alert", (e)=>{
console.log("worker on...");
})
```
4.
- name
| once(type:string, listener:EventListener) | Adds an event listener to the worker and removes the event listener automically after it is invoked once |
|---|---|
- example
```
import worker from "@ohos.worker"
const worker = new worker.Worker("workers/worker.js");
worker.once("alert", (e)=>{
console.log("worker on...");
})
```
5.
- name
| off(type:string, listener?:EventListener) | Removes an event listener to the worker |
|---|---|
- example
```
import worker from "@ohos.worker"
const worker = new worker.Worker("workers/worker.js");
worker.off("alert");
```
6.
- name
| terminate() | Terminates the worker thread to stop the worker from receiving messages |
|---|---|
- example
```
import worker from "@ohos.worker"
const worker = new worker.Worker("workers/worker.js");
worker.terminate();
```
7.
- name
| removeEventListener(type:string, listener?:EventListener) | Removes an event defined for the worker |
|---|---|
- example
```
import worker from "@ohos.worker"
const worker = new worker.Worker("workers/worker.js");
worker.removeEventListener("alert");
```
8.
- name
| dispatchEvent(event: Event) | Dispatches the event defined for the worker |
|---|---|
- example
```
import worker from "@ohos.worker"
const worker = new worker.Worker("workers/worker.js");
worker.dispatchEvent({type:"alert"});
```
9.
- name
| removeAllListener() | Removes all event listeners for the worker |
|---|---|
- example
```
import worker from "@ohos.worker"
const worker = new worker.Worker("workers/worker.js");
worker.removeAllListener();
```
##### Attribute
1.
- name
| onexit?:(code:number)=>void | The onexit attribute of the worker specifies the event handler to be called when the worker exits. The handler is executed in the host thread |
|---|---|
- example
```
import worker from "@ohos.worker"
const worker = new worker.Worker("workers/worker.js");
worker.onexit = function(e) {
console.log("onexit...");
}
```
2.
- name
| onerror?:(ev:ErrorEvent)=>void | The onerror attribute of the worker specifies the event handler to be called when an exception occurs during worker execution. The event handler is executed in the host thread |
|---|---|
- example
```
import worker from "@ohos.worker"
const worker = new worker.Worker("workers/worker.js");
worker.onerror = function(e) {
console.log("onerror...");
}
```
3.
- name
| onmessage?:(ev:MessageEvent)=>void | The onmessage attribute of the worker specifies the event handler to be called then the host thread receives a message created by itself and sent by the worker through the parentPort.postMessage. The event handler is executed in the host thread |
|---|---|
- example
```
import worker from "@ohos.worker"
const worker = new worker.Worker("workers/worker.js");
worker.onmessage = function(e) {
console.log("onmessage...");
}
```
4.
- name
| onmessageerror?:(event:MessageEvent)=>void | The onmessage attribute of the worker specifies the event handler when the worker receives a message that cannot be serialized. The event handler is executed in the host thread |
|---|---|
- example
```
import worker from "@ohos.worker"
const worker = new worker.Worker("workers/worker.js");
worker.onmessageerror = function(e) {
console.log("onmessageerror...");
}
```
#### parentPort object description
Object of the worker thread used to communicate with the host thread
##### Interface
1.
- name
| postMessage(message:Object, options?:PostMessageOptions) | Send a message to host thread |
|---|---|
| postMessage(message:Object, transfer:ArrayBuffer[]) | Send a message to host thread |
- example
```
// main.js
import worker from "@ohos.worker"
const worker = new worker.Worker("workers/worker.js");
worker.postMessage("hello world");
// worker.js
import worker from "@ohos.worker"
const parentPort = worker.parentPort;
parentPort.onmessage = function(e) {
parentPort.postMessage("hello world from worker.js");
}
```
2.
- name
| close() | Close the worker thread to stop the worker from receiving messages |
|---|---|
- example
```
// main.js
import worker from "@ohos.worker"
const worker = new worker.Worker("workers/worker.js");
worker.postMessage("hello world");
// worker.js
import worker from "@ohos.worker"
const parentPort = worker.parentPort;
parentPort.onmessage = function(e) {
parentPort.close();
}
```
##### Attribute
1.
- name
| onmessage?:(event:MessageEvent)=>void | The onmessage attribute of parentPort specifies the event handler to be called then the worker thread receives a message sent by the host thread through worker postMessage. The event handler is executed in the worker thread |
|---|---|
- example
```
// main.js
import worker from "@ohos.worker"
const worker = new worker.Worker("workers/worker.js");
worker.postMessage("hello world");
// worker.js
import worker from "@ohos.worker"
const parentPort = worker.parentPort;
parentPort.onmessage = function(e) {
console.log("receive main.js message");
}
```
2.
- name
| onerror?:(ev: ErrorEvent)=>void | The onerror attribute of parentPort specifies the event handler to be called when an exception occurs during worker execution. The event handler is executed in the worker thread |
|---|---|
- example
```
// main.js
import worker from "@ohos.worker"
const worker = new worker.Worker("workers/worker.js");
worker.postMessage("hello world");
// worker.js
import worker from "@ohos.worker"
const parentPort = worker.parentPort;
parentPort.onerror = function(e) {
console.log("onerror...");
}
```
3.
- name
| onmessageerror?:(event: MessageEvent)=>void | The onmessage attribute of parentPort specifies the event handler to be called then the worker receives a message that cannot be deserialized. The event handler is executed in the worker thread. |
|---|---|
- example
```
// main.js
import worker from "@ohos.worker"
const worker = new worker.Worker("workers/worker.js");
worker.postMessage("hello world");
// worker.js
import worker from "@ohos.worker"
const parentPort = worker.parentPort;
parentPort.onmessageerror = function(e) {
console.log("onmessageerror...");
}
```
### Repositories Involved
- ace_ace_engine(foundation/arkui/ace_engine-readme.md)
- ace_napi(foundation/arkui/napi-readme.md)
## Related warehouse
[js_worker_module Subsystem](base/compileruntime/js_worker_module-readme.md)
### License
Worker is available under [Mozilla license](https://www.mozilla.org/en-US/MPL/), and the documentation is detailed in [documentation](https://gitee.com/openharmony/js_worker_module/blob/master/mozilla_docs.txt). See [LICENSE](https://gitee.com/openharmony/js_worker_module/blob/master/LICENSE) for the full license text.
-368
View File
@@ -1,368 +0,0 @@
# js_worker_module
### 简介
worker能够让js拥有多线程的能力,通过postMessage完成worker线程与宿主线程通信。
### 接口说明
接口实现详见:js_worker_module/jsapi/worker
#### Worker对象描述
宿主线程用于与worker线程通信的Object对象。
##### 接口
1.
- 接口名
|constructor(scriptURL:string, options? WorkerOptions) | 构造函数 |
|---|---|
- 使用示例
```
import worker from "@ohos.worker"
const worker = new worker.Worker("workers/worker.js");
```
2.
- 接口名
| postMessage(message:Object, options?:PostMessageOptions) | 向worker线程发送消息 |
|---|---|
| postMessage(message:Object, transfer:ArrayBuffer[]) | 向worker线程发送消息 |
- 使用示例
```
// 示例一
import worker from "@ohos.worker"
const worker = new worker.Worker("workers/worker.js");
worker.postMessage("hello world");
// 示例二
import worker from "@ohos.worker"
const worker = new worker.Worker("workers/worker.js");
var buffer = new ArrayBuffer(8);
worker.postMessage(buffer, [buffer]);
```
3.
- 接口名
| on(type:string, listener:EventListener) | 向worker添加一个事件监听 |
|---|---|
- 使用示例
```
import worker from "@ohos.worker"
const worker = new worker.Worker("workers/worker.js");
worker.on("alert", (e)=>{
console.log("worker on...");
})
```
4.
- 接口名
| once(type:string, listener:EventListener) | 向worker添加一个事件监听, 事件监听只执行一次便自动删除 |
|---|---|
- 使用示例
```
import worker from "@ohos.worker"
const worker = new worker.Worker("workers/worker.js");
worker.once("alert", (e)=>{
console.log("worker on...");
})
```
5.
- 接口名
| off(type:string, listener?:EventListener) | 删除worker的事件监听 |
|---|---|
- 使用示例
```
import worker from "@ohos.worker"
const worker = new worker.Worker("workers/worker.js");
worker.off("alert");
```
6.
- 接口名
| terminate() | 关闭worker线程,终止worker发送消息 |
|---|---|
- 使用示例
```
import worker from "@ohos.worker"
const worker = new worker.Worker("workers/worker.js");
worker.terminate();
```
7.
- 接口名
| removeEventListener(type:string, listener?:EventListener) | 删除worker的事件监听 |
|---|---|
- 使用示例
```
import worker from "@ohos.worker"
const worker = new worker.Worker("workers/worker.js");
worker.removeEventListener("alert");
```
8.
- 接口名
| dispatchEvent(event: Event) | 分发定义在worker的事件 |
|---|---|
- 使用示例
```
import worker from "@ohos.worker"
const worker = new worker.Worker("workers/worker.js");
worker.dispatchEvent({type:"alert"});
```
9.
- 接口名
| removeAllListener() | 删除worker的所有事件监听 |
|---|---|
- 使用示例
```
import worker from "@ohos.worker"
const worker = new worker.Worker("workers/worker.js");
worker.removeAllListener();
```
##### 属性
1.
- 属性名
| onexit?:(code:number)=>void | worker退出时被调用的事件处理程序,处理程序在宿主线程中执行 |
|---|---|
- 使用示例
```
import worker from "@ohos.worker"
const worker = new worker.Worker("workers/worker.js");
worker.onexit = function(e) {
console.log("onexit...");
}
```
2.
- 属性名
| onerror?:(ev:ErrorEvent)=>void | worker在执行过程中发生异常被调用的事件处理程序,处理程序在宿主线程中执行 |
|---|---|
- 使用示例
```
import worker from "@ohos.worker"
const worker = new worker.Worker("workers/worker.js");
worker.onerror = function(e) {
console.log("onerror...");
}
```
3.
- 属性名
| onmessage?:(ev:MessageEvent)=>void | 宿主线程收到来自其创建的worker通过parentPort.postMessage接口发送的消息时被调用的事件处理程序, 处理程序在宿主线程中执行 |
|---|---|
- 使用示例
```
import worker from "@ohos.worker"
const worker = new worker.Worker("workers/worker.js");
worker.onmessage = function(e) {
console.log("onmessage...");
}
```
4.
- 属性名
| onmessageerror?:(event:MessageEvent)=>void | worker对象接收到一条无法序列化的消息时被调用的事件处理程序, 处理程序在宿主线程中执行 |
|---|---|
- 使用示例
```
import worker from "@ohos.worker"
const worker = new worker.Worker("workers/worker.js");
worker.onmessageerror = function(e) {
console.log("onmessageerror...");
}
```
#### parentPort对象描述
worker线程用于与宿主线程通信的Object对象。
##### 接口
1.
- 接口名
| postMessage(message:Object, options?:PostMessageOptions) | 向宿主线程发送消息 |
|---|---|
| postMessage(message:Object, transfer:ArrayBuffer[]) | 向宿主线程发送消息 |
- 使用示例
```
// main.js
import worker from "@ohos.worker"
const worker = new worker.Worker("workers/worker.js");
worker.postMessage("hello world");
// worker.js
import worker from "@ohos.worker"
const parentPort = worker.parentPort;
parentPort.onmessage = function(e) {
parentPort.postMessage("hello world from worker.js");
}
```
2.
- 接口名
| close() | 关闭worker线程,终止worker接收消息 |
|---|---|
- 使用示例
```
// main.js
import worker from "@ohos.worker"
const worker = new worker.Worker("workers/worker.js");
worker.postMessage("hello world");
// worker.js
import worker from "@ohos.worker"
const parentPort = worker.parentPort;
parentPort.onmessage = function(e) {
parentPort.close();
}
```
##### 属性
1.
- 属性名
| onmessage?:(event:MessageEvent)=>void | 宿主线程收到来自其创建的worker通过worker.postMessage接口发送的消息时被调用的事件处理程序,处理程序在worker线程中执行 |
|---|---|
- 使用示例
```
// main.js
import worker from "@ohos.worker"
const worker = new worker.Worker("workers/worker.js");
worker.postMessage("hello world");
// worker.js
import worker from "@ohos.worker"
const parentPort = worker.parentPort;
parentPort.onmessage = function(e) {
console.log("receive main.js message");
}
```
2.
- 属性名
| onerror?:(ev: ErrorEvent)=>void | worker在执行过程中发生异常被调用的事件处理程序,处理程序在worker线程中执行 |
|---|---|
- 使用示例
```
// main.js
import worker from "@ohos.worker"
const worker = new worker.Worker("workers/worker.js");
worker.postMessage("hello world");
// worker.js
import worker from "@ohos.worker"
const parentPort = worker.parentPort;
parentPort.onerror = function(e) {
console.log("onerror...");
}
```
3.
- 属性名
| onmessageerror?:(event: MessageEvent)=>void | worker对象接收到一条无法被反序列化的消息时被调用的事件处理程序, 处理程序在worker线程中执行 |
|---|---|
- 使用示例
```
// main.js
import worker from "@ohos.worker"
const worker = new worker.Worker("workers/worker.js");
worker.postMessage("hello world");
// worker.js
import worker from "@ohos.worker"
const parentPort = worker.parentPort;
parentPort.onmessageerror = function(e) {
console.log("onmessageerror...");
}
```
### 涉及仓
- ace_ace_engine(foundation/arkui/ace_engine-readme_zh.md)
- ace_napi(foundation/arkui/napi-readme_zh.md)
## 相关仓
[js_worker_module 子系统](base/compileruntime/js_worker_module-readme_zh.md)
### 许可证
Worker在[Mozilla许可证](https://www.mozilla.org/en-US/MPL/)下可用,说明文档详见[说明文档](https://gitee.com/openharmony/js_worker_module/blob/master/mozilla_docs.txt)。有关完整的许可证文本,有关完整的许可证文本,请参见[许可证](https://gitee.com/openharmony/js_worker_module/blob/master/LICENSE)
-58
View File
@@ -1,58 +0,0 @@
{
"name": "@ohos/js_worker_module",
"version": "",
"description": "Provide JS multi-threading capability | 提供JS多线程能力",
"homePage": "https://gitee.com/openharmony",
"license": "Apache V2",
"repository": "https://gitee.com/openharmony/js_worker_module",
"domain": "os",
"language": "",
"publishAs": "code-segment",
"private": false,
"scripts": {},
"tags": [
"js"
],
"keywords": [
"js",
"worker",
"module"
],
"envs": {},
"dirs": {},
"author": {
"name": "",
"email": "",
"url": ""
},
"contributors": [
{
"name": "",
"email": "",
"url": ""
}
],
"segment": {
"destPath": "base/compileruntime/js_worker_module"
},
"component": {
"name": "jsapi_worker",
"subsystem": "utils",
"syscap": [],
"features": [],
"adapted_system_type": [],
"rom": "",
"ram": "",
"deps": {
"components": [],
"third_party": []
},
"build": {
"sub_component": [
"//base/compileruntime/js_worker_module:jsapi_packages"
],
"inner_kits": [],
"test": []
}
}
}
+1 -1
View File
@@ -13,7 +13,7 @@
* limitations under the License.
*/
#include "base/compileruntime/js_worker_module/helper/napi_helper.h"
#include "napi_helper.h"
#include "native_engine/native_value.h"
+1 -1
View File
@@ -13,7 +13,7 @@
* limitations under the License.
*/
#include "base/compileruntime/js_worker_module/plugin/timer.h"
#include "timer.h"
#include "utils/log.h"
+2 -2
View File
@@ -19,8 +19,8 @@
#include <map>
#include <uv.h>
#include "base/compileruntime/js_worker_module/helper/napi_helper.h"
#include "base/compileruntime/js_worker_module/helper/object_helper.h"
#include "../helper/napi_helper.h"
#include "../helper/object_helper.h"
#include "napi/native_api.h"
#include "napi/native_node_api.h"
+1 -1
View File
@@ -13,7 +13,7 @@
* limitations under the License.
*/
#include "base/compileruntime/js_worker_module/worker/message_queue.h"
#include "message_queue.h"
#include "utils/log.h"
namespace CompilerRuntime::WorkerModule {
@@ -13,7 +13,7 @@
* limitations under the License.
*/
#include "base/compileruntime/js_worker_module/worker/worker.h"
#include "worker.h"
/*
* module define
+1 -1
View File
@@ -13,7 +13,7 @@
* limitations under the License.
*/
#include "base/compileruntime/js_worker_module/worker/thread.h"
#include "thread.h"
namespace CompilerRuntime::WorkerModule {
Thread::Thread() : tId_() {}
+2 -2
View File
@@ -13,8 +13,8 @@
* limitations under the License.
*/
#include "base/compileruntime/js_worker_module/worker/worker.h"
#include "base/compileruntime/js_worker_module/plugin/timer.h"
#include "worker.h"
#include "../plugin/timer.h"
namespace CompilerRuntime::WorkerModule {
const static int MAXWORKERS = 8;
+4 -4
View File
@@ -19,10 +19,10 @@
#include <list>
#include <map>
#include <mutex>
#include "base/compileruntime/js_worker_module/worker/message_queue.h"
#include "base/compileruntime/js_worker_module/helper/napi_helper.h"
#include "base/compileruntime/js_worker_module/helper/object_helper.h"
#include "base/compileruntime/js_worker_module/worker/worker_runner.h"
#include "message_queue.h"
#include "../helper/napi_helper.h"
#include "../helper/object_helper.h"
#include "worker_runner.h"
#include "napi/native_api.h"
#include "napi/native_node_api.h"
#include "native_engine/native_engine.h"
+2 -2
View File
@@ -13,9 +13,9 @@
* limitations under the License.
*/
#include "base/compileruntime/js_worker_module/worker/worker_runner.h"
#include "worker_runner.h"
#include "base/compileruntime/js_worker_module/helper/object_helper.h"
#include "../helper/object_helper.h"
namespace CompilerRuntime::WorkerModule {
WorkerRunner::WorkerRunner(WorkerStartCallback callback) : callback_(callback), selfThreadId_(uv_thread_self()) {}
+1 -1
View File
@@ -19,7 +19,7 @@
#include <functional>
#include "native_engine/native_engine.h"
#include "base/compileruntime/js_worker_module/worker/thread.h"
#include "thread.h"
namespace CompilerRuntime::WorkerModule {
struct WorkerStartCallback {