diff --git a/OpenHarmony/.eslintignore b/OpenHarmony/.eslintignore
new file mode 100644
index 000000000..9965211db
--- /dev/null
+++ b/OpenHarmony/.eslintignore
@@ -0,0 +1,3 @@
+hvigor/hvigor-wrapper.js
+entry/src/main/ets/pages/user.js
+src/main/ets/pages/user.d.ts
\ No newline at end of file
diff --git a/OpenHarmony/.gitignore b/OpenHarmony/.gitignore
new file mode 100644
index 000000000..c05990056
--- /dev/null
+++ b/OpenHarmony/.gitignore
@@ -0,0 +1,18 @@
+*.iml
+.gradle
+/local.properties
+/.idea
+.DS_Store
+/build
+/captures
+.externalNativeBuild
+/entry/.preview
+.cxx
+/node_modules
+/.preview
+**/build
+.hvigor
+**/package-lock.json
+/oh_modules
+/entry/oh_modules
+/oh-package-lock.json5
\ No newline at end of file
diff --git a/OpenHarmony/AppScope/app.json5 b/OpenHarmony/AppScope/app.json5
new file mode 100644
index 000000000..9262595c6
--- /dev/null
+++ b/OpenHarmony/AppScope/app.json5
@@ -0,0 +1,10 @@
+{
+ "app": {
+ "bundleName": "cn.openharmony.protobuf",
+ "vendor": "example",
+ "versionCode": 1000000,
+ "versionName": "1.0.0",
+ "icon": "$media:app_icon",
+ "label": "$string:app_name"
+ }
+}
diff --git a/OpenHarmony/AppScope/resources/base/element/string.json b/OpenHarmony/AppScope/resources/base/element/string.json
new file mode 100644
index 000000000..eb88f5608
--- /dev/null
+++ b/OpenHarmony/AppScope/resources/base/element/string.json
@@ -0,0 +1,8 @@
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "protobuf"
+ }
+ ]
+}
diff --git a/OpenHarmony/AppScope/resources/base/media/app_icon.png b/OpenHarmony/AppScope/resources/base/media/app_icon.png
new file mode 100644
index 000000000..ce307a882
Binary files /dev/null and b/OpenHarmony/AppScope/resources/base/media/app_icon.png differ
diff --git a/OpenHarmony/CHANGELOG.md b/OpenHarmony/CHANGELOG.md
new file mode 100644
index 000000000..e8c67e68b
--- /dev/null
+++ b/OpenHarmony/CHANGELOG.md
@@ -0,0 +1,40 @@
+### 3.0.0
+- Support BigInt type
+
+### 2.1.0
+- 发布2.1.0正式版
+
+### 2.1.0-rc.0
+- 重构protobufjs运行时,修复了taskpool下重复序列化反序列化数据丢失的问题
+
+### 2.0.1
+- 更新README:修改了依赖的引入名称,更新了bigint在protobuf中的使用方式
+
+### 2.0.0
+- 适配DevEco Studio 版本:4.1 Canary(4.1.3.317),OpenHarmony SDK:API11 (4.1.0.36)
+- ArkTS新语法适配
+- protobufjs 7.2.4 版本适配
+- 取消以load方式加载proto文件或者字符串
+
+### 1.2.1
+1.适配DevEco Studio 3.1 Beta1版本
+
+### 1.2.0
+1.适配api9
+
+### 1.1.1
+1.新增rpc和websocket使用样例
+
+### 1.1.0
+1.样例适配的系统版本是OpenHarmony API Version 8,且将原来工程转为hvigor工程。
+
+### 1.0.0
+
+1.样例适配的系统版本是OpenHarmony API Version 5~7。
+
+2.使用三方库protobufjs版本支持@5.0.3
+
+3.支持序列化和反序列化的样例
+
+4.支持buffer读写的样例
+
diff --git a/OpenHarmony/LICENSE b/OpenHarmony/LICENSE
new file mode 100644
index 000000000..57b7e3097
--- /dev/null
+++ b/OpenHarmony/LICENSE
@@ -0,0 +1,39 @@
+This license applies to all parts of protobuf.js except those files
+either explicitly including or referencing a different license or
+located in a directory containing a different LICENSE file.
+
+---
+
+Copyright (c) 2016, Daniel Wirtz All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+* Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+* Neither the name of its author, nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+---
+
+Code generated by the command line utilities is owned by the owner
+of the input file used when generating it. This code is not
+standalone and requires a support library to be linked with it. This
+support library is itself covered by the above license.
diff --git a/OpenHarmony/NOTICE b/OpenHarmony/NOTICE
new file mode 100644
index 000000000..ab64d42b2
--- /dev/null
+++ b/OpenHarmony/NOTICE
@@ -0,0 +1,45 @@
+OPEN SOURCE SOFTWARE NOTICE
+
+Please note we provide an open source software notice for the third party open source software along with this software and/or this software component (in the following just “this SOFTWARE”). The open source software licenses are granted by the respective right holders.
+
+Warranty Disclaimer
+THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
+
+Copyright Notice and License Texts
+
+----------------------------------------------------------------------
+Software: protobufjs 7.2.4
+
+Copyright (c) 2016, Daniel Wirtz All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+* Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+* Neither the name of its author, nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+---
+
+Code generated by the command line utilities is owned by the owner
+of the input file used when generating it. This code is not
+standalone and requires a support library to be linked with it. This
+support library is itself covered by the above license.
\ No newline at end of file
diff --git a/OpenHarmony/OAT.xml b/OpenHarmony/OAT.xml
new file mode 100644
index 000000000..3ece0b965
--- /dev/null
+++ b/OpenHarmony/OAT.xml
@@ -0,0 +1,125 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OpenHarmony/README.OpenSource b/OpenHarmony/README.OpenSource
new file mode 100644
index 000000000..b2400242a
--- /dev/null
+++ b/OpenHarmony/README.OpenSource
@@ -0,0 +1,11 @@
+[
+ {
+ "Name": "protobuf",
+ "License": "BSD 3-Clause License",
+ "License File": " LICENSE ",
+ "Version Number": "7.2.4",
+ "Owner" : "xiafeng@huawei.com",
+ "Upstream URL": "https://github.com/protobufjs/protobuf.js",
+ "Description": "protoubuf.js is a pure JavaScript implementation with TypeScript for node.js and the browser.Its easy to use,blazingly fast and works out of the box with .proto files "
+ }
+]
\ No newline at end of file
diff --git a/OpenHarmony/README.md b/OpenHarmony/README.md
new file mode 100644
index 000000000..0044e1d1a
--- /dev/null
+++ b/OpenHarmony/README.md
@@ -0,0 +1,294 @@
+# protobuf
+
+## Introduction
+
+Protocol buffers (ProtoBuf) is a language-neutral, platform-neutral extensible mechanism for serializing structured data. It is used in (data) communication protocols and for data storage. As a flexible, efficient, and automatic structured data serialization method, ProtoBuf is smaller, faster, and simpler than XML.
+
+In this project, [protobuf.js 7.2.4](https://github.com/protobufjs/protobuf.js) has been adapted for use with OpenHarmony.
+
+## How to Install
+
+1. Install protobufjs.
+
+```
+ohpm install @ohos/protobufjs
+```
+For details about the OpenHarmony ohpm environment configuration, see [OpenHarmony HAR](https://gitcode.com/openharmony-tpc/docs/blob/master/OpenHarmony_har_usage.en.md).
+
+
+2. Define a message body struct in a .proto file.
+
+For example, define a message body struct in the **userproto.proto** file.
+
+```
+syntax = "proto3";
+
+package user;
+message UserLoginResponse{
+ string sessionId = 1;
+ string userPrivilege = 2;
+ bool isTokenType = 3;
+ int64 formatTimestamp = 5;
+ bytes data =6;
+}
+```
+
+3. Generate .js and .d.ts files.
+
+```
+Install protobufjs globally.
+npm install -g protobufjs@7.2.4
+Install protobufjs-cli globally.
+npm install -g protobufjs-cli
+
+Run the following commands in the .proto file directory:
+pbjs -t static-module -w es6 -o user.js user.proto
+pbts user.js -o user.d.ts
+```
+
+4. Modify the generated files.
+
+```
+1. In the .js file, change import * as $protobuf from "protobufjs/minimal"; to
+**import { index } from "@ohos/protobufjs";
+const $protobuf = index;**.
+
+2. In the generated .d.ts file, change import * as $protobuf from "protobufjs"; to
+**import * as $protobuf from "@ohos/protobufjs";**.
+
+3. In the generated .js file, add the following code below const $protobuf = index;:
+import Long from 'long';
+$protobuf.util.Long=Long
+$protobuf.configure()
+```
+
+5. Install long in the **entry** directory.
+
+```
+ohpm install long
+```
+
+6. use BigInt
+
+```
+In the generated JS file, add $protobuf.util Set Long to undefined
+
+import Long from 'long';
+$protobuf.util.Long = undefined
+$protobuf.configure()
+
+let msg = user.UserLoginResponse.create({
+ sessionId: "215135415351435",
+ userPrivilege: "John123",
+ isTokenType: false,
+ formatTimestamp: BigInt("9223372036854775807"),
+);
+```
+
+7. Copy the generated .js and .d.ts files to the project.
+
+## Using protobufjs-cli
+```
+Translate between file formats and generate static code.
+ -t, --target Specifies the target format, which can be any of the following:
+ json JSON
+ json-module JSON representation as a module
+ proto2 Protocol Buffers, Version 2
+ proto3 Protocol Buffers, Version 3
+ static Static code without reflection (non-functional on its own)
+ static-module Static code without reflection as a module
+ -p, --path Adds a directory to the include path.
+ -o, --out Saves a file instead of writing to stdout.
+ --sparse Exports only those types referenced from a main file (experimental).
+ Module targets only:
+ -w, --wrap Specifies the wrapper to use, which can be any of the following:
+ default Default wrapper supporting both CommonJS and AMD
+ commonjs CommonJS wrapper
+ amd AMD wrapper
+ es6 ES6 wrapper
+ closure A closure added to protobuf.roots where protobuf is global
+ --dependency Specifies the protobuf version. A valid module ID is accepted.
+ -r, --root Specifies an alternative protobuf.roots name.
+ -l, --lint Linter configuration. Defaults to protobuf.js-compatible rules:
+ eslint-disable block-scoped-var, id-length,
+ no-control-regex, no-magic-numbers, no-prototype-builtins,
+ no-redeclare, no-shadow, no-var, sort-vars
+ --es6 Enables ES6 syntax.
+ Proto sources only:
+ --keep-case Keeps field casing instead of converting to camel case.
+ Static targets only:
+ --no-create Does not generate create functions used for reflection compatibility.
+ --no-encode Does not generate encode functions.
+ --no-decode Does not generate decode functions.
+ --no-verify Does not generate verify functions.
+ --no-convert Does not generate convert functions.
+ --no-delimited Does not generate delimited encode/decode functions.
+ --no-beautify Does not beautify generated code.
+ --no-comments Does not output any JSDoc annotations.
+ --force-long Enforces the use of 'Long' for s-/u-/int64 and s-/fixed64 fields.
+ --force-number Enforces the use of 'number' for s-/u-/int64 and s-/fixed64 fields.
+ --force-message Enforces the use of message instances instead of plain objects.
+```
+For details, see https://github.com/protobufjs/protobuf.js/blob/master/cli/README.md.
+
+## How to Use
+
+1. Proto code
+
+```
+import { user } from './user.js'
+
+ let msg = user.UserLoginResponse.create({
+ sessionId: "testSynchronouslyLoadProtoFile",
+ userPrivilege: "John123",
+ isTokenType: false,
+ formatTimestamp: "12342222"
+ });
+
+ let arrayBuffer: Uint8Array = user.UserLoginResponse.encode(msg).finish()
+```
+
+2. Proto code
+```
+let decodeMsg = user.UserLoginResponse.decode(arrayBuffer);
+```
+
+## Available APIs
+
+**create**
+
+create(properties?: { [k: string]: any }): Message<{}>
+
+Creates a message object.
+
+Parameters:
+
+| Name | Type | Mandatory| Description |
+| ---------- | ------ | ---- | -------------- |
+| properties | Object | No | Properties to set.|
+
+Return value:
+
+| Type | Description |
+| ------- | ------------- |
+| Message | **Message** instance created.|
+
+**encode**
+
+encode(message: (Message<{}>|{ [k: string]: any }), writer?: Writer): Writer
+
+Encodes a message.
+
+Parameters:
+
+| Name | Type | Mandatory| Description |
+| ------- | ---------------------------- | ---- | ------------------------- |
+| message | Message<{}> | Object | Yes | Message instance or object to encode.|
+| writer | Writer | No | Writer used to encode the message. |
+
+Return value:
+
+| Type | Description |
+| ------ | ------------------ |
+| Writer | Protocol message body builder.|
+
+**decode**
+
+decode(reader: (Reader|Uint8Array), length?: number): Message<{}>
+
+Decodes a message.
+
+| Name| Type | Mandatory| Description |
+| ------ | ------------------------ | ---- | ---------------------- |
+| reader | Reader | Uint8Array | Yes | Reader or buffer for decoding.|
+| length | number | No | Length. |
+
+Return value:
+
+| Type | Description |
+| ----------- | ------------ |
+| Message<{}> | Decoded message.|
+
+**verify**
+
+static verify(message: { [k: string]: any }): (string|null)
+
+Verifies the message validity.
+
+| Name | Type | Mandatory| Description |
+| ------- | -------- | ---- | ---------- |
+| message | Object.| Yes | Message to verify.|
+
+Return value:
+
+| Type | Description |
+| ------------------ | ------------------------------- |
+| string | null | Returns **null** if the value is valid; returns a specific cause otherwise.|
+
+**fromObject**
+
+static fromObject(object: { [k: string]: any }): Message<{}>
+
+Creates a message instance of this type from an object, and converts values to their respective internal types.
+
+Parameters:
+
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | -------- |
+| object | Object | Yes | Object.|
+
+Return value:
+
+| Type | Description |
+| ------ | ---------- |
+| object | Object created.|
+
+**toObject**
+
+static toObject(message: Message<{}>, options?: IConversionOptions): { [k: string]: any }
+
+Converts an array of key-value pairs to an object, omitting undefined values.
+
+| Name | Type | Mandatory| Description |
+| ------- | ------------------ | ---- | -------------- |
+| message | Message | Yes | Message to convert.|
+| options | IConversionOptions | No | Conversion options. |
+
+Return value:
+
+| Type | Description |
+| ------ | ---------- |
+| object | Object obtained.|
+
+
+## Constraints
+This project has been verified in the following version:
+
+- DevEco Studio: 4.1 Canary (4.1.3.317), OpenHarmony SDK: API 11 (4.1.0.36)
+
+## Directory Structure
+
+```
+|---- protobuf
+| |---- AppScrope # Sample code
+| |---- entry # Sample code
+| |---- library # Core library
+| |---- src/main # Module code
+| |---- ets/ # Module code
+| |---- dist # Package file
+| |---- index.ets # Entry file
+| |---- .ohpmignore # Ignore files released by ohpm
+| |---- *.json5 # Configuration file
+| |---- README.md # Readme
+| |---- README_zh.md # Readme
+| |---- README.OpenSource # Open source description
+| |---- CHANGELOG.md # Changelog
+```
+
+## How to Contribute
+
+If you find any problem when using the project, submit an [issue](https://gitcode.com/openharmony-tpc/protobuf/issues) or a [PR](https://gitcode.com/openharmony-tpc/protobuf/pulls).
+
+## License
+
+This project is licensed under [BSD License](https://gitcode.com/openharmony-tpc/protobuf/blob/master/LICENSE).
diff --git a/OpenHarmony/README_zh.md b/OpenHarmony/README_zh.md
new file mode 100644
index 000000000..57841c603
--- /dev/null
+++ b/OpenHarmony/README_zh.md
@@ -0,0 +1,295 @@
+# protobuf
+
+## 介绍
+
+ProtoBuf(protocol buffers) 是一种语言无关、平台无关、可扩展的序列化结构数据的方法,它可用于(数据)通信协议、数据存储等。,是一种灵活,高效,自动化机制的结构数据序列化方法比XML更小,更快,更为简单。
+
+本项目主要是OpenHarmony系统下以[protobuf.js 7.2.4](https://github.com/protobufjs/protobuf.js)为主要依赖开发,主要接口针对OpenHarmony系统进行合理的适配研发。
+
+## 下载安装
+
+1.安装
+
+```
+ohpm install @ohos/protobufjs
+```
+OpenHarmony ohpm环境配置等更多内容,请参考 [如何安装OpenHarmony ohpm包](https://gitcode.com/openharmony-tpc/docs/blob/master/OpenHarmony_har_usage.md) 。
+
+
+2.proto文件
+
+按照.proto文件格式定义消息体结构,如:userproto.proto文件。
+
+```
+syntax = "proto3";
+
+package user;
+message UserLoginResponse{
+ string sessionId = 1;
+ string userPrivilege = 2;
+ bool isTokenType = 3;
+ int64 formatTimestamp = 5;
+ bytes data =6;
+}
+```
+
+3.生成js和.d.ts文件
+
+```
+全局安装protobufjs
+npm install -g protobufjs@7.2.4
+全局安装protobufjs-cli
+npm install -g protobufjs-cli
+
+在.proto文件目录下执行下列命令
+pbjs -t static-module -w es6 -o user.js user.proto
+pbts user.js -o user.d.ts
+```
+
+4.修改生成的文件
+
+```
+1.将生成的js文件中的 import * as $protobuf from "protobufjs/minimal";
+修改为
+修改为 import $protobuf from "@ohos/protobufjs";
+
+2.将生成的.d.ts文件中的 import * as $protobuf from "protobufjs";
+修改为 import $protobuf from "@ohos/protobufjs";
+
+3.在生成的js文件中 const $protobuf = index;这行代码下方添加如下代码
+import Long from 'long';
+$protobuf.util.Long=Long
+$protobuf.configure()
+```
+
+5.在entry目录下安装long
+
+```
+ohpm install long
+```
+
+6.BigInt使用
+
+```
+在生成的js文件中 将$protobuf.util.Long 设置为undefined
+import Long from 'long';
+$protobuf.util.Long = undefined
+$protobuf.configure()
+
+let msg = user.UserLoginResponse.create({
+ sessionId: "215135415351435",
+ userPrivilege: "John123",
+ isTokenType: false,
+ formatTimestamp: BigInt("9223372036854775807")
+);
+```
+
+7.将生成js和.d.ts文件复制到工程中
+
+## protobufjs-cli使用说明
+```
+在文件格式之间转换并生成静态代码
+ -t, --target 指定目标格式,可以接受需要自定义目标的路径。
+ json JSON
+ json-module JSON表示为模块
+ proto2 Protocol Buffers, Version 2
+ proto3 Protocol Buffers, Version 3
+ static 无反射的静态代码(本身不起作用)
+ static-module 无反射模块的静态代码
+ -p, --path 将某个目录添加到包含路径中
+ -o, --out 保存文件而非写入到标准输出
+ --sparse 只导出从主文件引用的类型(实验)
+ 仅限模块目标:
+ -w, --wrap 指定要使用的包装器,可接受需要自定义包装器的路径。
+ default 默认包装器支持CommonJS与AMD标准
+ commonjs CommonJS包装器
+ amd AMD包装器
+ es6 ES6包装器
+ closure 添加到全局protobuf的protobuf.roots上的闭包
+ --dependency 指定protobuf版本,可接受有效的模块ID。
+ -r, --root 指定备用的protobuf.roots名称
+ -l, --lint Linter配置,默认protbuf.js兼容规则:
+ eslint-disable block-scoped-var, id-length,
+ no-control-regex, no-magic-numbers, no-prototype-builtins,
+ no-redeclare, no-shadow, no-var, sort-vars
+ --es6 启用ES6语法
+ 仅限原始源:
+ --keep-case 保留字段大小写而非是转换为驼峰大小写
+ 仅限静态目标:
+ --no-create 不生成用于反射兼容性的创建函数.
+ --no-encode 不生成编码函数.
+ --no-decode 不生成解码函数.
+ --no-verify 不生成验证函数.
+ --no-convert 不生成转换函数
+ --no-delimited 不生成风格的编码/解码函数.
+ --no-beautify 不美化生成的代码.
+ --no-comments 不输出任何JSDoc注释.
+ --force-long 强制对s-/u-/int64和s-/fixed64字段使用Long
+ --force-number 强制对s-/u-/int64和s-/fixed64字段使用number
+ --force-message 强制使用消息而非普通对象
+```
+详细使用方式请参考:https://github.com/protobufjs/protobuf.js/blob/master/cli/README.md
+
+## 使用说明
+
+1.proto编码
+
+```
+import { user } from './user.js'
+
+ let msg = user.UserLoginResponse.create({
+ sessionId: "testSynchronouslyLoadProtoFile",
+ userPrivilege: "John123",
+ isTokenType: false,
+ formatTimestamp: "12342222"
+ });
+
+ let arrayBuffer: Uint8Array = user.UserLoginResponse.encode(msg).finish()
+```
+
+2.proto编码
+```
+let decodeMsg = user.UserLoginResponse.decode(arrayBuffer);
+```
+
+## 接口说明
+
+**create**
+
+create(properties?: { [k: string]: any }): Message<{}>
+
+生成Message对象
+
+参数:
+
+| 参数名 | 类型 | 必填 | 说明 |
+| -------- |--------| ---- | ------------------------------------------------------ |
+| properties | Object | 否 | 要设置的属性。 |
+
+返回值:
+
+| 类型 | 说明 |
+| ------- |------------|
+| Message | Message实例。 |
+
+**encode**
+
+encode(message: (Message<{}>|{ [k: string]: any }), writer?: Writer): Writer
+
+编码消息
+
+参数
+
+| 参数名 | 类型 | 必填 | 说明 |
+| -------- |------------------------------| ---- |-----------------------------|
+| message | Message<{}> | Object | 是 | Message示例或者普通对象。 |
+| writer | Writer | 否 | 编码的写入器。 |
+
+返回值:
+
+| 类型 | 说明 |
+| ------- | ------------------ |
+| Writer | 协议消息体构建器。 |
+
+**decode**
+
+decode(reader: (Reader|Uint8Array), length?: number): Message<{}>
+
+解码消息
+
+| 参数名 | 类型 | 必填 | 说明 |
+| --------------- | ------------------------------------------ | ---- |------------|
+| reader | Reader | Uint8Array | 是 | 解码的读取器或缓冲区。 |
+| length | number | 否 | 长度。 |
+
+返回值:
+
+| 类型 | 说明 |
+| ------------------- | ------------------ |
+| Message<{}> | 解码的消息。 |
+
+**verify**
+
+static verify(message: { [k: string]: any }): (string|null)
+
+验证消息有效性
+
+| 参数名 | 类型 | 必填 | 说明 |
+| --------------- |------| ---- | ------------------------------------------------------------ |
+| message | 普通对象 | 是 | 普通对象。 |
+
+返回值:
+
+| 类型 | 说明 |
+|--------------------|--------------------|
+| string | null | 合法返回null,否则返回具体原因。 |
+
+**fromObject**
+
+static fromObject(object: { [k: string]: any }): Message<{}>
+
+从纯对象创建此类型的新消息。还将值转换为各自的内部类型
+
+参数:
+
+| 参数名 | 类型 | 必填 | 说明 |
+| -------- |-------------------------------------------------------------| ---- |------|
+| object | Object | 是 | 普通对象 |
+
+返回值:
+
+| 类型 | 说明 |
+| ------- | ------------------ |
+| object | 普通对象。 |
+
+**toObject**
+
+static toObject(message: Message<{}>, options?: IConversionOptions): { [k: string]: any }
+
+将一个由键及其各自的值组成的数组转换为对象,省略未定义的值
+
+| 参数名 | 类型 | 必填 | 说明 |
+|-----------------|----------------------------------------| ---- |---------------|
+| message | Message | 是 | Message 消息对象。 |
+| options | IConversionOptions | 否 | 转换选项。 |
+
+返回值:
+
+| 类型 | 说明 |
+| ------- | ------------------ |
+| object | 普通对象。 |
+
+
+## 约束与限制
+在下述版本验证通过:
+
+- DevEco Studio: NEXT Beta1-5.0.3.806, SDK: API12 Release(5.0.0.66)
+
+- DevEco Studio 版本:4.1 Canary(4.1.3.317),OpenHarmony SDK:API11 (4.1.0.36)
+
+## 目录结构
+
+```
+|---- protobuf
+| |---- AppScrope # 示例代码文件夹
+| |---- entry # 示例代码文件夹
+| |---- library # 核心库
+| |---- src/main # 模块代码
+| |---- ets/ # 模块代码
+| |---- dist # 打包文件
+| |---- index.ets # 入口文件
+| |---- .ohpmignore # ohpm发布的忽略文件
+| |---- *.json5 # 配置文件
+| |---- README.md # 安装使用方法
+| |---- README_zh.md # 安装使用方法
+| |---- README.OpenSource # 开源说明
+| |---- CHANGELOG.md # 更新日志
+```
+
+## 贡献代码
+
+使用过程中发现任何问题都可以提 [Issue](https://gitcode.com/openharmony-tpc/protobuf/issues) 给组件,当然,也非常欢迎发 [PR](https://gitcode.com/openharmony-tpc/protobuf/pulls)共建 。
+
+## 开源协议
+
+本项目基于 [BSD License](https://gitcode.com/openharmony-tpc/protobuf/blob/master/LICENSE) ,请自由地享受和参与开源。
diff --git a/OpenHarmony/build-profile.json5 b/OpenHarmony/build-profile.json5
new file mode 100644
index 000000000..8f713a632
--- /dev/null
+++ b/OpenHarmony/build-profile.json5
@@ -0,0 +1,41 @@
+{
+ "app": {
+ "signingConfigs": [],
+ "products": [
+ {
+ "name": "default",
+ "compileSdkVersion": 12,
+ "compatibleSdkVersion": 12,
+ "targetSdkVersion": 12,
+ "runtimeOS": "OpenHarmony",
+ "signingConfig": "debug_default"
+ }
+ ],
+ "buildModeSet": [
+ {
+ "name": "debug"
+ },
+ {
+ "name": "release"
+ }
+ ]
+ },
+ "modules": [
+ {
+ "name": "entry",
+ "srcPath": "./entry",
+ "targets": [
+ {
+ "name": "default",
+ "applyToProducts": [
+ "default"
+ ]
+ }
+ ]
+ },
+ {
+ "name": "library",
+ "srcPath": "./library"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/OpenHarmony/entry/.gitignore b/OpenHarmony/entry/.gitignore
new file mode 100644
index 000000000..e2713a277
--- /dev/null
+++ b/OpenHarmony/entry/.gitignore
@@ -0,0 +1,6 @@
+/node_modules
+/oh_modules
+/.preview
+/build
+/.cxx
+/.test
\ No newline at end of file
diff --git a/OpenHarmony/entry/build-profile.json5 b/OpenHarmony/entry/build-profile.json5
new file mode 100644
index 000000000..75c41e9ad
--- /dev/null
+++ b/OpenHarmony/entry/build-profile.json5
@@ -0,0 +1,13 @@
+{
+ "apiType": "stageMode",
+ "buildOption": {
+ },
+ "targets": [
+ {
+ "name": "default"
+ },
+ {
+ "name": "ohosTest",
+ }
+ ]
+}
\ No newline at end of file
diff --git a/OpenHarmony/entry/hvigorfile.ts b/OpenHarmony/entry/hvigorfile.ts
new file mode 100644
index 000000000..c6edcd904
--- /dev/null
+++ b/OpenHarmony/entry/hvigorfile.ts
@@ -0,0 +1,6 @@
+import { hapTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/OpenHarmony/entry/oh-package.json5 b/OpenHarmony/entry/oh-package.json5
new file mode 100644
index 000000000..85a4f42d7
--- /dev/null
+++ b/OpenHarmony/entry/oh-package.json5
@@ -0,0 +1,18 @@
+{
+ "license": "BSD License",
+ "devDependencies": {},
+ "author": "",
+ "name": "entry",
+ "description": "example description",
+ "ohos": {
+ "org": "huawei",
+ "directoryLevel": "module",
+ "buildTool": "hvigor"
+ },
+ "main": "",
+ "version": "3.0.0",
+ "dependencies": {
+ "@ohos/protobufjs": "file:../library",
+ "long": "^5.2.1"
+ }
+}
\ No newline at end of file
diff --git a/OpenHarmony/entry/src/main/ets/entryability/EntryAbility.ts b/OpenHarmony/entry/src/main/ets/entryability/EntryAbility.ts
new file mode 100644
index 000000000..5f0b372eb
--- /dev/null
+++ b/OpenHarmony/entry/src/main/ets/entryability/EntryAbility.ts
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2022 Huawei Device Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import AbilityConstant from '@ohos.app.ability.AbilityConstant';
+import hilog from '@ohos.hilog';
+import UIAbility from '@ohos.app.ability.UIAbility';
+import Want from '@ohos.app.ability.Want';
+import window from '@ohos.window';
+
+export default class EntryAbility extends UIAbility {
+ onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
+ }
+
+ onDestroy() {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
+ }
+
+ onWindowStageCreate(windowStage: window.WindowStage) {
+ // Main window is created, set main page for this ability
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
+
+ windowStage.loadContent('pages/index', (err, data) => {
+ if (err.code) {
+ hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
+ return;
+ }
+ hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? '');
+ });
+ }
+
+ onWindowStageDestroy() {
+ // Main window is destroyed, release UI related resources
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
+ }
+
+ onForeground() {
+ // Ability has brought to foreground
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
+ }
+
+ onBackground() {
+ // Ability has back to background
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
+ }
+}
diff --git a/OpenHarmony/entry/src/main/ets/pages/index.ets b/OpenHarmony/entry/src/main/ets/pages/index.ets
new file mode 100644
index 000000000..dbc36818f
--- /dev/null
+++ b/OpenHarmony/entry/src/main/ets/pages/index.ets
@@ -0,0 +1,217 @@
+/*
+ * Copyright (c) 2022 Huawei Device Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import Long from 'long';
+
+import { user } from './user.js'
+import buffer from '@ohos.buffer'
+import util from '@ohos.util';
+
+@Entry
+@Component
+struct Index {
+ @State result: string = "";
+ str: string = '';
+ scroller: Scroller = new Scroller();
+ controller: TextInputController = new TextInputController();
+ bigInt:string='9223372036854775807'
+
+ getResourceString(res: Resource) {
+ return getContext().resourceManager.getStringSync(res.id)
+ }
+ build() {
+ Stack({ alignContent: Alignment.TopStart }) {
+ Scroll(this.scroller) {
+ Column() {
+ Text($r('app.string.proto_serialization_deserialization'))
+ .width('90%')
+ .height(60)
+ .backgroundColor(0xFFFFFF)
+ .borderRadius(15)
+ .fontSize(16)
+ .textAlign(TextAlign.Center)
+ .margin({ top: 10 })
+ .onClick(event => {
+ this.result = ""
+ let msg = user.UserLoginResponse.create({
+ sessionId: "215135415351435",
+ userPrivilege: "John123",
+ isTokenType: false,
+ formatTimestamp: Long.fromString("9223372036854775807"),
+ data:new Uint8Array(buffer.from(this.getResourceString($r('app.string.test'))).buffer)
+ });
+
+ let arrayBuffer: Uint8Array = user.UserLoginResponse.encode(msg).finish()
+ console.log("protobuf arrayBuffer:" + arrayBuffer);
+ this.result = this.result + this.getResourceString($r('app.string.serialized_data'))+":" + JSON.stringify(arrayBuffer) + "\r\n";
+
+ let decodeMsg = user.UserLoginResponse.decode(arrayBuffer);
+ let timestamp=decodeMsg.formatTimestamp as Long
+ const decoder = util.TextDecoder.create('utf-8');
+ const utfStr = decoder.decodeToString(decodeMsg.data);
+ this.result = this.result + this.getResourceString($r('app.string.Deserialize_data'))+": \r\n"
+ +"sessionId: " + decodeMsg.sessionId+"\r\n"
+ +"userPrivilege: " + decodeMsg.userPrivilege+"\r\n"
+ +"isTokenType: " + decodeMsg.isTokenType+"\r\n"
+ +"formatTimesStamp: " + timestamp.toString()+"\r\n"
+ + "data: " + utfStr
+ });
+
+ TextInput({ text: this.bigInt})
+ .width('90%')
+ .height(50)
+ .margin({ top: 10 })
+ .onChange((value: string) => {
+ this.bigInt = value;
+ })
+
+ Text($r('app.string.proto_serialization_deserialization_bigInt'))
+ .width('90%')
+ .height(60)
+ .backgroundColor(0xFFFFFF)
+ .borderRadius(15)
+ .fontSize(16)
+ .textAlign(TextAlign.Center)
+ .margin({ top: 10 })
+ .onClick(event => {
+ this.result = ""
+ let msg = user.UserLoginResponse.create({
+ sessionId: "215135415351435",
+ userPrivilege: "John123",
+ isTokenType: false,
+ formatTimestamp: BigInt(this.bigInt),
+ });
+
+ let arrayBuffer: Uint8Array = user.UserLoginResponse.encode(msg).finish()
+ this.result = this.result + this.getResourceString($r('app.string.serialized_data'))+":" + JSON.stringify(arrayBuffer) + "\r\n";
+
+ let decodeMsg = user.UserLoginResponse.decode(arrayBuffer);
+ let timestamp=decodeMsg.formatTimestamp
+ this.result = this.result + this.getResourceString($r('app.string.Deserialize_data'))+": \r\n"
+ +"sessionId: " + decodeMsg.sessionId+"\r\n"
+ +"userPrivilege: " + decodeMsg.userPrivilege+"\r\n"
+ +"isTokenType: " + decodeMsg.isTokenType+"\r\n"
+ +"formatTimesStamp: " + timestamp.toString()+"\r\n"
+ });
+
+
+ Text(this.getResourceString($r('app.string.proto_serialization_deserialization'))+`( ${this.getResourceString($r('app.string.Encode_to_decode'))} )`)
+ .width('90%')
+ .height(60)
+ .backgroundColor(0xFFFFFF)
+ .borderRadius(15)
+ .fontSize(16)
+ .textAlign(TextAlign.Center)
+ .margin({ top: 10 })
+ .onClick(event => {
+ this.result = "";
+ let msg = user.UserLoginResponse.create({
+ sessionId: "testSynchronouslyLoadProtoFile",
+ userPrivilege: "John123",
+ isTokenType: false,
+ formatTimestamp: Long.fromString("9007199254740991")
+ });
+
+
+ let arrayBuffer: Uint8Array = user.UserLoginResponse.encodeDelimited(msg).finish()
+ console.log("protobuf arrayBuffer:" + arrayBuffer);
+ this.result = this.result + this.getResourceString($r('app.string.serialized_data'))+":" + JSON.stringify(arrayBuffer) + "\r\n";
+
+ let decodeMsg = user.UserLoginResponse.decodeDelimited(arrayBuffer);
+ let timestamp=decodeMsg.formatTimestamp
+ console.info("protobuf--> timestamp: "+timestamp)
+ this.result = this.result + this.getResourceString($r('app.string.Deserialize_data'))+": \r\n"
+ +"sessionId: " + decodeMsg.sessionId+"\r\n"
+ +"userPrivilege: " + decodeMsg.userPrivilege+"\r\n"
+ +"isTokenType: " + decodeMsg.isTokenType+"\r\n"
+ +"formatTimesStamp: " + timestamp.toString()+"\r\n"
+ });
+
+ Text($r('app.string.Create_normal_message'))
+ .width('90%')
+ .height(60)
+ .backgroundColor(0xFFFFFF)
+ .borderRadius(15)
+ .fontSize(16)
+ .textAlign(TextAlign.Center)
+ .margin({ top: 10 })
+ .onClick(event => {
+ this.result = ""
+ let msg = user.UserLoginResponse.create({
+ sessionId: "testSynchronouslyLoadProtoFile",
+ userPrivilege: "John123",
+ isTokenType: false,
+ // formatTimestamp: "12342222"
+ });
+ let obj = user.UserLoginResponse.toObject(msg)
+ this.result = JSON.stringify(obj)
+ });
+
+ Text(this.getResourceString($r('app.string.Verify_protobuf_validity'))+`(${this.getResourceString($r('app.string.null_means_valid'))})`)
+ .width('90%')
+ .height(60)
+ .backgroundColor(0xFFFFFF)
+ .borderRadius(15)
+ .fontSize(16)
+ .textAlign(TextAlign.Center)
+ .margin({ top: 10 })
+ .onClick(event => {
+ this.result = ""
+ let msg = user.UserLoginResponse.verify({
+ sessionId: "testSynchronouslyLoadProtoFile",
+ userPrivilege: "zhansgan",
+ isTokenType: false,
+ formatTimestamp: "687568"
+ })
+ this.result = JSON.stringify(msg)
+ });
+
+ Text($r('app.string.Pure_object'))
+ .width('90%')
+ .height(60)
+ .backgroundColor(0xFFFFFF)
+ .borderRadius(15)
+ .fontSize(16)
+ .textAlign(TextAlign.Center)
+ .margin({ top: 10 })
+ .onClick(event => {
+ this.result = ""
+ let msg = user.UserLoginResponse.fromObject({
+ sessionId: "testSynchronouslyLoadProtoFile",
+ userPrivilege: "John123",
+ isTokenType: false,
+ formatTimestamp: "8976796"
+ })
+ this.result = JSON.stringify(msg)
+ });
+
+ Text(this.getResourceString($r('app.string.result'))+" :\r\n " + this.result)
+ .fontSize(15)
+ .margin({ top: 55, left: 10,right:10 })
+
+ }.width('100%');
+ }
+ .scrollable(ScrollDirection.Vertical).scrollBar(BarState.On)
+ .scrollBarColor(Color.Gray).scrollBarWidth(30);
+ Button($r('app.string.reset_display'), { type: ButtonType.Capsule, stateEffect: true })
+ .backgroundColor(0x317aff)
+ .margin({ top: 430, left: 5 })
+ .width(110)
+ .onClick(event => {
+ this.result = "";
+ });
+ }.width('100%').height('100%').backgroundColor(0xDCDCDC)
+ }
+}
\ No newline at end of file
diff --git a/OpenHarmony/entry/src/main/ets/pages/user.d.ts b/OpenHarmony/entry/src/main/ets/pages/user.d.ts
new file mode 100644
index 000000000..45b01bad1
--- /dev/null
+++ b/OpenHarmony/entry/src/main/ets/pages/user.d.ts
@@ -0,0 +1,143 @@
+/*
+ * Copyright (c) 2022 Huawei Device Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import $protobuf from "@ohos/protobufjs";
+import Long from 'long';
+$protobuf.util.Long=Long
+$protobuf.configure()
+/** Namespace user. */
+export namespace user {
+
+ /** Properties of a UserLoginResponse. */
+ interface IUserLoginResponse {
+
+ /** UserLoginResponse sessionId */
+ sessionId?: (string|null);
+
+ /** UserLoginResponse userPrivilege */
+ userPrivilege?: (string|null);
+
+ /** UserLoginResponse isTokenType */
+ isTokenType?: (boolean|null);
+
+ /** UserLoginResponse formatTimestamp */
+ formatTimestamp?: (number|Long|BigInt|null);
+
+ /** UserLoginResponse data */
+ data?: (Uint8Array|null);
+ }
+
+ /** Represents a UserLoginResponse. */
+ class UserLoginResponse implements IUserLoginResponse {
+
+ /**
+ * Constructs a new UserLoginResponse.
+ * @param [properties] Properties to set
+ */
+ constructor(properties?: user.IUserLoginResponse);
+
+ /** UserLoginResponse sessionId. */
+ public sessionId: string;
+
+ /** UserLoginResponse userPrivilege. */
+ public userPrivilege: string;
+
+ /** UserLoginResponse isTokenType. */
+ public isTokenType: boolean;
+
+ /** UserLoginResponse formatTimestamp. */
+ public formatTimestamp: (number|Long|BigInt);
+
+ /** UserLoginResponse data. */
+ public data: Uint8Array;
+
+ /**
+ * Creates a new UserLoginResponse instance using the specified properties.
+ * @param [properties] Properties to set
+ * @returns UserLoginResponse instance
+ */
+ public static create(properties?: user.IUserLoginResponse): user.UserLoginResponse;
+
+ /**
+ * Encodes the specified UserLoginResponse message. Does not implicitly {@link user.UserLoginResponse.verify|verify} messages.
+ * @param message UserLoginResponse message or plain object to encode
+ * @param [writer] Writer to encode to
+ * @returns Writer
+ */
+ public static encode(message: user.IUserLoginResponse, writer?: $protobuf.Writer): $protobuf.Writer;
+
+ /**
+ * Encodes the specified UserLoginResponse message, length delimited. Does not implicitly {@link user.UserLoginResponse.verify|verify} messages.
+ * @param message UserLoginResponse message or plain object to encode
+ * @param [writer] Writer to encode to
+ * @returns Writer
+ */
+ public static encodeDelimited(message: user.IUserLoginResponse, writer?: $protobuf.Writer): $protobuf.Writer;
+
+ /**
+ * Decodes a UserLoginResponse message from the specified reader or buffer.
+ * @param reader Reader or buffer to decode from
+ * @param [length] Message length if known beforehand
+ * @returns UserLoginResponse
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): user.UserLoginResponse;
+
+ /**
+ * Decodes a UserLoginResponse message from the specified reader or buffer, length delimited.
+ * @param reader Reader or buffer to decode from
+ * @returns UserLoginResponse
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): user.UserLoginResponse;
+
+ /**
+ * Verifies a UserLoginResponse message.
+ * @param message Plain object to verify
+ * @returns `null` if valid, otherwise the reason why it is not
+ */
+ public static verify(message: { [k: string]: any }): (string|null);
+
+ /**
+ * Creates a UserLoginResponse message from a plain object. Also converts values to their respective internal types.
+ * @param object Plain object
+ * @returns UserLoginResponse
+ */
+ public static fromObject(object: { [k: string]: any }): user.UserLoginResponse;
+
+ /**
+ * Creates a plain object from a UserLoginResponse message. Also converts values to other types if specified.
+ * @param message UserLoginResponse
+ * @param [options] Conversion options
+ * @returns Plain object
+ */
+ public static toObject(message: user.UserLoginResponse, options?: $protobuf.IConversionOptions): { [k: string]: any };
+
+ /**
+ * Converts this UserLoginResponse to JSON.
+ * @returns JSON object
+ */
+ public toJSON(): { [k: string]: any };
+
+ /**
+ * Gets the default type url for UserLoginResponse
+ * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
+ * @returns The default type url
+ */
+ public static getTypeUrl(typeUrlPrefix?: string): string;
+ }
+}
diff --git a/OpenHarmony/entry/src/main/ets/pages/user.js b/OpenHarmony/entry/src/main/ets/pages/user.js
new file mode 100644
index 000000000..136bd0d2f
--- /dev/null
+++ b/OpenHarmony/entry/src/main/ets/pages/user.js
@@ -0,0 +1,356 @@
+/*
+ * Copyright (c) 2022 Huawei Device Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import $protobuf from "@ohos/protobufjs";
+$protobuf.util.Long=undefined
+$protobuf.configure()
+// Common aliases
+const $Reader = $protobuf.Reader, $Writer = $protobuf.Writer, $util = $protobuf.util;
+
+// Exported root namespace
+const $root = $protobuf.roots["default"] || ($protobuf.roots["default"] = {});
+
+export const user = $root.user = (() => {
+
+ /**
+ * Namespace user.
+ * @exports user
+ * @namespace
+ */
+ const user = {};
+
+ user.UserLoginResponse = (function() {
+
+ /**
+ * Properties of a UserLoginResponse.
+ * @memberof user
+ * @interface IUserLoginResponse
+ * @property {string|null} [sessionId] UserLoginResponse sessionId
+ * @property {string|null} [userPrivilege] UserLoginResponse userPrivilege
+ * @property {boolean|null} [isTokenType] UserLoginResponse isTokenType
+ * @property {number|Long|null} [formatTimestamp] UserLoginResponse formatTimestamp
+ * @property {Uint8Array|null} [data] UserLoginResponse data
+ */
+
+ /**
+ * Constructs a new UserLoginResponse.
+ * @memberof user
+ * @classdesc Represents a UserLoginResponse.
+ * @implements IUserLoginResponse
+ * @constructor
+ * @param {user.IUserLoginResponse=} [properties] Properties to set
+ */
+ function UserLoginResponse(properties) {
+ if (properties)
+ for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
+ if (properties[keys[i]] != null)
+ this[keys[i]] = properties[keys[i]];
+ }
+
+ /**
+ * UserLoginResponse sessionId.
+ * @member {string} sessionId
+ * @memberof user.UserLoginResponse
+ * @instance
+ */
+ UserLoginResponse.prototype.sessionId = "";
+
+ /**
+ * UserLoginResponse userPrivilege.
+ * @member {string} userPrivilege
+ * @memberof user.UserLoginResponse
+ * @instance
+ */
+ UserLoginResponse.prototype.userPrivilege = "";
+
+ /**
+ * UserLoginResponse isTokenType.
+ * @member {boolean} isTokenType
+ * @memberof user.UserLoginResponse
+ * @instance
+ */
+ UserLoginResponse.prototype.isTokenType = false;
+
+ /**
+ * UserLoginResponse formatTimestamp.
+ * @member {number|Long} formatTimestamp
+ * @memberof user.UserLoginResponse
+ * @instance
+ */
+ UserLoginResponse.prototype.formatTimestamp = $util.Long ? $util.Long.fromBits(0,0,false) : 0;
+
+ /**
+ * UserLoginResponse data.
+ * @member {Uint8Array} data
+ * @memberof user.UserLoginResponse
+ * @instance
+ */
+ UserLoginResponse.prototype.data = $util.newBuffer([]);
+
+ /**
+ * Creates a new UserLoginResponse instance using the specified properties.
+ * @function create
+ * @memberof user.UserLoginResponse
+ * @static
+ * @param {user.IUserLoginResponse=} [properties] Properties to set
+ * @returns {user.UserLoginResponse} UserLoginResponse instance
+ */
+ UserLoginResponse.create = function create(properties) {
+ return new UserLoginResponse(properties);
+ };
+
+ /**
+ * Encodes the specified UserLoginResponse message. Does not implicitly {@link user.UserLoginResponse.verify|verify} messages.
+ * @function encode
+ * @memberof user.UserLoginResponse
+ * @static
+ * @param {user.IUserLoginResponse} message UserLoginResponse message or plain object to encode
+ * @param {$protobuf.Writer} [writer] Writer to encode to
+ * @returns {$protobuf.Writer} Writer
+ */
+ UserLoginResponse.encode = function encode(message, writer) {
+ if (!writer)
+ writer = $Writer.create();
+ if (message.sessionId != null && Object.hasOwnProperty.call(message, "sessionId"))
+ writer.uint32(/* id 1, wireType 2 =*/10).string(message.sessionId);
+ if (message.userPrivilege != null && Object.hasOwnProperty.call(message, "userPrivilege"))
+ writer.uint32(/* id 2, wireType 2 =*/18).string(message.userPrivilege);
+ if (message.isTokenType != null && Object.hasOwnProperty.call(message, "isTokenType"))
+ writer.uint32(/* id 3, wireType 0 =*/24).bool(message.isTokenType);
+ if (message.formatTimestamp != null && Object.hasOwnProperty.call(message, "formatTimestamp"))
+ writer.uint32(/* id 5, wireType 0 =*/40).int64(message.formatTimestamp);
+ if (message.data != null && Object.hasOwnProperty.call(message, "data"))
+ writer.uint32(/* id 6, wireType 2 =*/50).bytes(message.data);
+ return writer;
+ };
+
+ /**
+ * Encodes the specified UserLoginResponse message, length delimited. Does not implicitly {@link user.UserLoginResponse.verify|verify} messages.
+ * @function encodeDelimited
+ * @memberof user.UserLoginResponse
+ * @static
+ * @param {user.IUserLoginResponse} message UserLoginResponse message or plain object to encode
+ * @param {$protobuf.Writer} [writer] Writer to encode to
+ * @returns {$protobuf.Writer} Writer
+ */
+ UserLoginResponse.encodeDelimited = function encodeDelimited(message, writer) {
+ return this.encode(message, writer).ldelim();
+ };
+
+ /**
+ * Decodes a UserLoginResponse message from the specified reader or buffer.
+ * @function decode
+ * @memberof user.UserLoginResponse
+ * @static
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
+ * @param {number} [length] Message length if known beforehand
+ * @returns {user.UserLoginResponse} UserLoginResponse
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ UserLoginResponse.decode = function decode(reader, length) {
+ if (!(reader instanceof $Reader))
+ reader = $Reader.create(reader);
+ let end = length === undefined ? reader.len : reader.pos + length, message = new $root.user.UserLoginResponse();
+ while (reader.pos < end) {
+ let tag = reader.uint32();
+ switch (tag >>> 3) {
+ case 1: {
+ message.sessionId = reader.string();
+ break;
+ }
+ case 2: {
+ message.userPrivilege = reader.string();
+ break;
+ }
+ case 3: {
+ message.isTokenType = reader.bool();
+ break;
+ }
+ case 5: {
+ message.formatTimestamp = reader.int64();
+ break;
+ }
+ case 6: {
+ message.data = reader.bytes();
+ break;
+ }
+ default:
+ reader.skipType(tag & 7);
+ break;
+ }
+ }
+ return message;
+ };
+
+ /**
+ * Decodes a UserLoginResponse message from the specified reader or buffer, length delimited.
+ * @function decodeDelimited
+ * @memberof user.UserLoginResponse
+ * @static
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
+ * @returns {user.UserLoginResponse} UserLoginResponse
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ UserLoginResponse.decodeDelimited = function decodeDelimited(reader) {
+ if (!(reader instanceof $Reader))
+ reader = new $Reader(reader);
+ return this.decode(reader, reader.uint32());
+ };
+
+ /**
+ * Verifies a UserLoginResponse message.
+ * @function verify
+ * @memberof user.UserLoginResponse
+ * @static
+ * @param {Object.} message Plain object to verify
+ * @returns {string|null} `null` if valid, otherwise the reason why it is not
+ */
+ UserLoginResponse.verify = function verify(message) {
+ if (typeof message !== "object" || message === null)
+ return "object expected";
+ if (message.sessionId != null && message.hasOwnProperty("sessionId"))
+ if (!$util.isString(message.sessionId))
+ return "sessionId: string expected";
+ if (message.userPrivilege != null && message.hasOwnProperty("userPrivilege"))
+ if (!$util.isString(message.userPrivilege))
+ return "userPrivilege: string expected";
+ if (message.isTokenType != null && message.hasOwnProperty("isTokenType"))
+ if (typeof message.isTokenType !== "boolean")
+ return "isTokenType: boolean expected";
+ if (message.formatTimestamp != null && message.hasOwnProperty("formatTimestamp"))
+ if (!$util.isInteger(message.formatTimestamp) && !(message.formatTimestamp && $util.isInteger(message.formatTimestamp.low) && $util.isInteger(message.formatTimestamp.high)))
+ return "formatTimestamp: integer|Long expected";
+ if (message.data != null && message.hasOwnProperty("data"))
+ if (!(message.data && typeof message.data.length === "number" || $util.isString(message.data)))
+ return "data: buffer expected";
+ return null;
+ };
+
+ /**
+ * Creates a UserLoginResponse message from a plain object. Also converts values to their respective internal types.
+ * @function fromObject
+ * @memberof user.UserLoginResponse
+ * @static
+ * @param {Object.} object Plain object
+ * @returns {user.UserLoginResponse} UserLoginResponse
+ */
+ UserLoginResponse.fromObject = function fromObject(object) {
+ if (object instanceof $root.user.UserLoginResponse)
+ return object;
+ let message = new $root.user.UserLoginResponse();
+ if (object.sessionId != null)
+ message.sessionId = String(object.sessionId);
+ if (object.userPrivilege != null)
+ message.userPrivilege = String(object.userPrivilege);
+ if (object.isTokenType != null)
+ message.isTokenType = Boolean(object.isTokenType);
+ if (object.formatTimestamp != null)
+ if ($util.Long)
+ (message.formatTimestamp = $util.Long.fromValue(object.formatTimestamp)).unsigned = false;
+ else if (typeof object.formatTimestamp === "string")
+ message.formatTimestamp = parseInt(object.formatTimestamp, 10);
+ else if (typeof object.formatTimestamp === "number")
+ message.formatTimestamp = object.formatTimestamp;
+ else if (typeof object.formatTimestamp === "object")
+ message.formatTimestamp = new $util.LongBits(object.formatTimestamp.low >>> 0, object.formatTimestamp.high >>> 0).toNumber();
+ if (object.data != null)
+ if (typeof object.data === "string")
+ $util.base64.decode(object.data, message.data = $util.newBuffer($util.base64.length(object.data)), 0);
+ else if (object.data.length >= 0)
+ message.data = object.data;
+ return message;
+ };
+
+ /**
+ * Creates a plain object from a UserLoginResponse message. Also converts values to other types if specified.
+ * @function toObject
+ * @memberof user.UserLoginResponse
+ * @static
+ * @param {user.UserLoginResponse} message UserLoginResponse
+ * @param {$protobuf.IConversionOptions} [options] Conversion options
+ * @returns {Object.} Plain object
+ */
+ UserLoginResponse.toObject = function toObject(message, options) {
+ if (!options)
+ options = {};
+ let object = {};
+ if (options.defaults) {
+ object.sessionId = "";
+ object.userPrivilege = "";
+ object.isTokenType = false;
+ if ($util.Long) {
+ let long = new $util.Long(0, 0, false);
+ object.formatTimestamp = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
+ } else
+ object.formatTimestamp = options.longs === String ? "0" : 0;
+ if (options.bytes === String)
+ object.data = "";
+ else {
+ object.data = [];
+ if (options.bytes !== Array)
+ object.data = $util.newBuffer(object.data);
+ }
+ }
+ if (message.sessionId != null && message.hasOwnProperty("sessionId"))
+ object.sessionId = message.sessionId;
+ if (message.userPrivilege != null && message.hasOwnProperty("userPrivilege"))
+ object.userPrivilege = message.userPrivilege;
+ if (message.isTokenType != null && message.hasOwnProperty("isTokenType"))
+ object.isTokenType = message.isTokenType;
+ if (message.formatTimestamp != null && message.hasOwnProperty("formatTimestamp"))
+ if (typeof message.formatTimestamp === "number")
+ object.formatTimestamp = options.longs === String ? String(message.formatTimestamp) : message.formatTimestamp;
+ else
+ object.formatTimestamp = options.longs === String ? $util.Long.prototype.toString.call(message.formatTimestamp) : options.longs === Number ? new $util.LongBits(message.formatTimestamp.low >>> 0, message.formatTimestamp.high >>> 0).toNumber() : message.formatTimestamp;
+ if (message.data != null && message.hasOwnProperty("data"))
+ object.data = options.bytes === String ? $util.base64.encode(message.data, 0, message.data.length) : options.bytes === Array ? Array.prototype.slice.call(message.data) : message.data;
+ return object;
+ };
+
+ /**
+ * Converts this UserLoginResponse to JSON.
+ * @function toJSON
+ * @memberof user.UserLoginResponse
+ * @instance
+ * @returns {Object.} JSON object
+ */
+ UserLoginResponse.prototype.toJSON = function toJSON() {
+ return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
+ };
+
+ /**
+ * Gets the default type url for UserLoginResponse
+ * @function getTypeUrl
+ * @memberof user.UserLoginResponse
+ * @static
+ * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
+ * @returns {string} The default type url
+ */
+ UserLoginResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
+ if (typeUrlPrefix === undefined) {
+ typeUrlPrefix = "type.googleapis.com";
+ }
+ return typeUrlPrefix + "/user.UserLoginResponse";
+ };
+
+ return UserLoginResponse;
+ })();
+
+ return user;
+})();
+
+export { $root as default };
diff --git a/OpenHarmony/entry/src/main/module.json5 b/OpenHarmony/entry/src/main/module.json5
new file mode 100644
index 000000000..6f0c4dc95
--- /dev/null
+++ b/OpenHarmony/entry/src/main/module.json5
@@ -0,0 +1,43 @@
+{
+ "module": {
+ "name": "entry",
+ "type": "entry",
+ "description": "$string:module_desc",
+ "mainElement": "EntryAbility",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false,
+ "pages": "$profile:main_pages",
+ "metadata": [
+ {
+ "name": "ArkTSPartialUpdate",
+ "value": "true"
+ }
+ ],
+ "abilities": [
+ {
+ "name": "EntryAbility",
+ "srcEntry": "./ets/entryability/EntryAbility.ts",
+ "description": "$string:EntryAbility_desc",
+ "icon": "$media:icon",
+ "label": "$string:EntryAbility_label",
+ "startWindowIcon": "$media:icon",
+ "startWindowBackground": "$color:start_window_background",
+ "exported": true,
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ]
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/OpenHarmony/entry/src/main/resources/base/element/color.json b/OpenHarmony/entry/src/main/resources/base/element/color.json
new file mode 100644
index 000000000..3c712962d
--- /dev/null
+++ b/OpenHarmony/entry/src/main/resources/base/element/color.json
@@ -0,0 +1,8 @@
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#FFFFFF"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/OpenHarmony/entry/src/main/resources/base/element/string.json b/OpenHarmony/entry/src/main/resources/base/element/string.json
new file mode 100644
index 000000000..199b7543d
--- /dev/null
+++ b/OpenHarmony/entry/src/main/resources/base/element/string.json
@@ -0,0 +1,64 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "module description"
+ },
+ {
+ "name": "EntryAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "EntryAbility_label",
+ "value": "protobuf"
+ },
+ {
+ "name": "proto_serialization_deserialization",
+ "value": "proto serialization deserialization"
+ },
+ {
+ "name": "proto_serialization_deserialization_bigInt",
+ "value": "proto serialization deserialization (BigInt)"
+ },
+ {
+ "name": "serialized_data",
+ "value": "serialized data"
+ },
+ {
+ "name": "Deserialize_data",
+ "value": "Deserialize data"
+ },
+ {
+ "name": "test",
+ "value": "Test"
+ },
+ {
+ "name": "Encode_to_decode",
+ "value": "Encode to/decode message from delimiter-delimited byte sequence"
+ },
+ {
+ "name": "Create_normal_message",
+ "value": "Create a normal object using message"
+ },
+ {
+ "name": "Verify_protobuf_validity",
+ "value": "Verify protobuf validity"
+ },
+ {
+ "name": "null_means_valid",
+ "value": "null means valid, otherwise the invalid reason will be returned"
+ },
+ {
+ "name": "Pure_object",
+ "value": "Pure object creation message"
+ },
+ {
+ "name": "result",
+ "value": "Result"
+ },
+ {
+ "name": "reset_display",
+ "value": "reset display"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/OpenHarmony/entry/src/main/resources/base/media/icon.png b/OpenHarmony/entry/src/main/resources/base/media/icon.png
new file mode 100644
index 000000000..ce307a882
Binary files /dev/null and b/OpenHarmony/entry/src/main/resources/base/media/icon.png differ
diff --git a/OpenHarmony/entry/src/main/resources/base/profile/main_pages.json b/OpenHarmony/entry/src/main/resources/base/profile/main_pages.json
new file mode 100644
index 000000000..feec276e1
--- /dev/null
+++ b/OpenHarmony/entry/src/main/resources/base/profile/main_pages.json
@@ -0,0 +1,5 @@
+{
+ "src": [
+ "pages/index"
+ ]
+}
diff --git a/OpenHarmony/entry/src/main/resources/en_US/element/string.json b/OpenHarmony/entry/src/main/resources/en_US/element/string.json
new file mode 100644
index 000000000..199b7543d
--- /dev/null
+++ b/OpenHarmony/entry/src/main/resources/en_US/element/string.json
@@ -0,0 +1,64 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "module description"
+ },
+ {
+ "name": "EntryAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "EntryAbility_label",
+ "value": "protobuf"
+ },
+ {
+ "name": "proto_serialization_deserialization",
+ "value": "proto serialization deserialization"
+ },
+ {
+ "name": "proto_serialization_deserialization_bigInt",
+ "value": "proto serialization deserialization (BigInt)"
+ },
+ {
+ "name": "serialized_data",
+ "value": "serialized data"
+ },
+ {
+ "name": "Deserialize_data",
+ "value": "Deserialize data"
+ },
+ {
+ "name": "test",
+ "value": "Test"
+ },
+ {
+ "name": "Encode_to_decode",
+ "value": "Encode to/decode message from delimiter-delimited byte sequence"
+ },
+ {
+ "name": "Create_normal_message",
+ "value": "Create a normal object using message"
+ },
+ {
+ "name": "Verify_protobuf_validity",
+ "value": "Verify protobuf validity"
+ },
+ {
+ "name": "null_means_valid",
+ "value": "null means valid, otherwise the invalid reason will be returned"
+ },
+ {
+ "name": "Pure_object",
+ "value": "Pure object creation message"
+ },
+ {
+ "name": "result",
+ "value": "Result"
+ },
+ {
+ "name": "reset_display",
+ "value": "reset display"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/OpenHarmony/entry/src/main/resources/zh_CN/element/string.json b/OpenHarmony/entry/src/main/resources/zh_CN/element/string.json
new file mode 100644
index 000000000..cf37714a0
--- /dev/null
+++ b/OpenHarmony/entry/src/main/resources/zh_CN/element/string.json
@@ -0,0 +1,64 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "模块描述"
+ },
+ {
+ "name": "EntryAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "EntryAbility_label",
+ "value": "protobuf"
+ },
+ {
+ "name": "proto_serialization_deserialization",
+ "value": "proto序列化反序列化"
+ },
+ {
+ "name": "proto_serialization_deserialization_bigInt",
+ "value": "proto序列化反序列化(包含BigInt)"
+ },
+ {
+ "name": "serialized_data",
+ "value": "序列化数据"
+ },
+ {
+ "name": "Deserialize_data",
+ "value": "反序列化数据"
+ },
+ {
+ "name": "test",
+ "value": "测试"
+ },
+ {
+ "name": "Encode_to_decode",
+ "value": "编码为分隔符分隔的字节序列/从分隔符分隔的字节序列中解码消息"
+ },
+ {
+ "name": "Create_normal_message",
+ "value": "使用message创建一个普通对象"
+ },
+ {
+ "name": "Verify_protobuf_validity",
+ "value": "验证protobuf有效性"
+ },
+ {
+ "name": "null_means_valid",
+ "value": "null代表有效,否则返回无效原因"
+ },
+ {
+ "name": "Pure_object",
+ "value": "纯对象创建消息"
+ },
+ {
+ "name": "result",
+ "value": "结果"
+ },
+ {
+ "name": "reset_display",
+ "value": "重置显示"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/OpenHarmony/entry/src/ohosTest/ets/test/Ability.test.ets b/OpenHarmony/entry/src/ohosTest/ets/test/Ability.test.ets
new file mode 100644
index 000000000..b6f7f0eac
--- /dev/null
+++ b/OpenHarmony/entry/src/ohosTest/ets/test/Ability.test.ets
@@ -0,0 +1,266 @@
+/*
+ * Copyright (c) 2022 Huawei Device Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import { describe, it, expect } from '@ohos/hypium'
+import { RnRouteNotFound } from './tracker_apm_rn'
+import { user } from './user.js'
+const BASE_COUNT: number = 2000;
+const HTTP_COUNT = 2
+export default function abilityTest() {
+ describe('protobufTest', () => {
+ it('create', 0, () => {
+ class RnRoute {
+ prevPageUrl: string = ""
+ firstPageUrl: string = ""
+ prevRoutePath: string = ""
+ targetRouteName: string = ""
+ }
+
+ let rnRoute: RnRoute = {
+ prevPageUrl: "http://example.com",
+ firstPageUrl: "ws://example.com",
+ prevRoutePath: "https://test.com",
+ targetRouteName: "https://target.com"
+ }
+
+ let startTime=new Date().getMilliseconds()
+ let startTimes=new Date().getTime();
+ for (let index = 0; index < BASE_COUNT; index++) {
+ RnRouteNotFound.create(rnRoute);
+ }
+ endTime(startTimes,'create');
+ let msg = RnRouteNotFound.create(rnRoute)
+ console.info("protobuf create consuming time"+(new Date().getMilliseconds()-startTime))
+ expect(JSON.stringify(msg)).assertEqual(JSON.stringify(rnRoute))
+ })
+
+ it('TestBigInt', 0, () => {
+ let msg = user.UserLoginResponse.create({
+ formatTimestamp: BigInt("9223372036854775807"),
+ });
+
+ let arrayBuffer: Uint8Array = user.UserLoginResponse.encode(msg).finish()
+
+ let decodeMsg = user.UserLoginResponse.decode(arrayBuffer);
+ let timestamp=decodeMsg.formatTimestamp
+ expect(timestamp).assertEqual(BigInt('9223372036854775807'))
+ })
+
+ it('encode', 0, () => {
+ class RnRoute {
+ prevPageUrl: string = ""
+ firstPageUrl: string = ""
+ prevRoutePath: string = ""
+ targetRouteName: string = ""
+ }
+
+ let rnRoute: RnRoute = {
+ prevPageUrl: "http://example.com",
+ firstPageUrl: "ws://example.com",
+ prevRoutePath: "https://test.com",
+ targetRouteName: "https://target.com"
+ }
+
+ let msg = RnRouteNotFound.create(rnRoute)
+ let startTime=new Date().getMilliseconds()
+ let startTimes=new Date().getTime();
+ for (let index = 0; index < BASE_COUNT; index++) {
+ RnRouteNotFound.encode(msg).finish();
+ }
+ endTime(startTimes,'encode');
+ let arrayBuffer: Uint8Array = RnRouteNotFound.encode(msg).finish()
+ console.info("protobuf encode consuming time"+(new Date().getMilliseconds()-startTime))
+ let expectValue = "[10,18,104,116,116,112,58,47,47,101,120,97,109,112,108,101,46,99,111,109,18,16,119,115,58,47,47,101,120,97,109,112,108,101,46,99,111,109,26,16,104,116,116,112,115,58,47,47,116,101,115,116,46,99,111,109,34,18,104,116,116,112,115,58,47,47,116,97,114,103,101,116,46,99,111,109]"
+ expect(JSON.stringify(Array.from(arrayBuffer))).assertDeepEquals(expectValue)
+ })
+
+ it('encodeDelimited', 0, () => {
+ class RnRoute {
+ prevPageUrl: string = ""
+ firstPageUrl: string = ""
+ prevRoutePath: string = ""
+ targetRouteName: string = ""
+ }
+
+ let rnRoute: RnRoute = {
+ prevPageUrl: "http://example.com",
+ firstPageUrl: "ws://example.com",
+ prevRoutePath: "https://test.com",
+ targetRouteName: "https://target.com"
+ }
+
+ let msg = RnRouteNotFound.create(rnRoute)
+ let startTime=new Date().getMilliseconds()
+ let startTimes=new Date().getTime();
+ for (let index = 0; index < BASE_COUNT; index++) {
+ RnRouteNotFound.encodeDelimited(msg).finish();
+ }
+ endTime(startTimes,'encodeDelimited');
+ let arrayBuffer: Uint8Array = RnRouteNotFound.encodeDelimited(msg).finish()
+ console.info("protobuf encodeDelimited consuming time"+(new Date().getMilliseconds()-startTime))
+ let expectValue = "[76,10,18,104,116,116,112,58,47,47,101,120,97,109,112,108,101,46,99,111,109,18,16,119,115,58,47,47,101,120,97,109,112,108,101,46,99,111,109,26,16,104,116,116,112,115,58,47,47,116,101,115,116,46,99,111,109,34,18,104,116,116,112,115,58,47,47,116,97,114,103,101,116,46,99,111,109]"
+ expect(JSON.stringify(Array.from(arrayBuffer))).assertDeepEquals(expectValue)
+ })
+
+ it('decode', 0, () => {
+ class RnRoute {
+ prevPageUrl: string = ""
+ targetRouteName: string = ""
+ }
+
+ let rnRoute: RnRoute = {
+ prevPageUrl: "http://www.baidu.com",
+ targetRouteName: "https://welcom.com"
+ }
+
+ let msg = RnRouteNotFound.create(rnRoute)
+ let arrayBuffer: Uint8Array = RnRouteNotFound.encode(msg).finish()
+ let startTime=new Date().getMilliseconds()
+ let startTimes=new Date().getTime();
+ for (let index = 0; index < BASE_COUNT; index++) {
+ RnRouteNotFound.decode(arrayBuffer);
+ }
+ endTime(startTimes,'decode');
+ let decodeMsg = RnRouteNotFound.decode(arrayBuffer);
+ console.info("protobuf decode consuming time"+(new Date().getMilliseconds()-startTime))
+ expect(JSON.stringify(decodeMsg)).assertEqual(JSON.stringify(rnRoute))
+ })
+
+
+ it('decodeDelimited', 0, () => {
+ class RnRoute {
+ prevPageUrl: string = ""
+ targetRouteName: string = ""
+ }
+
+ let rnRoute: RnRoute = {
+ prevPageUrl: "http://www.baidu.com",
+ targetRouteName: "https://welcom.com"
+ }
+
+ let msg = RnRouteNotFound.create(rnRoute)
+ let arrayBuffer: Uint8Array = RnRouteNotFound.encodeDelimited(msg).finish()
+
+ let startTime=new Date().getMilliseconds()
+ let startTimes=new Date().getTime();
+ for (let index = 0; index < BASE_COUNT; index++) {
+ RnRouteNotFound.decodeDelimited(arrayBuffer);
+ }
+ endTime(startTimes,'decodeDelimited');
+ let decodeMsg = RnRouteNotFound.decodeDelimited(arrayBuffer);
+ console.info("protobuf decodeDelimited consuming time"+(new Date().getMilliseconds()-startTime))
+ expect(JSON.stringify(decodeMsg)).assertEqual(JSON.stringify(rnRoute))
+ })
+
+ it('verify', 0, () => {
+ class RnRoute {
+ prevPageUrl: string = ""
+ targetRouteName: string = ""
+ id:BigInt=121n
+ }
+
+ let rnRoute: RnRoute = {
+ prevPageUrl: "http://www.baidu.com",
+ targetRouteName: "https://welcom.com",
+ id:BigInt('215315343545351531534')
+ }
+ let startTime=new Date().getMilliseconds()
+ let startTimes=new Date().getTime();
+ for (let index = 0; index < BASE_COUNT; index++) {
+ RnRouteNotFound.verify(rnRoute);
+ }
+ endTime(startTimes,'verify');
+ let result = RnRouteNotFound.verify(rnRoute)
+ console.info("protobuf verify consuming time"+(new Date().getMilliseconds()-startTime))
+ expect(result).assertNull()
+ })
+
+ it('verifyFalse', 0, () => {
+ class RnRoute {
+ prevPageUrl: number = 0
+ }
+
+ let rnRoute: RnRoute = {
+ prevPageUrl: 8,
+ }
+ let result = RnRouteNotFound.verify(rnRoute)
+ expect(result != null).assertTrue()
+ let startTime=new Date().getMilliseconds()
+ let startTimes=new Date().getTime();
+ for (let index = 0; index < BASE_COUNT; index++) {
+ RnRouteNotFound.verify(rnRoute);
+ }
+ endTime(startTimes,'verifyFalse');
+ })
+
+ it('toObject', 0, () => {
+ class RnRoute {
+ prevPageUrl: string = ""
+ firstPageUrl: string = ""
+ prevRoutePath: string = ""
+ targetRouteName: string = ""
+ }
+
+ let rnRoute: RnRoute = {
+ prevPageUrl: "http://example.com",
+ firstPageUrl: "ws://example.com",
+ prevRoutePath: "https://test.com",
+ targetRouteName: "https://target.com"
+ }
+
+ let msg = RnRouteNotFound.create(rnRoute)
+ let startTime=new Date().getMilliseconds()
+ let startTimes=new Date().getTime();
+ for (let index = 0; index < BASE_COUNT; index++) {
+ RnRouteNotFound.toObject(msg);
+ }
+ endTime(startTimes,'toObject');
+ let obj = RnRouteNotFound.toObject(msg)
+ console.info("protobuf toObject consuming time"+(new Date().getMilliseconds()-startTime))
+ expect(JSON.stringify(obj)).assertEqual(JSON.stringify(rnRoute))
+ })
+
+ it('fromObject', 0, () => {
+ class RnRoute {
+ firstPageUrl: string = ""
+ prevRoutePath: string = ""
+ targetRouteName: string = ""
+ }
+
+ let rnRoute: RnRoute = {
+ firstPageUrl: "ws://example.com",
+ prevRoutePath: "https://test.com",
+ targetRouteName: "https://target.com"
+ }
+
+ let startTime=new Date().getMilliseconds()
+ let startTimes=new Date().getTime();
+ for (let index = 0; index < BASE_COUNT; index++) {
+ RnRouteNotFound.fromObject(rnRoute);
+ }
+ endTime(startTimes,'fromObject');
+ let msg = RnRouteNotFound.fromObject(rnRoute)
+ console.info("protobuf fromObject consuming time"+(new Date().getMilliseconds()-startTime))
+ expect(JSON.stringify(msg)).assertEqual(JSON.stringify(rnRoute))
+ })
+ })
+}
+function endTime(startTime: number, tag: string) {
+ console.info(tag + ":startTime:" + startTime)
+ let endTime: number = new Date().getTime();
+ let averageTime = ((endTime - startTime) * 1000 / BASE_COUNT)
+ console.info(tag + ":endTime:" + endTime)
+ console.log(tag + ":averageTime:" + averageTime + "μs");
+}
\ No newline at end of file
diff --git a/OpenHarmony/entry/src/ohosTest/ets/test/List.test.ets b/OpenHarmony/entry/src/ohosTest/ets/test/List.test.ets
new file mode 100644
index 000000000..9bc389d19
--- /dev/null
+++ b/OpenHarmony/entry/src/ohosTest/ets/test/List.test.ets
@@ -0,0 +1,19 @@
+/*
+ * Copyright (c) 2022 Huawei Device Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import abilityTest from './Ability.test'
+export default function testsuite() {
+ abilityTest()
+}
\ No newline at end of file
diff --git a/OpenHarmony/entry/src/ohosTest/ets/test/tracker_apm_rn.d.ts b/OpenHarmony/entry/src/ohosTest/ets/test/tracker_apm_rn.d.ts
new file mode 100644
index 000000000..a3ffb5f73
--- /dev/null
+++ b/OpenHarmony/entry/src/ohosTest/ets/test/tracker_apm_rn.d.ts
@@ -0,0 +1,1639 @@
+/*
+ * Copyright (c) 2022 Huawei Device Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import * as $protobuf from "@ohos/protobufjs";
+import Long from 'long';
+$protobuf.util.Long=Long
+$protobuf.configure()
+/** Properties of a RnApmTracker. */
+export interface IRnApmTracker {
+
+ /** RnApmTracker rnScriptExecutionTiming */
+ rnScriptExecutionTiming?: (IRnPerformanceMeasure|null);
+
+ /** RnApmTracker rnPageFirstAppearTiming */
+ rnPageFirstAppearTiming?: (IRnPerformanceMeasure|null);
+
+ /** RnApmTracker rnHttpRequestTiming */
+ rnHttpRequestTiming?: (IRnHttpRequestTiming|null);
+
+ /** RnApmTracker rnPerformanceMeasure */
+ rnPerformanceMeasure?: (IRnPerformanceMeasure|null);
+
+ /** RnApmTracker rnResourceTiming */
+ rnResourceTiming?: (IRnResourceTiming[]|null);
+
+ /** RnApmTracker rnVideoResourceTiming */
+ rnVideoResourceTiming?: (IRnVideoResourceTiming|null);
+
+ /** RnApmTracker rnApmContext */
+ rnApmContext?: (IRnApmContext|null);
+
+ /** RnApmTracker rnRouteNotFound */
+ rnRouteNotFound?: (IRnRouteNotFound|null);
+}
+
+/** Represents a RnApmTracker. */
+export class RnApmTracker implements IRnApmTracker {
+
+ /**
+ * Constructs a new RnApmTracker.
+ * @param [properties] Properties to set
+ */
+ constructor(properties?: IRnApmTracker);
+
+ /** RnApmTracker rnScriptExecutionTiming. */
+ public rnScriptExecutionTiming?: (IRnPerformanceMeasure|null);
+
+ /** RnApmTracker rnPageFirstAppearTiming. */
+ public rnPageFirstAppearTiming?: (IRnPerformanceMeasure|null);
+
+ /** RnApmTracker rnHttpRequestTiming. */
+ public rnHttpRequestTiming?: (IRnHttpRequestTiming|null);
+
+ /** RnApmTracker rnPerformanceMeasure. */
+ public rnPerformanceMeasure?: (IRnPerformanceMeasure|null);
+
+ /** RnApmTracker rnResourceTiming. */
+ public rnResourceTiming: IRnResourceTiming[];
+
+ /** RnApmTracker rnVideoResourceTiming. */
+ public rnVideoResourceTiming?: (IRnVideoResourceTiming|null);
+
+ /** RnApmTracker rnApmContext. */
+ public rnApmContext?: (IRnApmContext|null);
+
+ /** RnApmTracker rnRouteNotFound. */
+ public rnRouteNotFound?: (IRnRouteNotFound|null);
+
+ /**
+ * Creates a new RnApmTracker instance using the specified properties.
+ * @param [properties] Properties to set
+ * @returns RnApmTracker instance
+ */
+ public static create(properties?: IRnApmTracker): RnApmTracker;
+
+ /**
+ * Encodes the specified RnApmTracker message. Does not implicitly {@link RnApmTracker.verify|verify} messages.
+ * @param message RnApmTracker message or plain object to encode
+ * @param [writer] Writer to encode to
+ * @returns Writer
+ */
+ public static encode(message: IRnApmTracker, writer?: $protobuf.Writer): $protobuf.Writer;
+
+ /**
+ * Encodes the specified RnApmTracker message, length delimited. Does not implicitly {@link RnApmTracker.verify|verify} messages.
+ * @param message RnApmTracker message or plain object to encode
+ * @param [writer] Writer to encode to
+ * @returns Writer
+ */
+ public static encodeDelimited(message: IRnApmTracker, writer?: $protobuf.Writer): $protobuf.Writer;
+
+ /**
+ * Decodes a RnApmTracker message from the specified reader or buffer.
+ * @param reader Reader or buffer to decode from
+ * @param [length] Message length if known beforehand
+ * @returns RnApmTracker
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): RnApmTracker;
+
+ /**
+ * Decodes a RnApmTracker message from the specified reader or buffer, length delimited.
+ * @param reader Reader or buffer to decode from
+ * @returns RnApmTracker
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): RnApmTracker;
+
+ /**
+ * Verifies a RnApmTracker message.
+ * @param message Plain object to verify
+ * @returns `null` if valid, otherwise the reason why it is not
+ */
+ public static verify(message: { [k: string]: any }): (string|null);
+
+ /**
+ * Creates a RnApmTracker message from a plain object. Also converts values to their respective internal types.
+ * @param object Plain object
+ * @returns RnApmTracker
+ */
+ public static fromObject(object: { [k: string]: any }): RnApmTracker;
+
+ /**
+ * Creates a plain object from a RnApmTracker message. Also converts values to other types if specified.
+ * @param message RnApmTracker
+ * @param [options] Conversion options
+ * @returns Plain object
+ */
+ public static toObject(message: RnApmTracker, options?: $protobuf.IConversionOptions): { [k: string]: any };
+
+ /**
+ * Converts this RnApmTracker to JSON.
+ * @returns JSON object
+ */
+ public toJSON(): { [k: string]: any };
+
+ /**
+ * Gets the default type url for RnApmTracker
+ * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
+ * @returns The default type url
+ */
+ public static getTypeUrl(typeUrlPrefix?: string): string;
+}
+
+/** Properties of a RnApmContext. */
+export interface IRnApmContext {
+
+ /** RnApmContext fakeAppVersion */
+ fakeAppVersion?: (string|null);
+
+ /** RnApmContext isInstanceReuse */
+ isInstanceReuse?: (boolean|null);
+
+ /** RnApmContext isInstancePreload */
+ isInstancePreload?: (boolean|null);
+}
+
+/** Represents a RnApmContext. */
+export class RnApmContext implements IRnApmContext {
+
+ /**
+ * Constructs a new RnApmContext.
+ * @param [properties] Properties to set
+ */
+ constructor(properties?: IRnApmContext);
+
+ /** RnApmContext fakeAppVersion. */
+ public fakeAppVersion: string;
+
+ /** RnApmContext isInstanceReuse. */
+ public isInstanceReuse: boolean;
+
+ /** RnApmContext isInstancePreload. */
+ public isInstancePreload: boolean;
+
+ /**
+ * Creates a new RnApmContext instance using the specified properties.
+ * @param [properties] Properties to set
+ * @returns RnApmContext instance
+ */
+ public static create(properties?: IRnApmContext): RnApmContext;
+
+ /**
+ * Encodes the specified RnApmContext message. Does not implicitly {@link RnApmContext.verify|verify} messages.
+ * @param message RnApmContext message or plain object to encode
+ * @param [writer] Writer to encode to
+ * @returns Writer
+ */
+ public static encode(message: IRnApmContext, writer?: $protobuf.Writer): $protobuf.Writer;
+
+ /**
+ * Encodes the specified RnApmContext message, length delimited. Does not implicitly {@link RnApmContext.verify|verify} messages.
+ * @param message RnApmContext message or plain object to encode
+ * @param [writer] Writer to encode to
+ * @returns Writer
+ */
+ public static encodeDelimited(message: IRnApmContext, writer?: $protobuf.Writer): $protobuf.Writer;
+
+ /**
+ * Decodes a RnApmContext message from the specified reader or buffer.
+ * @param reader Reader or buffer to decode from
+ * @param [length] Message length if known beforehand
+ * @returns RnApmContext
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): RnApmContext;
+
+ /**
+ * Decodes a RnApmContext message from the specified reader or buffer, length delimited.
+ * @param reader Reader or buffer to decode from
+ * @returns RnApmContext
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): RnApmContext;
+
+ /**
+ * Verifies a RnApmContext message.
+ * @param message Plain object to verify
+ * @returns `null` if valid, otherwise the reason why it is not
+ */
+ public static verify(message: { [k: string]: any }): (string|null);
+
+ /**
+ * Creates a RnApmContext message from a plain object. Also converts values to their respective internal types.
+ * @param object Plain object
+ * @returns RnApmContext
+ */
+ public static fromObject(object: { [k: string]: any }): RnApmContext;
+
+ /**
+ * Creates a plain object from a RnApmContext message. Also converts values to other types if specified.
+ * @param message RnApmContext
+ * @param [options] Conversion options
+ * @returns Plain object
+ */
+ public static toObject(message: RnApmContext, options?: $protobuf.IConversionOptions): { [k: string]: any };
+
+ /**
+ * Converts this RnApmContext to JSON.
+ * @returns JSON object
+ */
+ public toJSON(): { [k: string]: any };
+
+ /**
+ * Gets the default type url for RnApmContext
+ * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
+ * @returns The default type url
+ */
+ public static getTypeUrl(typeUrlPrefix?: string): string;
+}
+
+/** Properties of a RnHttpRequestTiming. */
+export interface IRnHttpRequestTiming {
+
+ /** RnHttpRequestTiming rnPerformanceMeasure */
+ rnPerformanceMeasure?: (IRnPerformanceMeasure|null);
+
+ /** RnHttpRequestTiming method */
+ method?: (string|null);
+
+ /** RnHttpRequestTiming matchedPath */
+ matchedPath?: (string|null);
+
+ /** RnHttpRequestTiming status */
+ status?: (number|null);
+
+ /** RnHttpRequestTiming errorCode */
+ errorCode?: (number|null);
+
+ /** RnHttpRequestTiming clientErrorMessage */
+ clientErrorMessage?: (string|null);
+
+ /** RnHttpRequestTiming errorType */
+ errorType?: (string|null);
+
+ /** RnHttpRequestTiming code */
+ code?: (string|null);
+
+ /** RnHttpRequestTiming traceId */
+ traceId?: (string|null);
+
+ /** RnHttpRequestTiming duration */
+ duration?: (number|null);
+
+ /** RnHttpRequestTiming url */
+ url?: (string|null);
+
+ /** RnHttpRequestTiming data */
+ data?: (string|null);
+
+ /** RnHttpRequestTiming level */
+ level?: (string|null);
+
+ /** RnHttpRequestTiming errorMsg */
+ errorMsg?: (string|null);
+
+ /** RnHttpRequestTiming networkErrorInfo */
+ networkErrorInfo?: (IRnNetworkErrorInfo|null);
+}
+
+/** Represents a RnHttpRequestTiming. */
+export class RnHttpRequestTiming implements IRnHttpRequestTiming {
+
+ /**
+ * Constructs a new RnHttpRequestTiming.
+ * @param [properties] Properties to set
+ */
+ constructor(properties?: IRnHttpRequestTiming);
+
+ /** RnHttpRequestTiming rnPerformanceMeasure. */
+ public rnPerformanceMeasure?: (IRnPerformanceMeasure|null);
+
+ /** RnHttpRequestTiming method. */
+ public method: string;
+
+ /** RnHttpRequestTiming matchedPath. */
+ public matchedPath: string;
+
+ /** RnHttpRequestTiming status. */
+ public status: number;
+
+ /** RnHttpRequestTiming errorCode. */
+ public errorCode: number;
+
+ /** RnHttpRequestTiming clientErrorMessage. */
+ public clientErrorMessage: string;
+
+ /** RnHttpRequestTiming errorType. */
+ public errorType: string;
+
+ /** RnHttpRequestTiming code. */
+ public code: string;
+
+ /** RnHttpRequestTiming traceId. */
+ public traceId: string;
+
+ /** RnHttpRequestTiming duration. */
+ public duration: number;
+
+ /** RnHttpRequestTiming url. */
+ public url: string;
+
+ /** RnHttpRequestTiming data. */
+ public data: string;
+
+ /** RnHttpRequestTiming level. */
+ public level: string;
+
+ /** RnHttpRequestTiming errorMsg. */
+ public errorMsg: string;
+
+ /** RnHttpRequestTiming networkErrorInfo. */
+ public networkErrorInfo?: (IRnNetworkErrorInfo|null);
+
+ /**
+ * Creates a new RnHttpRequestTiming instance using the specified properties.
+ * @param [properties] Properties to set
+ * @returns RnHttpRequestTiming instance
+ */
+ public static create(properties?: IRnHttpRequestTiming): RnHttpRequestTiming;
+
+ /**
+ * Encodes the specified RnHttpRequestTiming message. Does not implicitly {@link RnHttpRequestTiming.verify|verify} messages.
+ * @param message RnHttpRequestTiming message or plain object to encode
+ * @param [writer] Writer to encode to
+ * @returns Writer
+ */
+ public static encode(message: IRnHttpRequestTiming, writer?: $protobuf.Writer): $protobuf.Writer;
+
+ /**
+ * Encodes the specified RnHttpRequestTiming message, length delimited. Does not implicitly {@link RnHttpRequestTiming.verify|verify} messages.
+ * @param message RnHttpRequestTiming message or plain object to encode
+ * @param [writer] Writer to encode to
+ * @returns Writer
+ */
+ public static encodeDelimited(message: IRnHttpRequestTiming, writer?: $protobuf.Writer): $protobuf.Writer;
+
+ /**
+ * Decodes a RnHttpRequestTiming message from the specified reader or buffer.
+ * @param reader Reader or buffer to decode from
+ * @param [length] Message length if known beforehand
+ * @returns RnHttpRequestTiming
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): RnHttpRequestTiming;
+
+ /**
+ * Decodes a RnHttpRequestTiming message from the specified reader or buffer, length delimited.
+ * @param reader Reader or buffer to decode from
+ * @returns RnHttpRequestTiming
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): RnHttpRequestTiming;
+
+ /**
+ * Verifies a RnHttpRequestTiming message.
+ * @param message Plain object to verify
+ * @returns `null` if valid, otherwise the reason why it is not
+ */
+ public static verify(message: { [k: string]: any }): (string|null);
+
+ /**
+ * Creates a RnHttpRequestTiming message from a plain object. Also converts values to their respective internal types.
+ * @param object Plain object
+ * @returns RnHttpRequestTiming
+ */
+ public static fromObject(object: { [k: string]: any }): RnHttpRequestTiming;
+
+ /**
+ * Creates a plain object from a RnHttpRequestTiming message. Also converts values to other types if specified.
+ * @param message RnHttpRequestTiming
+ * @param [options] Conversion options
+ * @returns Plain object
+ */
+ public static toObject(message: RnHttpRequestTiming, options?: $protobuf.IConversionOptions): { [k: string]: any };
+
+ /**
+ * Converts this RnHttpRequestTiming to JSON.
+ * @returns JSON object
+ */
+ public toJSON(): { [k: string]: any };
+
+ /**
+ * Gets the default type url for RnHttpRequestTiming
+ * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
+ * @returns The default type url
+ */
+ public static getTypeUrl(typeUrlPrefix?: string): string;
+}
+
+/** Properties of a RnResourceTiming. */
+export interface IRnResourceTiming {
+
+ /** RnResourceTiming name */
+ name?: (string|null);
+
+ /** RnResourceTiming entryType */
+ entryType?: (string|null);
+
+ /** RnResourceTiming startTime */
+ startTime?: (number|null);
+
+ /** RnResourceTiming duration */
+ duration?: (number|null);
+
+ /** RnResourceTiming initiatorType */
+ initiatorType?: (string|null);
+
+ /** RnResourceTiming nextHopProtocol */
+ nextHopProtocol?: (string|null);
+
+ /** RnResourceTiming workerStart */
+ workerStart?: (number|null);
+
+ /** RnResourceTiming redirectStart */
+ redirectStart?: (number|null);
+
+ /** RnResourceTiming redirectEnd */
+ redirectEnd?: (number|null);
+
+ /** RnResourceTiming fetchStart */
+ fetchStart?: (number|null);
+
+ /** RnResourceTiming domainLookupStart */
+ domainLookupStart?: (number|null);
+
+ /** RnResourceTiming domainLookupEnd */
+ domainLookupEnd?: (number|null);
+
+ /** RnResourceTiming connectStart */
+ connectStart?: (number|null);
+
+ /** RnResourceTiming connectEnd */
+ connectEnd?: (number|null);
+
+ /** RnResourceTiming secureConnectionStart */
+ secureConnectionStart?: (number|null);
+
+ /** RnResourceTiming requestStart */
+ requestStart?: (number|null);
+
+ /** RnResourceTiming responseStart */
+ responseStart?: (number|null);
+
+ /** RnResourceTiming responseEnd */
+ responseEnd?: (number|null);
+
+ /** RnResourceTiming transferSize */
+ transferSize?: (number|Long|null);
+
+ /** RnResourceTiming encodedBodySize */
+ encodedBodySize?: (number|Long|null);
+
+ /** RnResourceTiming decodedBodySize */
+ decodedBodySize?: (number|Long|null);
+
+ /** RnResourceTiming location */
+ location?: (IRnLocation|null);
+
+ /** RnResourceTiming resourceMeta */
+ resourceMeta?: (IRnResourceMeta[]|null);
+
+ /** RnResourceTiming networkErrorInfo */
+ networkErrorInfo?: (IRnNetworkErrorInfo|null);
+}
+
+/** Represents a RnResourceTiming. */
+export class RnResourceTiming implements IRnResourceTiming {
+
+ /**
+ * Constructs a new RnResourceTiming.
+ * @param [properties] Properties to set
+ */
+ constructor(properties?: IRnResourceTiming);
+
+ /** RnResourceTiming name. */
+ public name: string;
+
+ /** RnResourceTiming entryType. */
+ public entryType: string;
+
+ /** RnResourceTiming startTime. */
+ public startTime: number;
+
+ /** RnResourceTiming duration. */
+ public duration: number;
+
+ /** RnResourceTiming initiatorType. */
+ public initiatorType: string;
+
+ /** RnResourceTiming nextHopProtocol. */
+ public nextHopProtocol: string;
+
+ /** RnResourceTiming workerStart. */
+ public workerStart: number;
+
+ /** RnResourceTiming redirectStart. */
+ public redirectStart: number;
+
+ /** RnResourceTiming redirectEnd. */
+ public redirectEnd: number;
+
+ /** RnResourceTiming fetchStart. */
+ public fetchStart: number;
+
+ /** RnResourceTiming domainLookupStart. */
+ public domainLookupStart: number;
+
+ /** RnResourceTiming domainLookupEnd. */
+ public domainLookupEnd: number;
+
+ /** RnResourceTiming connectStart. */
+ public connectStart: number;
+
+ /** RnResourceTiming connectEnd. */
+ public connectEnd: number;
+
+ /** RnResourceTiming secureConnectionStart. */
+ public secureConnectionStart: number;
+
+ /** RnResourceTiming requestStart. */
+ public requestStart: number;
+
+ /** RnResourceTiming responseStart. */
+ public responseStart: number;
+
+ /** RnResourceTiming responseEnd. */
+ public responseEnd: number;
+
+ /** RnResourceTiming transferSize. */
+ public transferSize: (number|Long);
+
+ /** RnResourceTiming encodedBodySize. */
+ public encodedBodySize: (number|Long);
+
+ /** RnResourceTiming decodedBodySize. */
+ public decodedBodySize: (number|Long);
+
+ /** RnResourceTiming location. */
+ public location?: (IRnLocation|null);
+
+ /** RnResourceTiming resourceMeta. */
+ public resourceMeta: IRnResourceMeta[];
+
+ /** RnResourceTiming networkErrorInfo. */
+ public networkErrorInfo?: (IRnNetworkErrorInfo|null);
+
+ /**
+ * Creates a new RnResourceTiming instance using the specified properties.
+ * @param [properties] Properties to set
+ * @returns RnResourceTiming instance
+ */
+ public static create(properties?: IRnResourceTiming): RnResourceTiming;
+
+ /**
+ * Encodes the specified RnResourceTiming message. Does not implicitly {@link RnResourceTiming.verify|verify} messages.
+ * @param message RnResourceTiming message or plain object to encode
+ * @param [writer] Writer to encode to
+ * @returns Writer
+ */
+ public static encode(message: IRnResourceTiming, writer?: $protobuf.Writer): $protobuf.Writer;
+
+ /**
+ * Encodes the specified RnResourceTiming message, length delimited. Does not implicitly {@link RnResourceTiming.verify|verify} messages.
+ * @param message RnResourceTiming message or plain object to encode
+ * @param [writer] Writer to encode to
+ * @returns Writer
+ */
+ public static encodeDelimited(message: IRnResourceTiming, writer?: $protobuf.Writer): $protobuf.Writer;
+
+ /**
+ * Decodes a RnResourceTiming message from the specified reader or buffer.
+ * @param reader Reader or buffer to decode from
+ * @param [length] Message length if known beforehand
+ * @returns RnResourceTiming
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): RnResourceTiming;
+
+ /**
+ * Decodes a RnResourceTiming message from the specified reader or buffer, length delimited.
+ * @param reader Reader or buffer to decode from
+ * @returns RnResourceTiming
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): RnResourceTiming;
+
+ /**
+ * Verifies a RnResourceTiming message.
+ * @param message Plain object to verify
+ * @returns `null` if valid, otherwise the reason why it is not
+ */
+ public static verify(message: { [k: string]: any }): (string|null);
+
+ /**
+ * Creates a RnResourceTiming message from a plain object. Also converts values to their respective internal types.
+ * @param object Plain object
+ * @returns RnResourceTiming
+ */
+ public static fromObject(object: { [k: string]: any }): RnResourceTiming;
+
+ /**
+ * Creates a plain object from a RnResourceTiming message. Also converts values to other types if specified.
+ * @param message RnResourceTiming
+ * @param [options] Conversion options
+ * @returns Plain object
+ */
+ public static toObject(message: RnResourceTiming, options?: $protobuf.IConversionOptions): { [k: string]: any };
+
+ /**
+ * Converts this RnResourceTiming to JSON.
+ * @returns JSON object
+ */
+ public toJSON(): { [k: string]: any };
+
+ /**
+ * Gets the default type url for RnResourceTiming
+ * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
+ * @returns The default type url
+ */
+ public static getTypeUrl(typeUrlPrefix?: string): string;
+}
+
+/** Properties of a RnPerformanceMeasure. */
+export interface IRnPerformanceMeasure {
+
+ /** RnPerformanceMeasure name */
+ name?: (string|null);
+
+ /** RnPerformanceMeasure entryType */
+ entryType?: (string|null);
+
+ /** RnPerformanceMeasure startTime */
+ startTime?: (number|null);
+
+ /** RnPerformanceMeasure duration */
+ duration?: (number|null);
+}
+
+/** Represents a RnPerformanceMeasure. */
+export class RnPerformanceMeasure implements IRnPerformanceMeasure {
+
+ /**
+ * Constructs a new RnPerformanceMeasure.
+ * @param [properties] Properties to set
+ */
+ constructor(properties?: IRnPerformanceMeasure);
+
+ /** RnPerformanceMeasure name. */
+ public name: string;
+
+ /** RnPerformanceMeasure entryType. */
+ public entryType: string;
+
+ /** RnPerformanceMeasure startTime. */
+ public startTime: number;
+
+ /** RnPerformanceMeasure duration. */
+ public duration: number;
+
+ /**
+ * Creates a new RnPerformanceMeasure instance using the specified properties.
+ * @param [properties] Properties to set
+ * @returns RnPerformanceMeasure instance
+ */
+ public static create(properties?: IRnPerformanceMeasure): RnPerformanceMeasure;
+
+ /**
+ * Encodes the specified RnPerformanceMeasure message. Does not implicitly {@link RnPerformanceMeasure.verify|verify} messages.
+ * @param message RnPerformanceMeasure message or plain object to encode
+ * @param [writer] Writer to encode to
+ * @returns Writer
+ */
+ public static encode(message: IRnPerformanceMeasure, writer?: $protobuf.Writer): $protobuf.Writer;
+
+ /**
+ * Encodes the specified RnPerformanceMeasure message, length delimited. Does not implicitly {@link RnPerformanceMeasure.verify|verify} messages.
+ * @param message RnPerformanceMeasure message or plain object to encode
+ * @param [writer] Writer to encode to
+ * @returns Writer
+ */
+ public static encodeDelimited(message: IRnPerformanceMeasure, writer?: $protobuf.Writer): $protobuf.Writer;
+
+ /**
+ * Decodes a RnPerformanceMeasure message from the specified reader or buffer.
+ * @param reader Reader or buffer to decode from
+ * @param [length] Message length if known beforehand
+ * @returns RnPerformanceMeasure
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): RnPerformanceMeasure;
+
+ /**
+ * Decodes a RnPerformanceMeasure message from the specified reader or buffer, length delimited.
+ * @param reader Reader or buffer to decode from
+ * @returns RnPerformanceMeasure
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): RnPerformanceMeasure;
+
+ /**
+ * Verifies a RnPerformanceMeasure message.
+ * @param message Plain object to verify
+ * @returns `null` if valid, otherwise the reason why it is not
+ */
+ public static verify(message: { [k: string]: any }): (string|null);
+
+ /**
+ * Creates a RnPerformanceMeasure message from a plain object. Also converts values to their respective internal types.
+ * @param object Plain object
+ * @returns RnPerformanceMeasure
+ */
+ public static fromObject(object: { [k: string]: any }): RnPerformanceMeasure;
+
+ /**
+ * Creates a plain object from a RnPerformanceMeasure message. Also converts values to other types if specified.
+ * @param message RnPerformanceMeasure
+ * @param [options] Conversion options
+ * @returns Plain object
+ */
+ public static toObject(message: RnPerformanceMeasure, options?: $protobuf.IConversionOptions): { [k: string]: any };
+
+ /**
+ * Converts this RnPerformanceMeasure to JSON.
+ * @returns JSON object
+ */
+ public toJSON(): { [k: string]: any };
+
+ /**
+ * Gets the default type url for RnPerformanceMeasure
+ * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
+ * @returns The default type url
+ */
+ public static getTypeUrl(typeUrlPrefix?: string): string;
+}
+
+/** Properties of a RnVideoResourceTiming. */
+export interface IRnVideoResourceTiming {
+
+ /** RnVideoResourceTiming uri */
+ uri?: (string|null);
+
+ /** RnVideoResourceTiming location */
+ location?: (IRnLocation|null);
+
+ /** RnVideoResourceTiming mime */
+ mime?: (string|null);
+
+ /** RnVideoResourceTiming size */
+ size?: (number|null);
+
+ /** RnVideoResourceTiming duration */
+ duration?: (number|null);
+
+ /** RnVideoResourceTiming resolution */
+ resolution?: (IRnVideoResolution|null);
+
+ /** RnVideoResourceTiming playComplete */
+ playComplete?: (boolean|null);
+
+ /** RnVideoResourceTiming videoLoadingTiming */
+ videoLoadingTiming?: (IRnVideoLoadingTiming|null);
+
+ /** RnVideoResourceTiming resourceMeta */
+ resourceMeta?: (IRnResourceMeta[]|null);
+
+ /** RnVideoResourceTiming networkErrorInfo */
+ networkErrorInfo?: (IRnNetworkErrorInfo|null);
+}
+
+/** Represents a RnVideoResourceTiming. */
+export class RnVideoResourceTiming implements IRnVideoResourceTiming {
+
+ /**
+ * Constructs a new RnVideoResourceTiming.
+ * @param [properties] Properties to set
+ */
+ constructor(properties?: IRnVideoResourceTiming);
+
+ /** RnVideoResourceTiming uri. */
+ public uri: string;
+
+ /** RnVideoResourceTiming location. */
+ public location?: (IRnLocation|null);
+
+ /** RnVideoResourceTiming mime. */
+ public mime: string;
+
+ /** RnVideoResourceTiming size. */
+ public size: number;
+
+ /** RnVideoResourceTiming duration. */
+ public duration: number;
+
+ /** RnVideoResourceTiming resolution. */
+ public resolution?: (IRnVideoResolution|null);
+
+ /** RnVideoResourceTiming playComplete. */
+ public playComplete: boolean;
+
+ /** RnVideoResourceTiming videoLoadingTiming. */
+ public videoLoadingTiming?: (IRnVideoLoadingTiming|null);
+
+ /** RnVideoResourceTiming resourceMeta. */
+ public resourceMeta: IRnResourceMeta[];
+
+ /** RnVideoResourceTiming networkErrorInfo. */
+ public networkErrorInfo?: (IRnNetworkErrorInfo|null);
+
+ /**
+ * Creates a new RnVideoResourceTiming instance using the specified properties.
+ * @param [properties] Properties to set
+ * @returns RnVideoResourceTiming instance
+ */
+ public static create(properties?: IRnVideoResourceTiming): RnVideoResourceTiming;
+
+ /**
+ * Encodes the specified RnVideoResourceTiming message. Does not implicitly {@link RnVideoResourceTiming.verify|verify} messages.
+ * @param message RnVideoResourceTiming message or plain object to encode
+ * @param [writer] Writer to encode to
+ * @returns Writer
+ */
+ public static encode(message: IRnVideoResourceTiming, writer?: $protobuf.Writer): $protobuf.Writer;
+
+ /**
+ * Encodes the specified RnVideoResourceTiming message, length delimited. Does not implicitly {@link RnVideoResourceTiming.verify|verify} messages.
+ * @param message RnVideoResourceTiming message or plain object to encode
+ * @param [writer] Writer to encode to
+ * @returns Writer
+ */
+ public static encodeDelimited(message: IRnVideoResourceTiming, writer?: $protobuf.Writer): $protobuf.Writer;
+
+ /**
+ * Decodes a RnVideoResourceTiming message from the specified reader or buffer.
+ * @param reader Reader or buffer to decode from
+ * @param [length] Message length if known beforehand
+ * @returns RnVideoResourceTiming
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): RnVideoResourceTiming;
+
+ /**
+ * Decodes a RnVideoResourceTiming message from the specified reader or buffer, length delimited.
+ * @param reader Reader or buffer to decode from
+ * @returns RnVideoResourceTiming
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): RnVideoResourceTiming;
+
+ /**
+ * Verifies a RnVideoResourceTiming message.
+ * @param message Plain object to verify
+ * @returns `null` if valid, otherwise the reason why it is not
+ */
+ public static verify(message: { [k: string]: any }): (string|null);
+
+ /**
+ * Creates a RnVideoResourceTiming message from a plain object. Also converts values to their respective internal types.
+ * @param object Plain object
+ * @returns RnVideoResourceTiming
+ */
+ public static fromObject(object: { [k: string]: any }): RnVideoResourceTiming;
+
+ /**
+ * Creates a plain object from a RnVideoResourceTiming message. Also converts values to other types if specified.
+ * @param message RnVideoResourceTiming
+ * @param [options] Conversion options
+ * @returns Plain object
+ */
+ public static toObject(message: RnVideoResourceTiming, options?: $protobuf.IConversionOptions): { [k: string]: any };
+
+ /**
+ * Converts this RnVideoResourceTiming to JSON.
+ * @returns JSON object
+ */
+ public toJSON(): { [k: string]: any };
+
+ /**
+ * Gets the default type url for RnVideoResourceTiming
+ * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
+ * @returns The default type url
+ */
+ public static getTypeUrl(typeUrlPrefix?: string): string;
+}
+
+/** Properties of a RnNetworkErrorInfo. */
+export interface IRnNetworkErrorInfo {
+
+ /** RnNetworkErrorInfo status */
+ status?: (number|null);
+
+ /** RnNetworkErrorInfo info */
+ info?: (string|null);
+}
+
+/** Represents a RnNetworkErrorInfo. */
+export class RnNetworkErrorInfo implements IRnNetworkErrorInfo {
+
+ /**
+ * Constructs a new RnNetworkErrorInfo.
+ * @param [properties] Properties to set
+ */
+ constructor(properties?: IRnNetworkErrorInfo);
+
+ /** RnNetworkErrorInfo status. */
+ public status: number;
+
+ /** RnNetworkErrorInfo info. */
+ public info: string;
+
+ /**
+ * Creates a new RnNetworkErrorInfo instance using the specified properties.
+ * @param [properties] Properties to set
+ * @returns RnNetworkErrorInfo instance
+ */
+ public static create(properties?: IRnNetworkErrorInfo): RnNetworkErrorInfo;
+
+ /**
+ * Encodes the specified RnNetworkErrorInfo message. Does not implicitly {@link RnNetworkErrorInfo.verify|verify} messages.
+ * @param message RnNetworkErrorInfo message or plain object to encode
+ * @param [writer] Writer to encode to
+ * @returns Writer
+ */
+ public static encode(message: IRnNetworkErrorInfo, writer?: $protobuf.Writer): $protobuf.Writer;
+
+ /**
+ * Encodes the specified RnNetworkErrorInfo message, length delimited. Does not implicitly {@link RnNetworkErrorInfo.verify|verify} messages.
+ * @param message RnNetworkErrorInfo message or plain object to encode
+ * @param [writer] Writer to encode to
+ * @returns Writer
+ */
+ public static encodeDelimited(message: IRnNetworkErrorInfo, writer?: $protobuf.Writer): $protobuf.Writer;
+
+ /**
+ * Decodes a RnNetworkErrorInfo message from the specified reader or buffer.
+ * @param reader Reader or buffer to decode from
+ * @param [length] Message length if known beforehand
+ * @returns RnNetworkErrorInfo
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): RnNetworkErrorInfo;
+
+ /**
+ * Decodes a RnNetworkErrorInfo message from the specified reader or buffer, length delimited.
+ * @param reader Reader or buffer to decode from
+ * @returns RnNetworkErrorInfo
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): RnNetworkErrorInfo;
+
+ /**
+ * Verifies a RnNetworkErrorInfo message.
+ * @param message Plain object to verify
+ * @returns `null` if valid, otherwise the reason why it is not
+ */
+ public static verify(message: { [k: string]: any }): (string|null);
+
+ /**
+ * Creates a RnNetworkErrorInfo message from a plain object. Also converts values to their respective internal types.
+ * @param object Plain object
+ * @returns RnNetworkErrorInfo
+ */
+ public static fromObject(object: { [k: string]: any }): RnNetworkErrorInfo;
+
+ /**
+ * Creates a plain object from a RnNetworkErrorInfo message. Also converts values to other types if specified.
+ * @param message RnNetworkErrorInfo
+ * @param [options] Conversion options
+ * @returns Plain object
+ */
+ public static toObject(message: RnNetworkErrorInfo, options?: $protobuf.IConversionOptions): { [k: string]: any };
+
+ /**
+ * Converts this RnNetworkErrorInfo to JSON.
+ * @returns JSON object
+ */
+ public toJSON(): { [k: string]: any };
+
+ /**
+ * Gets the default type url for RnNetworkErrorInfo
+ * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
+ * @returns The default type url
+ */
+ public static getTypeUrl(typeUrlPrefix?: string): string;
+}
+
+/** Properties of a RnLocation. */
+export interface IRnLocation {
+
+ /** RnLocation hash */
+ hash?: (string|null);
+
+ /** RnLocation host */
+ host?: (string|null);
+
+ /** RnLocation hostname */
+ hostname?: (string|null);
+
+ /** RnLocation href */
+ href?: (string|null);
+
+ /** RnLocation origin */
+ origin?: (string|null);
+
+ /** RnLocation pathname */
+ pathname?: (string|null);
+
+ /** RnLocation port */
+ port?: (string|null);
+
+ /** RnLocation protocol */
+ protocol?: (string|null);
+
+ /** RnLocation search */
+ search?: (string|null);
+}
+
+/** Represents a RnLocation. */
+export class RnLocation implements IRnLocation {
+
+ /**
+ * Constructs a new RnLocation.
+ * @param [properties] Properties to set
+ */
+ constructor(properties?: IRnLocation);
+
+ /** RnLocation hash. */
+ public hash: string;
+
+ /** RnLocation host. */
+ public host: string;
+
+ /** RnLocation hostname. */
+ public hostname: string;
+
+ /** RnLocation href. */
+ public href: string;
+
+ /** RnLocation origin. */
+ public origin: string;
+
+ /** RnLocation pathname. */
+ public pathname: string;
+
+ /** RnLocation port. */
+ public port: string;
+
+ /** RnLocation protocol. */
+ public protocol: string;
+
+ /** RnLocation search. */
+ public search: string;
+
+ /**
+ * Creates a new RnLocation instance using the specified properties.
+ * @param [properties] Properties to set
+ * @returns RnLocation instance
+ */
+ public static create(properties?: IRnLocation): RnLocation;
+
+ /**
+ * Encodes the specified RnLocation message. Does not implicitly {@link RnLocation.verify|verify} messages.
+ * @param message RnLocation message or plain object to encode
+ * @param [writer] Writer to encode to
+ * @returns Writer
+ */
+ public static encode(message: IRnLocation, writer?: $protobuf.Writer): $protobuf.Writer;
+
+ /**
+ * Encodes the specified RnLocation message, length delimited. Does not implicitly {@link RnLocation.verify|verify} messages.
+ * @param message RnLocation message or plain object to encode
+ * @param [writer] Writer to encode to
+ * @returns Writer
+ */
+ public static encodeDelimited(message: IRnLocation, writer?: $protobuf.Writer): $protobuf.Writer;
+
+ /**
+ * Decodes a RnLocation message from the specified reader or buffer.
+ * @param reader Reader or buffer to decode from
+ * @param [length] Message length if known beforehand
+ * @returns RnLocation
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): RnLocation;
+
+ /**
+ * Decodes a RnLocation message from the specified reader or buffer, length delimited.
+ * @param reader Reader or buffer to decode from
+ * @returns RnLocation
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): RnLocation;
+
+ /**
+ * Verifies a RnLocation message.
+ * @param message Plain object to verify
+ * @returns `null` if valid, otherwise the reason why it is not
+ */
+ public static verify(message: { [k: string]: any }): (string|null);
+
+ /**
+ * Creates a RnLocation message from a plain object. Also converts values to their respective internal types.
+ * @param object Plain object
+ * @returns RnLocation
+ */
+ public static fromObject(object: { [k: string]: any }): RnLocation;
+
+ /**
+ * Creates a plain object from a RnLocation message. Also converts values to other types if specified.
+ * @param message RnLocation
+ * @param [options] Conversion options
+ * @returns Plain object
+ */
+ public static toObject(message: RnLocation, options?: $protobuf.IConversionOptions): { [k: string]: any };
+
+ /**
+ * Converts this RnLocation to JSON.
+ * @returns JSON object
+ */
+ public toJSON(): { [k: string]: any };
+
+ /**
+ * Gets the default type url for RnLocation
+ * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
+ * @returns The default type url
+ */
+ public static getTypeUrl(typeUrlPrefix?: string): string;
+}
+
+/** Properties of a RnVideoResolution. */
+export interface IRnVideoResolution {
+
+ /** RnVideoResolution width */
+ width?: (number|null);
+
+ /** RnVideoResolution height */
+ height?: (number|null);
+
+ /** RnVideoResolution orientation */
+ orientation?: (string|null);
+}
+
+/** Represents a RnVideoResolution. */
+export class RnVideoResolution implements IRnVideoResolution {
+
+ /**
+ * Constructs a new RnVideoResolution.
+ * @param [properties] Properties to set
+ */
+ constructor(properties?: IRnVideoResolution);
+
+ /** RnVideoResolution width. */
+ public width: number;
+
+ /** RnVideoResolution height. */
+ public height: number;
+
+ /** RnVideoResolution orientation. */
+ public orientation: string;
+
+ /**
+ * Creates a new RnVideoResolution instance using the specified properties.
+ * @param [properties] Properties to set
+ * @returns RnVideoResolution instance
+ */
+ public static create(properties?: IRnVideoResolution): RnVideoResolution;
+
+ /**
+ * Encodes the specified RnVideoResolution message. Does not implicitly {@link RnVideoResolution.verify|verify} messages.
+ * @param message RnVideoResolution message or plain object to encode
+ * @param [writer] Writer to encode to
+ * @returns Writer
+ */
+ public static encode(message: IRnVideoResolution, writer?: $protobuf.Writer): $protobuf.Writer;
+
+ /**
+ * Encodes the specified RnVideoResolution message, length delimited. Does not implicitly {@link RnVideoResolution.verify|verify} messages.
+ * @param message RnVideoResolution message or plain object to encode
+ * @param [writer] Writer to encode to
+ * @returns Writer
+ */
+ public static encodeDelimited(message: IRnVideoResolution, writer?: $protobuf.Writer): $protobuf.Writer;
+
+ /**
+ * Decodes a RnVideoResolution message from the specified reader or buffer.
+ * @param reader Reader or buffer to decode from
+ * @param [length] Message length if known beforehand
+ * @returns RnVideoResolution
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): RnVideoResolution;
+
+ /**
+ * Decodes a RnVideoResolution message from the specified reader or buffer, length delimited.
+ * @param reader Reader or buffer to decode from
+ * @returns RnVideoResolution
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): RnVideoResolution;
+
+ /**
+ * Verifies a RnVideoResolution message.
+ * @param message Plain object to verify
+ * @returns `null` if valid, otherwise the reason why it is not
+ */
+ public static verify(message: { [k: string]: any }): (string|null);
+
+ /**
+ * Creates a RnVideoResolution message from a plain object. Also converts values to their respective internal types.
+ * @param object Plain object
+ * @returns RnVideoResolution
+ */
+ public static fromObject(object: { [k: string]: any }): RnVideoResolution;
+
+ /**
+ * Creates a plain object from a RnVideoResolution message. Also converts values to other types if specified.
+ * @param message RnVideoResolution
+ * @param [options] Conversion options
+ * @returns Plain object
+ */
+ public static toObject(message: RnVideoResolution, options?: $protobuf.IConversionOptions): { [k: string]: any };
+
+ /**
+ * Converts this RnVideoResolution to JSON.
+ * @returns JSON object
+ */
+ public toJSON(): { [k: string]: any };
+
+ /**
+ * Gets the default type url for RnVideoResolution
+ * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
+ * @returns The default type url
+ */
+ public static getTypeUrl(typeUrlPrefix?: string): string;
+}
+
+/** Properties of a RnVideoLoadingTiming. */
+export interface IRnVideoLoadingTiming {
+
+ /** RnVideoLoadingTiming loadStart */
+ loadStart?: (number|null);
+
+ /** RnVideoLoadingTiming canPlay */
+ canPlay?: (number|null);
+
+ /** RnVideoLoadingTiming bufferTime */
+ bufferTime?: (number|null);
+
+ /** RnVideoLoadingTiming playTime */
+ playTime?: (number|null);
+}
+
+/** Represents a RnVideoLoadingTiming. */
+export class RnVideoLoadingTiming implements IRnVideoLoadingTiming {
+
+ /**
+ * Constructs a new RnVideoLoadingTiming.
+ * @param [properties] Properties to set
+ */
+ constructor(properties?: IRnVideoLoadingTiming);
+
+ /** RnVideoLoadingTiming loadStart. */
+ public loadStart: number;
+
+ /** RnVideoLoadingTiming canPlay. */
+ public canPlay: number;
+
+ /** RnVideoLoadingTiming bufferTime. */
+ public bufferTime: number;
+
+ /** RnVideoLoadingTiming playTime. */
+ public playTime: number;
+
+ /**
+ * Creates a new RnVideoLoadingTiming instance using the specified properties.
+ * @param [properties] Properties to set
+ * @returns RnVideoLoadingTiming instance
+ */
+ public static create(properties?: IRnVideoLoadingTiming): RnVideoLoadingTiming;
+
+ /**
+ * Encodes the specified RnVideoLoadingTiming message. Does not implicitly {@link RnVideoLoadingTiming.verify|verify} messages.
+ * @param message RnVideoLoadingTiming message or plain object to encode
+ * @param [writer] Writer to encode to
+ * @returns Writer
+ */
+ public static encode(message: IRnVideoLoadingTiming, writer?: $protobuf.Writer): $protobuf.Writer;
+
+ /**
+ * Encodes the specified RnVideoLoadingTiming message, length delimited. Does not implicitly {@link RnVideoLoadingTiming.verify|verify} messages.
+ * @param message RnVideoLoadingTiming message or plain object to encode
+ * @param [writer] Writer to encode to
+ * @returns Writer
+ */
+ public static encodeDelimited(message: IRnVideoLoadingTiming, writer?: $protobuf.Writer): $protobuf.Writer;
+
+ /**
+ * Decodes a RnVideoLoadingTiming message from the specified reader or buffer.
+ * @param reader Reader or buffer to decode from
+ * @param [length] Message length if known beforehand
+ * @returns RnVideoLoadingTiming
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): RnVideoLoadingTiming;
+
+ /**
+ * Decodes a RnVideoLoadingTiming message from the specified reader or buffer, length delimited.
+ * @param reader Reader or buffer to decode from
+ * @returns RnVideoLoadingTiming
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): RnVideoLoadingTiming;
+
+ /**
+ * Verifies a RnVideoLoadingTiming message.
+ * @param message Plain object to verify
+ * @returns `null` if valid, otherwise the reason why it is not
+ */
+ public static verify(message: { [k: string]: any }): (string|null);
+
+ /**
+ * Creates a RnVideoLoadingTiming message from a plain object. Also converts values to their respective internal types.
+ * @param object Plain object
+ * @returns RnVideoLoadingTiming
+ */
+ public static fromObject(object: { [k: string]: any }): RnVideoLoadingTiming;
+
+ /**
+ * Creates a plain object from a RnVideoLoadingTiming message. Also converts values to other types if specified.
+ * @param message RnVideoLoadingTiming
+ * @param [options] Conversion options
+ * @returns Plain object
+ */
+ public static toObject(message: RnVideoLoadingTiming, options?: $protobuf.IConversionOptions): { [k: string]: any };
+
+ /**
+ * Converts this RnVideoLoadingTiming to JSON.
+ * @returns JSON object
+ */
+ public toJSON(): { [k: string]: any };
+
+ /**
+ * Gets the default type url for RnVideoLoadingTiming
+ * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
+ * @returns The default type url
+ */
+ public static getTypeUrl(typeUrlPrefix?: string): string;
+}
+
+/** Properties of a RnResourceMeta. */
+export interface IRnResourceMeta {
+
+ /** RnResourceMeta type */
+ type?: (string|null);
+
+ /** RnResourceMeta value */
+ value?: (string|null);
+}
+
+/** Represents a RnResourceMeta. */
+export class RnResourceMeta implements IRnResourceMeta {
+
+ /**
+ * Constructs a new RnResourceMeta.
+ * @param [properties] Properties to set
+ */
+ constructor(properties?: IRnResourceMeta);
+
+ /** RnResourceMeta type. */
+ public type: string;
+
+ /** RnResourceMeta value. */
+ public value: string;
+
+ /**
+ * Creates a new RnResourceMeta instance using the specified properties.
+ * @param [properties] Properties to set
+ * @returns RnResourceMeta instance
+ */
+ public static create(properties?: IRnResourceMeta): RnResourceMeta;
+
+ /**
+ * Encodes the specified RnResourceMeta message. Does not implicitly {@link RnResourceMeta.verify|verify} messages.
+ * @param message RnResourceMeta message or plain object to encode
+ * @param [writer] Writer to encode to
+ * @returns Writer
+ */
+ public static encode(message: IRnResourceMeta, writer?: $protobuf.Writer): $protobuf.Writer;
+
+ /**
+ * Encodes the specified RnResourceMeta message, length delimited. Does not implicitly {@link RnResourceMeta.verify|verify} messages.
+ * @param message RnResourceMeta message or plain object to encode
+ * @param [writer] Writer to encode to
+ * @returns Writer
+ */
+ public static encodeDelimited(message: IRnResourceMeta, writer?: $protobuf.Writer): $protobuf.Writer;
+
+ /**
+ * Decodes a RnResourceMeta message from the specified reader or buffer.
+ * @param reader Reader or buffer to decode from
+ * @param [length] Message length if known beforehand
+ * @returns RnResourceMeta
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): RnResourceMeta;
+
+ /**
+ * Decodes a RnResourceMeta message from the specified reader or buffer, length delimited.
+ * @param reader Reader or buffer to decode from
+ * @returns RnResourceMeta
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): RnResourceMeta;
+
+ /**
+ * Verifies a RnResourceMeta message.
+ * @param message Plain object to verify
+ * @returns `null` if valid, otherwise the reason why it is not
+ */
+ public static verify(message: { [k: string]: any }): (string|null);
+
+ /**
+ * Creates a RnResourceMeta message from a plain object. Also converts values to their respective internal types.
+ * @param object Plain object
+ * @returns RnResourceMeta
+ */
+ public static fromObject(object: { [k: string]: any }): RnResourceMeta;
+
+ /**
+ * Creates a plain object from a RnResourceMeta message. Also converts values to other types if specified.
+ * @param message RnResourceMeta
+ * @param [options] Conversion options
+ * @returns Plain object
+ */
+ public static toObject(message: RnResourceMeta, options?: $protobuf.IConversionOptions): { [k: string]: any };
+
+ /**
+ * Converts this RnResourceMeta to JSON.
+ * @returns JSON object
+ */
+ public toJSON(): { [k: string]: any };
+
+ /**
+ * Gets the default type url for RnResourceMeta
+ * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
+ * @returns The default type url
+ */
+ public static getTypeUrl(typeUrlPrefix?: string): string;
+}
+
+/** Properties of a RnRouteNotFound. */
+export interface IRnRouteNotFound {
+
+ /** RnRouteNotFound prevPageUrl */
+ prevPageUrl?: (string|null);
+
+ /** RnRouteNotFound firstPageUrl */
+ firstPageUrl?: (string|null);
+
+ /** RnRouteNotFound prevRoutePath */
+ prevRoutePath?: (string|null);
+
+ /** RnRouteNotFound targetRouteName */
+ targetRouteName?: (string|null);
+}
+
+/** Represents a RnRouteNotFound. */
+export class RnRouteNotFound implements IRnRouteNotFound {
+
+ /**
+ * Constructs a new RnRouteNotFound.
+ * @param [properties] Properties to set
+ */
+ constructor(properties?: IRnRouteNotFound);
+
+ /** RnRouteNotFound prevPageUrl. */
+ public prevPageUrl: string;
+
+ /** RnRouteNotFound firstPageUrl. */
+ public firstPageUrl: string;
+
+ /** RnRouteNotFound prevRoutePath. */
+ public prevRoutePath: string;
+
+ /** RnRouteNotFound targetRouteName. */
+ public targetRouteName: string;
+
+ /**
+ * Creates a new RnRouteNotFound instance using the specified properties.
+ * @param [properties] Properties to set
+ * @returns RnRouteNotFound instance
+ */
+ public static create(properties?: IRnRouteNotFound): RnRouteNotFound;
+
+ /**
+ * Encodes the specified RnRouteNotFound message. Does not implicitly {@link RnRouteNotFound.verify|verify} messages.
+ * @param message RnRouteNotFound message or plain object to encode
+ * @param [writer] Writer to encode to
+ * @returns Writer
+ */
+ public static encode(message: IRnRouteNotFound, writer?: $protobuf.Writer): $protobuf.Writer;
+
+ /**
+ * Encodes the specified RnRouteNotFound message, length delimited. Does not implicitly {@link RnRouteNotFound.verify|verify} messages.
+ * @param message RnRouteNotFound message or plain object to encode
+ * @param [writer] Writer to encode to
+ * @returns Writer
+ */
+ public static encodeDelimited(message: IRnRouteNotFound, writer?: $protobuf.Writer): $protobuf.Writer;
+
+ /**
+ * Decodes a RnRouteNotFound message from the specified reader or buffer.
+ * @param reader Reader or buffer to decode from
+ * @param [length] Message length if known beforehand
+ * @returns RnRouteNotFound
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): RnRouteNotFound;
+
+ /**
+ * Decodes a RnRouteNotFound message from the specified reader or buffer, length delimited.
+ * @param reader Reader or buffer to decode from
+ * @returns RnRouteNotFound
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): RnRouteNotFound;
+
+ /**
+ * Verifies a RnRouteNotFound message.
+ * @param message Plain object to verify
+ * @returns `null` if valid, otherwise the reason why it is not
+ */
+ public static verify(message: { [k: string]: any }): (string|null);
+
+ /**
+ * Creates a RnRouteNotFound message from a plain object. Also converts values to their respective internal types.
+ * @param object Plain object
+ * @returns RnRouteNotFound
+ */
+ public static fromObject(object: { [k: string]: any }): RnRouteNotFound;
+
+ /**
+ * Creates a plain object from a RnRouteNotFound message. Also converts values to other types if specified.
+ * @param message RnRouteNotFound
+ * @param [options] Conversion options
+ * @returns Plain object
+ */
+ public static toObject(message: RnRouteNotFound, options?: $protobuf.IConversionOptions): { [k: string]: any };
+
+ /**
+ * Converts this RnRouteNotFound to JSON.
+ * @returns JSON object
+ */
+ public toJSON(): { [k: string]: any };
+
+ /**
+ * Gets the default type url for RnRouteNotFound
+ * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
+ * @returns The default type url
+ */
+ public static getTypeUrl(typeUrlPrefix?: string): string;
+}
diff --git a/OpenHarmony/entry/src/ohosTest/ets/test/tracker_apm_rn.js b/OpenHarmony/entry/src/ohosTest/ets/test/tracker_apm_rn.js
new file mode 100644
index 000000000..3a5c0844e
--- /dev/null
+++ b/OpenHarmony/entry/src/ohosTest/ets/test/tracker_apm_rn.js
@@ -0,0 +1,4405 @@
+/*
+ * Copyright (c) 2022 Huawei Device Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*eslint-disable block-scoped-var, id-length, no-control-regex, no-magic-numbers, no-prototype-builtins, no-redeclare, no-shadow, no-var, sort-vars*/
+import $protobuf from "@ohos/protobufjs";
+
+// Common aliases
+const $Reader = $protobuf.Reader, $Writer = $protobuf.Writer, $util = $protobuf.util;
+
+// Exported root namespace
+const $root = $protobuf.roots["default"] || ($protobuf.roots["default"] = {});
+
+export const RnApmTracker = $root.RnApmTracker = (() => {
+
+ /**
+ * Properties of a RnApmTracker.
+ * @exports IRnApmTracker
+ * @interface IRnApmTracker
+ * @property {IRnPerformanceMeasure|null} [rnScriptExecutionTiming] RnApmTracker rnScriptExecutionTiming
+ * @property {IRnPerformanceMeasure|null} [rnPageFirstAppearTiming] RnApmTracker rnPageFirstAppearTiming
+ * @property {IRnHttpRequestTiming|null} [rnHttpRequestTiming] RnApmTracker rnHttpRequestTiming
+ * @property {IRnPerformanceMeasure|null} [rnPerformanceMeasure] RnApmTracker rnPerformanceMeasure
+ * @property {Array.|null} [rnResourceTiming] RnApmTracker rnResourceTiming
+ * @property {IRnVideoResourceTiming|null} [rnVideoResourceTiming] RnApmTracker rnVideoResourceTiming
+ * @property {IRnApmContext|null} [rnApmContext] RnApmTracker rnApmContext
+ * @property {IRnRouteNotFound|null} [rnRouteNotFound] RnApmTracker rnRouteNotFound
+ */
+
+ /**
+ * Constructs a new RnApmTracker.
+ * @exports RnApmTracker
+ * @classdesc Represents a RnApmTracker.
+ * @implements IRnApmTracker
+ * @constructor
+ * @param {IRnApmTracker=} [properties] Properties to set
+ */
+ function RnApmTracker(properties) {
+ this.rnResourceTiming = [];
+ if (properties)
+ for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
+ if (properties[keys[i]] != null)
+ this[keys[i]] = properties[keys[i]];
+ }
+
+ /**
+ * RnApmTracker rnScriptExecutionTiming.
+ * @member {IRnPerformanceMeasure|null|undefined} rnScriptExecutionTiming
+ * @memberof RnApmTracker
+ * @instance
+ */
+ RnApmTracker.prototype.rnScriptExecutionTiming = null;
+
+ /**
+ * RnApmTracker rnPageFirstAppearTiming.
+ * @member {IRnPerformanceMeasure|null|undefined} rnPageFirstAppearTiming
+ * @memberof RnApmTracker
+ * @instance
+ */
+ RnApmTracker.prototype.rnPageFirstAppearTiming = null;
+
+ /**
+ * RnApmTracker rnHttpRequestTiming.
+ * @member {IRnHttpRequestTiming|null|undefined} rnHttpRequestTiming
+ * @memberof RnApmTracker
+ * @instance
+ */
+ RnApmTracker.prototype.rnHttpRequestTiming = null;
+
+ /**
+ * RnApmTracker rnPerformanceMeasure.
+ * @member {IRnPerformanceMeasure|null|undefined} rnPerformanceMeasure
+ * @memberof RnApmTracker
+ * @instance
+ */
+ RnApmTracker.prototype.rnPerformanceMeasure = null;
+
+ /**
+ * RnApmTracker rnResourceTiming.
+ * @member {Array.} rnResourceTiming
+ * @memberof RnApmTracker
+ * @instance
+ */
+ RnApmTracker.prototype.rnResourceTiming = $util.emptyArray;
+
+ /**
+ * RnApmTracker rnVideoResourceTiming.
+ * @member {IRnVideoResourceTiming|null|undefined} rnVideoResourceTiming
+ * @memberof RnApmTracker
+ * @instance
+ */
+ RnApmTracker.prototype.rnVideoResourceTiming = null;
+
+ /**
+ * RnApmTracker rnApmContext.
+ * @member {IRnApmContext|null|undefined} rnApmContext
+ * @memberof RnApmTracker
+ * @instance
+ */
+ RnApmTracker.prototype.rnApmContext = null;
+
+ /**
+ * RnApmTracker rnRouteNotFound.
+ * @member {IRnRouteNotFound|null|undefined} rnRouteNotFound
+ * @memberof RnApmTracker
+ * @instance
+ */
+ RnApmTracker.prototype.rnRouteNotFound = null;
+
+ /**
+ * Creates a new RnApmTracker instance using the specified properties.
+ * @function create
+ * @memberof RnApmTracker
+ * @static
+ * @param {IRnApmTracker=} [properties] Properties to set
+ * @returns {RnApmTracker} RnApmTracker instance
+ */
+ RnApmTracker.create = function create(properties) {
+ return new RnApmTracker(properties);
+ };
+
+ /**
+ * Encodes the specified RnApmTracker message. Does not implicitly {@link RnApmTracker.verify|verify} messages.
+ * @function encode
+ * @memberof RnApmTracker
+ * @static
+ * @param {IRnApmTracker} message RnApmTracker message or plain object to encode
+ * @param {$protobuf.Writer} [writer] Writer to encode to
+ * @returns {$protobuf.Writer} Writer
+ */
+ RnApmTracker.encode = function encode(message, writer) {
+ if (!writer)
+ writer = $Writer.create();
+ if (message.rnScriptExecutionTiming != null && Object.hasOwnProperty.call(message, "rnScriptExecutionTiming"))
+ $root.RnPerformanceMeasure.encode(message.rnScriptExecutionTiming, writer.uint32(/* id 4001, wireType 2 =*/32010).fork()).ldelim();
+ if (message.rnPageFirstAppearTiming != null && Object.hasOwnProperty.call(message, "rnPageFirstAppearTiming"))
+ $root.RnPerformanceMeasure.encode(message.rnPageFirstAppearTiming, writer.uint32(/* id 4002, wireType 2 =*/32018).fork()).ldelim();
+ if (message.rnHttpRequestTiming != null && Object.hasOwnProperty.call(message, "rnHttpRequestTiming"))
+ $root.RnHttpRequestTiming.encode(message.rnHttpRequestTiming, writer.uint32(/* id 4003, wireType 2 =*/32026).fork()).ldelim();
+ if (message.rnPerformanceMeasure != null && Object.hasOwnProperty.call(message, "rnPerformanceMeasure"))
+ $root.RnPerformanceMeasure.encode(message.rnPerformanceMeasure, writer.uint32(/* id 4004, wireType 2 =*/32034).fork()).ldelim();
+ if (message.rnResourceTiming != null && message.rnResourceTiming.length)
+ for (let i = 0; i < message.rnResourceTiming.length; ++i)
+ $root.RnResourceTiming.encode(message.rnResourceTiming[i], writer.uint32(/* id 4005, wireType 2 =*/32042).fork()).ldelim();
+ if (message.rnVideoResourceTiming != null && Object.hasOwnProperty.call(message, "rnVideoResourceTiming"))
+ $root.RnVideoResourceTiming.encode(message.rnVideoResourceTiming, writer.uint32(/* id 4006, wireType 2 =*/32050).fork()).ldelim();
+ if (message.rnApmContext != null && Object.hasOwnProperty.call(message, "rnApmContext"))
+ $root.RnApmContext.encode(message.rnApmContext, writer.uint32(/* id 4007, wireType 2 =*/32058).fork()).ldelim();
+ if (message.rnRouteNotFound != null && Object.hasOwnProperty.call(message, "rnRouteNotFound"))
+ $root.RnRouteNotFound.encode(message.rnRouteNotFound, writer.uint32(/* id 4008, wireType 2 =*/32066).fork()).ldelim();
+ return writer;
+ };
+
+ /**
+ * Encodes the specified RnApmTracker message, length delimited. Does not implicitly {@link RnApmTracker.verify|verify} messages.
+ * @function encodeDelimited
+ * @memberof RnApmTracker
+ * @static
+ * @param {IRnApmTracker} message RnApmTracker message or plain object to encode
+ * @param {$protobuf.Writer} [writer] Writer to encode to
+ * @returns {$protobuf.Writer} Writer
+ */
+ RnApmTracker.encodeDelimited = function encodeDelimited(message, writer) {
+ return this.encode(message, writer).ldelim();
+ };
+
+ /**
+ * Decodes a RnApmTracker message from the specified reader or buffer.
+ * @function decode
+ * @memberof RnApmTracker
+ * @static
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
+ * @param {number} [length] Message length if known beforehand
+ * @returns {RnApmTracker} RnApmTracker
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ RnApmTracker.decode = function decode(reader, length) {
+ if (!(reader instanceof $Reader))
+ reader = $Reader.create(reader);
+ let end = length === undefined ? reader.len : reader.pos + length, message = new $root.RnApmTracker();
+ while (reader.pos < end) {
+ let tag = reader.uint32();
+ switch (tag >>> 3) {
+ case 4001: {
+ message.rnScriptExecutionTiming = $root.RnPerformanceMeasure.decode(reader, reader.uint32());
+ break;
+ }
+ case 4002: {
+ message.rnPageFirstAppearTiming = $root.RnPerformanceMeasure.decode(reader, reader.uint32());
+ break;
+ }
+ case 4003: {
+ message.rnHttpRequestTiming = $root.RnHttpRequestTiming.decode(reader, reader.uint32());
+ break;
+ }
+ case 4004: {
+ message.rnPerformanceMeasure = $root.RnPerformanceMeasure.decode(reader, reader.uint32());
+ break;
+ }
+ case 4005: {
+ if (!(message.rnResourceTiming && message.rnResourceTiming.length))
+ message.rnResourceTiming = [];
+ message.rnResourceTiming.push($root.RnResourceTiming.decode(reader, reader.uint32()));
+ break;
+ }
+ case 4006: {
+ message.rnVideoResourceTiming = $root.RnVideoResourceTiming.decode(reader, reader.uint32());
+ break;
+ }
+ case 4007: {
+ message.rnApmContext = $root.RnApmContext.decode(reader, reader.uint32());
+ break;
+ }
+ case 4008: {
+ message.rnRouteNotFound = $root.RnRouteNotFound.decode(reader, reader.uint32());
+ break;
+ }
+ default:
+ reader.skipType(tag & 7);
+ break;
+ }
+ }
+ return message;
+ };
+
+ /**
+ * Decodes a RnApmTracker message from the specified reader or buffer, length delimited.
+ * @function decodeDelimited
+ * @memberof RnApmTracker
+ * @static
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
+ * @returns {RnApmTracker} RnApmTracker
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ RnApmTracker.decodeDelimited = function decodeDelimited(reader) {
+ if (!(reader instanceof $Reader))
+ reader = new $Reader(reader);
+ return this.decode(reader, reader.uint32());
+ };
+
+ /**
+ * Verifies a RnApmTracker message.
+ * @function verify
+ * @memberof RnApmTracker
+ * @static
+ * @param {Object.} message Plain object to verify
+ * @returns {string|null} `null` if valid, otherwise the reason why it is not
+ */
+ RnApmTracker.verify = function verify(message) {
+ if (typeof message !== "object" || message === null)
+ return "object expected";
+ if (message.rnScriptExecutionTiming != null && message.hasOwnProperty("rnScriptExecutionTiming")) {
+ let error = $root.RnPerformanceMeasure.verify(message.rnScriptExecutionTiming);
+ if (error)
+ return "rnScriptExecutionTiming." + error;
+ }
+ if (message.rnPageFirstAppearTiming != null && message.hasOwnProperty("rnPageFirstAppearTiming")) {
+ let error = $root.RnPerformanceMeasure.verify(message.rnPageFirstAppearTiming);
+ if (error)
+ return "rnPageFirstAppearTiming." + error;
+ }
+ if (message.rnHttpRequestTiming != null && message.hasOwnProperty("rnHttpRequestTiming")) {
+ let error = $root.RnHttpRequestTiming.verify(message.rnHttpRequestTiming);
+ if (error)
+ return "rnHttpRequestTiming." + error;
+ }
+ if (message.rnPerformanceMeasure != null && message.hasOwnProperty("rnPerformanceMeasure")) {
+ let error = $root.RnPerformanceMeasure.verify(message.rnPerformanceMeasure);
+ if (error)
+ return "rnPerformanceMeasure." + error;
+ }
+ if (message.rnResourceTiming != null && message.hasOwnProperty("rnResourceTiming")) {
+ if (!Array.isArray(message.rnResourceTiming))
+ return "rnResourceTiming: array expected";
+ for (let i = 0; i < message.rnResourceTiming.length; ++i) {
+ let error = $root.RnResourceTiming.verify(message.rnResourceTiming[i]);
+ if (error)
+ return "rnResourceTiming." + error;
+ }
+ }
+ if (message.rnVideoResourceTiming != null && message.hasOwnProperty("rnVideoResourceTiming")) {
+ let error = $root.RnVideoResourceTiming.verify(message.rnVideoResourceTiming);
+ if (error)
+ return "rnVideoResourceTiming." + error;
+ }
+ if (message.rnApmContext != null && message.hasOwnProperty("rnApmContext")) {
+ let error = $root.RnApmContext.verify(message.rnApmContext);
+ if (error)
+ return "rnApmContext." + error;
+ }
+ if (message.rnRouteNotFound != null && message.hasOwnProperty("rnRouteNotFound")) {
+ let error = $root.RnRouteNotFound.verify(message.rnRouteNotFound);
+ if (error)
+ return "rnRouteNotFound." + error;
+ }
+ return null;
+ };
+
+ /**
+ * Creates a RnApmTracker message from a plain object. Also converts values to their respective internal types.
+ * @function fromObject
+ * @memberof RnApmTracker
+ * @static
+ * @param {Object.} object Plain object
+ * @returns {RnApmTracker} RnApmTracker
+ */
+ RnApmTracker.fromObject = function fromObject(object) {
+ if (object instanceof $root.RnApmTracker)
+ return object;
+ let message = new $root.RnApmTracker();
+ if (object.rnScriptExecutionTiming != null) {
+ if (typeof object.rnScriptExecutionTiming !== "object")
+ throw TypeError(".RnApmTracker.rnScriptExecutionTiming: object expected");
+ message.rnScriptExecutionTiming = $root.RnPerformanceMeasure.fromObject(object.rnScriptExecutionTiming);
+ }
+ if (object.rnPageFirstAppearTiming != null) {
+ if (typeof object.rnPageFirstAppearTiming !== "object")
+ throw TypeError(".RnApmTracker.rnPageFirstAppearTiming: object expected");
+ message.rnPageFirstAppearTiming = $root.RnPerformanceMeasure.fromObject(object.rnPageFirstAppearTiming);
+ }
+ if (object.rnHttpRequestTiming != null) {
+ if (typeof object.rnHttpRequestTiming !== "object")
+ throw TypeError(".RnApmTracker.rnHttpRequestTiming: object expected");
+ message.rnHttpRequestTiming = $root.RnHttpRequestTiming.fromObject(object.rnHttpRequestTiming);
+ }
+ if (object.rnPerformanceMeasure != null) {
+ if (typeof object.rnPerformanceMeasure !== "object")
+ throw TypeError(".RnApmTracker.rnPerformanceMeasure: object expected");
+ message.rnPerformanceMeasure = $root.RnPerformanceMeasure.fromObject(object.rnPerformanceMeasure);
+ }
+ if (object.rnResourceTiming) {
+ if (!Array.isArray(object.rnResourceTiming))
+ throw TypeError(".RnApmTracker.rnResourceTiming: array expected");
+ message.rnResourceTiming = [];
+ for (let i = 0; i < object.rnResourceTiming.length; ++i) {
+ if (typeof object.rnResourceTiming[i] !== "object")
+ throw TypeError(".RnApmTracker.rnResourceTiming: object expected");
+ message.rnResourceTiming[i] = $root.RnResourceTiming.fromObject(object.rnResourceTiming[i]);
+ }
+ }
+ if (object.rnVideoResourceTiming != null) {
+ if (typeof object.rnVideoResourceTiming !== "object")
+ throw TypeError(".RnApmTracker.rnVideoResourceTiming: object expected");
+ message.rnVideoResourceTiming = $root.RnVideoResourceTiming.fromObject(object.rnVideoResourceTiming);
+ }
+ if (object.rnApmContext != null) {
+ if (typeof object.rnApmContext !== "object")
+ throw TypeError(".RnApmTracker.rnApmContext: object expected");
+ message.rnApmContext = $root.RnApmContext.fromObject(object.rnApmContext);
+ }
+ if (object.rnRouteNotFound != null) {
+ if (typeof object.rnRouteNotFound !== "object")
+ throw TypeError(".RnApmTracker.rnRouteNotFound: object expected");
+ message.rnRouteNotFound = $root.RnRouteNotFound.fromObject(object.rnRouteNotFound);
+ }
+ return message;
+ };
+
+ /**
+ * Creates a plain object from a RnApmTracker message. Also converts values to other types if specified.
+ * @function toObject
+ * @memberof RnApmTracker
+ * @static
+ * @param {RnApmTracker} message RnApmTracker
+ * @param {$protobuf.IConversionOptions} [options] Conversion options
+ * @returns {Object.} Plain object
+ */
+ RnApmTracker.toObject = function toObject(message, options) {
+ if (!options)
+ options = {};
+ let object = {};
+ if (options.arrays || options.defaults)
+ object.rnResourceTiming = [];
+ if (options.defaults) {
+ object.rnScriptExecutionTiming = null;
+ object.rnPageFirstAppearTiming = null;
+ object.rnHttpRequestTiming = null;
+ object.rnPerformanceMeasure = null;
+ object.rnVideoResourceTiming = null;
+ object.rnApmContext = null;
+ object.rnRouteNotFound = null;
+ }
+ if (message.rnScriptExecutionTiming != null && message.hasOwnProperty("rnScriptExecutionTiming"))
+ object.rnScriptExecutionTiming = $root.RnPerformanceMeasure.toObject(message.rnScriptExecutionTiming, options);
+ if (message.rnPageFirstAppearTiming != null && message.hasOwnProperty("rnPageFirstAppearTiming"))
+ object.rnPageFirstAppearTiming = $root.RnPerformanceMeasure.toObject(message.rnPageFirstAppearTiming, options);
+ if (message.rnHttpRequestTiming != null && message.hasOwnProperty("rnHttpRequestTiming"))
+ object.rnHttpRequestTiming = $root.RnHttpRequestTiming.toObject(message.rnHttpRequestTiming, options);
+ if (message.rnPerformanceMeasure != null && message.hasOwnProperty("rnPerformanceMeasure"))
+ object.rnPerformanceMeasure = $root.RnPerformanceMeasure.toObject(message.rnPerformanceMeasure, options);
+ if (message.rnResourceTiming && message.rnResourceTiming.length) {
+ object.rnResourceTiming = [];
+ for (let j = 0; j < message.rnResourceTiming.length; ++j)
+ object.rnResourceTiming[j] = $root.RnResourceTiming.toObject(message.rnResourceTiming[j], options);
+ }
+ if (message.rnVideoResourceTiming != null && message.hasOwnProperty("rnVideoResourceTiming"))
+ object.rnVideoResourceTiming = $root.RnVideoResourceTiming.toObject(message.rnVideoResourceTiming, options);
+ if (message.rnApmContext != null && message.hasOwnProperty("rnApmContext"))
+ object.rnApmContext = $root.RnApmContext.toObject(message.rnApmContext, options);
+ if (message.rnRouteNotFound != null && message.hasOwnProperty("rnRouteNotFound"))
+ object.rnRouteNotFound = $root.RnRouteNotFound.toObject(message.rnRouteNotFound, options);
+ return object;
+ };
+
+ /**
+ * Converts this RnApmTracker to JSON.
+ * @function toJSON
+ * @memberof RnApmTracker
+ * @instance
+ * @returns {Object.} JSON object
+ */
+ RnApmTracker.prototype.toJSON = function toJSON() {
+ return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
+ };
+
+ /**
+ * Gets the default type url for RnApmTracker
+ * @function getTypeUrl
+ * @memberof RnApmTracker
+ * @static
+ * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
+ * @returns {string} The default type url
+ */
+ RnApmTracker.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
+ if (typeUrlPrefix === undefined) {
+ typeUrlPrefix = "type.googleapis.com";
+ }
+ return typeUrlPrefix + "/RnApmTracker";
+ };
+
+ return RnApmTracker;
+})();
+
+export const RnApmContext = $root.RnApmContext = (() => {
+
+ /**
+ * Properties of a RnApmContext.
+ * @exports IRnApmContext
+ * @interface IRnApmContext
+ * @property {string|null} [fakeAppVersion] RnApmContext fakeAppVersion
+ * @property {boolean|null} [isInstanceReuse] RnApmContext isInstanceReuse
+ * @property {boolean|null} [isInstancePreload] RnApmContext isInstancePreload
+ */
+
+ /**
+ * Constructs a new RnApmContext.
+ * @exports RnApmContext
+ * @classdesc Represents a RnApmContext.
+ * @implements IRnApmContext
+ * @constructor
+ * @param {IRnApmContext=} [properties] Properties to set
+ */
+ function RnApmContext(properties) {
+ if (properties)
+ for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
+ if (properties[keys[i]] != null)
+ this[keys[i]] = properties[keys[i]];
+ }
+
+ /**
+ * RnApmContext fakeAppVersion.
+ * @member {string} fakeAppVersion
+ * @memberof RnApmContext
+ * @instance
+ */
+ RnApmContext.prototype.fakeAppVersion = "";
+
+ /**
+ * RnApmContext isInstanceReuse.
+ * @member {boolean} isInstanceReuse
+ * @memberof RnApmContext
+ * @instance
+ */
+ RnApmContext.prototype.isInstanceReuse = false;
+
+ /**
+ * RnApmContext isInstancePreload.
+ * @member {boolean} isInstancePreload
+ * @memberof RnApmContext
+ * @instance
+ */
+ RnApmContext.prototype.isInstancePreload = false;
+
+ /**
+ * Creates a new RnApmContext instance using the specified properties.
+ * @function create
+ * @memberof RnApmContext
+ * @static
+ * @param {IRnApmContext=} [properties] Properties to set
+ * @returns {RnApmContext} RnApmContext instance
+ */
+ RnApmContext.create = function create(properties) {
+ return new RnApmContext(properties);
+ };
+
+ /**
+ * Encodes the specified RnApmContext message. Does not implicitly {@link RnApmContext.verify|verify} messages.
+ * @function encode
+ * @memberof RnApmContext
+ * @static
+ * @param {IRnApmContext} message RnApmContext message or plain object to encode
+ * @param {$protobuf.Writer} [writer] Writer to encode to
+ * @returns {$protobuf.Writer} Writer
+ */
+ RnApmContext.encode = function encode(message, writer) {
+ if (!writer)
+ writer = $Writer.create();
+ if (message.fakeAppVersion != null && Object.hasOwnProperty.call(message, "fakeAppVersion"))
+ writer.uint32(/* id 1, wireType 2 =*/10).string(message.fakeAppVersion);
+ if (message.isInstanceReuse != null && Object.hasOwnProperty.call(message, "isInstanceReuse"))
+ writer.uint32(/* id 2, wireType 0 =*/16).bool(message.isInstanceReuse);
+ if (message.isInstancePreload != null && Object.hasOwnProperty.call(message, "isInstancePreload"))
+ writer.uint32(/* id 3, wireType 0 =*/24).bool(message.isInstancePreload);
+ return writer;
+ };
+
+ /**
+ * Encodes the specified RnApmContext message, length delimited. Does not implicitly {@link RnApmContext.verify|verify} messages.
+ * @function encodeDelimited
+ * @memberof RnApmContext
+ * @static
+ * @param {IRnApmContext} message RnApmContext message or plain object to encode
+ * @param {$protobuf.Writer} [writer] Writer to encode to
+ * @returns {$protobuf.Writer} Writer
+ */
+ RnApmContext.encodeDelimited = function encodeDelimited(message, writer) {
+ return this.encode(message, writer).ldelim();
+ };
+
+ /**
+ * Decodes a RnApmContext message from the specified reader or buffer.
+ * @function decode
+ * @memberof RnApmContext
+ * @static
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
+ * @param {number} [length] Message length if known beforehand
+ * @returns {RnApmContext} RnApmContext
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ RnApmContext.decode = function decode(reader, length) {
+ if (!(reader instanceof $Reader))
+ reader = $Reader.create(reader);
+ let end = length === undefined ? reader.len : reader.pos + length, message = new $root.RnApmContext();
+ while (reader.pos < end) {
+ let tag = reader.uint32();
+ switch (tag >>> 3) {
+ case 1: {
+ message.fakeAppVersion = reader.string();
+ break;
+ }
+ case 2: {
+ message.isInstanceReuse = reader.bool();
+ break;
+ }
+ case 3: {
+ message.isInstancePreload = reader.bool();
+ break;
+ }
+ default:
+ reader.skipType(tag & 7);
+ break;
+ }
+ }
+ return message;
+ };
+
+ /**
+ * Decodes a RnApmContext message from the specified reader or buffer, length delimited.
+ * @function decodeDelimited
+ * @memberof RnApmContext
+ * @static
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
+ * @returns {RnApmContext} RnApmContext
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ RnApmContext.decodeDelimited = function decodeDelimited(reader) {
+ if (!(reader instanceof $Reader))
+ reader = new $Reader(reader);
+ return this.decode(reader, reader.uint32());
+ };
+
+ /**
+ * Verifies a RnApmContext message.
+ * @function verify
+ * @memberof RnApmContext
+ * @static
+ * @param {Object.} message Plain object to verify
+ * @returns {string|null} `null` if valid, otherwise the reason why it is not
+ */
+ RnApmContext.verify = function verify(message) {
+ if (typeof message !== "object" || message === null)
+ return "object expected";
+ if (message.fakeAppVersion != null && message.hasOwnProperty("fakeAppVersion"))
+ if (!$util.isString(message.fakeAppVersion))
+ return "fakeAppVersion: string expected";
+ if (message.isInstanceReuse != null && message.hasOwnProperty("isInstanceReuse"))
+ if (typeof message.isInstanceReuse !== "boolean")
+ return "isInstanceReuse: boolean expected";
+ if (message.isInstancePreload != null && message.hasOwnProperty("isInstancePreload"))
+ if (typeof message.isInstancePreload !== "boolean")
+ return "isInstancePreload: boolean expected";
+ return null;
+ };
+
+ /**
+ * Creates a RnApmContext message from a plain object. Also converts values to their respective internal types.
+ * @function fromObject
+ * @memberof RnApmContext
+ * @static
+ * @param {Object.} object Plain object
+ * @returns {RnApmContext} RnApmContext
+ */
+ RnApmContext.fromObject = function fromObject(object) {
+ if (object instanceof $root.RnApmContext)
+ return object;
+ let message = new $root.RnApmContext();
+ if (object.fakeAppVersion != null)
+ message.fakeAppVersion = String(object.fakeAppVersion);
+ if (object.isInstanceReuse != null)
+ message.isInstanceReuse = Boolean(object.isInstanceReuse);
+ if (object.isInstancePreload != null)
+ message.isInstancePreload = Boolean(object.isInstancePreload);
+ return message;
+ };
+
+ /**
+ * Creates a plain object from a RnApmContext message. Also converts values to other types if specified.
+ * @function toObject
+ * @memberof RnApmContext
+ * @static
+ * @param {RnApmContext} message RnApmContext
+ * @param {$protobuf.IConversionOptions} [options] Conversion options
+ * @returns {Object.} Plain object
+ */
+ RnApmContext.toObject = function toObject(message, options) {
+ if (!options)
+ options = {};
+ let object = {};
+ if (options.defaults) {
+ object.fakeAppVersion = "";
+ object.isInstanceReuse = false;
+ object.isInstancePreload = false;
+ }
+ if (message.fakeAppVersion != null && message.hasOwnProperty("fakeAppVersion"))
+ object.fakeAppVersion = message.fakeAppVersion;
+ if (message.isInstanceReuse != null && message.hasOwnProperty("isInstanceReuse"))
+ object.isInstanceReuse = message.isInstanceReuse;
+ if (message.isInstancePreload != null && message.hasOwnProperty("isInstancePreload"))
+ object.isInstancePreload = message.isInstancePreload;
+ return object;
+ };
+
+ /**
+ * Converts this RnApmContext to JSON.
+ * @function toJSON
+ * @memberof RnApmContext
+ * @instance
+ * @returns {Object.} JSON object
+ */
+ RnApmContext.prototype.toJSON = function toJSON() {
+ return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
+ };
+
+ /**
+ * Gets the default type url for RnApmContext
+ * @function getTypeUrl
+ * @memberof RnApmContext
+ * @static
+ * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
+ * @returns {string} The default type url
+ */
+ RnApmContext.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
+ if (typeUrlPrefix === undefined) {
+ typeUrlPrefix = "type.googleapis.com";
+ }
+ return typeUrlPrefix + "/RnApmContext";
+ };
+
+ return RnApmContext;
+})();
+
+export const RnHttpRequestTiming = $root.RnHttpRequestTiming = (() => {
+
+ /**
+ * Properties of a RnHttpRequestTiming.
+ * @exports IRnHttpRequestTiming
+ * @interface IRnHttpRequestTiming
+ * @property {IRnPerformanceMeasure|null} [rnPerformanceMeasure] RnHttpRequestTiming rnPerformanceMeasure
+ * @property {string|null} [method] RnHttpRequestTiming method
+ * @property {string|null} [matchedPath] RnHttpRequestTiming matchedPath
+ * @property {number|null} [status] RnHttpRequestTiming status
+ * @property {number|null} [errorCode] RnHttpRequestTiming errorCode
+ * @property {string|null} [clientErrorMessage] RnHttpRequestTiming clientErrorMessage
+ * @property {string|null} [errorType] RnHttpRequestTiming errorType
+ * @property {string|null} [code] RnHttpRequestTiming code
+ * @property {string|null} [traceId] RnHttpRequestTiming traceId
+ * @property {number|null} [duration] RnHttpRequestTiming duration
+ * @property {string|null} [url] RnHttpRequestTiming url
+ * @property {string|null} [data] RnHttpRequestTiming data
+ * @property {string|null} [level] RnHttpRequestTiming level
+ * @property {string|null} [errorMsg] RnHttpRequestTiming errorMsg
+ * @property {IRnNetworkErrorInfo|null} [networkErrorInfo] RnHttpRequestTiming networkErrorInfo
+ */
+
+ /**
+ * Constructs a new RnHttpRequestTiming.
+ * @exports RnHttpRequestTiming
+ * @classdesc Represents a RnHttpRequestTiming.
+ * @implements IRnHttpRequestTiming
+ * @constructor
+ * @param {IRnHttpRequestTiming=} [properties] Properties to set
+ */
+ function RnHttpRequestTiming(properties) {
+ if (properties)
+ for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
+ if (properties[keys[i]] != null)
+ this[keys[i]] = properties[keys[i]];
+ }
+
+ /**
+ * RnHttpRequestTiming rnPerformanceMeasure.
+ * @member {IRnPerformanceMeasure|null|undefined} rnPerformanceMeasure
+ * @memberof RnHttpRequestTiming
+ * @instance
+ */
+ RnHttpRequestTiming.prototype.rnPerformanceMeasure = null;
+
+ /**
+ * RnHttpRequestTiming method.
+ * @member {string} method
+ * @memberof RnHttpRequestTiming
+ * @instance
+ */
+ RnHttpRequestTiming.prototype.method = "";
+
+ /**
+ * RnHttpRequestTiming matchedPath.
+ * @member {string} matchedPath
+ * @memberof RnHttpRequestTiming
+ * @instance
+ */
+ RnHttpRequestTiming.prototype.matchedPath = "";
+
+ /**
+ * RnHttpRequestTiming status.
+ * @member {number} status
+ * @memberof RnHttpRequestTiming
+ * @instance
+ */
+ RnHttpRequestTiming.prototype.status = 0;
+
+ /**
+ * RnHttpRequestTiming errorCode.
+ * @member {number} errorCode
+ * @memberof RnHttpRequestTiming
+ * @instance
+ */
+ RnHttpRequestTiming.prototype.errorCode = 0;
+
+ /**
+ * RnHttpRequestTiming clientErrorMessage.
+ * @member {string} clientErrorMessage
+ * @memberof RnHttpRequestTiming
+ * @instance
+ */
+ RnHttpRequestTiming.prototype.clientErrorMessage = "";
+
+ /**
+ * RnHttpRequestTiming errorType.
+ * @member {string} errorType
+ * @memberof RnHttpRequestTiming
+ * @instance
+ */
+ RnHttpRequestTiming.prototype.errorType = "";
+
+ /**
+ * RnHttpRequestTiming code.
+ * @member {string} code
+ * @memberof RnHttpRequestTiming
+ * @instance
+ */
+ RnHttpRequestTiming.prototype.code = "";
+
+ /**
+ * RnHttpRequestTiming traceId.
+ * @member {string} traceId
+ * @memberof RnHttpRequestTiming
+ * @instance
+ */
+ RnHttpRequestTiming.prototype.traceId = "";
+
+ /**
+ * RnHttpRequestTiming duration.
+ * @member {number} duration
+ * @memberof RnHttpRequestTiming
+ * @instance
+ */
+ RnHttpRequestTiming.prototype.duration = 0;
+
+ /**
+ * RnHttpRequestTiming url.
+ * @member {string} url
+ * @memberof RnHttpRequestTiming
+ * @instance
+ */
+ RnHttpRequestTiming.prototype.url = "";
+
+ /**
+ * RnHttpRequestTiming data.
+ * @member {string} data
+ * @memberof RnHttpRequestTiming
+ * @instance
+ */
+ RnHttpRequestTiming.prototype.data = "";
+
+ /**
+ * RnHttpRequestTiming level.
+ * @member {string} level
+ * @memberof RnHttpRequestTiming
+ * @instance
+ */
+ RnHttpRequestTiming.prototype.level = "";
+
+ /**
+ * RnHttpRequestTiming errorMsg.
+ * @member {string} errorMsg
+ * @memberof RnHttpRequestTiming
+ * @instance
+ */
+ RnHttpRequestTiming.prototype.errorMsg = "";
+
+ /**
+ * RnHttpRequestTiming networkErrorInfo.
+ * @member {IRnNetworkErrorInfo|null|undefined} networkErrorInfo
+ * @memberof RnHttpRequestTiming
+ * @instance
+ */
+ RnHttpRequestTiming.prototype.networkErrorInfo = null;
+
+ /**
+ * Creates a new RnHttpRequestTiming instance using the specified properties.
+ * @function create
+ * @memberof RnHttpRequestTiming
+ * @static
+ * @param {IRnHttpRequestTiming=} [properties] Properties to set
+ * @returns {RnHttpRequestTiming} RnHttpRequestTiming instance
+ */
+ RnHttpRequestTiming.create = function create(properties) {
+ return new RnHttpRequestTiming(properties);
+ };
+
+ /**
+ * Encodes the specified RnHttpRequestTiming message. Does not implicitly {@link RnHttpRequestTiming.verify|verify} messages.
+ * @function encode
+ * @memberof RnHttpRequestTiming
+ * @static
+ * @param {IRnHttpRequestTiming} message RnHttpRequestTiming message or plain object to encode
+ * @param {$protobuf.Writer} [writer] Writer to encode to
+ * @returns {$protobuf.Writer} Writer
+ */
+ RnHttpRequestTiming.encode = function encode(message, writer) {
+ if (!writer)
+ writer = $Writer.create();
+ if (message.rnPerformanceMeasure != null && Object.hasOwnProperty.call(message, "rnPerformanceMeasure"))
+ $root.RnPerformanceMeasure.encode(message.rnPerformanceMeasure, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim();
+ if (message.method != null && Object.hasOwnProperty.call(message, "method"))
+ writer.uint32(/* id 2, wireType 2 =*/18).string(message.method);
+ if (message.matchedPath != null && Object.hasOwnProperty.call(message, "matchedPath"))
+ writer.uint32(/* id 3, wireType 2 =*/26).string(message.matchedPath);
+ if (message.status != null && Object.hasOwnProperty.call(message, "status"))
+ writer.uint32(/* id 4, wireType 0 =*/32).int32(message.status);
+ if (message.errorCode != null && Object.hasOwnProperty.call(message, "errorCode"))
+ writer.uint32(/* id 5, wireType 0 =*/40).int32(message.errorCode);
+ if (message.clientErrorMessage != null && Object.hasOwnProperty.call(message, "clientErrorMessage"))
+ writer.uint32(/* id 6, wireType 2 =*/50).string(message.clientErrorMessage);
+ if (message.errorType != null && Object.hasOwnProperty.call(message, "errorType"))
+ writer.uint32(/* id 7, wireType 2 =*/58).string(message.errorType);
+ if (message.code != null && Object.hasOwnProperty.call(message, "code"))
+ writer.uint32(/* id 8, wireType 2 =*/66).string(message.code);
+ if (message.traceId != null && Object.hasOwnProperty.call(message, "traceId"))
+ writer.uint32(/* id 9, wireType 2 =*/74).string(message.traceId);
+ if (message.duration != null && Object.hasOwnProperty.call(message, "duration"))
+ writer.uint32(/* id 10, wireType 1 =*/81).double(message.duration);
+ if (message.url != null && Object.hasOwnProperty.call(message, "url"))
+ writer.uint32(/* id 11, wireType 2 =*/90).string(message.url);
+ if (message.data != null && Object.hasOwnProperty.call(message, "data"))
+ writer.uint32(/* id 12, wireType 2 =*/98).string(message.data);
+ if (message.level != null && Object.hasOwnProperty.call(message, "level"))
+ writer.uint32(/* id 13, wireType 2 =*/106).string(message.level);
+ if (message.errorMsg != null && Object.hasOwnProperty.call(message, "errorMsg"))
+ writer.uint32(/* id 14, wireType 2 =*/114).string(message.errorMsg);
+ if (message.networkErrorInfo != null && Object.hasOwnProperty.call(message, "networkErrorInfo"))
+ $root.RnNetworkErrorInfo.encode(message.networkErrorInfo, writer.uint32(/* id 100, wireType 2 =*/802).fork()).ldelim();
+ return writer;
+ };
+
+ /**
+ * Encodes the specified RnHttpRequestTiming message, length delimited. Does not implicitly {@link RnHttpRequestTiming.verify|verify} messages.
+ * @function encodeDelimited
+ * @memberof RnHttpRequestTiming
+ * @static
+ * @param {IRnHttpRequestTiming} message RnHttpRequestTiming message or plain object to encode
+ * @param {$protobuf.Writer} [writer] Writer to encode to
+ * @returns {$protobuf.Writer} Writer
+ */
+ RnHttpRequestTiming.encodeDelimited = function encodeDelimited(message, writer) {
+ return this.encode(message, writer).ldelim();
+ };
+
+ /**
+ * Decodes a RnHttpRequestTiming message from the specified reader or buffer.
+ * @function decode
+ * @memberof RnHttpRequestTiming
+ * @static
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
+ * @param {number} [length] Message length if known beforehand
+ * @returns {RnHttpRequestTiming} RnHttpRequestTiming
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ RnHttpRequestTiming.decode = function decode(reader, length) {
+ if (!(reader instanceof $Reader))
+ reader = $Reader.create(reader);
+ let end = length === undefined ? reader.len : reader.pos + length, message = new $root.RnHttpRequestTiming();
+ while (reader.pos < end) {
+ let tag = reader.uint32();
+ switch (tag >>> 3) {
+ case 1: {
+ message.rnPerformanceMeasure = $root.RnPerformanceMeasure.decode(reader, reader.uint32());
+ break;
+ }
+ case 2: {
+ message.method = reader.string();
+ break;
+ }
+ case 3: {
+ message.matchedPath = reader.string();
+ break;
+ }
+ case 4: {
+ message.status = reader.int32();
+ break;
+ }
+ case 5: {
+ message.errorCode = reader.int32();
+ break;
+ }
+ case 6: {
+ message.clientErrorMessage = reader.string();
+ break;
+ }
+ case 7: {
+ message.errorType = reader.string();
+ break;
+ }
+ case 8: {
+ message.code = reader.string();
+ break;
+ }
+ case 9: {
+ message.traceId = reader.string();
+ break;
+ }
+ case 10: {
+ message.duration = reader.double();
+ break;
+ }
+ case 11: {
+ message.url = reader.string();
+ break;
+ }
+ case 12: {
+ message.data = reader.string();
+ break;
+ }
+ case 13: {
+ message.level = reader.string();
+ break;
+ }
+ case 14: {
+ message.errorMsg = reader.string();
+ break;
+ }
+ case 100: {
+ message.networkErrorInfo = $root.RnNetworkErrorInfo.decode(reader, reader.uint32());
+ break;
+ }
+ default:
+ reader.skipType(tag & 7);
+ break;
+ }
+ }
+ return message;
+ };
+
+ /**
+ * Decodes a RnHttpRequestTiming message from the specified reader or buffer, length delimited.
+ * @function decodeDelimited
+ * @memberof RnHttpRequestTiming
+ * @static
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
+ * @returns {RnHttpRequestTiming} RnHttpRequestTiming
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ RnHttpRequestTiming.decodeDelimited = function decodeDelimited(reader) {
+ if (!(reader instanceof $Reader))
+ reader = new $Reader(reader);
+ return this.decode(reader, reader.uint32());
+ };
+
+ /**
+ * Verifies a RnHttpRequestTiming message.
+ * @function verify
+ * @memberof RnHttpRequestTiming
+ * @static
+ * @param {Object.} message Plain object to verify
+ * @returns {string|null} `null` if valid, otherwise the reason why it is not
+ */
+ RnHttpRequestTiming.verify = function verify(message) {
+ if (typeof message !== "object" || message === null)
+ return "object expected";
+ if (message.rnPerformanceMeasure != null && message.hasOwnProperty("rnPerformanceMeasure")) {
+ let error = $root.RnPerformanceMeasure.verify(message.rnPerformanceMeasure);
+ if (error)
+ return "rnPerformanceMeasure." + error;
+ }
+ if (message.method != null && message.hasOwnProperty("method"))
+ if (!$util.isString(message.method))
+ return "method: string expected";
+ if (message.matchedPath != null && message.hasOwnProperty("matchedPath"))
+ if (!$util.isString(message.matchedPath))
+ return "matchedPath: string expected";
+ if (message.status != null && message.hasOwnProperty("status"))
+ if (!$util.isInteger(message.status))
+ return "status: integer expected";
+ if (message.errorCode != null && message.hasOwnProperty("errorCode"))
+ if (!$util.isInteger(message.errorCode))
+ return "errorCode: integer expected";
+ if (message.clientErrorMessage != null && message.hasOwnProperty("clientErrorMessage"))
+ if (!$util.isString(message.clientErrorMessage))
+ return "clientErrorMessage: string expected";
+ if (message.errorType != null && message.hasOwnProperty("errorType"))
+ if (!$util.isString(message.errorType))
+ return "errorType: string expected";
+ if (message.code != null && message.hasOwnProperty("code"))
+ if (!$util.isString(message.code))
+ return "code: string expected";
+ if (message.traceId != null && message.hasOwnProperty("traceId"))
+ if (!$util.isString(message.traceId))
+ return "traceId: string expected";
+ if (message.duration != null && message.hasOwnProperty("duration"))
+ if (typeof message.duration !== "number")
+ return "duration: number expected";
+ if (message.url != null && message.hasOwnProperty("url"))
+ if (!$util.isString(message.url))
+ return "url: string expected";
+ if (message.data != null && message.hasOwnProperty("data"))
+ if (!$util.isString(message.data))
+ return "data: string expected";
+ if (message.level != null && message.hasOwnProperty("level"))
+ if (!$util.isString(message.level))
+ return "level: string expected";
+ if (message.errorMsg != null && message.hasOwnProperty("errorMsg"))
+ if (!$util.isString(message.errorMsg))
+ return "errorMsg: string expected";
+ if (message.networkErrorInfo != null && message.hasOwnProperty("networkErrorInfo")) {
+ let error = $root.RnNetworkErrorInfo.verify(message.networkErrorInfo);
+ if (error)
+ return "networkErrorInfo." + error;
+ }
+ return null;
+ };
+
+ /**
+ * Creates a RnHttpRequestTiming message from a plain object. Also converts values to their respective internal types.
+ * @function fromObject
+ * @memberof RnHttpRequestTiming
+ * @static
+ * @param {Object.} object Plain object
+ * @returns {RnHttpRequestTiming} RnHttpRequestTiming
+ */
+ RnHttpRequestTiming.fromObject = function fromObject(object) {
+ if (object instanceof $root.RnHttpRequestTiming)
+ return object;
+ let message = new $root.RnHttpRequestTiming();
+ if (object.rnPerformanceMeasure != null) {
+ if (typeof object.rnPerformanceMeasure !== "object")
+ throw TypeError(".RnHttpRequestTiming.rnPerformanceMeasure: object expected");
+ message.rnPerformanceMeasure = $root.RnPerformanceMeasure.fromObject(object.rnPerformanceMeasure);
+ }
+ if (object.method != null)
+ message.method = String(object.method);
+ if (object.matchedPath != null)
+ message.matchedPath = String(object.matchedPath);
+ if (object.status != null)
+ message.status = object.status | 0;
+ if (object.errorCode != null)
+ message.errorCode = object.errorCode | 0;
+ if (object.clientErrorMessage != null)
+ message.clientErrorMessage = String(object.clientErrorMessage);
+ if (object.errorType != null)
+ message.errorType = String(object.errorType);
+ if (object.code != null)
+ message.code = String(object.code);
+ if (object.traceId != null)
+ message.traceId = String(object.traceId);
+ if (object.duration != null)
+ message.duration = Number(object.duration);
+ if (object.url != null)
+ message.url = String(object.url);
+ if (object.data != null)
+ message.data = String(object.data);
+ if (object.level != null)
+ message.level = String(object.level);
+ if (object.errorMsg != null)
+ message.errorMsg = String(object.errorMsg);
+ if (object.networkErrorInfo != null) {
+ if (typeof object.networkErrorInfo !== "object")
+ throw TypeError(".RnHttpRequestTiming.networkErrorInfo: object expected");
+ message.networkErrorInfo = $root.RnNetworkErrorInfo.fromObject(object.networkErrorInfo);
+ }
+ return message;
+ };
+
+ /**
+ * Creates a plain object from a RnHttpRequestTiming message. Also converts values to other types if specified.
+ * @function toObject
+ * @memberof RnHttpRequestTiming
+ * @static
+ * @param {RnHttpRequestTiming} message RnHttpRequestTiming
+ * @param {$protobuf.IConversionOptions} [options] Conversion options
+ * @returns {Object.} Plain object
+ */
+ RnHttpRequestTiming.toObject = function toObject(message, options) {
+ if (!options)
+ options = {};
+ let object = {};
+ if (options.defaults) {
+ object.rnPerformanceMeasure = null;
+ object.method = "";
+ object.matchedPath = "";
+ object.status = 0;
+ object.errorCode = 0;
+ object.clientErrorMessage = "";
+ object.errorType = "";
+ object.code = "";
+ object.traceId = "";
+ object.duration = 0;
+ object.url = "";
+ object.data = "";
+ object.level = "";
+ object.errorMsg = "";
+ object.networkErrorInfo = null;
+ }
+ if (message.rnPerformanceMeasure != null && message.hasOwnProperty("rnPerformanceMeasure"))
+ object.rnPerformanceMeasure = $root.RnPerformanceMeasure.toObject(message.rnPerformanceMeasure, options);
+ if (message.method != null && message.hasOwnProperty("method"))
+ object.method = message.method;
+ if (message.matchedPath != null && message.hasOwnProperty("matchedPath"))
+ object.matchedPath = message.matchedPath;
+ if (message.status != null && message.hasOwnProperty("status"))
+ object.status = message.status;
+ if (message.errorCode != null && message.hasOwnProperty("errorCode"))
+ object.errorCode = message.errorCode;
+ if (message.clientErrorMessage != null && message.hasOwnProperty("clientErrorMessage"))
+ object.clientErrorMessage = message.clientErrorMessage;
+ if (message.errorType != null && message.hasOwnProperty("errorType"))
+ object.errorType = message.errorType;
+ if (message.code != null && message.hasOwnProperty("code"))
+ object.code = message.code;
+ if (message.traceId != null && message.hasOwnProperty("traceId"))
+ object.traceId = message.traceId;
+ if (message.duration != null && message.hasOwnProperty("duration"))
+ object.duration = options.json && !isFinite(message.duration) ? String(message.duration) : message.duration;
+ if (message.url != null && message.hasOwnProperty("url"))
+ object.url = message.url;
+ if (message.data != null && message.hasOwnProperty("data"))
+ object.data = message.data;
+ if (message.level != null && message.hasOwnProperty("level"))
+ object.level = message.level;
+ if (message.errorMsg != null && message.hasOwnProperty("errorMsg"))
+ object.errorMsg = message.errorMsg;
+ if (message.networkErrorInfo != null && message.hasOwnProperty("networkErrorInfo"))
+ object.networkErrorInfo = $root.RnNetworkErrorInfo.toObject(message.networkErrorInfo, options);
+ return object;
+ };
+
+ /**
+ * Converts this RnHttpRequestTiming to JSON.
+ * @function toJSON
+ * @memberof RnHttpRequestTiming
+ * @instance
+ * @returns {Object.} JSON object
+ */
+ RnHttpRequestTiming.prototype.toJSON = function toJSON() {
+ return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
+ };
+
+ /**
+ * Gets the default type url for RnHttpRequestTiming
+ * @function getTypeUrl
+ * @memberof RnHttpRequestTiming
+ * @static
+ * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
+ * @returns {string} The default type url
+ */
+ RnHttpRequestTiming.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
+ if (typeUrlPrefix === undefined) {
+ typeUrlPrefix = "type.googleapis.com";
+ }
+ return typeUrlPrefix + "/RnHttpRequestTiming";
+ };
+
+ return RnHttpRequestTiming;
+})();
+
+export const RnResourceTiming = $root.RnResourceTiming = (() => {
+
+ /**
+ * Properties of a RnResourceTiming.
+ * @exports IRnResourceTiming
+ * @interface IRnResourceTiming
+ * @property {string|null} [name] RnResourceTiming name
+ * @property {string|null} [entryType] RnResourceTiming entryType
+ * @property {number|null} [startTime] RnResourceTiming startTime
+ * @property {number|null} [duration] RnResourceTiming duration
+ * @property {string|null} [initiatorType] RnResourceTiming initiatorType
+ * @property {string|null} [nextHopProtocol] RnResourceTiming nextHopProtocol
+ * @property {number|null} [workerStart] RnResourceTiming workerStart
+ * @property {number|null} [redirectStart] RnResourceTiming redirectStart
+ * @property {number|null} [redirectEnd] RnResourceTiming redirectEnd
+ * @property {number|null} [fetchStart] RnResourceTiming fetchStart
+ * @property {number|null} [domainLookupStart] RnResourceTiming domainLookupStart
+ * @property {number|null} [domainLookupEnd] RnResourceTiming domainLookupEnd
+ * @property {number|null} [connectStart] RnResourceTiming connectStart
+ * @property {number|null} [connectEnd] RnResourceTiming connectEnd
+ * @property {number|null} [secureConnectionStart] RnResourceTiming secureConnectionStart
+ * @property {number|null} [requestStart] RnResourceTiming requestStart
+ * @property {number|null} [responseStart] RnResourceTiming responseStart
+ * @property {number|null} [responseEnd] RnResourceTiming responseEnd
+ * @property {number|Long|null} [transferSize] RnResourceTiming transferSize
+ * @property {number|Long|null} [encodedBodySize] RnResourceTiming encodedBodySize
+ * @property {number|Long|null} [decodedBodySize] RnResourceTiming decodedBodySize
+ * @property {IRnLocation|null} [location] RnResourceTiming location
+ * @property {Array.|null} [resourceMeta] RnResourceTiming resourceMeta
+ * @property {IRnNetworkErrorInfo|null} [networkErrorInfo] RnResourceTiming networkErrorInfo
+ */
+
+ /**
+ * Constructs a new RnResourceTiming.
+ * @exports RnResourceTiming
+ * @classdesc Represents a RnResourceTiming.
+ * @implements IRnResourceTiming
+ * @constructor
+ * @param {IRnResourceTiming=} [properties] Properties to set
+ */
+ function RnResourceTiming(properties) {
+ this.resourceMeta = [];
+ if (properties)
+ for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
+ if (properties[keys[i]] != null)
+ this[keys[i]] = properties[keys[i]];
+ }
+
+ /**
+ * RnResourceTiming name.
+ * @member {string} name
+ * @memberof RnResourceTiming
+ * @instance
+ */
+ RnResourceTiming.prototype.name = "";
+
+ /**
+ * RnResourceTiming entryType.
+ * @member {string} entryType
+ * @memberof RnResourceTiming
+ * @instance
+ */
+ RnResourceTiming.prototype.entryType = "";
+
+ /**
+ * RnResourceTiming startTime.
+ * @member {number} startTime
+ * @memberof RnResourceTiming
+ * @instance
+ */
+ RnResourceTiming.prototype.startTime = 0;
+
+ /**
+ * RnResourceTiming duration.
+ * @member {number} duration
+ * @memberof RnResourceTiming
+ * @instance
+ */
+ RnResourceTiming.prototype.duration = 0;
+
+ /**
+ * RnResourceTiming initiatorType.
+ * @member {string} initiatorType
+ * @memberof RnResourceTiming
+ * @instance
+ */
+ RnResourceTiming.prototype.initiatorType = "";
+
+ /**
+ * RnResourceTiming nextHopProtocol.
+ * @member {string} nextHopProtocol
+ * @memberof RnResourceTiming
+ * @instance
+ */
+ RnResourceTiming.prototype.nextHopProtocol = "";
+
+ /**
+ * RnResourceTiming workerStart.
+ * @member {number} workerStart
+ * @memberof RnResourceTiming
+ * @instance
+ */
+ RnResourceTiming.prototype.workerStart = 0;
+
+ /**
+ * RnResourceTiming redirectStart.
+ * @member {number} redirectStart
+ * @memberof RnResourceTiming
+ * @instance
+ */
+ RnResourceTiming.prototype.redirectStart = 0;
+
+ /**
+ * RnResourceTiming redirectEnd.
+ * @member {number} redirectEnd
+ * @memberof RnResourceTiming
+ * @instance
+ */
+ RnResourceTiming.prototype.redirectEnd = 0;
+
+ /**
+ * RnResourceTiming fetchStart.
+ * @member {number} fetchStart
+ * @memberof RnResourceTiming
+ * @instance
+ */
+ RnResourceTiming.prototype.fetchStart = 0;
+
+ /**
+ * RnResourceTiming domainLookupStart.
+ * @member {number} domainLookupStart
+ * @memberof RnResourceTiming
+ * @instance
+ */
+ RnResourceTiming.prototype.domainLookupStart = 0;
+
+ /**
+ * RnResourceTiming domainLookupEnd.
+ * @member {number} domainLookupEnd
+ * @memberof RnResourceTiming
+ * @instance
+ */
+ RnResourceTiming.prototype.domainLookupEnd = 0;
+
+ /**
+ * RnResourceTiming connectStart.
+ * @member {number} connectStart
+ * @memberof RnResourceTiming
+ * @instance
+ */
+ RnResourceTiming.prototype.connectStart = 0;
+
+ /**
+ * RnResourceTiming connectEnd.
+ * @member {number} connectEnd
+ * @memberof RnResourceTiming
+ * @instance
+ */
+ RnResourceTiming.prototype.connectEnd = 0;
+
+ /**
+ * RnResourceTiming secureConnectionStart.
+ * @member {number} secureConnectionStart
+ * @memberof RnResourceTiming
+ * @instance
+ */
+ RnResourceTiming.prototype.secureConnectionStart = 0;
+
+ /**
+ * RnResourceTiming requestStart.
+ * @member {number} requestStart
+ * @memberof RnResourceTiming
+ * @instance
+ */
+ RnResourceTiming.prototype.requestStart = 0;
+
+ /**
+ * RnResourceTiming responseStart.
+ * @member {number} responseStart
+ * @memberof RnResourceTiming
+ * @instance
+ */
+ RnResourceTiming.prototype.responseStart = 0;
+
+ /**
+ * RnResourceTiming responseEnd.
+ * @member {number} responseEnd
+ * @memberof RnResourceTiming
+ * @instance
+ */
+ RnResourceTiming.prototype.responseEnd = 0;
+
+ /**
+ * RnResourceTiming transferSize.
+ * @member {number|Long} transferSize
+ * @memberof RnResourceTiming
+ * @instance
+ */
+ RnResourceTiming.prototype.transferSize = $util.Long ? $util.Long.fromBits(0,0,false) : 0;
+
+ /**
+ * RnResourceTiming encodedBodySize.
+ * @member {number|Long} encodedBodySize
+ * @memberof RnResourceTiming
+ * @instance
+ */
+ RnResourceTiming.prototype.encodedBodySize = $util.Long ? $util.Long.fromBits(0,0,false) : 0;
+
+ /**
+ * RnResourceTiming decodedBodySize.
+ * @member {number|Long} decodedBodySize
+ * @memberof RnResourceTiming
+ * @instance
+ */
+ RnResourceTiming.prototype.decodedBodySize = $util.Long ? $util.Long.fromBits(0,0,false) : 0;
+
+ /**
+ * RnResourceTiming location.
+ * @member {IRnLocation|null|undefined} location
+ * @memberof RnResourceTiming
+ * @instance
+ */
+ RnResourceTiming.prototype.location = null;
+
+ /**
+ * RnResourceTiming resourceMeta.
+ * @member {Array.} resourceMeta
+ * @memberof RnResourceTiming
+ * @instance
+ */
+ RnResourceTiming.prototype.resourceMeta = $util.emptyArray;
+
+ /**
+ * RnResourceTiming networkErrorInfo.
+ * @member {IRnNetworkErrorInfo|null|undefined} networkErrorInfo
+ * @memberof RnResourceTiming
+ * @instance
+ */
+ RnResourceTiming.prototype.networkErrorInfo = null;
+
+ /**
+ * Creates a new RnResourceTiming instance using the specified properties.
+ * @function create
+ * @memberof RnResourceTiming
+ * @static
+ * @param {IRnResourceTiming=} [properties] Properties to set
+ * @returns {RnResourceTiming} RnResourceTiming instance
+ */
+ RnResourceTiming.create = function create(properties) {
+ return new RnResourceTiming(properties);
+ };
+
+ /**
+ * Encodes the specified RnResourceTiming message. Does not implicitly {@link RnResourceTiming.verify|verify} messages.
+ * @function encode
+ * @memberof RnResourceTiming
+ * @static
+ * @param {IRnResourceTiming} message RnResourceTiming message or plain object to encode
+ * @param {$protobuf.Writer} [writer] Writer to encode to
+ * @returns {$protobuf.Writer} Writer
+ */
+ RnResourceTiming.encode = function encode(message, writer) {
+ if (!writer)
+ writer = $Writer.create();
+ if (message.name != null && Object.hasOwnProperty.call(message, "name"))
+ writer.uint32(/* id 1, wireType 2 =*/10).string(message.name);
+ if (message.entryType != null && Object.hasOwnProperty.call(message, "entryType"))
+ writer.uint32(/* id 2, wireType 2 =*/18).string(message.entryType);
+ if (message.startTime != null && Object.hasOwnProperty.call(message, "startTime"))
+ writer.uint32(/* id 3, wireType 1 =*/25).double(message.startTime);
+ if (message.duration != null && Object.hasOwnProperty.call(message, "duration"))
+ writer.uint32(/* id 4, wireType 1 =*/33).double(message.duration);
+ if (message.initiatorType != null && Object.hasOwnProperty.call(message, "initiatorType"))
+ writer.uint32(/* id 5, wireType 2 =*/42).string(message.initiatorType);
+ if (message.nextHopProtocol != null && Object.hasOwnProperty.call(message, "nextHopProtocol"))
+ writer.uint32(/* id 6, wireType 2 =*/50).string(message.nextHopProtocol);
+ if (message.workerStart != null && Object.hasOwnProperty.call(message, "workerStart"))
+ writer.uint32(/* id 7, wireType 1 =*/57).double(message.workerStart);
+ if (message.redirectStart != null && Object.hasOwnProperty.call(message, "redirectStart"))
+ writer.uint32(/* id 8, wireType 1 =*/65).double(message.redirectStart);
+ if (message.redirectEnd != null && Object.hasOwnProperty.call(message, "redirectEnd"))
+ writer.uint32(/* id 9, wireType 1 =*/73).double(message.redirectEnd);
+ if (message.fetchStart != null && Object.hasOwnProperty.call(message, "fetchStart"))
+ writer.uint32(/* id 10, wireType 1 =*/81).double(message.fetchStart);
+ if (message.domainLookupStart != null && Object.hasOwnProperty.call(message, "domainLookupStart"))
+ writer.uint32(/* id 11, wireType 1 =*/89).double(message.domainLookupStart);
+ if (message.domainLookupEnd != null && Object.hasOwnProperty.call(message, "domainLookupEnd"))
+ writer.uint32(/* id 12, wireType 1 =*/97).double(message.domainLookupEnd);
+ if (message.connectStart != null && Object.hasOwnProperty.call(message, "connectStart"))
+ writer.uint32(/* id 13, wireType 1 =*/105).double(message.connectStart);
+ if (message.connectEnd != null && Object.hasOwnProperty.call(message, "connectEnd"))
+ writer.uint32(/* id 14, wireType 1 =*/113).double(message.connectEnd);
+ if (message.secureConnectionStart != null && Object.hasOwnProperty.call(message, "secureConnectionStart"))
+ writer.uint32(/* id 15, wireType 1 =*/121).double(message.secureConnectionStart);
+ if (message.requestStart != null && Object.hasOwnProperty.call(message, "requestStart"))
+ writer.uint32(/* id 16, wireType 1 =*/129).double(message.requestStart);
+ if (message.responseStart != null && Object.hasOwnProperty.call(message, "responseStart"))
+ writer.uint32(/* id 17, wireType 1 =*/137).double(message.responseStart);
+ if (message.responseEnd != null && Object.hasOwnProperty.call(message, "responseEnd"))
+ writer.uint32(/* id 18, wireType 1 =*/145).double(message.responseEnd);
+ if (message.transferSize != null && Object.hasOwnProperty.call(message, "transferSize"))
+ writer.uint32(/* id 19, wireType 0 =*/152).int64(message.transferSize);
+ if (message.encodedBodySize != null && Object.hasOwnProperty.call(message, "encodedBodySize"))
+ writer.uint32(/* id 20, wireType 0 =*/160).int64(message.encodedBodySize);
+ if (message.decodedBodySize != null && Object.hasOwnProperty.call(message, "decodedBodySize"))
+ writer.uint32(/* id 21, wireType 0 =*/168).int64(message.decodedBodySize);
+ if (message.location != null && Object.hasOwnProperty.call(message, "location"))
+ $root.RnLocation.encode(message.location, writer.uint32(/* id 100, wireType 2 =*/802).fork()).ldelim();
+ if (message.resourceMeta != null && message.resourceMeta.length)
+ for (let i = 0; i < message.resourceMeta.length; ++i)
+ $root.RnResourceMeta.encode(message.resourceMeta[i], writer.uint32(/* id 101, wireType 2 =*/810).fork()).ldelim();
+ if (message.networkErrorInfo != null && Object.hasOwnProperty.call(message, "networkErrorInfo"))
+ $root.RnNetworkErrorInfo.encode(message.networkErrorInfo, writer.uint32(/* id 102, wireType 2 =*/818).fork()).ldelim();
+ return writer;
+ };
+
+ /**
+ * Encodes the specified RnResourceTiming message, length delimited. Does not implicitly {@link RnResourceTiming.verify|verify} messages.
+ * @function encodeDelimited
+ * @memberof RnResourceTiming
+ * @static
+ * @param {IRnResourceTiming} message RnResourceTiming message or plain object to encode
+ * @param {$protobuf.Writer} [writer] Writer to encode to
+ * @returns {$protobuf.Writer} Writer
+ */
+ RnResourceTiming.encodeDelimited = function encodeDelimited(message, writer) {
+ return this.encode(message, writer).ldelim();
+ };
+
+ /**
+ * Decodes a RnResourceTiming message from the specified reader or buffer.
+ * @function decode
+ * @memberof RnResourceTiming
+ * @static
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
+ * @param {number} [length] Message length if known beforehand
+ * @returns {RnResourceTiming} RnResourceTiming
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ RnResourceTiming.decode = function decode(reader, length) {
+ if (!(reader instanceof $Reader))
+ reader = $Reader.create(reader);
+ let end = length === undefined ? reader.len : reader.pos + length, message = new $root.RnResourceTiming();
+ while (reader.pos < end) {
+ let tag = reader.uint32();
+ switch (tag >>> 3) {
+ case 1: {
+ message.name = reader.string();
+ break;
+ }
+ case 2: {
+ message.entryType = reader.string();
+ break;
+ }
+ case 3: {
+ message.startTime = reader.double();
+ break;
+ }
+ case 4: {
+ message.duration = reader.double();
+ break;
+ }
+ case 5: {
+ message.initiatorType = reader.string();
+ break;
+ }
+ case 6: {
+ message.nextHopProtocol = reader.string();
+ break;
+ }
+ case 7: {
+ message.workerStart = reader.double();
+ break;
+ }
+ case 8: {
+ message.redirectStart = reader.double();
+ break;
+ }
+ case 9: {
+ message.redirectEnd = reader.double();
+ break;
+ }
+ case 10: {
+ message.fetchStart = reader.double();
+ break;
+ }
+ case 11: {
+ message.domainLookupStart = reader.double();
+ break;
+ }
+ case 12: {
+ message.domainLookupEnd = reader.double();
+ break;
+ }
+ case 13: {
+ message.connectStart = reader.double();
+ break;
+ }
+ case 14: {
+ message.connectEnd = reader.double();
+ break;
+ }
+ case 15: {
+ message.secureConnectionStart = reader.double();
+ break;
+ }
+ case 16: {
+ message.requestStart = reader.double();
+ break;
+ }
+ case 17: {
+ message.responseStart = reader.double();
+ break;
+ }
+ case 18: {
+ message.responseEnd = reader.double();
+ break;
+ }
+ case 19: {
+ message.transferSize = reader.int64();
+ break;
+ }
+ case 20: {
+ message.encodedBodySize = reader.int64();
+ break;
+ }
+ case 21: {
+ message.decodedBodySize = reader.int64();
+ break;
+ }
+ case 100: {
+ message.location = $root.RnLocation.decode(reader, reader.uint32());
+ break;
+ }
+ case 101: {
+ if (!(message.resourceMeta && message.resourceMeta.length))
+ message.resourceMeta = [];
+ message.resourceMeta.push($root.RnResourceMeta.decode(reader, reader.uint32()));
+ break;
+ }
+ case 102: {
+ message.networkErrorInfo = $root.RnNetworkErrorInfo.decode(reader, reader.uint32());
+ break;
+ }
+ default:
+ reader.skipType(tag & 7);
+ break;
+ }
+ }
+ return message;
+ };
+
+ /**
+ * Decodes a RnResourceTiming message from the specified reader or buffer, length delimited.
+ * @function decodeDelimited
+ * @memberof RnResourceTiming
+ * @static
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
+ * @returns {RnResourceTiming} RnResourceTiming
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ RnResourceTiming.decodeDelimited = function decodeDelimited(reader) {
+ if (!(reader instanceof $Reader))
+ reader = new $Reader(reader);
+ return this.decode(reader, reader.uint32());
+ };
+
+ /**
+ * Verifies a RnResourceTiming message.
+ * @function verify
+ * @memberof RnResourceTiming
+ * @static
+ * @param {Object.} message Plain object to verify
+ * @returns {string|null} `null` if valid, otherwise the reason why it is not
+ */
+ RnResourceTiming.verify = function verify(message) {
+ if (typeof message !== "object" || message === null)
+ return "object expected";
+ if (message.name != null && message.hasOwnProperty("name"))
+ if (!$util.isString(message.name))
+ return "name: string expected";
+ if (message.entryType != null && message.hasOwnProperty("entryType"))
+ if (!$util.isString(message.entryType))
+ return "entryType: string expected";
+ if (message.startTime != null && message.hasOwnProperty("startTime"))
+ if (typeof message.startTime !== "number")
+ return "startTime: number expected";
+ if (message.duration != null && message.hasOwnProperty("duration"))
+ if (typeof message.duration !== "number")
+ return "duration: number expected";
+ if (message.initiatorType != null && message.hasOwnProperty("initiatorType"))
+ if (!$util.isString(message.initiatorType))
+ return "initiatorType: string expected";
+ if (message.nextHopProtocol != null && message.hasOwnProperty("nextHopProtocol"))
+ if (!$util.isString(message.nextHopProtocol))
+ return "nextHopProtocol: string expected";
+ if (message.workerStart != null && message.hasOwnProperty("workerStart"))
+ if (typeof message.workerStart !== "number")
+ return "workerStart: number expected";
+ if (message.redirectStart != null && message.hasOwnProperty("redirectStart"))
+ if (typeof message.redirectStart !== "number")
+ return "redirectStart: number expected";
+ if (message.redirectEnd != null && message.hasOwnProperty("redirectEnd"))
+ if (typeof message.redirectEnd !== "number")
+ return "redirectEnd: number expected";
+ if (message.fetchStart != null && message.hasOwnProperty("fetchStart"))
+ if (typeof message.fetchStart !== "number")
+ return "fetchStart: number expected";
+ if (message.domainLookupStart != null && message.hasOwnProperty("domainLookupStart"))
+ if (typeof message.domainLookupStart !== "number")
+ return "domainLookupStart: number expected";
+ if (message.domainLookupEnd != null && message.hasOwnProperty("domainLookupEnd"))
+ if (typeof message.domainLookupEnd !== "number")
+ return "domainLookupEnd: number expected";
+ if (message.connectStart != null && message.hasOwnProperty("connectStart"))
+ if (typeof message.connectStart !== "number")
+ return "connectStart: number expected";
+ if (message.connectEnd != null && message.hasOwnProperty("connectEnd"))
+ if (typeof message.connectEnd !== "number")
+ return "connectEnd: number expected";
+ if (message.secureConnectionStart != null && message.hasOwnProperty("secureConnectionStart"))
+ if (typeof message.secureConnectionStart !== "number")
+ return "secureConnectionStart: number expected";
+ if (message.requestStart != null && message.hasOwnProperty("requestStart"))
+ if (typeof message.requestStart !== "number")
+ return "requestStart: number expected";
+ if (message.responseStart != null && message.hasOwnProperty("responseStart"))
+ if (typeof message.responseStart !== "number")
+ return "responseStart: number expected";
+ if (message.responseEnd != null && message.hasOwnProperty("responseEnd"))
+ if (typeof message.responseEnd !== "number")
+ return "responseEnd: number expected";
+ if (message.transferSize != null && message.hasOwnProperty("transferSize"))
+ if (!$util.isInteger(message.transferSize) && !(message.transferSize && $util.isInteger(message.transferSize.low) && $util.isInteger(message.transferSize.high)))
+ return "transferSize: integer|Long expected";
+ if (message.encodedBodySize != null && message.hasOwnProperty("encodedBodySize"))
+ if (!$util.isInteger(message.encodedBodySize) && !(message.encodedBodySize && $util.isInteger(message.encodedBodySize.low) && $util.isInteger(message.encodedBodySize.high)))
+ return "encodedBodySize: integer|Long expected";
+ if (message.decodedBodySize != null && message.hasOwnProperty("decodedBodySize"))
+ if (!$util.isInteger(message.decodedBodySize) && !(message.decodedBodySize && $util.isInteger(message.decodedBodySize.low) && $util.isInteger(message.decodedBodySize.high)))
+ return "decodedBodySize: integer|Long expected";
+ if (message.location != null && message.hasOwnProperty("location")) {
+ let error = $root.RnLocation.verify(message.location);
+ if (error)
+ return "location." + error;
+ }
+ if (message.resourceMeta != null && message.hasOwnProperty("resourceMeta")) {
+ if (!Array.isArray(message.resourceMeta))
+ return "resourceMeta: array expected";
+ for (let i = 0; i < message.resourceMeta.length; ++i) {
+ let error = $root.RnResourceMeta.verify(message.resourceMeta[i]);
+ if (error)
+ return "resourceMeta." + error;
+ }
+ }
+ if (message.networkErrorInfo != null && message.hasOwnProperty("networkErrorInfo")) {
+ let error = $root.RnNetworkErrorInfo.verify(message.networkErrorInfo);
+ if (error)
+ return "networkErrorInfo." + error;
+ }
+ return null;
+ };
+
+ /**
+ * Creates a RnResourceTiming message from a plain object. Also converts values to their respective internal types.
+ * @function fromObject
+ * @memberof RnResourceTiming
+ * @static
+ * @param {Object.} object Plain object
+ * @returns {RnResourceTiming} RnResourceTiming
+ */
+ RnResourceTiming.fromObject = function fromObject(object) {
+ if (object instanceof $root.RnResourceTiming)
+ return object;
+ let message = new $root.RnResourceTiming();
+ if (object.name != null)
+ message.name = String(object.name);
+ if (object.entryType != null)
+ message.entryType = String(object.entryType);
+ if (object.startTime != null)
+ message.startTime = Number(object.startTime);
+ if (object.duration != null)
+ message.duration = Number(object.duration);
+ if (object.initiatorType != null)
+ message.initiatorType = String(object.initiatorType);
+ if (object.nextHopProtocol != null)
+ message.nextHopProtocol = String(object.nextHopProtocol);
+ if (object.workerStart != null)
+ message.workerStart = Number(object.workerStart);
+ if (object.redirectStart != null)
+ message.redirectStart = Number(object.redirectStart);
+ if (object.redirectEnd != null)
+ message.redirectEnd = Number(object.redirectEnd);
+ if (object.fetchStart != null)
+ message.fetchStart = Number(object.fetchStart);
+ if (object.domainLookupStart != null)
+ message.domainLookupStart = Number(object.domainLookupStart);
+ if (object.domainLookupEnd != null)
+ message.domainLookupEnd = Number(object.domainLookupEnd);
+ if (object.connectStart != null)
+ message.connectStart = Number(object.connectStart);
+ if (object.connectEnd != null)
+ message.connectEnd = Number(object.connectEnd);
+ if (object.secureConnectionStart != null)
+ message.secureConnectionStart = Number(object.secureConnectionStart);
+ if (object.requestStart != null)
+ message.requestStart = Number(object.requestStart);
+ if (object.responseStart != null)
+ message.responseStart = Number(object.responseStart);
+ if (object.responseEnd != null)
+ message.responseEnd = Number(object.responseEnd);
+ if (object.transferSize != null)
+ if ($util.Long)
+ (message.transferSize = $util.Long.fromValue(object.transferSize)).unsigned = false;
+ else if (typeof object.transferSize === "string")
+ message.transferSize = parseInt(object.transferSize, 10);
+ else if (typeof object.transferSize === "number")
+ message.transferSize = object.transferSize;
+ else if (typeof object.transferSize === "object")
+ message.transferSize = new $util.LongBits(object.transferSize.low >>> 0, object.transferSize.high >>> 0).toNumber();
+ if (object.encodedBodySize != null)
+ if ($util.Long)
+ (message.encodedBodySize = $util.Long.fromValue(object.encodedBodySize)).unsigned = false;
+ else if (typeof object.encodedBodySize === "string")
+ message.encodedBodySize = parseInt(object.encodedBodySize, 10);
+ else if (typeof object.encodedBodySize === "number")
+ message.encodedBodySize = object.encodedBodySize;
+ else if (typeof object.encodedBodySize === "object")
+ message.encodedBodySize = new $util.LongBits(object.encodedBodySize.low >>> 0, object.encodedBodySize.high >>> 0).toNumber();
+ if (object.decodedBodySize != null)
+ if ($util.Long)
+ (message.decodedBodySize = $util.Long.fromValue(object.decodedBodySize)).unsigned = false;
+ else if (typeof object.decodedBodySize === "string")
+ message.decodedBodySize = parseInt(object.decodedBodySize, 10);
+ else if (typeof object.decodedBodySize === "number")
+ message.decodedBodySize = object.decodedBodySize;
+ else if (typeof object.decodedBodySize === "object")
+ message.decodedBodySize = new $util.LongBits(object.decodedBodySize.low >>> 0, object.decodedBodySize.high >>> 0).toNumber();
+ if (object.location != null) {
+ if (typeof object.location !== "object")
+ throw TypeError(".RnResourceTiming.location: object expected");
+ message.location = $root.RnLocation.fromObject(object.location);
+ }
+ if (object.resourceMeta) {
+ if (!Array.isArray(object.resourceMeta))
+ throw TypeError(".RnResourceTiming.resourceMeta: array expected");
+ message.resourceMeta = [];
+ for (let i = 0; i < object.resourceMeta.length; ++i) {
+ if (typeof object.resourceMeta[i] !== "object")
+ throw TypeError(".RnResourceTiming.resourceMeta: object expected");
+ message.resourceMeta[i] = $root.RnResourceMeta.fromObject(object.resourceMeta[i]);
+ }
+ }
+ if (object.networkErrorInfo != null) {
+ if (typeof object.networkErrorInfo !== "object")
+ throw TypeError(".RnResourceTiming.networkErrorInfo: object expected");
+ message.networkErrorInfo = $root.RnNetworkErrorInfo.fromObject(object.networkErrorInfo);
+ }
+ return message;
+ };
+
+ /**
+ * Creates a plain object from a RnResourceTiming message. Also converts values to other types if specified.
+ * @function toObject
+ * @memberof RnResourceTiming
+ * @static
+ * @param {RnResourceTiming} message RnResourceTiming
+ * @param {$protobuf.IConversionOptions} [options] Conversion options
+ * @returns {Object.} Plain object
+ */
+ RnResourceTiming.toObject = function toObject(message, options) {
+ if (!options)
+ options = {};
+ let object = {};
+ if (options.arrays || options.defaults)
+ object.resourceMeta = [];
+ if (options.defaults) {
+ object.name = "";
+ object.entryType = "";
+ object.startTime = 0;
+ object.duration = 0;
+ object.initiatorType = "";
+ object.nextHopProtocol = "";
+ object.workerStart = 0;
+ object.redirectStart = 0;
+ object.redirectEnd = 0;
+ object.fetchStart = 0;
+ object.domainLookupStart = 0;
+ object.domainLookupEnd = 0;
+ object.connectStart = 0;
+ object.connectEnd = 0;
+ object.secureConnectionStart = 0;
+ object.requestStart = 0;
+ object.responseStart = 0;
+ object.responseEnd = 0;
+ if ($util.Long) {
+ let long = new $util.Long(0, 0, false);
+ object.transferSize = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
+ } else
+ object.transferSize = options.longs === String ? "0" : 0;
+ if ($util.Long) {
+ let long = new $util.Long(0, 0, false);
+ object.encodedBodySize = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
+ } else
+ object.encodedBodySize = options.longs === String ? "0" : 0;
+ if ($util.Long) {
+ let long = new $util.Long(0, 0, false);
+ object.decodedBodySize = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
+ } else
+ object.decodedBodySize = options.longs === String ? "0" : 0;
+ object.location = null;
+ object.networkErrorInfo = null;
+ }
+ if (message.name != null && message.hasOwnProperty("name"))
+ object.name = message.name;
+ if (message.entryType != null && message.hasOwnProperty("entryType"))
+ object.entryType = message.entryType;
+ if (message.startTime != null && message.hasOwnProperty("startTime"))
+ object.startTime = options.json && !isFinite(message.startTime) ? String(message.startTime) : message.startTime;
+ if (message.duration != null && message.hasOwnProperty("duration"))
+ object.duration = options.json && !isFinite(message.duration) ? String(message.duration) : message.duration;
+ if (message.initiatorType != null && message.hasOwnProperty("initiatorType"))
+ object.initiatorType = message.initiatorType;
+ if (message.nextHopProtocol != null && message.hasOwnProperty("nextHopProtocol"))
+ object.nextHopProtocol = message.nextHopProtocol;
+ if (message.workerStart != null && message.hasOwnProperty("workerStart"))
+ object.workerStart = options.json && !isFinite(message.workerStart) ? String(message.workerStart) : message.workerStart;
+ if (message.redirectStart != null && message.hasOwnProperty("redirectStart"))
+ object.redirectStart = options.json && !isFinite(message.redirectStart) ? String(message.redirectStart) : message.redirectStart;
+ if (message.redirectEnd != null && message.hasOwnProperty("redirectEnd"))
+ object.redirectEnd = options.json && !isFinite(message.redirectEnd) ? String(message.redirectEnd) : message.redirectEnd;
+ if (message.fetchStart != null && message.hasOwnProperty("fetchStart"))
+ object.fetchStart = options.json && !isFinite(message.fetchStart) ? String(message.fetchStart) : message.fetchStart;
+ if (message.domainLookupStart != null && message.hasOwnProperty("domainLookupStart"))
+ object.domainLookupStart = options.json && !isFinite(message.domainLookupStart) ? String(message.domainLookupStart) : message.domainLookupStart;
+ if (message.domainLookupEnd != null && message.hasOwnProperty("domainLookupEnd"))
+ object.domainLookupEnd = options.json && !isFinite(message.domainLookupEnd) ? String(message.domainLookupEnd) : message.domainLookupEnd;
+ if (message.connectStart != null && message.hasOwnProperty("connectStart"))
+ object.connectStart = options.json && !isFinite(message.connectStart) ? String(message.connectStart) : message.connectStart;
+ if (message.connectEnd != null && message.hasOwnProperty("connectEnd"))
+ object.connectEnd = options.json && !isFinite(message.connectEnd) ? String(message.connectEnd) : message.connectEnd;
+ if (message.secureConnectionStart != null && message.hasOwnProperty("secureConnectionStart"))
+ object.secureConnectionStart = options.json && !isFinite(message.secureConnectionStart) ? String(message.secureConnectionStart) : message.secureConnectionStart;
+ if (message.requestStart != null && message.hasOwnProperty("requestStart"))
+ object.requestStart = options.json && !isFinite(message.requestStart) ? String(message.requestStart) : message.requestStart;
+ if (message.responseStart != null && message.hasOwnProperty("responseStart"))
+ object.responseStart = options.json && !isFinite(message.responseStart) ? String(message.responseStart) : message.responseStart;
+ if (message.responseEnd != null && message.hasOwnProperty("responseEnd"))
+ object.responseEnd = options.json && !isFinite(message.responseEnd) ? String(message.responseEnd) : message.responseEnd;
+ if (message.transferSize != null && message.hasOwnProperty("transferSize"))
+ if (typeof message.transferSize === "number")
+ object.transferSize = options.longs === String ? String(message.transferSize) : message.transferSize;
+ else
+ object.transferSize = options.longs === String ? $util.Long.prototype.toString.call(message.transferSize) : options.longs === Number ? new $util.LongBits(message.transferSize.low >>> 0, message.transferSize.high >>> 0).toNumber() : message.transferSize;
+ if (message.encodedBodySize != null && message.hasOwnProperty("encodedBodySize"))
+ if (typeof message.encodedBodySize === "number")
+ object.encodedBodySize = options.longs === String ? String(message.encodedBodySize) : message.encodedBodySize;
+ else
+ object.encodedBodySize = options.longs === String ? $util.Long.prototype.toString.call(message.encodedBodySize) : options.longs === Number ? new $util.LongBits(message.encodedBodySize.low >>> 0, message.encodedBodySize.high >>> 0).toNumber() : message.encodedBodySize;
+ if (message.decodedBodySize != null && message.hasOwnProperty("decodedBodySize"))
+ if (typeof message.decodedBodySize === "number")
+ object.decodedBodySize = options.longs === String ? String(message.decodedBodySize) : message.decodedBodySize;
+ else
+ object.decodedBodySize = options.longs === String ? $util.Long.prototype.toString.call(message.decodedBodySize) : options.longs === Number ? new $util.LongBits(message.decodedBodySize.low >>> 0, message.decodedBodySize.high >>> 0).toNumber() : message.decodedBodySize;
+ if (message.location != null && message.hasOwnProperty("location"))
+ object.location = $root.RnLocation.toObject(message.location, options);
+ if (message.resourceMeta && message.resourceMeta.length) {
+ object.resourceMeta = [];
+ for (let j = 0; j < message.resourceMeta.length; ++j)
+ object.resourceMeta[j] = $root.RnResourceMeta.toObject(message.resourceMeta[j], options);
+ }
+ if (message.networkErrorInfo != null && message.hasOwnProperty("networkErrorInfo"))
+ object.networkErrorInfo = $root.RnNetworkErrorInfo.toObject(message.networkErrorInfo, options);
+ return object;
+ };
+
+ /**
+ * Converts this RnResourceTiming to JSON.
+ * @function toJSON
+ * @memberof RnResourceTiming
+ * @instance
+ * @returns {Object.} JSON object
+ */
+ RnResourceTiming.prototype.toJSON = function toJSON() {
+ return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
+ };
+
+ /**
+ * Gets the default type url for RnResourceTiming
+ * @function getTypeUrl
+ * @memberof RnResourceTiming
+ * @static
+ * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
+ * @returns {string} The default type url
+ */
+ RnResourceTiming.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
+ if (typeUrlPrefix === undefined) {
+ typeUrlPrefix = "type.googleapis.com";
+ }
+ return typeUrlPrefix + "/RnResourceTiming";
+ };
+
+ return RnResourceTiming;
+})();
+
+export const RnPerformanceMeasure = $root.RnPerformanceMeasure = (() => {
+
+ /**
+ * Properties of a RnPerformanceMeasure.
+ * @exports IRnPerformanceMeasure
+ * @interface IRnPerformanceMeasure
+ * @property {string|null} [name] RnPerformanceMeasure name
+ * @property {string|null} [entryType] RnPerformanceMeasure entryType
+ * @property {number|null} [startTime] RnPerformanceMeasure startTime
+ * @property {number|null} [duration] RnPerformanceMeasure duration
+ */
+
+ /**
+ * Constructs a new RnPerformanceMeasure.
+ * @exports RnPerformanceMeasure
+ * @classdesc Represents a RnPerformanceMeasure.
+ * @implements IRnPerformanceMeasure
+ * @constructor
+ * @param {IRnPerformanceMeasure=} [properties] Properties to set
+ */
+ function RnPerformanceMeasure(properties) {
+ if (properties)
+ for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
+ if (properties[keys[i]] != null)
+ this[keys[i]] = properties[keys[i]];
+ }
+
+ /**
+ * RnPerformanceMeasure name.
+ * @member {string} name
+ * @memberof RnPerformanceMeasure
+ * @instance
+ */
+ RnPerformanceMeasure.prototype.name = "";
+
+ /**
+ * RnPerformanceMeasure entryType.
+ * @member {string} entryType
+ * @memberof RnPerformanceMeasure
+ * @instance
+ */
+ RnPerformanceMeasure.prototype.entryType = "";
+
+ /**
+ * RnPerformanceMeasure startTime.
+ * @member {number} startTime
+ * @memberof RnPerformanceMeasure
+ * @instance
+ */
+ RnPerformanceMeasure.prototype.startTime = 0;
+
+ /**
+ * RnPerformanceMeasure duration.
+ * @member {number} duration
+ * @memberof RnPerformanceMeasure
+ * @instance
+ */
+ RnPerformanceMeasure.prototype.duration = 0;
+
+ /**
+ * Creates a new RnPerformanceMeasure instance using the specified properties.
+ * @function create
+ * @memberof RnPerformanceMeasure
+ * @static
+ * @param {IRnPerformanceMeasure=} [properties] Properties to set
+ * @returns {RnPerformanceMeasure} RnPerformanceMeasure instance
+ */
+ RnPerformanceMeasure.create = function create(properties) {
+ return new RnPerformanceMeasure(properties);
+ };
+
+ /**
+ * Encodes the specified RnPerformanceMeasure message. Does not implicitly {@link RnPerformanceMeasure.verify|verify} messages.
+ * @function encode
+ * @memberof RnPerformanceMeasure
+ * @static
+ * @param {IRnPerformanceMeasure} message RnPerformanceMeasure message or plain object to encode
+ * @param {$protobuf.Writer} [writer] Writer to encode to
+ * @returns {$protobuf.Writer} Writer
+ */
+ RnPerformanceMeasure.encode = function encode(message, writer) {
+ if (!writer)
+ writer = $Writer.create();
+ if (message.name != null && Object.hasOwnProperty.call(message, "name"))
+ writer.uint32(/* id 1, wireType 2 =*/10).string(message.name);
+ if (message.entryType != null && Object.hasOwnProperty.call(message, "entryType"))
+ writer.uint32(/* id 2, wireType 2 =*/18).string(message.entryType);
+ if (message.startTime != null && Object.hasOwnProperty.call(message, "startTime"))
+ writer.uint32(/* id 3, wireType 1 =*/25).double(message.startTime);
+ if (message.duration != null && Object.hasOwnProperty.call(message, "duration"))
+ writer.uint32(/* id 4, wireType 1 =*/33).double(message.duration);
+ return writer;
+ };
+
+ /**
+ * Encodes the specified RnPerformanceMeasure message, length delimited. Does not implicitly {@link RnPerformanceMeasure.verify|verify} messages.
+ * @function encodeDelimited
+ * @memberof RnPerformanceMeasure
+ * @static
+ * @param {IRnPerformanceMeasure} message RnPerformanceMeasure message or plain object to encode
+ * @param {$protobuf.Writer} [writer] Writer to encode to
+ * @returns {$protobuf.Writer} Writer
+ */
+ RnPerformanceMeasure.encodeDelimited = function encodeDelimited(message, writer) {
+ return this.encode(message, writer).ldelim();
+ };
+
+ /**
+ * Decodes a RnPerformanceMeasure message from the specified reader or buffer.
+ * @function decode
+ * @memberof RnPerformanceMeasure
+ * @static
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
+ * @param {number} [length] Message length if known beforehand
+ * @returns {RnPerformanceMeasure} RnPerformanceMeasure
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ RnPerformanceMeasure.decode = function decode(reader, length) {
+ if (!(reader instanceof $Reader))
+ reader = $Reader.create(reader);
+ let end = length === undefined ? reader.len : reader.pos + length, message = new $root.RnPerformanceMeasure();
+ while (reader.pos < end) {
+ let tag = reader.uint32();
+ switch (tag >>> 3) {
+ case 1: {
+ message.name = reader.string();
+ break;
+ }
+ case 2: {
+ message.entryType = reader.string();
+ break;
+ }
+ case 3: {
+ message.startTime = reader.double();
+ break;
+ }
+ case 4: {
+ message.duration = reader.double();
+ break;
+ }
+ default:
+ reader.skipType(tag & 7);
+ break;
+ }
+ }
+ return message;
+ };
+
+ /**
+ * Decodes a RnPerformanceMeasure message from the specified reader or buffer, length delimited.
+ * @function decodeDelimited
+ * @memberof RnPerformanceMeasure
+ * @static
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
+ * @returns {RnPerformanceMeasure} RnPerformanceMeasure
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ RnPerformanceMeasure.decodeDelimited = function decodeDelimited(reader) {
+ if (!(reader instanceof $Reader))
+ reader = new $Reader(reader);
+ return this.decode(reader, reader.uint32());
+ };
+
+ /**
+ * Verifies a RnPerformanceMeasure message.
+ * @function verify
+ * @memberof RnPerformanceMeasure
+ * @static
+ * @param {Object.} message Plain object to verify
+ * @returns {string|null} `null` if valid, otherwise the reason why it is not
+ */
+ RnPerformanceMeasure.verify = function verify(message) {
+ if (typeof message !== "object" || message === null)
+ return "object expected";
+ if (message.name != null && message.hasOwnProperty("name"))
+ if (!$util.isString(message.name))
+ return "name: string expected";
+ if (message.entryType != null && message.hasOwnProperty("entryType"))
+ if (!$util.isString(message.entryType))
+ return "entryType: string expected";
+ if (message.startTime != null && message.hasOwnProperty("startTime"))
+ if (typeof message.startTime !== "number")
+ return "startTime: number expected";
+ if (message.duration != null && message.hasOwnProperty("duration"))
+ if (typeof message.duration !== "number")
+ return "duration: number expected";
+ return null;
+ };
+
+ /**
+ * Creates a RnPerformanceMeasure message from a plain object. Also converts values to their respective internal types.
+ * @function fromObject
+ * @memberof RnPerformanceMeasure
+ * @static
+ * @param {Object.} object Plain object
+ * @returns {RnPerformanceMeasure} RnPerformanceMeasure
+ */
+ RnPerformanceMeasure.fromObject = function fromObject(object) {
+ if (object instanceof $root.RnPerformanceMeasure)
+ return object;
+ let message = new $root.RnPerformanceMeasure();
+ if (object.name != null)
+ message.name = String(object.name);
+ if (object.entryType != null)
+ message.entryType = String(object.entryType);
+ if (object.startTime != null)
+ message.startTime = Number(object.startTime);
+ if (object.duration != null)
+ message.duration = Number(object.duration);
+ return message;
+ };
+
+ /**
+ * Creates a plain object from a RnPerformanceMeasure message. Also converts values to other types if specified.
+ * @function toObject
+ * @memberof RnPerformanceMeasure
+ * @static
+ * @param {RnPerformanceMeasure} message RnPerformanceMeasure
+ * @param {$protobuf.IConversionOptions} [options] Conversion options
+ * @returns {Object.} Plain object
+ */
+ RnPerformanceMeasure.toObject = function toObject(message, options) {
+ if (!options)
+ options = {};
+ let object = {};
+ if (options.defaults) {
+ object.name = "";
+ object.entryType = "";
+ object.startTime = 0;
+ object.duration = 0;
+ }
+ if (message.name != null && message.hasOwnProperty("name"))
+ object.name = message.name;
+ if (message.entryType != null && message.hasOwnProperty("entryType"))
+ object.entryType = message.entryType;
+ if (message.startTime != null && message.hasOwnProperty("startTime"))
+ object.startTime = options.json && !isFinite(message.startTime) ? String(message.startTime) : message.startTime;
+ if (message.duration != null && message.hasOwnProperty("duration"))
+ object.duration = options.json && !isFinite(message.duration) ? String(message.duration) : message.duration;
+ return object;
+ };
+
+ /**
+ * Converts this RnPerformanceMeasure to JSON.
+ * @function toJSON
+ * @memberof RnPerformanceMeasure
+ * @instance
+ * @returns {Object.} JSON object
+ */
+ RnPerformanceMeasure.prototype.toJSON = function toJSON() {
+ return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
+ };
+
+ /**
+ * Gets the default type url for RnPerformanceMeasure
+ * @function getTypeUrl
+ * @memberof RnPerformanceMeasure
+ * @static
+ * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
+ * @returns {string} The default type url
+ */
+ RnPerformanceMeasure.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
+ if (typeUrlPrefix === undefined) {
+ typeUrlPrefix = "type.googleapis.com";
+ }
+ return typeUrlPrefix + "/RnPerformanceMeasure";
+ };
+
+ return RnPerformanceMeasure;
+})();
+
+export const RnVideoResourceTiming = $root.RnVideoResourceTiming = (() => {
+
+ /**
+ * Properties of a RnVideoResourceTiming.
+ * @exports IRnVideoResourceTiming
+ * @interface IRnVideoResourceTiming
+ * @property {string|null} [uri] RnVideoResourceTiming uri
+ * @property {IRnLocation|null} [location] RnVideoResourceTiming location
+ * @property {string|null} [mime] RnVideoResourceTiming mime
+ * @property {number|null} [size] RnVideoResourceTiming size
+ * @property {number|null} [duration] RnVideoResourceTiming duration
+ * @property {IRnVideoResolution|null} [resolution] RnVideoResourceTiming resolution
+ * @property {boolean|null} [playComplete] RnVideoResourceTiming playComplete
+ * @property {IRnVideoLoadingTiming|null} [videoLoadingTiming] RnVideoResourceTiming videoLoadingTiming
+ * @property {Array.|null} [resourceMeta] RnVideoResourceTiming resourceMeta
+ * @property {IRnNetworkErrorInfo|null} [networkErrorInfo] RnVideoResourceTiming networkErrorInfo
+ */
+
+ /**
+ * Constructs a new RnVideoResourceTiming.
+ * @exports RnVideoResourceTiming
+ * @classdesc Represents a RnVideoResourceTiming.
+ * @implements IRnVideoResourceTiming
+ * @constructor
+ * @param {IRnVideoResourceTiming=} [properties] Properties to set
+ */
+ function RnVideoResourceTiming(properties) {
+ this.resourceMeta = [];
+ if (properties)
+ for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
+ if (properties[keys[i]] != null)
+ this[keys[i]] = properties[keys[i]];
+ }
+
+ /**
+ * RnVideoResourceTiming uri.
+ * @member {string} uri
+ * @memberof RnVideoResourceTiming
+ * @instance
+ */
+ RnVideoResourceTiming.prototype.uri = "";
+
+ /**
+ * RnVideoResourceTiming location.
+ * @member {IRnLocation|null|undefined} location
+ * @memberof RnVideoResourceTiming
+ * @instance
+ */
+ RnVideoResourceTiming.prototype.location = null;
+
+ /**
+ * RnVideoResourceTiming mime.
+ * @member {string} mime
+ * @memberof RnVideoResourceTiming
+ * @instance
+ */
+ RnVideoResourceTiming.prototype.mime = "";
+
+ /**
+ * RnVideoResourceTiming size.
+ * @member {number} size
+ * @memberof RnVideoResourceTiming
+ * @instance
+ */
+ RnVideoResourceTiming.prototype.size = 0;
+
+ /**
+ * RnVideoResourceTiming duration.
+ * @member {number} duration
+ * @memberof RnVideoResourceTiming
+ * @instance
+ */
+ RnVideoResourceTiming.prototype.duration = 0;
+
+ /**
+ * RnVideoResourceTiming resolution.
+ * @member {IRnVideoResolution|null|undefined} resolution
+ * @memberof RnVideoResourceTiming
+ * @instance
+ */
+ RnVideoResourceTiming.prototype.resolution = null;
+
+ /**
+ * RnVideoResourceTiming playComplete.
+ * @member {boolean} playComplete
+ * @memberof RnVideoResourceTiming
+ * @instance
+ */
+ RnVideoResourceTiming.prototype.playComplete = false;
+
+ /**
+ * RnVideoResourceTiming videoLoadingTiming.
+ * @member {IRnVideoLoadingTiming|null|undefined} videoLoadingTiming
+ * @memberof RnVideoResourceTiming
+ * @instance
+ */
+ RnVideoResourceTiming.prototype.videoLoadingTiming = null;
+
+ /**
+ * RnVideoResourceTiming resourceMeta.
+ * @member {Array.} resourceMeta
+ * @memberof RnVideoResourceTiming
+ * @instance
+ */
+ RnVideoResourceTiming.prototype.resourceMeta = $util.emptyArray;
+
+ /**
+ * RnVideoResourceTiming networkErrorInfo.
+ * @member {IRnNetworkErrorInfo|null|undefined} networkErrorInfo
+ * @memberof RnVideoResourceTiming
+ * @instance
+ */
+ RnVideoResourceTiming.prototype.networkErrorInfo = null;
+
+ /**
+ * Creates a new RnVideoResourceTiming instance using the specified properties.
+ * @function create
+ * @memberof RnVideoResourceTiming
+ * @static
+ * @param {IRnVideoResourceTiming=} [properties] Properties to set
+ * @returns {RnVideoResourceTiming} RnVideoResourceTiming instance
+ */
+ RnVideoResourceTiming.create = function create(properties) {
+ return new RnVideoResourceTiming(properties);
+ };
+
+ /**
+ * Encodes the specified RnVideoResourceTiming message. Does not implicitly {@link RnVideoResourceTiming.verify|verify} messages.
+ * @function encode
+ * @memberof RnVideoResourceTiming
+ * @static
+ * @param {IRnVideoResourceTiming} message RnVideoResourceTiming message or plain object to encode
+ * @param {$protobuf.Writer} [writer] Writer to encode to
+ * @returns {$protobuf.Writer} Writer
+ */
+ RnVideoResourceTiming.encode = function encode(message, writer) {
+ if (!writer)
+ writer = $Writer.create();
+ if (message.uri != null && Object.hasOwnProperty.call(message, "uri"))
+ writer.uint32(/* id 1, wireType 2 =*/10).string(message.uri);
+ if (message.mime != null && Object.hasOwnProperty.call(message, "mime"))
+ writer.uint32(/* id 2, wireType 2 =*/18).string(message.mime);
+ if (message.size != null && Object.hasOwnProperty.call(message, "size"))
+ writer.uint32(/* id 3, wireType 1 =*/25).double(message.size);
+ if (message.duration != null && Object.hasOwnProperty.call(message, "duration"))
+ writer.uint32(/* id 4, wireType 1 =*/33).double(message.duration);
+ if (message.resolution != null && Object.hasOwnProperty.call(message, "resolution"))
+ $root.RnVideoResolution.encode(message.resolution, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim();
+ if (message.playComplete != null && Object.hasOwnProperty.call(message, "playComplete"))
+ writer.uint32(/* id 6, wireType 0 =*/48).bool(message.playComplete);
+ if (message.location != null && Object.hasOwnProperty.call(message, "location"))
+ $root.RnLocation.encode(message.location, writer.uint32(/* id 10, wireType 2 =*/82).fork()).ldelim();
+ if (message.videoLoadingTiming != null && Object.hasOwnProperty.call(message, "videoLoadingTiming"))
+ $root.RnVideoLoadingTiming.encode(message.videoLoadingTiming, writer.uint32(/* id 100, wireType 2 =*/802).fork()).ldelim();
+ if (message.resourceMeta != null && message.resourceMeta.length)
+ for (let i = 0; i < message.resourceMeta.length; ++i)
+ $root.RnResourceMeta.encode(message.resourceMeta[i], writer.uint32(/* id 101, wireType 2 =*/810).fork()).ldelim();
+ if (message.networkErrorInfo != null && Object.hasOwnProperty.call(message, "networkErrorInfo"))
+ $root.RnNetworkErrorInfo.encode(message.networkErrorInfo, writer.uint32(/* id 102, wireType 2 =*/818).fork()).ldelim();
+ return writer;
+ };
+
+ /**
+ * Encodes the specified RnVideoResourceTiming message, length delimited. Does not implicitly {@link RnVideoResourceTiming.verify|verify} messages.
+ * @function encodeDelimited
+ * @memberof RnVideoResourceTiming
+ * @static
+ * @param {IRnVideoResourceTiming} message RnVideoResourceTiming message or plain object to encode
+ * @param {$protobuf.Writer} [writer] Writer to encode to
+ * @returns {$protobuf.Writer} Writer
+ */
+ RnVideoResourceTiming.encodeDelimited = function encodeDelimited(message, writer) {
+ return this.encode(message, writer).ldelim();
+ };
+
+ /**
+ * Decodes a RnVideoResourceTiming message from the specified reader or buffer.
+ * @function decode
+ * @memberof RnVideoResourceTiming
+ * @static
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
+ * @param {number} [length] Message length if known beforehand
+ * @returns {RnVideoResourceTiming} RnVideoResourceTiming
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ RnVideoResourceTiming.decode = function decode(reader, length) {
+ if (!(reader instanceof $Reader))
+ reader = $Reader.create(reader);
+ let end = length === undefined ? reader.len : reader.pos + length, message = new $root.RnVideoResourceTiming();
+ while (reader.pos < end) {
+ let tag = reader.uint32();
+ switch (tag >>> 3) {
+ case 1: {
+ message.uri = reader.string();
+ break;
+ }
+ case 10: {
+ message.location = $root.RnLocation.decode(reader, reader.uint32());
+ break;
+ }
+ case 2: {
+ message.mime = reader.string();
+ break;
+ }
+ case 3: {
+ message.size = reader.double();
+ break;
+ }
+ case 4: {
+ message.duration = reader.double();
+ break;
+ }
+ case 5: {
+ message.resolution = $root.RnVideoResolution.decode(reader, reader.uint32());
+ break;
+ }
+ case 6: {
+ message.playComplete = reader.bool();
+ break;
+ }
+ case 100: {
+ message.videoLoadingTiming = $root.RnVideoLoadingTiming.decode(reader, reader.uint32());
+ break;
+ }
+ case 101: {
+ if (!(message.resourceMeta && message.resourceMeta.length))
+ message.resourceMeta = [];
+ message.resourceMeta.push($root.RnResourceMeta.decode(reader, reader.uint32()));
+ break;
+ }
+ case 102: {
+ message.networkErrorInfo = $root.RnNetworkErrorInfo.decode(reader, reader.uint32());
+ break;
+ }
+ default:
+ reader.skipType(tag & 7);
+ break;
+ }
+ }
+ return message;
+ };
+
+ /**
+ * Decodes a RnVideoResourceTiming message from the specified reader or buffer, length delimited.
+ * @function decodeDelimited
+ * @memberof RnVideoResourceTiming
+ * @static
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
+ * @returns {RnVideoResourceTiming} RnVideoResourceTiming
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ RnVideoResourceTiming.decodeDelimited = function decodeDelimited(reader) {
+ if (!(reader instanceof $Reader))
+ reader = new $Reader(reader);
+ return this.decode(reader, reader.uint32());
+ };
+
+ /**
+ * Verifies a RnVideoResourceTiming message.
+ * @function verify
+ * @memberof RnVideoResourceTiming
+ * @static
+ * @param {Object.} message Plain object to verify
+ * @returns {string|null} `null` if valid, otherwise the reason why it is not
+ */
+ RnVideoResourceTiming.verify = function verify(message) {
+ if (typeof message !== "object" || message === null)
+ return "object expected";
+ if (message.uri != null && message.hasOwnProperty("uri"))
+ if (!$util.isString(message.uri))
+ return "uri: string expected";
+ if (message.location != null && message.hasOwnProperty("location")) {
+ let error = $root.RnLocation.verify(message.location);
+ if (error)
+ return "location." + error;
+ }
+ if (message.mime != null && message.hasOwnProperty("mime"))
+ if (!$util.isString(message.mime))
+ return "mime: string expected";
+ if (message.size != null && message.hasOwnProperty("size"))
+ if (typeof message.size !== "number")
+ return "size: number expected";
+ if (message.duration != null && message.hasOwnProperty("duration"))
+ if (typeof message.duration !== "number")
+ return "duration: number expected";
+ if (message.resolution != null && message.hasOwnProperty("resolution")) {
+ let error = $root.RnVideoResolution.verify(message.resolution);
+ if (error)
+ return "resolution." + error;
+ }
+ if (message.playComplete != null && message.hasOwnProperty("playComplete"))
+ if (typeof message.playComplete !== "boolean")
+ return "playComplete: boolean expected";
+ if (message.videoLoadingTiming != null && message.hasOwnProperty("videoLoadingTiming")) {
+ let error = $root.RnVideoLoadingTiming.verify(message.videoLoadingTiming);
+ if (error)
+ return "videoLoadingTiming." + error;
+ }
+ if (message.resourceMeta != null && message.hasOwnProperty("resourceMeta")) {
+ if (!Array.isArray(message.resourceMeta))
+ return "resourceMeta: array expected";
+ for (let i = 0; i < message.resourceMeta.length; ++i) {
+ let error = $root.RnResourceMeta.verify(message.resourceMeta[i]);
+ if (error)
+ return "resourceMeta." + error;
+ }
+ }
+ if (message.networkErrorInfo != null && message.hasOwnProperty("networkErrorInfo")) {
+ let error = $root.RnNetworkErrorInfo.verify(message.networkErrorInfo);
+ if (error)
+ return "networkErrorInfo." + error;
+ }
+ return null;
+ };
+
+ /**
+ * Creates a RnVideoResourceTiming message from a plain object. Also converts values to their respective internal types.
+ * @function fromObject
+ * @memberof RnVideoResourceTiming
+ * @static
+ * @param {Object.} object Plain object
+ * @returns {RnVideoResourceTiming} RnVideoResourceTiming
+ */
+ RnVideoResourceTiming.fromObject = function fromObject(object) {
+ if (object instanceof $root.RnVideoResourceTiming)
+ return object;
+ let message = new $root.RnVideoResourceTiming();
+ if (object.uri != null)
+ message.uri = String(object.uri);
+ if (object.location != null) {
+ if (typeof object.location !== "object")
+ throw TypeError(".RnVideoResourceTiming.location: object expected");
+ message.location = $root.RnLocation.fromObject(object.location);
+ }
+ if (object.mime != null)
+ message.mime = String(object.mime);
+ if (object.size != null)
+ message.size = Number(object.size);
+ if (object.duration != null)
+ message.duration = Number(object.duration);
+ if (object.resolution != null) {
+ if (typeof object.resolution !== "object")
+ throw TypeError(".RnVideoResourceTiming.resolution: object expected");
+ message.resolution = $root.RnVideoResolution.fromObject(object.resolution);
+ }
+ if (object.playComplete != null)
+ message.playComplete = Boolean(object.playComplete);
+ if (object.videoLoadingTiming != null) {
+ if (typeof object.videoLoadingTiming !== "object")
+ throw TypeError(".RnVideoResourceTiming.videoLoadingTiming: object expected");
+ message.videoLoadingTiming = $root.RnVideoLoadingTiming.fromObject(object.videoLoadingTiming);
+ }
+ if (object.resourceMeta) {
+ if (!Array.isArray(object.resourceMeta))
+ throw TypeError(".RnVideoResourceTiming.resourceMeta: array expected");
+ message.resourceMeta = [];
+ for (let i = 0; i < object.resourceMeta.length; ++i) {
+ if (typeof object.resourceMeta[i] !== "object")
+ throw TypeError(".RnVideoResourceTiming.resourceMeta: object expected");
+ message.resourceMeta[i] = $root.RnResourceMeta.fromObject(object.resourceMeta[i]);
+ }
+ }
+ if (object.networkErrorInfo != null) {
+ if (typeof object.networkErrorInfo !== "object")
+ throw TypeError(".RnVideoResourceTiming.networkErrorInfo: object expected");
+ message.networkErrorInfo = $root.RnNetworkErrorInfo.fromObject(object.networkErrorInfo);
+ }
+ return message;
+ };
+
+ /**
+ * Creates a plain object from a RnVideoResourceTiming message. Also converts values to other types if specified.
+ * @function toObject
+ * @memberof RnVideoResourceTiming
+ * @static
+ * @param {RnVideoResourceTiming} message RnVideoResourceTiming
+ * @param {$protobuf.IConversionOptions} [options] Conversion options
+ * @returns {Object.} Plain object
+ */
+ RnVideoResourceTiming.toObject = function toObject(message, options) {
+ if (!options)
+ options = {};
+ let object = {};
+ if (options.arrays || options.defaults)
+ object.resourceMeta = [];
+ if (options.defaults) {
+ object.uri = "";
+ object.mime = "";
+ object.size = 0;
+ object.duration = 0;
+ object.resolution = null;
+ object.playComplete = false;
+ object.location = null;
+ object.videoLoadingTiming = null;
+ object.networkErrorInfo = null;
+ }
+ if (message.uri != null && message.hasOwnProperty("uri"))
+ object.uri = message.uri;
+ if (message.mime != null && message.hasOwnProperty("mime"))
+ object.mime = message.mime;
+ if (message.size != null && message.hasOwnProperty("size"))
+ object.size = options.json && !isFinite(message.size) ? String(message.size) : message.size;
+ if (message.duration != null && message.hasOwnProperty("duration"))
+ object.duration = options.json && !isFinite(message.duration) ? String(message.duration) : message.duration;
+ if (message.resolution != null && message.hasOwnProperty("resolution"))
+ object.resolution = $root.RnVideoResolution.toObject(message.resolution, options);
+ if (message.playComplete != null && message.hasOwnProperty("playComplete"))
+ object.playComplete = message.playComplete;
+ if (message.location != null && message.hasOwnProperty("location"))
+ object.location = $root.RnLocation.toObject(message.location, options);
+ if (message.videoLoadingTiming != null && message.hasOwnProperty("videoLoadingTiming"))
+ object.videoLoadingTiming = $root.RnVideoLoadingTiming.toObject(message.videoLoadingTiming, options);
+ if (message.resourceMeta && message.resourceMeta.length) {
+ object.resourceMeta = [];
+ for (let j = 0; j < message.resourceMeta.length; ++j)
+ object.resourceMeta[j] = $root.RnResourceMeta.toObject(message.resourceMeta[j], options);
+ }
+ if (message.networkErrorInfo != null && message.hasOwnProperty("networkErrorInfo"))
+ object.networkErrorInfo = $root.RnNetworkErrorInfo.toObject(message.networkErrorInfo, options);
+ return object;
+ };
+
+ /**
+ * Converts this RnVideoResourceTiming to JSON.
+ * @function toJSON
+ * @memberof RnVideoResourceTiming
+ * @instance
+ * @returns {Object.} JSON object
+ */
+ RnVideoResourceTiming.prototype.toJSON = function toJSON() {
+ return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
+ };
+
+ /**
+ * Gets the default type url for RnVideoResourceTiming
+ * @function getTypeUrl
+ * @memberof RnVideoResourceTiming
+ * @static
+ * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
+ * @returns {string} The default type url
+ */
+ RnVideoResourceTiming.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
+ if (typeUrlPrefix === undefined) {
+ typeUrlPrefix = "type.googleapis.com";
+ }
+ return typeUrlPrefix + "/RnVideoResourceTiming";
+ };
+
+ return RnVideoResourceTiming;
+})();
+
+export const RnNetworkErrorInfo = $root.RnNetworkErrorInfo = (() => {
+
+ /**
+ * Properties of a RnNetworkErrorInfo.
+ * @exports IRnNetworkErrorInfo
+ * @interface IRnNetworkErrorInfo
+ * @property {number|null} [status] RnNetworkErrorInfo status
+ * @property {string|null} [info] RnNetworkErrorInfo info
+ */
+
+ /**
+ * Constructs a new RnNetworkErrorInfo.
+ * @exports RnNetworkErrorInfo
+ * @classdesc Represents a RnNetworkErrorInfo.
+ * @implements IRnNetworkErrorInfo
+ * @constructor
+ * @param {IRnNetworkErrorInfo=} [properties] Properties to set
+ */
+ function RnNetworkErrorInfo(properties) {
+ if (properties)
+ for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
+ if (properties[keys[i]] != null)
+ this[keys[i]] = properties[keys[i]];
+ }
+
+ /**
+ * RnNetworkErrorInfo status.
+ * @member {number} status
+ * @memberof RnNetworkErrorInfo
+ * @instance
+ */
+ RnNetworkErrorInfo.prototype.status = 0;
+
+ /**
+ * RnNetworkErrorInfo info.
+ * @member {string} info
+ * @memberof RnNetworkErrorInfo
+ * @instance
+ */
+ RnNetworkErrorInfo.prototype.info = "";
+
+ /**
+ * Creates a new RnNetworkErrorInfo instance using the specified properties.
+ * @function create
+ * @memberof RnNetworkErrorInfo
+ * @static
+ * @param {IRnNetworkErrorInfo=} [properties] Properties to set
+ * @returns {RnNetworkErrorInfo} RnNetworkErrorInfo instance
+ */
+ RnNetworkErrorInfo.create = function create(properties) {
+ return new RnNetworkErrorInfo(properties);
+ };
+
+ /**
+ * Encodes the specified RnNetworkErrorInfo message. Does not implicitly {@link RnNetworkErrorInfo.verify|verify} messages.
+ * @function encode
+ * @memberof RnNetworkErrorInfo
+ * @static
+ * @param {IRnNetworkErrorInfo} message RnNetworkErrorInfo message or plain object to encode
+ * @param {$protobuf.Writer} [writer] Writer to encode to
+ * @returns {$protobuf.Writer} Writer
+ */
+ RnNetworkErrorInfo.encode = function encode(message, writer) {
+ if (!writer)
+ writer = $Writer.create();
+ if (message.status != null && Object.hasOwnProperty.call(message, "status"))
+ writer.uint32(/* id 1, wireType 0 =*/8).int32(message.status);
+ if (message.info != null && Object.hasOwnProperty.call(message, "info"))
+ writer.uint32(/* id 2, wireType 2 =*/18).string(message.info);
+ return writer;
+ };
+
+ /**
+ * Encodes the specified RnNetworkErrorInfo message, length delimited. Does not implicitly {@link RnNetworkErrorInfo.verify|verify} messages.
+ * @function encodeDelimited
+ * @memberof RnNetworkErrorInfo
+ * @static
+ * @param {IRnNetworkErrorInfo} message RnNetworkErrorInfo message or plain object to encode
+ * @param {$protobuf.Writer} [writer] Writer to encode to
+ * @returns {$protobuf.Writer} Writer
+ */
+ RnNetworkErrorInfo.encodeDelimited = function encodeDelimited(message, writer) {
+ return this.encode(message, writer).ldelim();
+ };
+
+ /**
+ * Decodes a RnNetworkErrorInfo message from the specified reader or buffer.
+ * @function decode
+ * @memberof RnNetworkErrorInfo
+ * @static
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
+ * @param {number} [length] Message length if known beforehand
+ * @returns {RnNetworkErrorInfo} RnNetworkErrorInfo
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ RnNetworkErrorInfo.decode = function decode(reader, length) {
+ if (!(reader instanceof $Reader))
+ reader = $Reader.create(reader);
+ let end = length === undefined ? reader.len : reader.pos + length, message = new $root.RnNetworkErrorInfo();
+ while (reader.pos < end) {
+ let tag = reader.uint32();
+ switch (tag >>> 3) {
+ case 1: {
+ message.status = reader.int32();
+ break;
+ }
+ case 2: {
+ message.info = reader.string();
+ break;
+ }
+ default:
+ reader.skipType(tag & 7);
+ break;
+ }
+ }
+ return message;
+ };
+
+ /**
+ * Decodes a RnNetworkErrorInfo message from the specified reader or buffer, length delimited.
+ * @function decodeDelimited
+ * @memberof RnNetworkErrorInfo
+ * @static
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
+ * @returns {RnNetworkErrorInfo} RnNetworkErrorInfo
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ RnNetworkErrorInfo.decodeDelimited = function decodeDelimited(reader) {
+ if (!(reader instanceof $Reader))
+ reader = new $Reader(reader);
+ return this.decode(reader, reader.uint32());
+ };
+
+ /**
+ * Verifies a RnNetworkErrorInfo message.
+ * @function verify
+ * @memberof RnNetworkErrorInfo
+ * @static
+ * @param {Object.} message Plain object to verify
+ * @returns {string|null} `null` if valid, otherwise the reason why it is not
+ */
+ RnNetworkErrorInfo.verify = function verify(message) {
+ if (typeof message !== "object" || message === null)
+ return "object expected";
+ if (message.status != null && message.hasOwnProperty("status"))
+ if (!$util.isInteger(message.status))
+ return "status: integer expected";
+ if (message.info != null && message.hasOwnProperty("info"))
+ if (!$util.isString(message.info))
+ return "info: string expected";
+ return null;
+ };
+
+ /**
+ * Creates a RnNetworkErrorInfo message from a plain object. Also converts values to their respective internal types.
+ * @function fromObject
+ * @memberof RnNetworkErrorInfo
+ * @static
+ * @param {Object.} object Plain object
+ * @returns {RnNetworkErrorInfo} RnNetworkErrorInfo
+ */
+ RnNetworkErrorInfo.fromObject = function fromObject(object) {
+ if (object instanceof $root.RnNetworkErrorInfo)
+ return object;
+ let message = new $root.RnNetworkErrorInfo();
+ if (object.status != null)
+ message.status = object.status | 0;
+ if (object.info != null)
+ message.info = String(object.info);
+ return message;
+ };
+
+ /**
+ * Creates a plain object from a RnNetworkErrorInfo message. Also converts values to other types if specified.
+ * @function toObject
+ * @memberof RnNetworkErrorInfo
+ * @static
+ * @param {RnNetworkErrorInfo} message RnNetworkErrorInfo
+ * @param {$protobuf.IConversionOptions} [options] Conversion options
+ * @returns {Object.} Plain object
+ */
+ RnNetworkErrorInfo.toObject = function toObject(message, options) {
+ if (!options)
+ options = {};
+ let object = {};
+ if (options.defaults) {
+ object.status = 0;
+ object.info = "";
+ }
+ if (message.status != null && message.hasOwnProperty("status"))
+ object.status = message.status;
+ if (message.info != null && message.hasOwnProperty("info"))
+ object.info = message.info;
+ return object;
+ };
+
+ /**
+ * Converts this RnNetworkErrorInfo to JSON.
+ * @function toJSON
+ * @memberof RnNetworkErrorInfo
+ * @instance
+ * @returns {Object.} JSON object
+ */
+ RnNetworkErrorInfo.prototype.toJSON = function toJSON() {
+ return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
+ };
+
+ /**
+ * Gets the default type url for RnNetworkErrorInfo
+ * @function getTypeUrl
+ * @memberof RnNetworkErrorInfo
+ * @static
+ * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
+ * @returns {string} The default type url
+ */
+ RnNetworkErrorInfo.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
+ if (typeUrlPrefix === undefined) {
+ typeUrlPrefix = "type.googleapis.com";
+ }
+ return typeUrlPrefix + "/RnNetworkErrorInfo";
+ };
+
+ return RnNetworkErrorInfo;
+})();
+
+export const RnLocation = $root.RnLocation = (() => {
+
+ /**
+ * Properties of a RnLocation.
+ * @exports IRnLocation
+ * @interface IRnLocation
+ * @property {string|null} [hash] RnLocation hash
+ * @property {string|null} [host] RnLocation host
+ * @property {string|null} [hostname] RnLocation hostname
+ * @property {string|null} [href] RnLocation href
+ * @property {string|null} [origin] RnLocation origin
+ * @property {string|null} [pathname] RnLocation pathname
+ * @property {string|null} [port] RnLocation port
+ * @property {string|null} [protocol] RnLocation protocol
+ * @property {string|null} [search] RnLocation search
+ */
+
+ /**
+ * Constructs a new RnLocation.
+ * @exports RnLocation
+ * @classdesc Represents a RnLocation.
+ * @implements IRnLocation
+ * @constructor
+ * @param {IRnLocation=} [properties] Properties to set
+ */
+ function RnLocation(properties) {
+ if (properties)
+ for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
+ if (properties[keys[i]] != null)
+ this[keys[i]] = properties[keys[i]];
+ }
+
+ /**
+ * RnLocation hash.
+ * @member {string} hash
+ * @memberof RnLocation
+ * @instance
+ */
+ RnLocation.prototype.hash = "";
+
+ /**
+ * RnLocation host.
+ * @member {string} host
+ * @memberof RnLocation
+ * @instance
+ */
+ RnLocation.prototype.host = "";
+
+ /**
+ * RnLocation hostname.
+ * @member {string} hostname
+ * @memberof RnLocation
+ * @instance
+ */
+ RnLocation.prototype.hostname = "";
+
+ /**
+ * RnLocation href.
+ * @member {string} href
+ * @memberof RnLocation
+ * @instance
+ */
+ RnLocation.prototype.href = "";
+
+ /**
+ * RnLocation origin.
+ * @member {string} origin
+ * @memberof RnLocation
+ * @instance
+ */
+ RnLocation.prototype.origin = "";
+
+ /**
+ * RnLocation pathname.
+ * @member {string} pathname
+ * @memberof RnLocation
+ * @instance
+ */
+ RnLocation.prototype.pathname = "";
+
+ /**
+ * RnLocation port.
+ * @member {string} port
+ * @memberof RnLocation
+ * @instance
+ */
+ RnLocation.prototype.port = "";
+
+ /**
+ * RnLocation protocol.
+ * @member {string} protocol
+ * @memberof RnLocation
+ * @instance
+ */
+ RnLocation.prototype.protocol = "";
+
+ /**
+ * RnLocation search.
+ * @member {string} search
+ * @memberof RnLocation
+ * @instance
+ */
+ RnLocation.prototype.search = "";
+
+ /**
+ * Creates a new RnLocation instance using the specified properties.
+ * @function create
+ * @memberof RnLocation
+ * @static
+ * @param {IRnLocation=} [properties] Properties to set
+ * @returns {RnLocation} RnLocation instance
+ */
+ RnLocation.create = function create(properties) {
+ return new RnLocation(properties);
+ };
+
+ /**
+ * Encodes the specified RnLocation message. Does not implicitly {@link RnLocation.verify|verify} messages.
+ * @function encode
+ * @memberof RnLocation
+ * @static
+ * @param {IRnLocation} message RnLocation message or plain object to encode
+ * @param {$protobuf.Writer} [writer] Writer to encode to
+ * @returns {$protobuf.Writer} Writer
+ */
+ RnLocation.encode = function encode(message, writer) {
+ if (!writer)
+ writer = $Writer.create();
+ if (message.hash != null && Object.hasOwnProperty.call(message, "hash"))
+ writer.uint32(/* id 1, wireType 2 =*/10).string(message.hash);
+ if (message.host != null && Object.hasOwnProperty.call(message, "host"))
+ writer.uint32(/* id 2, wireType 2 =*/18).string(message.host);
+ if (message.hostname != null && Object.hasOwnProperty.call(message, "hostname"))
+ writer.uint32(/* id 3, wireType 2 =*/26).string(message.hostname);
+ if (message.href != null && Object.hasOwnProperty.call(message, "href"))
+ writer.uint32(/* id 4, wireType 2 =*/34).string(message.href);
+ if (message.origin != null && Object.hasOwnProperty.call(message, "origin"))
+ writer.uint32(/* id 5, wireType 2 =*/42).string(message.origin);
+ if (message.pathname != null && Object.hasOwnProperty.call(message, "pathname"))
+ writer.uint32(/* id 6, wireType 2 =*/50).string(message.pathname);
+ if (message.port != null && Object.hasOwnProperty.call(message, "port"))
+ writer.uint32(/* id 7, wireType 2 =*/58).string(message.port);
+ if (message.protocol != null && Object.hasOwnProperty.call(message, "protocol"))
+ writer.uint32(/* id 8, wireType 2 =*/66).string(message.protocol);
+ if (message.search != null && Object.hasOwnProperty.call(message, "search"))
+ writer.uint32(/* id 9, wireType 2 =*/74).string(message.search);
+ return writer;
+ };
+
+ /**
+ * Encodes the specified RnLocation message, length delimited. Does not implicitly {@link RnLocation.verify|verify} messages.
+ * @function encodeDelimited
+ * @memberof RnLocation
+ * @static
+ * @param {IRnLocation} message RnLocation message or plain object to encode
+ * @param {$protobuf.Writer} [writer] Writer to encode to
+ * @returns {$protobuf.Writer} Writer
+ */
+ RnLocation.encodeDelimited = function encodeDelimited(message, writer) {
+ return this.encode(message, writer).ldelim();
+ };
+
+ /**
+ * Decodes a RnLocation message from the specified reader or buffer.
+ * @function decode
+ * @memberof RnLocation
+ * @static
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
+ * @param {number} [length] Message length if known beforehand
+ * @returns {RnLocation} RnLocation
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ RnLocation.decode = function decode(reader, length) {
+ if (!(reader instanceof $Reader))
+ reader = $Reader.create(reader);
+ let end = length === undefined ? reader.len : reader.pos + length, message = new $root.RnLocation();
+ while (reader.pos < end) {
+ let tag = reader.uint32();
+ switch (tag >>> 3) {
+ case 1: {
+ message.hash = reader.string();
+ break;
+ }
+ case 2: {
+ message.host = reader.string();
+ break;
+ }
+ case 3: {
+ message.hostname = reader.string();
+ break;
+ }
+ case 4: {
+ message.href = reader.string();
+ break;
+ }
+ case 5: {
+ message.origin = reader.string();
+ break;
+ }
+ case 6: {
+ message.pathname = reader.string();
+ break;
+ }
+ case 7: {
+ message.port = reader.string();
+ break;
+ }
+ case 8: {
+ message.protocol = reader.string();
+ break;
+ }
+ case 9: {
+ message.search = reader.string();
+ break;
+ }
+ default:
+ reader.skipType(tag & 7);
+ break;
+ }
+ }
+ return message;
+ };
+
+ /**
+ * Decodes a RnLocation message from the specified reader or buffer, length delimited.
+ * @function decodeDelimited
+ * @memberof RnLocation
+ * @static
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
+ * @returns {RnLocation} RnLocation
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ RnLocation.decodeDelimited = function decodeDelimited(reader) {
+ if (!(reader instanceof $Reader))
+ reader = new $Reader(reader);
+ return this.decode(reader, reader.uint32());
+ };
+
+ /**
+ * Verifies a RnLocation message.
+ * @function verify
+ * @memberof RnLocation
+ * @static
+ * @param {Object.} message Plain object to verify
+ * @returns {string|null} `null` if valid, otherwise the reason why it is not
+ */
+ RnLocation.verify = function verify(message) {
+ if (typeof message !== "object" || message === null)
+ return "object expected";
+ if (message.hash != null && message.hasOwnProperty("hash"))
+ if (!$util.isString(message.hash))
+ return "hash: string expected";
+ if (message.host != null && message.hasOwnProperty("host"))
+ if (!$util.isString(message.host))
+ return "host: string expected";
+ if (message.hostname != null && message.hasOwnProperty("hostname"))
+ if (!$util.isString(message.hostname))
+ return "hostname: string expected";
+ if (message.href != null && message.hasOwnProperty("href"))
+ if (!$util.isString(message.href))
+ return "href: string expected";
+ if (message.origin != null && message.hasOwnProperty("origin"))
+ if (!$util.isString(message.origin))
+ return "origin: string expected";
+ if (message.pathname != null && message.hasOwnProperty("pathname"))
+ if (!$util.isString(message.pathname))
+ return "pathname: string expected";
+ if (message.port != null && message.hasOwnProperty("port"))
+ if (!$util.isString(message.port))
+ return "port: string expected";
+ if (message.protocol != null && message.hasOwnProperty("protocol"))
+ if (!$util.isString(message.protocol))
+ return "protocol: string expected";
+ if (message.search != null && message.hasOwnProperty("search"))
+ if (!$util.isString(message.search))
+ return "search: string expected";
+ return null;
+ };
+
+ /**
+ * Creates a RnLocation message from a plain object. Also converts values to their respective internal types.
+ * @function fromObject
+ * @memberof RnLocation
+ * @static
+ * @param {Object.} object Plain object
+ * @returns {RnLocation} RnLocation
+ */
+ RnLocation.fromObject = function fromObject(object) {
+ if (object instanceof $root.RnLocation)
+ return object;
+ let message = new $root.RnLocation();
+ if (object.hash != null)
+ message.hash = String(object.hash);
+ if (object.host != null)
+ message.host = String(object.host);
+ if (object.hostname != null)
+ message.hostname = String(object.hostname);
+ if (object.href != null)
+ message.href = String(object.href);
+ if (object.origin != null)
+ message.origin = String(object.origin);
+ if (object.pathname != null)
+ message.pathname = String(object.pathname);
+ if (object.port != null)
+ message.port = String(object.port);
+ if (object.protocol != null)
+ message.protocol = String(object.protocol);
+ if (object.search != null)
+ message.search = String(object.search);
+ return message;
+ };
+
+ /**
+ * Creates a plain object from a RnLocation message. Also converts values to other types if specified.
+ * @function toObject
+ * @memberof RnLocation
+ * @static
+ * @param {RnLocation} message RnLocation
+ * @param {$protobuf.IConversionOptions} [options] Conversion options
+ * @returns {Object.} Plain object
+ */
+ RnLocation.toObject = function toObject(message, options) {
+ if (!options)
+ options = {};
+ let object = {};
+ if (options.defaults) {
+ object.hash = "";
+ object.host = "";
+ object.hostname = "";
+ object.href = "";
+ object.origin = "";
+ object.pathname = "";
+ object.port = "";
+ object.protocol = "";
+ object.search = "";
+ }
+ if (message.hash != null && message.hasOwnProperty("hash"))
+ object.hash = message.hash;
+ if (message.host != null && message.hasOwnProperty("host"))
+ object.host = message.host;
+ if (message.hostname != null && message.hasOwnProperty("hostname"))
+ object.hostname = message.hostname;
+ if (message.href != null && message.hasOwnProperty("href"))
+ object.href = message.href;
+ if (message.origin != null && message.hasOwnProperty("origin"))
+ object.origin = message.origin;
+ if (message.pathname != null && message.hasOwnProperty("pathname"))
+ object.pathname = message.pathname;
+ if (message.port != null && message.hasOwnProperty("port"))
+ object.port = message.port;
+ if (message.protocol != null && message.hasOwnProperty("protocol"))
+ object.protocol = message.protocol;
+ if (message.search != null && message.hasOwnProperty("search"))
+ object.search = message.search;
+ return object;
+ };
+
+ /**
+ * Converts this RnLocation to JSON.
+ * @function toJSON
+ * @memberof RnLocation
+ * @instance
+ * @returns {Object.} JSON object
+ */
+ RnLocation.prototype.toJSON = function toJSON() {
+ return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
+ };
+
+ /**
+ * Gets the default type url for RnLocation
+ * @function getTypeUrl
+ * @memberof RnLocation
+ * @static
+ * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
+ * @returns {string} The default type url
+ */
+ RnLocation.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
+ if (typeUrlPrefix === undefined) {
+ typeUrlPrefix = "type.googleapis.com";
+ }
+ return typeUrlPrefix + "/RnLocation";
+ };
+
+ return RnLocation;
+})();
+
+export const RnVideoResolution = $root.RnVideoResolution = (() => {
+
+ /**
+ * Properties of a RnVideoResolution.
+ * @exports IRnVideoResolution
+ * @interface IRnVideoResolution
+ * @property {number|null} [width] RnVideoResolution width
+ * @property {number|null} [height] RnVideoResolution height
+ * @property {string|null} [orientation] RnVideoResolution orientation
+ */
+
+ /**
+ * Constructs a new RnVideoResolution.
+ * @exports RnVideoResolution
+ * @classdesc Represents a RnVideoResolution.
+ * @implements IRnVideoResolution
+ * @constructor
+ * @param {IRnVideoResolution=} [properties] Properties to set
+ */
+ function RnVideoResolution(properties) {
+ if (properties)
+ for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
+ if (properties[keys[i]] != null)
+ this[keys[i]] = properties[keys[i]];
+ }
+
+ /**
+ * RnVideoResolution width.
+ * @member {number} width
+ * @memberof RnVideoResolution
+ * @instance
+ */
+ RnVideoResolution.prototype.width = 0;
+
+ /**
+ * RnVideoResolution height.
+ * @member {number} height
+ * @memberof RnVideoResolution
+ * @instance
+ */
+ RnVideoResolution.prototype.height = 0;
+
+ /**
+ * RnVideoResolution orientation.
+ * @member {string} orientation
+ * @memberof RnVideoResolution
+ * @instance
+ */
+ RnVideoResolution.prototype.orientation = "";
+
+ /**
+ * Creates a new RnVideoResolution instance using the specified properties.
+ * @function create
+ * @memberof RnVideoResolution
+ * @static
+ * @param {IRnVideoResolution=} [properties] Properties to set
+ * @returns {RnVideoResolution} RnVideoResolution instance
+ */
+ RnVideoResolution.create = function create(properties) {
+ return new RnVideoResolution(properties);
+ };
+
+ /**
+ * Encodes the specified RnVideoResolution message. Does not implicitly {@link RnVideoResolution.verify|verify} messages.
+ * @function encode
+ * @memberof RnVideoResolution
+ * @static
+ * @param {IRnVideoResolution} message RnVideoResolution message or plain object to encode
+ * @param {$protobuf.Writer} [writer] Writer to encode to
+ * @returns {$protobuf.Writer} Writer
+ */
+ RnVideoResolution.encode = function encode(message, writer) {
+ if (!writer)
+ writer = $Writer.create();
+ if (message.width != null && Object.hasOwnProperty.call(message, "width"))
+ writer.uint32(/* id 1, wireType 1 =*/9).double(message.width);
+ if (message.height != null && Object.hasOwnProperty.call(message, "height"))
+ writer.uint32(/* id 2, wireType 1 =*/17).double(message.height);
+ if (message.orientation != null && Object.hasOwnProperty.call(message, "orientation"))
+ writer.uint32(/* id 3, wireType 2 =*/26).string(message.orientation);
+ return writer;
+ };
+
+ /**
+ * Encodes the specified RnVideoResolution message, length delimited. Does not implicitly {@link RnVideoResolution.verify|verify} messages.
+ * @function encodeDelimited
+ * @memberof RnVideoResolution
+ * @static
+ * @param {IRnVideoResolution} message RnVideoResolution message or plain object to encode
+ * @param {$protobuf.Writer} [writer] Writer to encode to
+ * @returns {$protobuf.Writer} Writer
+ */
+ RnVideoResolution.encodeDelimited = function encodeDelimited(message, writer) {
+ return this.encode(message, writer).ldelim();
+ };
+
+ /**
+ * Decodes a RnVideoResolution message from the specified reader or buffer.
+ * @function decode
+ * @memberof RnVideoResolution
+ * @static
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
+ * @param {number} [length] Message length if known beforehand
+ * @returns {RnVideoResolution} RnVideoResolution
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ RnVideoResolution.decode = function decode(reader, length) {
+ if (!(reader instanceof $Reader))
+ reader = $Reader.create(reader);
+ let end = length === undefined ? reader.len : reader.pos + length, message = new $root.RnVideoResolution();
+ while (reader.pos < end) {
+ let tag = reader.uint32();
+ switch (tag >>> 3) {
+ case 1: {
+ message.width = reader.double();
+ break;
+ }
+ case 2: {
+ message.height = reader.double();
+ break;
+ }
+ case 3: {
+ message.orientation = reader.string();
+ break;
+ }
+ default:
+ reader.skipType(tag & 7);
+ break;
+ }
+ }
+ return message;
+ };
+
+ /**
+ * Decodes a RnVideoResolution message from the specified reader or buffer, length delimited.
+ * @function decodeDelimited
+ * @memberof RnVideoResolution
+ * @static
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
+ * @returns {RnVideoResolution} RnVideoResolution
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ RnVideoResolution.decodeDelimited = function decodeDelimited(reader) {
+ if (!(reader instanceof $Reader))
+ reader = new $Reader(reader);
+ return this.decode(reader, reader.uint32());
+ };
+
+ /**
+ * Verifies a RnVideoResolution message.
+ * @function verify
+ * @memberof RnVideoResolution
+ * @static
+ * @param {Object.} message Plain object to verify
+ * @returns {string|null} `null` if valid, otherwise the reason why it is not
+ */
+ RnVideoResolution.verify = function verify(message) {
+ if (typeof message !== "object" || message === null)
+ return "object expected";
+ if (message.width != null && message.hasOwnProperty("width"))
+ if (typeof message.width !== "number")
+ return "width: number expected";
+ if (message.height != null && message.hasOwnProperty("height"))
+ if (typeof message.height !== "number")
+ return "height: number expected";
+ if (message.orientation != null && message.hasOwnProperty("orientation"))
+ if (!$util.isString(message.orientation))
+ return "orientation: string expected";
+ return null;
+ };
+
+ /**
+ * Creates a RnVideoResolution message from a plain object. Also converts values to their respective internal types.
+ * @function fromObject
+ * @memberof RnVideoResolution
+ * @static
+ * @param {Object.} object Plain object
+ * @returns {RnVideoResolution} RnVideoResolution
+ */
+ RnVideoResolution.fromObject = function fromObject(object) {
+ if (object instanceof $root.RnVideoResolution)
+ return object;
+ let message = new $root.RnVideoResolution();
+ if (object.width != null)
+ message.width = Number(object.width);
+ if (object.height != null)
+ message.height = Number(object.height);
+ if (object.orientation != null)
+ message.orientation = String(object.orientation);
+ return message;
+ };
+
+ /**
+ * Creates a plain object from a RnVideoResolution message. Also converts values to other types if specified.
+ * @function toObject
+ * @memberof RnVideoResolution
+ * @static
+ * @param {RnVideoResolution} message RnVideoResolution
+ * @param {$protobuf.IConversionOptions} [options] Conversion options
+ * @returns {Object.} Plain object
+ */
+ RnVideoResolution.toObject = function toObject(message, options) {
+ if (!options)
+ options = {};
+ let object = {};
+ if (options.defaults) {
+ object.width = 0;
+ object.height = 0;
+ object.orientation = "";
+ }
+ if (message.width != null && message.hasOwnProperty("width"))
+ object.width = options.json && !isFinite(message.width) ? String(message.width) : message.width;
+ if (message.height != null && message.hasOwnProperty("height"))
+ object.height = options.json && !isFinite(message.height) ? String(message.height) : message.height;
+ if (message.orientation != null && message.hasOwnProperty("orientation"))
+ object.orientation = message.orientation;
+ return object;
+ };
+
+ /**
+ * Converts this RnVideoResolution to JSON.
+ * @function toJSON
+ * @memberof RnVideoResolution
+ * @instance
+ * @returns {Object.} JSON object
+ */
+ RnVideoResolution.prototype.toJSON = function toJSON() {
+ return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
+ };
+
+ /**
+ * Gets the default type url for RnVideoResolution
+ * @function getTypeUrl
+ * @memberof RnVideoResolution
+ * @static
+ * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
+ * @returns {string} The default type url
+ */
+ RnVideoResolution.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
+ if (typeUrlPrefix === undefined) {
+ typeUrlPrefix = "type.googleapis.com";
+ }
+ return typeUrlPrefix + "/RnVideoResolution";
+ };
+
+ return RnVideoResolution;
+})();
+
+export const RnVideoLoadingTiming = $root.RnVideoLoadingTiming = (() => {
+
+ /**
+ * Properties of a RnVideoLoadingTiming.
+ * @exports IRnVideoLoadingTiming
+ * @interface IRnVideoLoadingTiming
+ * @property {number|null} [loadStart] RnVideoLoadingTiming loadStart
+ * @property {number|null} [canPlay] RnVideoLoadingTiming canPlay
+ * @property {number|null} [bufferTime] RnVideoLoadingTiming bufferTime
+ * @property {number|null} [playTime] RnVideoLoadingTiming playTime
+ */
+
+ /**
+ * Constructs a new RnVideoLoadingTiming.
+ * @exports RnVideoLoadingTiming
+ * @classdesc Represents a RnVideoLoadingTiming.
+ * @implements IRnVideoLoadingTiming
+ * @constructor
+ * @param {IRnVideoLoadingTiming=} [properties] Properties to set
+ */
+ function RnVideoLoadingTiming(properties) {
+ if (properties)
+ for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
+ if (properties[keys[i]] != null)
+ this[keys[i]] = properties[keys[i]];
+ }
+
+ /**
+ * RnVideoLoadingTiming loadStart.
+ * @member {number} loadStart
+ * @memberof RnVideoLoadingTiming
+ * @instance
+ */
+ RnVideoLoadingTiming.prototype.loadStart = 0;
+
+ /**
+ * RnVideoLoadingTiming canPlay.
+ * @member {number} canPlay
+ * @memberof RnVideoLoadingTiming
+ * @instance
+ */
+ RnVideoLoadingTiming.prototype.canPlay = 0;
+
+ /**
+ * RnVideoLoadingTiming bufferTime.
+ * @member {number} bufferTime
+ * @memberof RnVideoLoadingTiming
+ * @instance
+ */
+ RnVideoLoadingTiming.prototype.bufferTime = 0;
+
+ /**
+ * RnVideoLoadingTiming playTime.
+ * @member {number} playTime
+ * @memberof RnVideoLoadingTiming
+ * @instance
+ */
+ RnVideoLoadingTiming.prototype.playTime = 0;
+
+ /**
+ * Creates a new RnVideoLoadingTiming instance using the specified properties.
+ * @function create
+ * @memberof RnVideoLoadingTiming
+ * @static
+ * @param {IRnVideoLoadingTiming=} [properties] Properties to set
+ * @returns {RnVideoLoadingTiming} RnVideoLoadingTiming instance
+ */
+ RnVideoLoadingTiming.create = function create(properties) {
+ return new RnVideoLoadingTiming(properties);
+ };
+
+ /**
+ * Encodes the specified RnVideoLoadingTiming message. Does not implicitly {@link RnVideoLoadingTiming.verify|verify} messages.
+ * @function encode
+ * @memberof RnVideoLoadingTiming
+ * @static
+ * @param {IRnVideoLoadingTiming} message RnVideoLoadingTiming message or plain object to encode
+ * @param {$protobuf.Writer} [writer] Writer to encode to
+ * @returns {$protobuf.Writer} Writer
+ */
+ RnVideoLoadingTiming.encode = function encode(message, writer) {
+ if (!writer)
+ writer = $Writer.create();
+ if (message.loadStart != null && Object.hasOwnProperty.call(message, "loadStart"))
+ writer.uint32(/* id 1, wireType 1 =*/9).double(message.loadStart);
+ if (message.canPlay != null && Object.hasOwnProperty.call(message, "canPlay"))
+ writer.uint32(/* id 2, wireType 1 =*/17).double(message.canPlay);
+ if (message.bufferTime != null && Object.hasOwnProperty.call(message, "bufferTime"))
+ writer.uint32(/* id 3, wireType 1 =*/25).double(message.bufferTime);
+ if (message.playTime != null && Object.hasOwnProperty.call(message, "playTime"))
+ writer.uint32(/* id 4, wireType 1 =*/33).double(message.playTime);
+ return writer;
+ };
+
+ /**
+ * Encodes the specified RnVideoLoadingTiming message, length delimited. Does not implicitly {@link RnVideoLoadingTiming.verify|verify} messages.
+ * @function encodeDelimited
+ * @memberof RnVideoLoadingTiming
+ * @static
+ * @param {IRnVideoLoadingTiming} message RnVideoLoadingTiming message or plain object to encode
+ * @param {$protobuf.Writer} [writer] Writer to encode to
+ * @returns {$protobuf.Writer} Writer
+ */
+ RnVideoLoadingTiming.encodeDelimited = function encodeDelimited(message, writer) {
+ return this.encode(message, writer).ldelim();
+ };
+
+ /**
+ * Decodes a RnVideoLoadingTiming message from the specified reader or buffer.
+ * @function decode
+ * @memberof RnVideoLoadingTiming
+ * @static
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
+ * @param {number} [length] Message length if known beforehand
+ * @returns {RnVideoLoadingTiming} RnVideoLoadingTiming
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ RnVideoLoadingTiming.decode = function decode(reader, length) {
+ if (!(reader instanceof $Reader))
+ reader = $Reader.create(reader);
+ let end = length === undefined ? reader.len : reader.pos + length, message = new $root.RnVideoLoadingTiming();
+ while (reader.pos < end) {
+ let tag = reader.uint32();
+ switch (tag >>> 3) {
+ case 1: {
+ message.loadStart = reader.double();
+ break;
+ }
+ case 2: {
+ message.canPlay = reader.double();
+ break;
+ }
+ case 3: {
+ message.bufferTime = reader.double();
+ break;
+ }
+ case 4: {
+ message.playTime = reader.double();
+ break;
+ }
+ default:
+ reader.skipType(tag & 7);
+ break;
+ }
+ }
+ return message;
+ };
+
+ /**
+ * Decodes a RnVideoLoadingTiming message from the specified reader or buffer, length delimited.
+ * @function decodeDelimited
+ * @memberof RnVideoLoadingTiming
+ * @static
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
+ * @returns {RnVideoLoadingTiming} RnVideoLoadingTiming
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ RnVideoLoadingTiming.decodeDelimited = function decodeDelimited(reader) {
+ if (!(reader instanceof $Reader))
+ reader = new $Reader(reader);
+ return this.decode(reader, reader.uint32());
+ };
+
+ /**
+ * Verifies a RnVideoLoadingTiming message.
+ * @function verify
+ * @memberof RnVideoLoadingTiming
+ * @static
+ * @param {Object.} message Plain object to verify
+ * @returns {string|null} `null` if valid, otherwise the reason why it is not
+ */
+ RnVideoLoadingTiming.verify = function verify(message) {
+ if (typeof message !== "object" || message === null)
+ return "object expected";
+ if (message.loadStart != null && message.hasOwnProperty("loadStart"))
+ if (typeof message.loadStart !== "number")
+ return "loadStart: number expected";
+ if (message.canPlay != null && message.hasOwnProperty("canPlay"))
+ if (typeof message.canPlay !== "number")
+ return "canPlay: number expected";
+ if (message.bufferTime != null && message.hasOwnProperty("bufferTime"))
+ if (typeof message.bufferTime !== "number")
+ return "bufferTime: number expected";
+ if (message.playTime != null && message.hasOwnProperty("playTime"))
+ if (typeof message.playTime !== "number")
+ return "playTime: number expected";
+ return null;
+ };
+
+ /**
+ * Creates a RnVideoLoadingTiming message from a plain object. Also converts values to their respective internal types.
+ * @function fromObject
+ * @memberof RnVideoLoadingTiming
+ * @static
+ * @param {Object.} object Plain object
+ * @returns {RnVideoLoadingTiming} RnVideoLoadingTiming
+ */
+ RnVideoLoadingTiming.fromObject = function fromObject(object) {
+ if (object instanceof $root.RnVideoLoadingTiming)
+ return object;
+ let message = new $root.RnVideoLoadingTiming();
+ if (object.loadStart != null)
+ message.loadStart = Number(object.loadStart);
+ if (object.canPlay != null)
+ message.canPlay = Number(object.canPlay);
+ if (object.bufferTime != null)
+ message.bufferTime = Number(object.bufferTime);
+ if (object.playTime != null)
+ message.playTime = Number(object.playTime);
+ return message;
+ };
+
+ /**
+ * Creates a plain object from a RnVideoLoadingTiming message. Also converts values to other types if specified.
+ * @function toObject
+ * @memberof RnVideoLoadingTiming
+ * @static
+ * @param {RnVideoLoadingTiming} message RnVideoLoadingTiming
+ * @param {$protobuf.IConversionOptions} [options] Conversion options
+ * @returns {Object.} Plain object
+ */
+ RnVideoLoadingTiming.toObject = function toObject(message, options) {
+ if (!options)
+ options = {};
+ let object = {};
+ if (options.defaults) {
+ object.loadStart = 0;
+ object.canPlay = 0;
+ object.bufferTime = 0;
+ object.playTime = 0;
+ }
+ if (message.loadStart != null && message.hasOwnProperty("loadStart"))
+ object.loadStart = options.json && !isFinite(message.loadStart) ? String(message.loadStart) : message.loadStart;
+ if (message.canPlay != null && message.hasOwnProperty("canPlay"))
+ object.canPlay = options.json && !isFinite(message.canPlay) ? String(message.canPlay) : message.canPlay;
+ if (message.bufferTime != null && message.hasOwnProperty("bufferTime"))
+ object.bufferTime = options.json && !isFinite(message.bufferTime) ? String(message.bufferTime) : message.bufferTime;
+ if (message.playTime != null && message.hasOwnProperty("playTime"))
+ object.playTime = options.json && !isFinite(message.playTime) ? String(message.playTime) : message.playTime;
+ return object;
+ };
+
+ /**
+ * Converts this RnVideoLoadingTiming to JSON.
+ * @function toJSON
+ * @memberof RnVideoLoadingTiming
+ * @instance
+ * @returns {Object.} JSON object
+ */
+ RnVideoLoadingTiming.prototype.toJSON = function toJSON() {
+ return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
+ };
+
+ /**
+ * Gets the default type url for RnVideoLoadingTiming
+ * @function getTypeUrl
+ * @memberof RnVideoLoadingTiming
+ * @static
+ * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
+ * @returns {string} The default type url
+ */
+ RnVideoLoadingTiming.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
+ if (typeUrlPrefix === undefined) {
+ typeUrlPrefix = "type.googleapis.com";
+ }
+ return typeUrlPrefix + "/RnVideoLoadingTiming";
+ };
+
+ return RnVideoLoadingTiming;
+})();
+
+export const RnResourceMeta = $root.RnResourceMeta = (() => {
+
+ /**
+ * Properties of a RnResourceMeta.
+ * @exports IRnResourceMeta
+ * @interface IRnResourceMeta
+ * @property {string|null} [type] RnResourceMeta type
+ * @property {string|null} [value] RnResourceMeta value
+ */
+
+ /**
+ * Constructs a new RnResourceMeta.
+ * @exports RnResourceMeta
+ * @classdesc Represents a RnResourceMeta.
+ * @implements IRnResourceMeta
+ * @constructor
+ * @param {IRnResourceMeta=} [properties] Properties to set
+ */
+ function RnResourceMeta(properties) {
+ if (properties)
+ for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
+ if (properties[keys[i]] != null)
+ this[keys[i]] = properties[keys[i]];
+ }
+
+ /**
+ * RnResourceMeta type.
+ * @member {string} type
+ * @memberof RnResourceMeta
+ * @instance
+ */
+ RnResourceMeta.prototype.type = "";
+
+ /**
+ * RnResourceMeta value.
+ * @member {string} value
+ * @memberof RnResourceMeta
+ * @instance
+ */
+ RnResourceMeta.prototype.value = "";
+
+ /**
+ * Creates a new RnResourceMeta instance using the specified properties.
+ * @function create
+ * @memberof RnResourceMeta
+ * @static
+ * @param {IRnResourceMeta=} [properties] Properties to set
+ * @returns {RnResourceMeta} RnResourceMeta instance
+ */
+ RnResourceMeta.create = function create(properties) {
+ return new RnResourceMeta(properties);
+ };
+
+ /**
+ * Encodes the specified RnResourceMeta message. Does not implicitly {@link RnResourceMeta.verify|verify} messages.
+ * @function encode
+ * @memberof RnResourceMeta
+ * @static
+ * @param {IRnResourceMeta} message RnResourceMeta message or plain object to encode
+ * @param {$protobuf.Writer} [writer] Writer to encode to
+ * @returns {$protobuf.Writer} Writer
+ */
+ RnResourceMeta.encode = function encode(message, writer) {
+ if (!writer)
+ writer = $Writer.create();
+ if (message.type != null && Object.hasOwnProperty.call(message, "type"))
+ writer.uint32(/* id 1, wireType 2 =*/10).string(message.type);
+ if (message.value != null && Object.hasOwnProperty.call(message, "value"))
+ writer.uint32(/* id 2, wireType 2 =*/18).string(message.value);
+ return writer;
+ };
+
+ /**
+ * Encodes the specified RnResourceMeta message, length delimited. Does not implicitly {@link RnResourceMeta.verify|verify} messages.
+ * @function encodeDelimited
+ * @memberof RnResourceMeta
+ * @static
+ * @param {IRnResourceMeta} message RnResourceMeta message or plain object to encode
+ * @param {$protobuf.Writer} [writer] Writer to encode to
+ * @returns {$protobuf.Writer} Writer
+ */
+ RnResourceMeta.encodeDelimited = function encodeDelimited(message, writer) {
+ return this.encode(message, writer).ldelim();
+ };
+
+ /**
+ * Decodes a RnResourceMeta message from the specified reader or buffer.
+ * @function decode
+ * @memberof RnResourceMeta
+ * @static
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
+ * @param {number} [length] Message length if known beforehand
+ * @returns {RnResourceMeta} RnResourceMeta
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ RnResourceMeta.decode = function decode(reader, length) {
+ if (!(reader instanceof $Reader))
+ reader = $Reader.create(reader);
+ let end = length === undefined ? reader.len : reader.pos + length, message = new $root.RnResourceMeta();
+ while (reader.pos < end) {
+ let tag = reader.uint32();
+ switch (tag >>> 3) {
+ case 1: {
+ message.type = reader.string();
+ break;
+ }
+ case 2: {
+ message.value = reader.string();
+ break;
+ }
+ default:
+ reader.skipType(tag & 7);
+ break;
+ }
+ }
+ return message;
+ };
+
+ /**
+ * Decodes a RnResourceMeta message from the specified reader or buffer, length delimited.
+ * @function decodeDelimited
+ * @memberof RnResourceMeta
+ * @static
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
+ * @returns {RnResourceMeta} RnResourceMeta
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ RnResourceMeta.decodeDelimited = function decodeDelimited(reader) {
+ if (!(reader instanceof $Reader))
+ reader = new $Reader(reader);
+ return this.decode(reader, reader.uint32());
+ };
+
+ /**
+ * Verifies a RnResourceMeta message.
+ * @function verify
+ * @memberof RnResourceMeta
+ * @static
+ * @param {Object.} message Plain object to verify
+ * @returns {string|null} `null` if valid, otherwise the reason why it is not
+ */
+ RnResourceMeta.verify = function verify(message) {
+ if (typeof message !== "object" || message === null)
+ return "object expected";
+ if (message.type != null && message.hasOwnProperty("type"))
+ if (!$util.isString(message.type))
+ return "type: string expected";
+ if (message.value != null && message.hasOwnProperty("value"))
+ if (!$util.isString(message.value))
+ return "value: string expected";
+ return null;
+ };
+
+ /**
+ * Creates a RnResourceMeta message from a plain object. Also converts values to their respective internal types.
+ * @function fromObject
+ * @memberof RnResourceMeta
+ * @static
+ * @param {Object.} object Plain object
+ * @returns {RnResourceMeta} RnResourceMeta
+ */
+ RnResourceMeta.fromObject = function fromObject(object) {
+ if (object instanceof $root.RnResourceMeta)
+ return object;
+ let message = new $root.RnResourceMeta();
+ if (object.type != null)
+ message.type = String(object.type);
+ if (object.value != null)
+ message.value = String(object.value);
+ return message;
+ };
+
+ /**
+ * Creates a plain object from a RnResourceMeta message. Also converts values to other types if specified.
+ * @function toObject
+ * @memberof RnResourceMeta
+ * @static
+ * @param {RnResourceMeta} message RnResourceMeta
+ * @param {$protobuf.IConversionOptions} [options] Conversion options
+ * @returns {Object.} Plain object
+ */
+ RnResourceMeta.toObject = function toObject(message, options) {
+ if (!options)
+ options = {};
+ let object = {};
+ if (options.defaults) {
+ object.type = "";
+ object.value = "";
+ }
+ if (message.type != null && message.hasOwnProperty("type"))
+ object.type = message.type;
+ if (message.value != null && message.hasOwnProperty("value"))
+ object.value = message.value;
+ return object;
+ };
+
+ /**
+ * Converts this RnResourceMeta to JSON.
+ * @function toJSON
+ * @memberof RnResourceMeta
+ * @instance
+ * @returns {Object.} JSON object
+ */
+ RnResourceMeta.prototype.toJSON = function toJSON() {
+ return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
+ };
+
+ /**
+ * Gets the default type url for RnResourceMeta
+ * @function getTypeUrl
+ * @memberof RnResourceMeta
+ * @static
+ * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
+ * @returns {string} The default type url
+ */
+ RnResourceMeta.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
+ if (typeUrlPrefix === undefined) {
+ typeUrlPrefix = "type.googleapis.com";
+ }
+ return typeUrlPrefix + "/RnResourceMeta";
+ };
+
+ return RnResourceMeta;
+})();
+
+export const RnRouteNotFound = $root.RnRouteNotFound = (() => {
+
+ /**
+ * Properties of a RnRouteNotFound.
+ * @exports IRnRouteNotFound
+ * @interface IRnRouteNotFound
+ * @property {string|null} [prevPageUrl] RnRouteNotFound prevPageUrl
+ * @property {string|null} [firstPageUrl] RnRouteNotFound firstPageUrl
+ * @property {string|null} [prevRoutePath] RnRouteNotFound prevRoutePath
+ * @property {string|null} [targetRouteName] RnRouteNotFound targetRouteName
+ */
+
+ /**
+ * Constructs a new RnRouteNotFound.
+ * @exports RnRouteNotFound
+ * @classdesc Represents a RnRouteNotFound.
+ * @implements IRnRouteNotFound
+ * @constructor
+ * @param {IRnRouteNotFound=} [properties] Properties to set
+ */
+ function RnRouteNotFound(properties) {
+ if (properties)
+ for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
+ if (properties[keys[i]] != null)
+ this[keys[i]] = properties[keys[i]];
+ }
+
+ /**
+ * RnRouteNotFound prevPageUrl.
+ * @member {string} prevPageUrl
+ * @memberof RnRouteNotFound
+ * @instance
+ */
+ RnRouteNotFound.prototype.prevPageUrl = "";
+
+ /**
+ * RnRouteNotFound firstPageUrl.
+ * @member {string} firstPageUrl
+ * @memberof RnRouteNotFound
+ * @instance
+ */
+ RnRouteNotFound.prototype.firstPageUrl = "";
+
+ /**
+ * RnRouteNotFound prevRoutePath.
+ * @member {string} prevRoutePath
+ * @memberof RnRouteNotFound
+ * @instance
+ */
+ RnRouteNotFound.prototype.prevRoutePath = "";
+
+ /**
+ * RnRouteNotFound targetRouteName.
+ * @member {string} targetRouteName
+ * @memberof RnRouteNotFound
+ * @instance
+ */
+ RnRouteNotFound.prototype.targetRouteName = "";
+
+ /**
+ * Creates a new RnRouteNotFound instance using the specified properties.
+ * @function create
+ * @memberof RnRouteNotFound
+ * @static
+ * @param {IRnRouteNotFound=} [properties] Properties to set
+ * @returns {RnRouteNotFound} RnRouteNotFound instance
+ */
+ RnRouteNotFound.create = function create(properties) {
+ return new RnRouteNotFound(properties);
+ };
+
+ /**
+ * Encodes the specified RnRouteNotFound message. Does not implicitly {@link RnRouteNotFound.verify|verify} messages.
+ * @function encode
+ * @memberof RnRouteNotFound
+ * @static
+ * @param {IRnRouteNotFound} message RnRouteNotFound message or plain object to encode
+ * @param {$protobuf.Writer} [writer] Writer to encode to
+ * @returns {$protobuf.Writer} Writer
+ */
+ RnRouteNotFound.encode = function encode(message, writer) {
+ if (!writer)
+ writer = $Writer.create();
+ if (message.prevPageUrl != null && Object.hasOwnProperty.call(message, "prevPageUrl"))
+ writer.uint32(/* id 1, wireType 2 =*/10).string(message.prevPageUrl);
+ if (message.firstPageUrl != null && Object.hasOwnProperty.call(message, "firstPageUrl"))
+ writer.uint32(/* id 2, wireType 2 =*/18).string(message.firstPageUrl);
+ if (message.prevRoutePath != null && Object.hasOwnProperty.call(message, "prevRoutePath"))
+ writer.uint32(/* id 3, wireType 2 =*/26).string(message.prevRoutePath);
+ if (message.targetRouteName != null && Object.hasOwnProperty.call(message, "targetRouteName"))
+ writer.uint32(/* id 4, wireType 2 =*/34).string(message.targetRouteName);
+ return writer;
+ };
+
+ /**
+ * Encodes the specified RnRouteNotFound message, length delimited. Does not implicitly {@link RnRouteNotFound.verify|verify} messages.
+ * @function encodeDelimited
+ * @memberof RnRouteNotFound
+ * @static
+ * @param {IRnRouteNotFound} message RnRouteNotFound message or plain object to encode
+ * @param {$protobuf.Writer} [writer] Writer to encode to
+ * @returns {$protobuf.Writer} Writer
+ */
+ RnRouteNotFound.encodeDelimited = function encodeDelimited(message, writer) {
+ return this.encode(message, writer).ldelim();
+ };
+
+ /**
+ * Decodes a RnRouteNotFound message from the specified reader or buffer.
+ * @function decode
+ * @memberof RnRouteNotFound
+ * @static
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
+ * @param {number} [length] Message length if known beforehand
+ * @returns {RnRouteNotFound} RnRouteNotFound
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ RnRouteNotFound.decode = function decode(reader, length) {
+ if (!(reader instanceof $Reader))
+ reader = $Reader.create(reader);
+ let end = length === undefined ? reader.len : reader.pos + length, message = new $root.RnRouteNotFound();
+ while (reader.pos < end) {
+ let tag = reader.uint32();
+ switch (tag >>> 3) {
+ case 1: {
+ message.prevPageUrl = reader.string();
+ break;
+ }
+ case 2: {
+ message.firstPageUrl = reader.string();
+ break;
+ }
+ case 3: {
+ message.prevRoutePath = reader.string();
+ break;
+ }
+ case 4: {
+ message.targetRouteName = reader.string();
+ break;
+ }
+ default:
+ reader.skipType(tag & 7);
+ break;
+ }
+ }
+ return message;
+ };
+
+ /**
+ * Decodes a RnRouteNotFound message from the specified reader or buffer, length delimited.
+ * @function decodeDelimited
+ * @memberof RnRouteNotFound
+ * @static
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
+ * @returns {RnRouteNotFound} RnRouteNotFound
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ RnRouteNotFound.decodeDelimited = function decodeDelimited(reader) {
+ if (!(reader instanceof $Reader))
+ reader = new $Reader(reader);
+ return this.decode(reader, reader.uint32());
+ };
+
+ /**
+ * Verifies a RnRouteNotFound message.
+ * @function verify
+ * @memberof RnRouteNotFound
+ * @static
+ * @param {Object.} message Plain object to verify
+ * @returns {string|null} `null` if valid, otherwise the reason why it is not
+ */
+ RnRouteNotFound.verify = function verify(message) {
+ if (typeof message !== "object" || message === null)
+ return "object expected";
+ if (message.prevPageUrl != null && message.hasOwnProperty("prevPageUrl"))
+ if (!$util.isString(message.prevPageUrl))
+ return "prevPageUrl: string expected";
+ if (message.firstPageUrl != null && message.hasOwnProperty("firstPageUrl"))
+ if (!$util.isString(message.firstPageUrl))
+ return "firstPageUrl: string expected";
+ if (message.prevRoutePath != null && message.hasOwnProperty("prevRoutePath"))
+ if (!$util.isString(message.prevRoutePath))
+ return "prevRoutePath: string expected";
+ if (message.targetRouteName != null && message.hasOwnProperty("targetRouteName"))
+ if (!$util.isString(message.targetRouteName))
+ return "targetRouteName: string expected";
+ return null;
+ };
+
+ /**
+ * Creates a RnRouteNotFound message from a plain object. Also converts values to their respective internal types.
+ * @function fromObject
+ * @memberof RnRouteNotFound
+ * @static
+ * @param {Object.} object Plain object
+ * @returns {RnRouteNotFound} RnRouteNotFound
+ */
+ RnRouteNotFound.fromObject = function fromObject(object) {
+ if (object instanceof $root.RnRouteNotFound)
+ return object;
+ let message = new $root.RnRouteNotFound();
+ if (object.prevPageUrl != null)
+ message.prevPageUrl = String(object.prevPageUrl);
+ if (object.firstPageUrl != null)
+ message.firstPageUrl = String(object.firstPageUrl);
+ if (object.prevRoutePath != null)
+ message.prevRoutePath = String(object.prevRoutePath);
+ if (object.targetRouteName != null)
+ message.targetRouteName = String(object.targetRouteName);
+ return message;
+ };
+
+ /**
+ * Creates a plain object from a RnRouteNotFound message. Also converts values to other types if specified.
+ * @function toObject
+ * @memberof RnRouteNotFound
+ * @static
+ * @param {RnRouteNotFound} message RnRouteNotFound
+ * @param {$protobuf.IConversionOptions} [options] Conversion options
+ * @returns {Object.} Plain object
+ */
+ RnRouteNotFound.toObject = function toObject(message, options) {
+ if (!options)
+ options = {};
+ let object = {};
+ if (options.defaults) {
+ object.prevPageUrl = "";
+ object.firstPageUrl = "";
+ object.prevRoutePath = "";
+ object.targetRouteName = "";
+ }
+ if (message.prevPageUrl != null && message.hasOwnProperty("prevPageUrl"))
+ object.prevPageUrl = message.prevPageUrl;
+ if (message.firstPageUrl != null && message.hasOwnProperty("firstPageUrl"))
+ object.firstPageUrl = message.firstPageUrl;
+ if (message.prevRoutePath != null && message.hasOwnProperty("prevRoutePath"))
+ object.prevRoutePath = message.prevRoutePath;
+ if (message.targetRouteName != null && message.hasOwnProperty("targetRouteName"))
+ object.targetRouteName = message.targetRouteName;
+ return object;
+ };
+
+ /**
+ * Converts this RnRouteNotFound to JSON.
+ * @function toJSON
+ * @memberof RnRouteNotFound
+ * @instance
+ * @returns {Object.} JSON object
+ */
+ RnRouteNotFound.prototype.toJSON = function toJSON() {
+ return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
+ };
+
+ /**
+ * Gets the default type url for RnRouteNotFound
+ * @function getTypeUrl
+ * @memberof RnRouteNotFound
+ * @static
+ * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
+ * @returns {string} The default type url
+ */
+ RnRouteNotFound.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
+ if (typeUrlPrefix === undefined) {
+ typeUrlPrefix = "type.googleapis.com";
+ }
+ return typeUrlPrefix + "/RnRouteNotFound";
+ };
+
+ return RnRouteNotFound;
+})();
+
+export { $root as default };
diff --git a/OpenHarmony/entry/src/ohosTest/ets/test/user.d.ts b/OpenHarmony/entry/src/ohosTest/ets/test/user.d.ts
new file mode 100644
index 000000000..4839da456
--- /dev/null
+++ b/OpenHarmony/entry/src/ohosTest/ets/test/user.d.ts
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 2022 Huawei Device Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import * as $protobuf from "@ohos/protobufjs";
+import Long from 'long';
+/** Namespace user. */
+export namespace user {
+
+ /** Properties of a UserLoginResponse. */
+ interface IUserLoginResponse {
+
+ /** UserLoginResponse sessionId */
+ sessionId?: (string|null);
+
+ /** UserLoginResponse userPrivilege */
+ userPrivilege?: (string|null);
+
+ /** UserLoginResponse isTokenType */
+ isTokenType?: (boolean|null);
+
+ /** UserLoginResponse formatTimestamp */
+ formatTimestamp?: (number|Long|BigInt|null);
+
+ /** UserLoginResponse data */
+ data?: (Uint8Array|null);
+ }
+
+ /** Represents a UserLoginResponse. */
+ class UserLoginResponse implements IUserLoginResponse {
+
+ /**
+ * Constructs a new UserLoginResponse.
+ * @param [properties] Properties to set
+ */
+ constructor(properties?: user.IUserLoginResponse);
+
+ /** UserLoginResponse sessionId. */
+ public sessionId: string;
+
+ /** UserLoginResponse userPrivilege. */
+ public userPrivilege: string;
+
+ /** UserLoginResponse isTokenType. */
+ public isTokenType: boolean;
+
+ /** UserLoginResponse formatTimestamp. */
+ public formatTimestamp: (number|Long|BigInt);
+
+ /** UserLoginResponse data. */
+ public data: Uint8Array;
+
+ /**
+ * Creates a new UserLoginResponse instance using the specified properties.
+ * @param [properties] Properties to set
+ * @returns UserLoginResponse instance
+ */
+ public static create(properties?: user.IUserLoginResponse): user.UserLoginResponse;
+
+ /**
+ * Encodes the specified UserLoginResponse message. Does not implicitly {@link user.UserLoginResponse.verify|verify} messages.
+ * @param message UserLoginResponse message or plain object to encode
+ * @param [writer] Writer to encode to
+ * @returns Writer
+ */
+ public static encode(message: user.IUserLoginResponse, writer?: $protobuf.Writer): $protobuf.Writer;
+
+ /**
+ * Encodes the specified UserLoginResponse message, length delimited. Does not implicitly {@link user.UserLoginResponse.verify|verify} messages.
+ * @param message UserLoginResponse message or plain object to encode
+ * @param [writer] Writer to encode to
+ * @returns Writer
+ */
+ public static encodeDelimited(message: user.IUserLoginResponse, writer?: $protobuf.Writer): $protobuf.Writer;
+
+ /**
+ * Decodes a UserLoginResponse message from the specified reader or buffer.
+ * @param reader Reader or buffer to decode from
+ * @param [length] Message length if known beforehand
+ * @returns UserLoginResponse
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): user.UserLoginResponse;
+
+ /**
+ * Decodes a UserLoginResponse message from the specified reader or buffer, length delimited.
+ * @param reader Reader or buffer to decode from
+ * @returns UserLoginResponse
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): user.UserLoginResponse;
+
+ /**
+ * Verifies a UserLoginResponse message.
+ * @param message Plain object to verify
+ * @returns `null` if valid, otherwise the reason why it is not
+ */
+ public static verify(message: { [k: string]: any }): (string|null);
+
+ /**
+ * Creates a UserLoginResponse message from a plain object. Also converts values to their respective internal types.
+ * @param object Plain object
+ * @returns UserLoginResponse
+ */
+ public static fromObject(object: { [k: string]: any }): user.UserLoginResponse;
+
+ /**
+ * Creates a plain object from a UserLoginResponse message. Also converts values to other types if specified.
+ * @param message UserLoginResponse
+ * @param [options] Conversion options
+ * @returns Plain object
+ */
+ public static toObject(message: user.UserLoginResponse, options?: $protobuf.IConversionOptions): { [k: string]: any };
+
+ /**
+ * Converts this UserLoginResponse to JSON.
+ * @returns JSON object
+ */
+ public toJSON(): { [k: string]: any };
+
+ /**
+ * Gets the default type url for UserLoginResponse
+ * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
+ * @returns The default type url
+ */
+ public static getTypeUrl(typeUrlPrefix?: string): string;
+ }
+}
diff --git a/OpenHarmony/entry/src/ohosTest/ets/test/user.js b/OpenHarmony/entry/src/ohosTest/ets/test/user.js
new file mode 100644
index 000000000..136bd0d2f
--- /dev/null
+++ b/OpenHarmony/entry/src/ohosTest/ets/test/user.js
@@ -0,0 +1,356 @@
+/*
+ * Copyright (c) 2022 Huawei Device Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import $protobuf from "@ohos/protobufjs";
+$protobuf.util.Long=undefined
+$protobuf.configure()
+// Common aliases
+const $Reader = $protobuf.Reader, $Writer = $protobuf.Writer, $util = $protobuf.util;
+
+// Exported root namespace
+const $root = $protobuf.roots["default"] || ($protobuf.roots["default"] = {});
+
+export const user = $root.user = (() => {
+
+ /**
+ * Namespace user.
+ * @exports user
+ * @namespace
+ */
+ const user = {};
+
+ user.UserLoginResponse = (function() {
+
+ /**
+ * Properties of a UserLoginResponse.
+ * @memberof user
+ * @interface IUserLoginResponse
+ * @property {string|null} [sessionId] UserLoginResponse sessionId
+ * @property {string|null} [userPrivilege] UserLoginResponse userPrivilege
+ * @property {boolean|null} [isTokenType] UserLoginResponse isTokenType
+ * @property {number|Long|null} [formatTimestamp] UserLoginResponse formatTimestamp
+ * @property {Uint8Array|null} [data] UserLoginResponse data
+ */
+
+ /**
+ * Constructs a new UserLoginResponse.
+ * @memberof user
+ * @classdesc Represents a UserLoginResponse.
+ * @implements IUserLoginResponse
+ * @constructor
+ * @param {user.IUserLoginResponse=} [properties] Properties to set
+ */
+ function UserLoginResponse(properties) {
+ if (properties)
+ for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
+ if (properties[keys[i]] != null)
+ this[keys[i]] = properties[keys[i]];
+ }
+
+ /**
+ * UserLoginResponse sessionId.
+ * @member {string} sessionId
+ * @memberof user.UserLoginResponse
+ * @instance
+ */
+ UserLoginResponse.prototype.sessionId = "";
+
+ /**
+ * UserLoginResponse userPrivilege.
+ * @member {string} userPrivilege
+ * @memberof user.UserLoginResponse
+ * @instance
+ */
+ UserLoginResponse.prototype.userPrivilege = "";
+
+ /**
+ * UserLoginResponse isTokenType.
+ * @member {boolean} isTokenType
+ * @memberof user.UserLoginResponse
+ * @instance
+ */
+ UserLoginResponse.prototype.isTokenType = false;
+
+ /**
+ * UserLoginResponse formatTimestamp.
+ * @member {number|Long} formatTimestamp
+ * @memberof user.UserLoginResponse
+ * @instance
+ */
+ UserLoginResponse.prototype.formatTimestamp = $util.Long ? $util.Long.fromBits(0,0,false) : 0;
+
+ /**
+ * UserLoginResponse data.
+ * @member {Uint8Array} data
+ * @memberof user.UserLoginResponse
+ * @instance
+ */
+ UserLoginResponse.prototype.data = $util.newBuffer([]);
+
+ /**
+ * Creates a new UserLoginResponse instance using the specified properties.
+ * @function create
+ * @memberof user.UserLoginResponse
+ * @static
+ * @param {user.IUserLoginResponse=} [properties] Properties to set
+ * @returns {user.UserLoginResponse} UserLoginResponse instance
+ */
+ UserLoginResponse.create = function create(properties) {
+ return new UserLoginResponse(properties);
+ };
+
+ /**
+ * Encodes the specified UserLoginResponse message. Does not implicitly {@link user.UserLoginResponse.verify|verify} messages.
+ * @function encode
+ * @memberof user.UserLoginResponse
+ * @static
+ * @param {user.IUserLoginResponse} message UserLoginResponse message or plain object to encode
+ * @param {$protobuf.Writer} [writer] Writer to encode to
+ * @returns {$protobuf.Writer} Writer
+ */
+ UserLoginResponse.encode = function encode(message, writer) {
+ if (!writer)
+ writer = $Writer.create();
+ if (message.sessionId != null && Object.hasOwnProperty.call(message, "sessionId"))
+ writer.uint32(/* id 1, wireType 2 =*/10).string(message.sessionId);
+ if (message.userPrivilege != null && Object.hasOwnProperty.call(message, "userPrivilege"))
+ writer.uint32(/* id 2, wireType 2 =*/18).string(message.userPrivilege);
+ if (message.isTokenType != null && Object.hasOwnProperty.call(message, "isTokenType"))
+ writer.uint32(/* id 3, wireType 0 =*/24).bool(message.isTokenType);
+ if (message.formatTimestamp != null && Object.hasOwnProperty.call(message, "formatTimestamp"))
+ writer.uint32(/* id 5, wireType 0 =*/40).int64(message.formatTimestamp);
+ if (message.data != null && Object.hasOwnProperty.call(message, "data"))
+ writer.uint32(/* id 6, wireType 2 =*/50).bytes(message.data);
+ return writer;
+ };
+
+ /**
+ * Encodes the specified UserLoginResponse message, length delimited. Does not implicitly {@link user.UserLoginResponse.verify|verify} messages.
+ * @function encodeDelimited
+ * @memberof user.UserLoginResponse
+ * @static
+ * @param {user.IUserLoginResponse} message UserLoginResponse message or plain object to encode
+ * @param {$protobuf.Writer} [writer] Writer to encode to
+ * @returns {$protobuf.Writer} Writer
+ */
+ UserLoginResponse.encodeDelimited = function encodeDelimited(message, writer) {
+ return this.encode(message, writer).ldelim();
+ };
+
+ /**
+ * Decodes a UserLoginResponse message from the specified reader or buffer.
+ * @function decode
+ * @memberof user.UserLoginResponse
+ * @static
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
+ * @param {number} [length] Message length if known beforehand
+ * @returns {user.UserLoginResponse} UserLoginResponse
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ UserLoginResponse.decode = function decode(reader, length) {
+ if (!(reader instanceof $Reader))
+ reader = $Reader.create(reader);
+ let end = length === undefined ? reader.len : reader.pos + length, message = new $root.user.UserLoginResponse();
+ while (reader.pos < end) {
+ let tag = reader.uint32();
+ switch (tag >>> 3) {
+ case 1: {
+ message.sessionId = reader.string();
+ break;
+ }
+ case 2: {
+ message.userPrivilege = reader.string();
+ break;
+ }
+ case 3: {
+ message.isTokenType = reader.bool();
+ break;
+ }
+ case 5: {
+ message.formatTimestamp = reader.int64();
+ break;
+ }
+ case 6: {
+ message.data = reader.bytes();
+ break;
+ }
+ default:
+ reader.skipType(tag & 7);
+ break;
+ }
+ }
+ return message;
+ };
+
+ /**
+ * Decodes a UserLoginResponse message from the specified reader or buffer, length delimited.
+ * @function decodeDelimited
+ * @memberof user.UserLoginResponse
+ * @static
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
+ * @returns {user.UserLoginResponse} UserLoginResponse
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
+ */
+ UserLoginResponse.decodeDelimited = function decodeDelimited(reader) {
+ if (!(reader instanceof $Reader))
+ reader = new $Reader(reader);
+ return this.decode(reader, reader.uint32());
+ };
+
+ /**
+ * Verifies a UserLoginResponse message.
+ * @function verify
+ * @memberof user.UserLoginResponse
+ * @static
+ * @param {Object.} message Plain object to verify
+ * @returns {string|null} `null` if valid, otherwise the reason why it is not
+ */
+ UserLoginResponse.verify = function verify(message) {
+ if (typeof message !== "object" || message === null)
+ return "object expected";
+ if (message.sessionId != null && message.hasOwnProperty("sessionId"))
+ if (!$util.isString(message.sessionId))
+ return "sessionId: string expected";
+ if (message.userPrivilege != null && message.hasOwnProperty("userPrivilege"))
+ if (!$util.isString(message.userPrivilege))
+ return "userPrivilege: string expected";
+ if (message.isTokenType != null && message.hasOwnProperty("isTokenType"))
+ if (typeof message.isTokenType !== "boolean")
+ return "isTokenType: boolean expected";
+ if (message.formatTimestamp != null && message.hasOwnProperty("formatTimestamp"))
+ if (!$util.isInteger(message.formatTimestamp) && !(message.formatTimestamp && $util.isInteger(message.formatTimestamp.low) && $util.isInteger(message.formatTimestamp.high)))
+ return "formatTimestamp: integer|Long expected";
+ if (message.data != null && message.hasOwnProperty("data"))
+ if (!(message.data && typeof message.data.length === "number" || $util.isString(message.data)))
+ return "data: buffer expected";
+ return null;
+ };
+
+ /**
+ * Creates a UserLoginResponse message from a plain object. Also converts values to their respective internal types.
+ * @function fromObject
+ * @memberof user.UserLoginResponse
+ * @static
+ * @param {Object.} object Plain object
+ * @returns {user.UserLoginResponse} UserLoginResponse
+ */
+ UserLoginResponse.fromObject = function fromObject(object) {
+ if (object instanceof $root.user.UserLoginResponse)
+ return object;
+ let message = new $root.user.UserLoginResponse();
+ if (object.sessionId != null)
+ message.sessionId = String(object.sessionId);
+ if (object.userPrivilege != null)
+ message.userPrivilege = String(object.userPrivilege);
+ if (object.isTokenType != null)
+ message.isTokenType = Boolean(object.isTokenType);
+ if (object.formatTimestamp != null)
+ if ($util.Long)
+ (message.formatTimestamp = $util.Long.fromValue(object.formatTimestamp)).unsigned = false;
+ else if (typeof object.formatTimestamp === "string")
+ message.formatTimestamp = parseInt(object.formatTimestamp, 10);
+ else if (typeof object.formatTimestamp === "number")
+ message.formatTimestamp = object.formatTimestamp;
+ else if (typeof object.formatTimestamp === "object")
+ message.formatTimestamp = new $util.LongBits(object.formatTimestamp.low >>> 0, object.formatTimestamp.high >>> 0).toNumber();
+ if (object.data != null)
+ if (typeof object.data === "string")
+ $util.base64.decode(object.data, message.data = $util.newBuffer($util.base64.length(object.data)), 0);
+ else if (object.data.length >= 0)
+ message.data = object.data;
+ return message;
+ };
+
+ /**
+ * Creates a plain object from a UserLoginResponse message. Also converts values to other types if specified.
+ * @function toObject
+ * @memberof user.UserLoginResponse
+ * @static
+ * @param {user.UserLoginResponse} message UserLoginResponse
+ * @param {$protobuf.IConversionOptions} [options] Conversion options
+ * @returns {Object.} Plain object
+ */
+ UserLoginResponse.toObject = function toObject(message, options) {
+ if (!options)
+ options = {};
+ let object = {};
+ if (options.defaults) {
+ object.sessionId = "";
+ object.userPrivilege = "";
+ object.isTokenType = false;
+ if ($util.Long) {
+ let long = new $util.Long(0, 0, false);
+ object.formatTimestamp = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
+ } else
+ object.formatTimestamp = options.longs === String ? "0" : 0;
+ if (options.bytes === String)
+ object.data = "";
+ else {
+ object.data = [];
+ if (options.bytes !== Array)
+ object.data = $util.newBuffer(object.data);
+ }
+ }
+ if (message.sessionId != null && message.hasOwnProperty("sessionId"))
+ object.sessionId = message.sessionId;
+ if (message.userPrivilege != null && message.hasOwnProperty("userPrivilege"))
+ object.userPrivilege = message.userPrivilege;
+ if (message.isTokenType != null && message.hasOwnProperty("isTokenType"))
+ object.isTokenType = message.isTokenType;
+ if (message.formatTimestamp != null && message.hasOwnProperty("formatTimestamp"))
+ if (typeof message.formatTimestamp === "number")
+ object.formatTimestamp = options.longs === String ? String(message.formatTimestamp) : message.formatTimestamp;
+ else
+ object.formatTimestamp = options.longs === String ? $util.Long.prototype.toString.call(message.formatTimestamp) : options.longs === Number ? new $util.LongBits(message.formatTimestamp.low >>> 0, message.formatTimestamp.high >>> 0).toNumber() : message.formatTimestamp;
+ if (message.data != null && message.hasOwnProperty("data"))
+ object.data = options.bytes === String ? $util.base64.encode(message.data, 0, message.data.length) : options.bytes === Array ? Array.prototype.slice.call(message.data) : message.data;
+ return object;
+ };
+
+ /**
+ * Converts this UserLoginResponse to JSON.
+ * @function toJSON
+ * @memberof user.UserLoginResponse
+ * @instance
+ * @returns {Object.} JSON object
+ */
+ UserLoginResponse.prototype.toJSON = function toJSON() {
+ return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
+ };
+
+ /**
+ * Gets the default type url for UserLoginResponse
+ * @function getTypeUrl
+ * @memberof user.UserLoginResponse
+ * @static
+ * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
+ * @returns {string} The default type url
+ */
+ UserLoginResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
+ if (typeUrlPrefix === undefined) {
+ typeUrlPrefix = "type.googleapis.com";
+ }
+ return typeUrlPrefix + "/user.UserLoginResponse";
+ };
+
+ return UserLoginResponse;
+ })();
+
+ return user;
+})();
+
+export { $root as default };
diff --git a/OpenHarmony/entry/src/ohosTest/ets/testability/TestAbility.ets b/OpenHarmony/entry/src/ohosTest/ets/testability/TestAbility.ets
new file mode 100644
index 000000000..a25a8fb82
--- /dev/null
+++ b/OpenHarmony/entry/src/ohosTest/ets/testability/TestAbility.ets
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2022 Huawei Device Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import UIAbility from '@ohos.app.ability.UIAbility';
+import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
+import hilog from '@ohos.hilog';
+import { Hypium } from '@ohos/hypium';
+import testsuite from '../test/List.test';
+import window from '@ohos.window';
+import Want from '@ohos.app.ability.Want';
+import AbilityConstant from '@ohos.app.ability.AbilityConstant';
+
+export default class TestAbility extends UIAbility {
+ onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onCreate');
+ hilog.info(0x0000, 'testTag', '%{public}s', 'want param:' + JSON.stringify(want) ?? '');
+ hilog.info(0x0000, 'testTag', '%{public}s', 'launchParam:'+ JSON.stringify(launchParam) ?? '');
+ let abilityDelegator: ESObject
+ abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
+ let abilityDelegatorArguments: ESObject
+ abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
+ hilog.info(0x0000, 'testTag', '%{public}s', 'start run testcase!!!');
+ Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
+ }
+
+ onDestroy() {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onDestroy');
+ }
+
+ onWindowStageCreate(windowStage: window.WindowStage) {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageCreate');
+ windowStage.loadContent('testability/pages/Index', (err, data) => {
+ if (err.code) {
+ hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
+ return;
+ }
+ hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s',
+ JSON.stringify(data) ?? '');
+ });
+ }
+
+ onWindowStageDestroy() {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageDestroy');
+ }
+
+ onForeground() {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onForeground');
+ }
+
+ onBackground() {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onBackground');
+ }
+}
\ No newline at end of file
diff --git a/OpenHarmony/entry/src/ohosTest/ets/testability/pages/Index.ets b/OpenHarmony/entry/src/ohosTest/ets/testability/pages/Index.ets
new file mode 100644
index 000000000..f4e570018
--- /dev/null
+++ b/OpenHarmony/entry/src/ohosTest/ets/testability/pages/Index.ets
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2022 Huawei Device Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import hilog from '@ohos.hilog';
+
+@Entry
+@Component
+struct Index {
+ aboutToAppear() {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility index aboutToAppear');
+ }
+ @State message: string = 'Hello World'
+ build() {
+ Row() {
+ Column() {
+ Text(this.message)
+ .fontSize(50)
+ .fontWeight(FontWeight.Bold)
+ Button() {
+ Text('next page')
+ .fontSize(20)
+ .fontWeight(FontWeight.Bold)
+ }.type(ButtonType.Capsule)
+ .margin({
+ top: 20
+ })
+ .backgroundColor('#0D9FFB')
+ .width('35%')
+ .height('5%')
+ .onClick(()=>{
+ })
+ }
+ .width('100%')
+ }
+ .height('100%')
+ }
+ }
\ No newline at end of file
diff --git a/OpenHarmony/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts b/OpenHarmony/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts
new file mode 100644
index 000000000..a7b985839
--- /dev/null
+++ b/OpenHarmony/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2022 Huawei Device Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import hilog from '@ohos.hilog';
+import TestRunner from '@ohos.application.testRunner';
+import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
+
+var abilityDelegator = undefined
+var abilityDelegatorArguments = undefined
+
+async function onAbilityCreateCallback() {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'onAbilityCreateCallback');
+}
+
+async function addAbilityMonitorCallback(err: any) {
+ hilog.info(0x0000, 'testTag', 'addAbilityMonitorCallback : %{public}s', JSON.stringify(err) ?? '');
+}
+
+export default class OpenHarmonyTestRunner implements TestRunner {
+ constructor() {
+ }
+
+ onPrepare() {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner OnPrepare ');
+ }
+
+ async onRun() {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun run');
+ abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
+ abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
+ const bundleName = abilityDelegatorArguments.bundleName;
+ const testAbilityName = 'TestAbility';
+ let lMonitor = {
+ abilityName: testAbilityName,
+ onAbilityCreate: onAbilityCreateCallback,
+ };
+ abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback)
+ const want = {
+ bundleName: bundleName,
+ abilityName: testAbilityName
+ };
+ abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
+ abilityDelegator.startAbility(want, (err : any, data : any) => {
+ hilog.info(0x0000, 'testTag', 'startAbility : err : %{public}s', JSON.stringify(err) ?? '');
+ hilog.info(0x0000, 'testTag', 'startAbility : data : %{public}s',JSON.stringify(data) ?? '');
+ })
+ hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun end');
+ }
+}
\ No newline at end of file
diff --git a/OpenHarmony/entry/src/ohosTest/module.json5 b/OpenHarmony/entry/src/ohosTest/module.json5
new file mode 100644
index 000000000..4fc970170
--- /dev/null
+++ b/OpenHarmony/entry/src/ohosTest/module.json5
@@ -0,0 +1,37 @@
+{
+ "module": {
+ "name": "entry_test",
+ "type": "feature",
+ "description": "$string:module_test_desc",
+ "mainElement": "TestAbility",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false,
+ "pages": "$profile:test_pages",
+ "abilities": [
+ {
+ "name": "TestAbility",
+ "srcEntry": "./ets/testability/TestAbility.ets",
+ "description": "$string:TestAbility_desc",
+ "icon": "$media:icon",
+ "label": "$string:TestAbility_label",
+ "exported": true,
+ "startWindowIcon": "$media:icon",
+ "startWindowBackground": "$color:start_window_background",
+ "skills": [
+ {
+ "actions": [
+ "action.system.home"
+ ],
+ "entities": [
+ "entity.system.home"
+ ]
+ }
+ ]
+ }
+ ]
+ }
+}
diff --git a/OpenHarmony/entry/src/ohosTest/resources/base/element/color.json b/OpenHarmony/entry/src/ohosTest/resources/base/element/color.json
new file mode 100644
index 000000000..3c712962d
--- /dev/null
+++ b/OpenHarmony/entry/src/ohosTest/resources/base/element/color.json
@@ -0,0 +1,8 @@
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#FFFFFF"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/OpenHarmony/entry/src/ohosTest/resources/base/element/string.json b/OpenHarmony/entry/src/ohosTest/resources/base/element/string.json
new file mode 100644
index 000000000..65d8fa5a7
--- /dev/null
+++ b/OpenHarmony/entry/src/ohosTest/resources/base/element/string.json
@@ -0,0 +1,16 @@
+{
+ "string": [
+ {
+ "name": "module_test_desc",
+ "value": "test ability description"
+ },
+ {
+ "name": "TestAbility_desc",
+ "value": "the test ability"
+ },
+ {
+ "name": "TestAbility_label",
+ "value": "test label"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/OpenHarmony/entry/src/ohosTest/resources/base/media/icon.png b/OpenHarmony/entry/src/ohosTest/resources/base/media/icon.png
new file mode 100644
index 000000000..ce307a882
Binary files /dev/null and b/OpenHarmony/entry/src/ohosTest/resources/base/media/icon.png differ
diff --git a/OpenHarmony/entry/src/ohosTest/resources/base/profile/test_pages.json b/OpenHarmony/entry/src/ohosTest/resources/base/profile/test_pages.json
new file mode 100644
index 000000000..b7e7343ca
--- /dev/null
+++ b/OpenHarmony/entry/src/ohosTest/resources/base/profile/test_pages.json
@@ -0,0 +1,5 @@
+{
+ "src": [
+ "testability/pages/Index"
+ ]
+}
diff --git a/OpenHarmony/hvigor/hvigor-config.json5 b/OpenHarmony/hvigor/hvigor-config.json5
new file mode 100644
index 000000000..4933e8784
--- /dev/null
+++ b/OpenHarmony/hvigor/hvigor-config.json5
@@ -0,0 +1,18 @@
+{
+ "hvigorVersion": "4.0.5",
+ "dependencies": {
+ "@ohos/hvigor-ohos-plugin": "4.0.5"
+ },
+ "execution": {
+ // "daemon": true, /* Enable daemon compilation. Default: true */
+ // "incremental": true, /* Enable incremental compilation. Default: true */
+ // "parallel": true, /* Enable parallel compilation. Default: true */
+ // "typeCheck": false, /* Enable typeCheck. Default: false */
+ },
+ "logging": {
+ // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */
+ },
+ "debugging": {
+ // "stacktrace": false /* Disable stacktrace compilation. Default: false */
+ }
+}
\ No newline at end of file
diff --git a/OpenHarmony/hvigor/hvigor-wrapper.js b/OpenHarmony/hvigor/hvigor-wrapper.js
new file mode 100644
index 000000000..372eae8eb
--- /dev/null
+++ b/OpenHarmony/hvigor/hvigor-wrapper.js
@@ -0,0 +1 @@
+"use strict";var u=require("path"),D=require("os"),e=require("fs"),t=require("crypto"),r=require("child_process"),n="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},i={},C={},F=n&&n.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(C,"__esModule",{value:!0}),C.maxPathLength=C.isMac=C.isLinux=C.isWindows=void 0;const E=F(D),A="Windows_NT",o="Darwin";function a(){return E.default.type()===A}function c(){return E.default.type()===o}C.isWindows=a,C.isLinux=function(){return"Linux"===E.default.type()},C.isMac=c,C.maxPathLength=function(){return c()?1016:a()?259:4095},function(e){var t=n&&n.__createBinding||(Object.create?function(u,D,e,t){void 0===t&&(t=e);var r=Object.getOwnPropertyDescriptor(D,e);r&&!("get"in r?!D.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return D[e]}}),Object.defineProperty(u,t,r)}:function(u,D,e,t){void 0===t&&(t=e),u[t]=D[e]}),r=n&&n.__setModuleDefault||(Object.create?function(u,D){Object.defineProperty(u,"default",{enumerable:!0,value:D})}:function(u,D){u.default=D}),i=n&&n.__importStar||function(u){if(u&&u.__esModule)return u;var D={};if(null!=u)for(var e in u)"default"!==e&&Object.prototype.hasOwnProperty.call(u,e)&&t(D,u,e);return r(D,u),D};Object.defineProperty(e,"__esModule",{value:!0}),e.WORK_SPACE=e.HVIGOR_PROJECT_WRAPPER_HOME=e.HVIGOR_PROJECT_ROOT_DIR=e.HVIGOR_PROJECT_CACHES_HOME=e.HVIGOR_PNPM_STORE_PATH=e.HVIGOR_WRAPPER_PNPM_SCRIPT_PATH=e.PROJECT_CACHES=e.HVIGOR_WRAPPER_TOOLS_HOME=e.HVIGOR_USER_HOME=e.DEFAULT_PACKAGE_JSON=e.DEFAULT_HVIGOR_CONFIG_JSON_FILE_NAME=e.PNPM=e.HVIGOR=e.NPM_TOOL=e.PNPM_TOOL=e.HVIGOR_ENGINE_PACKAGE_NAME=void 0;const F=i(D),E=i(u),A=C;e.HVIGOR_ENGINE_PACKAGE_NAME="@ohos/hvigor",e.PNPM_TOOL=(0,A.isWindows)()?"pnpm.cmd":"pnpm",e.NPM_TOOL=(0,A.isWindows)()?"npm.cmd":"npm",e.HVIGOR="hvigor",e.PNPM="pnpm",e.DEFAULT_HVIGOR_CONFIG_JSON_FILE_NAME="hvigor-config.json5",e.DEFAULT_PACKAGE_JSON="package.json",e.HVIGOR_USER_HOME=E.resolve(F.homedir(),".hvigor"),e.HVIGOR_WRAPPER_TOOLS_HOME=E.resolve(e.HVIGOR_USER_HOME,"wrapper","tools"),e.PROJECT_CACHES="project_caches",e.HVIGOR_WRAPPER_PNPM_SCRIPT_PATH=E.resolve(e.HVIGOR_WRAPPER_TOOLS_HOME,"node_modules",".bin",e.PNPM_TOOL),e.HVIGOR_PNPM_STORE_PATH=E.resolve(e.HVIGOR_USER_HOME,"caches"),e.HVIGOR_PROJECT_CACHES_HOME=E.resolve(e.HVIGOR_USER_HOME,e.PROJECT_CACHES),e.HVIGOR_PROJECT_ROOT_DIR=process.cwd(),e.HVIGOR_PROJECT_WRAPPER_HOME=E.resolve(e.HVIGOR_PROJECT_ROOT_DIR,e.HVIGOR),e.WORK_SPACE="workspace"}(i);var s={},l={};Object.defineProperty(l,"__esModule",{value:!0}),l.logInfoPrintConsole=l.logErrorAndExit=void 0,l.logErrorAndExit=function(u){u instanceof Error?console.error(u.message):console.error(u),process.exit(-1)},l.logInfoPrintConsole=function(u){console.log(u)};var B=n&&n.__createBinding||(Object.create?function(u,D,e,t){void 0===t&&(t=e);var r=Object.getOwnPropertyDescriptor(D,e);r&&!("get"in r?!D.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return D[e]}}),Object.defineProperty(u,t,r)}:function(u,D,e,t){void 0===t&&(t=e),u[t]=D[e]}),d=n&&n.__setModuleDefault||(Object.create?function(u,D){Object.defineProperty(u,"default",{enumerable:!0,value:D})}:function(u,D){u.default=D}),f=n&&n.__importStar||function(u){if(u&&u.__esModule)return u;var D={};if(null!=u)for(var e in u)"default"!==e&&Object.prototype.hasOwnProperty.call(u,e)&&B(D,u,e);return d(D,u),D};Object.defineProperty(s,"__esModule",{value:!0});var _=s.executeBuild=void 0;const p=f(e),O=f(u),h=l;_=s.executeBuild=function(u){const D=O.resolve(u,"node_modules","@ohos","hvigor","bin","hvigor.js");try{const u=p.realpathSync(D);require(u)}catch(e){(0,h.logErrorAndExit)(`Error: ENOENT: no such file ${D},delete ${u} and retry.`)}};var P={},v={};!function(u){var D=n&&n.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(u,"__esModule",{value:!0}),u.hashFile=u.hash=u.createHash=void 0;const r=D(t),i=D(e);u.createHash=(u="MD5")=>r.default.createHash(u);u.hash=(D,e)=>(0,u.createHash)(e).update(D).digest("hex");u.hashFile=(D,e)=>{if(i.default.existsSync(D))return(0,u.hash)(i.default.readFileSync(D,"utf-8"),e)}}(v);var g={},m={},R={};Object.defineProperty(R,"__esModule",{value:!0}),R.Unicode=void 0;class y{}R.Unicode=y,y.SPACE_SEPARATOR=/[\u1680\u2000-\u200A\u202F\u205F\u3000]/,y.ID_START=/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE83\uDE86-\uDE89\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]/,y.ID_CONTINUE=/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u09FC\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9-\u0AFF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D00-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF9\u1D00-\u1DF9\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDE00-\uDE3E\uDE47\uDE50-\uDE83\uDE86-\uDE99\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD50-\uDD59]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4A\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/,Object.defineProperty(m,"__esModule",{value:!0}),m.JudgeUtil=void 0;const I=R;m.JudgeUtil=class{static isIgnoreChar(u){return"string"==typeof u&&("\t"===u||"\v"===u||"\f"===u||" "===u||" "===u||"\ufeff"===u||"\n"===u||"\r"===u||"\u2028"===u||"\u2029"===u)}static isSpaceSeparator(u){return"string"==typeof u&&I.Unicode.SPACE_SEPARATOR.test(u)}static isIdStartChar(u){return"string"==typeof u&&(u>="a"&&u<="z"||u>="A"&&u<="Z"||"$"===u||"_"===u||I.Unicode.ID_START.test(u))}static isIdContinueChar(u){return"string"==typeof u&&(u>="a"&&u<="z"||u>="A"&&u<="Z"||u>="0"&&u<="9"||"$"===u||"_"===u||""===u||""===u||I.Unicode.ID_CONTINUE.test(u))}static isDigitWithoutZero(u){return/[1-9]/.test(u)}static isDigit(u){return"string"==typeof u&&/[0-9]/.test(u)}static isHexDigit(u){return"string"==typeof u&&/[0-9A-Fa-f]/.test(u)}};var N=n&&n.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(g,"__esModule",{value:!0}),g.parseJsonText=g.parseJsonFile=void 0;const b=N(e),S=N(D),w=N(u),H=m;var x;!function(u){u[u.Char=0]="Char",u[u.EOF=1]="EOF",u[u.Identifier=2]="Identifier"}(x||(x={}));let M,T,V,G,j,J,W="start",U=[],L=0,$=1,k=0,K=!1,z="default",q="'",Z=1;function X(u,D=!1){T=String(u),W="start",U=[],L=0,$=1,k=0,G=void 0,K=D;do{M=Q(),nu[W]()}while("eof"!==M.type);return G}function Q(){for(z="default",j="",q="'",Z=1;;){J=Y();const u=Du[z]();if(u)return u}}function Y(){if(T[L])return String.fromCodePoint(T.codePointAt(L))}function uu(){const u=Y();return"\n"===u?($++,k=0):u?k+=u.length:k++,u&&(L+=u.length),u}g.parseJsonFile=function(u,D=!1,e="utf-8"){const t=b.default.readFileSync(w.default.resolve(u),{encoding:e});try{return X(t,D)}catch(D){if(D instanceof SyntaxError){const e=D.message.split("at");if(2===e.length)throw new Error(`${e[0].trim()}${S.default.EOL}\t at ${u}:${e[1].trim()}`)}throw new Error(`${u} is not in valid JSON/JSON5 format.`)}},g.parseJsonText=X;const Du={default(){switch(J){case"/":return uu(),void(z="comment");case void 0:return uu(),eu("eof")}if(!H.JudgeUtil.isIgnoreChar(J)&&!H.JudgeUtil.isSpaceSeparator(J))return Du[W]();uu()},start(){z="value"},beforePropertyName(){switch(J){case"$":case"_":return j=uu(),void(z="identifierName");case"\\":return uu(),void(z="identifierNameStartEscape");case"}":return eu("punctuator",uu());case'"':case"'":return q=J,uu(),void(z="string")}if(H.JudgeUtil.isIdStartChar(J))return j+=uu(),void(z="identifierName");throw Eu(x.Char,uu())},afterPropertyName(){if(":"===J)return eu("punctuator",uu());throw Eu(x.Char,uu())},beforePropertyValue(){z="value"},afterPropertyValue(){switch(J){case",":case"}":return eu("punctuator",uu())}throw Eu(x.Char,uu())},beforeArrayValue(){if("]"===J)return eu("punctuator",uu());z="value"},afterArrayValue(){switch(J){case",":case"]":return eu("punctuator",uu())}throw Eu(x.Char,uu())},end(){throw Eu(x.Char,uu())},comment(){switch(J){case"*":return uu(),void(z="multiLineComment");case"/":return uu(),void(z="singleLineComment")}throw Eu(x.Char,uu())},multiLineComment(){switch(J){case"*":return uu(),void(z="multiLineCommentAsterisk");case void 0:throw Eu(x.Char,uu())}uu()},multiLineCommentAsterisk(){switch(J){case"*":return void uu();case"/":return uu(),void(z="default");case void 0:throw Eu(x.Char,uu())}uu(),z="multiLineComment"},singleLineComment(){switch(J){case"\n":case"\r":case"\u2028":case"\u2029":return uu(),void(z="default");case void 0:return uu(),eu("eof")}uu()},value(){switch(J){case"{":case"[":return eu("punctuator",uu());case"n":return uu(),tu("ull"),eu("null",null);case"t":return uu(),tu("rue"),eu("boolean",!0);case"f":return uu(),tu("alse"),eu("boolean",!1);case"-":case"+":return"-"===uu()&&(Z=-1),void(z="numerical");case".":case"0":case"I":case"N":return void(z="numerical");case'"':case"'":return q=J,uu(),j="",void(z="string")}if(void 0===J||!H.JudgeUtil.isDigitWithoutZero(J))throw Eu(x.Char,uu());z="numerical"},numerical(){switch(J){case".":return j=uu(),void(z="decimalPointLeading");case"0":return j=uu(),void(z="zero");case"I":return uu(),tu("nfinity"),eu("numeric",Z*(1/0));case"N":return uu(),tu("aN"),eu("numeric",NaN)}if(void 0!==J&&H.JudgeUtil.isDigitWithoutZero(J))return j=uu(),void(z="decimalInteger");throw Eu(x.Char,uu())},zero(){switch(J){case".":case"e":case"E":return void(z="decimal");case"x":case"X":return j+=uu(),void(z="hexadecimal")}return eu("numeric",0)},decimalInteger(){switch(J){case".":case"e":case"E":return void(z="decimal")}if(!H.JudgeUtil.isDigit(J))return eu("numeric",Z*Number(j));j+=uu()},decimal(){switch(J){case".":j+=uu(),z="decimalFraction";break;case"e":case"E":j+=uu(),z="decimalExponent"}},decimalPointLeading(){if(H.JudgeUtil.isDigit(J))return j+=uu(),void(z="decimalFraction");throw Eu(x.Char,uu())},decimalFraction(){switch(J){case"e":case"E":return j+=uu(),void(z="decimalExponent")}if(!H.JudgeUtil.isDigit(J))return eu("numeric",Z*Number(j));j+=uu()},decimalExponent(){switch(J){case"+":case"-":return j+=uu(),void(z="decimalExponentSign")}if(H.JudgeUtil.isDigit(J))return j+=uu(),void(z="decimalExponentInteger");throw Eu(x.Char,uu())},decimalExponentSign(){if(H.JudgeUtil.isDigit(J))return j+=uu(),void(z="decimalExponentInteger");throw Eu(x.Char,uu())},decimalExponentInteger(){if(!H.JudgeUtil.isDigit(J))return eu("numeric",Z*Number(j));j+=uu()},hexadecimal(){if(H.JudgeUtil.isHexDigit(J))return j+=uu(),void(z="hexadecimalInteger");throw Eu(x.Char,uu())},hexadecimalInteger(){if(!H.JudgeUtil.isHexDigit(J))return eu("numeric",Z*Number(j));j+=uu()},identifierNameStartEscape(){if("u"!==J)throw Eu(x.Char,uu());uu();const u=ru();switch(u){case"$":case"_":break;default:if(!H.JudgeUtil.isIdStartChar(u))throw Eu(x.Identifier)}j+=u,z="identifierName"},identifierName(){switch(J){case"$":case"_":case"":case"":return void(j+=uu());case"\\":return uu(),void(z="identifierNameEscape")}if(!H.JudgeUtil.isIdContinueChar(J))return eu("identifier",j);j+=uu()},identifierNameEscape(){if("u"!==J)throw Eu(x.Char,uu());uu();const u=ru();switch(u){case"$":case"_":case"":case"":break;default:if(!H.JudgeUtil.isIdContinueChar(u))throw Eu(x.Identifier)}j+=u,z="identifierName"},string(){switch(J){case"\\":return uu(),void(j+=function(){const u=Y(),D=function(){switch(Y()){case"b":return uu(),"\b";case"f":return uu(),"\f";case"n":return uu(),"\n";case"r":return uu(),"\r";case"t":return uu(),"\t";case"v":return uu(),"\v"}return}();if(D)return D;switch(u){case"0":if(uu(),H.JudgeUtil.isDigit(Y()))throw Eu(x.Char,uu());return"\0";case"x":return uu(),function(){let u="",D=Y();if(!H.JudgeUtil.isHexDigit(D))throw Eu(x.Char,uu());if(u+=uu(),D=Y(),!H.JudgeUtil.isHexDigit(D))throw Eu(x.Char,uu());return u+=uu(),String.fromCodePoint(parseInt(u,16))}();case"u":return uu(),ru();case"\n":case"\u2028":case"\u2029":return uu(),"";case"\r":return uu(),"\n"===Y()&&uu(),""}if(void 0===u||H.JudgeUtil.isDigitWithoutZero(u))throw Eu(x.Char,uu());return uu()}());case'"':case"'":if(J===q){const u=eu("string",j);return uu(),u}return void(j+=uu());case"\n":case"\r":case void 0:throw Eu(x.Char,uu());case"\u2028":case"\u2029":!function(u){console.warn(`JSON5: '${Fu(u)}' in strings is not valid ECMAScript; consider escaping.`)}(J)}j+=uu()}};function eu(u,D){return{type:u,value:D,line:$,column:k}}function tu(u){for(const D of u){if(Y()!==D)throw Eu(x.Char,uu());uu()}}function ru(){let u="",D=4;for(;D-- >0;){const D=Y();if(!H.JudgeUtil.isHexDigit(D))throw Eu(x.Char,uu());u+=uu()}return String.fromCodePoint(parseInt(u,16))}const nu={start(){if("eof"===M.type)throw Eu(x.EOF);iu()},beforePropertyName(){switch(M.type){case"identifier":case"string":return V=M.value,void(W="afterPropertyName");case"punctuator":return void Cu();case"eof":throw Eu(x.EOF)}},afterPropertyName(){if("eof"===M.type)throw Eu(x.EOF);W="beforePropertyValue"},beforePropertyValue(){if("eof"===M.type)throw Eu(x.EOF);iu()},afterPropertyValue(){if("eof"===M.type)throw Eu(x.EOF);switch(M.value){case",":return void(W="beforePropertyName");case"}":Cu()}},beforeArrayValue(){if("eof"===M.type)throw Eu(x.EOF);"punctuator"!==M.type||"]"!==M.value?iu():Cu()},afterArrayValue(){if("eof"===M.type)throw Eu(x.EOF);switch(M.value){case",":return void(W="beforeArrayValue");case"]":Cu()}},end(){}};function iu(){const u=function(){let u;switch(M.type){case"punctuator":switch(M.value){case"{":u={};break;case"[":u=[]}break;case"null":case"boolean":case"numeric":case"string":u=M.value}return u}();if(K&&"object"==typeof u&&(u._line=$,u._column=k),void 0===G)G=u;else{const D=U[U.length-1];Array.isArray(D)?K&&"object"!=typeof u?D.push({value:u,_line:$,_column:k}):D.push(u):D[V]=K&&"object"!=typeof u?{value:u,_line:$,_column:k}:u}!function(u){if(u&&"object"==typeof u)U.push(u),W=Array.isArray(u)?"beforeArrayValue":"beforePropertyName";else{const u=U[U.length-1];W=u?Array.isArray(u)?"afterArrayValue":"afterPropertyValue":"end"}}(u)}function Cu(){U.pop();const u=U[U.length-1];W=u?Array.isArray(u)?"afterArrayValue":"afterPropertyValue":"end"}function Fu(u){const D={"'":"\\'",'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\v":"\\v","\0":"\\0","\u2028":"\\u2028","\u2029":"\\u2029"};if(D[u])return D[u];if(u<" "){const D=u.charCodeAt(0).toString(16);return`\\x${`00${D}`.substring(D.length)}`}return u}function Eu(u,D){let e="";switch(u){case x.Char:e=void 0===D?`JSON5: invalid end of input at ${$}:${k}`:`JSON5: invalid character '${Fu(D)}' at ${$}:${k}`;break;case x.EOF:e=`JSON5: invalid end of input at ${$}:${k}`;break;case x.Identifier:k-=5,e=`JSON5: invalid identifier character at ${$}:${k}`}const t=new Au(e);return t.lineNumber=$,t.columnNumber=k,t}class Au extends SyntaxError{}var ou={},au=n&&n.__createBinding||(Object.create?function(u,D,e,t){void 0===t&&(t=e);var r=Object.getOwnPropertyDescriptor(D,e);r&&!("get"in r?!D.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return D[e]}}),Object.defineProperty(u,t,r)}:function(u,D,e,t){void 0===t&&(t=e),u[t]=D[e]}),cu=n&&n.__setModuleDefault||(Object.create?function(u,D){Object.defineProperty(u,"default",{enumerable:!0,value:D})}:function(u,D){u.default=D}),su=n&&n.__importStar||function(u){if(u&&u.__esModule)return u;var D={};if(null!=u)for(var e in u)"default"!==e&&Object.prototype.hasOwnProperty.call(u,e)&&au(D,u,e);return cu(D,u),D},lu=n&&n.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(ou,"__esModule",{value:!0}),ou.isFileExists=ou.offlinePluginConversion=ou.executeCommand=ou.getNpmPath=ou.hasNpmPackInPaths=void 0;const Bu=r,du=lu(e),fu=su(u),_u=i,pu=l;ou.hasNpmPackInPaths=function(u,D){try{return require.resolve(u,{paths:[...D]}),!0}catch(u){return!1}},ou.getNpmPath=function(){const u=process.execPath;return fu.join(fu.dirname(u),_u.NPM_TOOL)},ou.executeCommand=function(u,D,e){0!==(0,Bu.spawnSync)(u,D,e).status&&(0,pu.logErrorAndExit)(`Error: ${u} ${D} execute failed.See above for details.`)},ou.offlinePluginConversion=function(u,D){return D.startsWith("file:")||D.endsWith(".tgz")?fu.resolve(u,_u.HVIGOR,D.replace("file:","")):D},ou.isFileExists=function(u){return du.default.existsSync(u)&&du.default.statSync(u).isFile()};var Ou=n&&n.__createBinding||(Object.create?function(u,D,e,t){void 0===t&&(t=e);var r=Object.getOwnPropertyDescriptor(D,e);r&&!("get"in r?!D.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return D[e]}}),Object.defineProperty(u,t,r)}:function(u,D,e,t){void 0===t&&(t=e),u[t]=D[e]}),hu=n&&n.__setModuleDefault||(Object.create?function(u,D){Object.defineProperty(u,"default",{enumerable:!0,value:D})}:function(u,D){u.default=D}),Pu=n&&n.__importStar||function(u){if(u&&u.__esModule)return u;var D={};if(null!=u)for(var e in u)"default"!==e&&Object.prototype.hasOwnProperty.call(u,e)&&Ou(D,u,e);return hu(D,u),D},vu=n&&n.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(P,"__esModule",{value:!0});var gu=P.initProjectWorkSpace=void 0;const mu=Pu(e),Ru=vu(D),yu=Pu(u),Iu=v,Nu=i,bu=g,Su=l,wu=ou;let Hu,xu,Mu;function Tu(u,D,e){return void 0!==e.dependencies&&(0,wu.offlinePluginConversion)(Nu.HVIGOR_PROJECT_ROOT_DIR,D.dependencies[u])===yu.normalize(e.dependencies[u])}function Vu(){const u=yu.join(Mu,Nu.WORK_SPACE);if((0,Su.logInfoPrintConsole)("Hvigor cleaning..."),!mu.existsSync(u))return;const D=mu.readdirSync(u);if(!D||0===D.length)return;const e=yu.resolve(Mu,"node_modules","@ohos","hvigor","bin","hvigor.js");mu.existsSync(e)&&(0,wu.executeCommand)(process.argv[0],[e,"--stop-daemon"],{});try{D.forEach((D=>{mu.rmSync(yu.resolve(u,D),{recursive:!0})}))}catch(D){(0,Su.logErrorAndExit)(`The hvigor build tool cannot be installed. Please manually clear the workspace directory and synchronize the project again.\n\n Workspace Path: ${u}.`)}}gu=P.initProjectWorkSpace=function(){if(Hu=function(){const u=yu.resolve(Nu.HVIGOR_PROJECT_WRAPPER_HOME,Nu.DEFAULT_HVIGOR_CONFIG_JSON_FILE_NAME);mu.existsSync(u)||(0,Su.logErrorAndExit)(`Error: Hvigor config file ${u} does not exist.`);return(0,bu.parseJsonFile)(u)}(),Mu=function(u){let D;D=function(u){let D=u.hvigorVersion;if(D.startsWith("file:")||D.endsWith(".tgz"))return!1;const e=u.dependencies,t=Object.getOwnPropertyNames(e);for(const u of t){const D=e[u];if(D.startsWith("file:")||D.endsWith(".tgz"))return!1}if(1===t.length&&"@ohos/hvigor-ohos-plugin"===t[0])return D>"2.5.0";return!1}(u)?function(u){let D=`${Nu.HVIGOR_ENGINE_PACKAGE_NAME}@${u.hvigorVersion}`;const e=u.dependencies;if(e){Object.getOwnPropertyNames(e).sort().forEach((u=>{D+=`,${u}@${e[u]}`}))}return(0,Iu.hash)(D)}(u):(0,Iu.hash)(process.cwd());return yu.resolve(Ru.default.homedir(),".hvigor","project_caches",D)}(Hu),xu=function(){const u=yu.resolve(Mu,Nu.WORK_SPACE,Nu.DEFAULT_PACKAGE_JSON);return mu.existsSync(u)?(0,bu.parseJsonFile)(u):{dependencies:{}}}(),!(0,wu.hasNpmPackInPaths)(Nu.HVIGOR_ENGINE_PACKAGE_NAME,[yu.join(Mu,Nu.WORK_SPACE)])||(0,wu.offlinePluginConversion)(Nu.HVIGOR_PROJECT_ROOT_DIR,Hu.hvigorVersion)!==xu.dependencies[Nu.HVIGOR_ENGINE_PACKAGE_NAME]||!function(){function u(u){const D=null==u?void 0:u.dependencies;return void 0===D?0:Object.getOwnPropertyNames(D).length}const D=u(Hu),e=u(xu);if(D+1!==e)return!1;for(const u in null==Hu?void 0:Hu.dependencies)if(!(0,wu.hasNpmPackInPaths)(u,[yu.join(Mu,Nu.WORK_SPACE)])||!Tu(u,Hu,xu))return!1;return!0}()){Vu();try{!function(){(0,Su.logInfoPrintConsole)("Hvigor installing...");for(const u in Hu.dependencies)Hu.dependencies[u]&&(Hu.dependencies[u]=(0,wu.offlinePluginConversion)(Nu.HVIGOR_PROJECT_ROOT_DIR,Hu.dependencies[u]));const u={dependencies:{...Hu.dependencies}};u.dependencies[Nu.HVIGOR_ENGINE_PACKAGE_NAME]=(0,wu.offlinePluginConversion)(Nu.HVIGOR_PROJECT_ROOT_DIR,Hu.hvigorVersion);const D=yu.join(Mu,Nu.WORK_SPACE);try{mu.mkdirSync(D,{recursive:!0});const e=yu.resolve(D,Nu.DEFAULT_PACKAGE_JSON);mu.writeFileSync(e,JSON.stringify(u))}catch(u){(0,Su.logErrorAndExit)(u)}(function(){const u=["config","set","store-dir",Nu.HVIGOR_PNPM_STORE_PATH],D={cwd:yu.join(Mu,Nu.WORK_SPACE),stdio:["inherit","inherit","inherit"]};(0,wu.executeCommand)(Nu.HVIGOR_WRAPPER_PNPM_SCRIPT_PATH,u,D)})(),function(){const u=["install"],D={cwd:yu.join(Mu,Nu.WORK_SPACE),stdio:["inherit","inherit","inherit"]};(0,wu.executeCommand)(Nu.HVIGOR_WRAPPER_PNPM_SCRIPT_PATH,u,D)}(),(0,Su.logInfoPrintConsole)("Hvigor install success.")}()}catch(u){Vu()}}return Mu};var Gu={};!function(t){var C=n&&n.__createBinding||(Object.create?function(u,D,e,t){void 0===t&&(t=e);var r=Object.getOwnPropertyDescriptor(D,e);r&&!("get"in r?!D.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return D[e]}}),Object.defineProperty(u,t,r)}:function(u,D,e,t){void 0===t&&(t=e),u[t]=D[e]}),F=n&&n.__setModuleDefault||(Object.create?function(u,D){Object.defineProperty(u,"default",{enumerable:!0,value:D})}:function(u,D){u.default=D}),E=n&&n.__importStar||function(u){if(u&&u.__esModule)return u;var D={};if(null!=u)for(var e in u)"default"!==e&&Object.prototype.hasOwnProperty.call(u,e)&&C(D,u,e);return F(D,u),D},A=n&&n.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(t,"__esModule",{value:!0}),t.executeInstallPnpm=t.isPnpmInstalled=t.environmentHandler=t.checkNpmConifg=t.PNPM_VERSION=void 0;const o=r,a=E(e),c=A(D),s=E(u),B=i,d=l,f=ou;t.PNPM_VERSION="7.30.0",t.checkNpmConifg=function(){const u=s.resolve(B.HVIGOR_PROJECT_ROOT_DIR,".npmrc"),D=s.resolve(c.default.homedir(),".npmrc");if((0,f.isFileExists)(u)||(0,f.isFileExists)(D))return;const e=(0,f.getNpmPath)(),t=(0,o.spawnSync)(e,["config","get","prefix"],{cwd:B.HVIGOR_PROJECT_ROOT_DIR});if(0!==t.status||!t.stdout)return void(0,d.logErrorAndExit)("Error: The hvigor depends on the npmrc file. Configure the npmrc file first.");const r=s.resolve(`${t.stdout}`.replace(/[\r\n]/gi,""),".npmrc");(0,f.isFileExists)(r)||(0,d.logErrorAndExit)("Error: The hvigor depends on the npmrc file. Configure the npmrc file first.")},t.environmentHandler=function(){process.env["npm_config_update-notifier"]="false"},t.isPnpmInstalled=function(){return!!a.existsSync(B.HVIGOR_WRAPPER_PNPM_SCRIPT_PATH)&&(0,f.hasNpmPackInPaths)("pnpm",[B.HVIGOR_WRAPPER_TOOLS_HOME])},t.executeInstallPnpm=function(){(0,d.logInfoPrintConsole)(`Installing pnpm@${t.PNPM_VERSION}...`);const u=(0,f.getNpmPath)();!function(){const u=s.resolve(B.HVIGOR_WRAPPER_TOOLS_HOME,B.DEFAULT_PACKAGE_JSON);try{a.existsSync(B.HVIGOR_WRAPPER_TOOLS_HOME)||a.mkdirSync(B.HVIGOR_WRAPPER_TOOLS_HOME,{recursive:!0});const D={dependencies:{}};D.dependencies[B.PNPM]=t.PNPM_VERSION,a.writeFileSync(u,JSON.stringify(D))}catch(D){(0,d.logErrorAndExit)(`Error: EPERM: operation not permitted,create ${u} failed.`)}}(),(0,f.executeCommand)(u,["install","pnpm"],{cwd:B.HVIGOR_WRAPPER_TOOLS_HOME,stdio:["inherit","inherit","inherit"],env:process.env}),(0,d.logInfoPrintConsole)("Pnpm install success.")}}(Gu),function(){Gu.checkNpmConifg(),Gu.environmentHandler(),Gu.isPnpmInstalled()||Gu.executeInstallPnpm();const D=gu();_(u.join(D,i.WORK_SPACE))}();
\ No newline at end of file
diff --git a/OpenHarmony/hvigorfile.ts b/OpenHarmony/hvigorfile.ts
new file mode 100644
index 000000000..f3cb9f1a8
--- /dev/null
+++ b/OpenHarmony/hvigorfile.ts
@@ -0,0 +1,6 @@
+import { appTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/OpenHarmony/hvigorw b/OpenHarmony/hvigorw
new file mode 100644
index 000000000..ff6a29a2a
--- /dev/null
+++ b/OpenHarmony/hvigorw
@@ -0,0 +1,48 @@
+#!/bin/bash
+
+# ----------------------------------------------------------------------------
+# Hvigor startup script, version 1.0.0
+#
+# Required ENV vars:
+# ------------------
+# NODE_HOME - location of a Node home dir
+# or
+# Add /usr/local/nodejs/bin to the PATH environment variable
+# ----------------------------------------------------------------------------
+
+HVIGOR_APP_HOME="`pwd -P`"
+HVIGOR_WRAPPER_SCRIPT=${HVIGOR_APP_HOME}/hvigor/hvigor-wrapper.js
+warn() {
+ echo ""
+ echo -e "\033[1;33m`date '+[%Y-%m-%d %H:%M:%S]'`$@\033[0m"
+}
+
+error() {
+ echo ""
+ echo -e "\033[1;31m`date '+[%Y-%m-%d %H:%M:%S]'`$@\033[0m"
+}
+
+fail() {
+ error "$@"
+ exit 1
+}
+
+# Determine node to start hvigor wrapper script
+if [ -n "${NODE_HOME}" ];then
+ EXECUTABLE_NODE="${NODE_HOME}/bin/node"
+ if [ ! -x "$EXECUTABLE_NODE" ];then
+ fail "ERROR: NODE_HOME is set to an invalid directory,check $NODE_HOME\n\nPlease set NODE_HOME in your environment to the location where your nodejs installed"
+ fi
+else
+ EXECUTABLE_NODE="node"
+ which ${EXECUTABLE_NODE} > /dev/null 2>&1 || fail "ERROR: NODE_HOME is not set and not 'node' command found in your path"
+fi
+
+# Check hvigor wrapper script
+if [ ! -r "$HVIGOR_WRAPPER_SCRIPT" ];then
+ fail "ERROR: Couldn't find hvigor/hvigor-wrapper.js in ${HVIGOR_APP_HOME}"
+fi
+
+# start hvigor-wrapper script
+exec "${EXECUTABLE_NODE}" \
+ "${HVIGOR_WRAPPER_SCRIPT}" "$@"
diff --git a/OpenHarmony/hvigorw.bat b/OpenHarmony/hvigorw.bat
new file mode 100644
index 000000000..d570007e8
--- /dev/null
+++ b/OpenHarmony/hvigorw.bat
@@ -0,0 +1,64 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Hvigor startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
+set WRAPPER_MODULE_PATH=%APP_HOME%\hvigor\hvigor-wrapper.js
+set NODE_EXE=node.exe
+
+goto start
+
+:start
+@rem Find node.exe
+if defined NODE_HOME goto findNodeFromNodeHome
+
+%NODE_EXE% --version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto execute
+
+echo.
+echo ERROR: NODE_HOME is not set and no 'node' command could be found in your PATH.
+echo.
+echo Please set the NODE_HOME variable in your environment to match the
+echo location of your NodeJs installation.
+
+goto fail
+
+:findNodeFromNodeHome
+set NODE_HOME=%NODE_HOME:"=%
+set NODE_EXE_PATH=%NODE_HOME%/%NODE_EXE%
+
+if exist "%NODE_EXE_PATH%" goto execute
+echo.
+echo ERROR: NODE_HOME is not set and no 'node' command could be found in your PATH.
+echo.
+echo Please set the NODE_HOME variable in your environment to match the
+echo location of your NodeJs installation.
+
+goto fail
+
+:execute
+@rem Execute hvigor
+"%NODE_EXE%" "%WRAPPER_MODULE_PATH%" %*
+
+if "%ERRORLEVEL%" == "0" goto hvigorwEnd
+
+:fail
+exit /b 1
+
+:hvigorwEnd
+if "%OS%" == "Windows_NT" endlocal
+
+:end
diff --git a/OpenHarmony/library/.gitignore b/OpenHarmony/library/.gitignore
new file mode 100644
index 000000000..e2713a277
--- /dev/null
+++ b/OpenHarmony/library/.gitignore
@@ -0,0 +1,6 @@
+/node_modules
+/oh_modules
+/.preview
+/build
+/.cxx
+/.test
\ No newline at end of file
diff --git a/OpenHarmony/library/build-profile.json5 b/OpenHarmony/library/build-profile.json5
new file mode 100644
index 000000000..08f43dcb5
--- /dev/null
+++ b/OpenHarmony/library/build-profile.json5
@@ -0,0 +1,28 @@
+{
+ "apiType": "stageMode",
+ "buildOption": {
+ },
+ "buildOptionSet": [
+ {
+ "name": "release",
+ "arkOptions": {
+ "obfuscation": {
+ "ruleOptions": {
+ "enable": true,
+ "files": [
+ "./obfuscation-rules.txt"
+ ]
+ },
+ "consumerFiles": [
+ "./consumer-rules.txt"
+ ]
+ }
+ }
+ },
+ ],
+ "targets": [
+ {
+ "name": "default"
+ }
+ ]
+}
diff --git a/OpenHarmony/library/consumer-rules.txt b/OpenHarmony/library/consumer-rules.txt
new file mode 100644
index 000000000..e69de29bb
diff --git a/OpenHarmony/library/hvigorfile.ts b/OpenHarmony/library/hvigorfile.ts
new file mode 100644
index 000000000..421870714
--- /dev/null
+++ b/OpenHarmony/library/hvigorfile.ts
@@ -0,0 +1,6 @@
+import { harTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: harTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/OpenHarmony/library/obfuscation-rules.txt b/OpenHarmony/library/obfuscation-rules.txt
new file mode 100644
index 000000000..4c41aa7bf
--- /dev/null
+++ b/OpenHarmony/library/obfuscation-rules.txt
@@ -0,0 +1,18 @@
+# Define project specific obfuscation rules here.
+# You can include the obfuscation configuration files in the current module's build-profile.json5.
+#
+# For more details, see
+# https://gitcode.com/openharmony/arkcompiler_ets_frontend/blob/master/arkguard/README.md
+
+# Obfuscation options:
+# -disable-obfuscation: disable all obfuscations
+# -enable-property-obfuscation: obfuscate the property names
+# -enable-toplevel-obfuscation: obfuscate the names in the global scope
+# -compact: remove unnecessary blank spaces and all line feeds
+# -remove-log: remove all console.* statements
+# -print-namecache: print the name cache that contains the mapping from the old names to new names
+# -apply-namecache: reuse the given cache file
+
+# Keep options:
+# -keep-property-name: specifies property names that you want to keep
+# -keep-global-name: specifies names that you want to keep in the global scope
\ No newline at end of file
diff --git a/OpenHarmony/library/oh-package.json5 b/OpenHarmony/library/oh-package.json5
new file mode 100644
index 000000000..522c63332
--- /dev/null
+++ b/OpenHarmony/library/oh-package.json5
@@ -0,0 +1,38 @@
+{
+ "types": "src/main/ets/index.d.ts",
+ "keywords": [
+ "dd-plist",
+ "OpenHarmony",
+ "HarmonyOS"
+ ],
+ "author": "hihope",
+ "description": "一种语言无关、平台无关、可扩展的序列化结构数据的方法,它可用于(数据)通信协议、数据存储等。,是一种灵活,高效,自动化机制的结构数据序列化方法比XML更小,更快,更为简单",
+ "repository": "https://gitcode.com/openharmony-tpc/protobuf",
+ "ohos": {
+ "org": "opensource"
+ },
+ "main": "src/main/ets/dist/protobuf.js",
+ "type": "module",
+ "version": "3.0.0",
+ "tags": [
+ "protobufjs",
+ "OpenHarmony",
+ "HarmonyOS"
+ ],
+ "dependencies": {
+ "@protobufjs/utf8": "^1.1.0",
+ "@protobufjs/eventemitter": "^1.1.0",
+ "@types/node": ">=13.7.0",
+ "@protobufjs/path": "^1.1.2",
+ "@protobufjs/float": "^1.0.2",
+ "@protobufjs/pool": "^1.1.0",
+ "@protobufjs/base64": "^1.1.2",
+ "long": "^5.2.1",
+ "@protobufjs/aspromise": "^1.1.2",
+ "buffer": "^6.0.3"
+ },
+ "license": "BSD License",
+ "devDependencies": {},
+ "name": "@ohos/protobufjs",
+ "dynamicDependencies": {}
+}
\ No newline at end of file
diff --git a/OpenHarmony/library/src/main/ets/LICENSE b/OpenHarmony/library/src/main/ets/LICENSE
new file mode 100644
index 000000000..57b7e3097
--- /dev/null
+++ b/OpenHarmony/library/src/main/ets/LICENSE
@@ -0,0 +1,39 @@
+This license applies to all parts of protobuf.js except those files
+either explicitly including or referencing a different license or
+located in a directory containing a different LICENSE file.
+
+---
+
+Copyright (c) 2016, Daniel Wirtz All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+* Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+* Neither the name of its author, nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+---
+
+Code generated by the command line utilities is owned by the owner
+of the input file used when generating it. This code is not
+standalone and requires a support library to be linked with it. This
+support library is itself covered by the above license.
diff --git a/OpenHarmony/library/src/main/ets/index.d.ts b/OpenHarmony/library/src/main/ets/index.d.ts
new file mode 100644
index 000000000..f0685d991
--- /dev/null
+++ b/OpenHarmony/library/src/main/ets/index.d.ts
@@ -0,0 +1,2674 @@
+// DO NOT EDIT! This is a generated file. Edit the JSDoc in src/*.js instead and run 'npm run build:types'.
+
+export as namespace protobuf;
+
+/**
+ * Provides common type definitions.
+ * Can also be used to provide additional google types or your own custom types.
+ * @param name Short name as in `google/protobuf/[name].proto` or full file name
+ * @param json JSON definition within `google.protobuf` if a short name, otherwise the file's root definition
+ */
+export function common(name: string, json: { [k: string]: any }): void;
+
+export namespace common {
+
+ /** Properties of a google.protobuf.Any message. */
+ interface IAny {
+ typeUrl?: string;
+ bytes?: Uint8Array;
+ }
+
+ /** Properties of a google.protobuf.Duration message. */
+ interface IDuration {
+ seconds?: (number|Long);
+ nanos?: number;
+ }
+
+ /** Properties of a google.protobuf.Timestamp message. */
+ interface ITimestamp {
+ seconds?: (number|Long);
+ nanos?: number;
+ }
+
+ /** Properties of a google.protobuf.Empty message. */
+ interface IEmpty {
+ }
+
+ /** Properties of a google.protobuf.Struct message. */
+ interface IStruct {
+ fields?: { [k: string]: IValue };
+ }
+
+ /** Properties of a google.protobuf.Value message. */
+ interface IValue {
+ kind?: string;
+ nullValue?: 0;
+ numberValue?: number;
+ stringValue?: string;
+ boolValue?: boolean;
+ structValue?: IStruct;
+ listValue?: IListValue;
+ }
+
+ /** Properties of a google.protobuf.ListValue message. */
+ interface IListValue {
+ values?: IValue[];
+ }
+
+ /** Properties of a google.protobuf.DoubleValue message. */
+ interface IDoubleValue {
+ value?: number;
+ }
+
+ /** Properties of a google.protobuf.FloatValue message. */
+ interface IFloatValue {
+ value?: number;
+ }
+
+ /** Properties of a google.protobuf.Int64Value message. */
+ interface IInt64Value {
+ value?: (number|Long);
+ }
+
+ /** Properties of a google.protobuf.UInt64Value message. */
+ interface IUInt64Value {
+ value?: (number|Long);
+ }
+
+ /** Properties of a google.protobuf.Int32Value message. */
+ interface IInt32Value {
+ value?: number;
+ }
+
+ /** Properties of a google.protobuf.UInt32Value message. */
+ interface IUInt32Value {
+ value?: number;
+ }
+
+ /** Properties of a google.protobuf.BoolValue message. */
+ interface IBoolValue {
+ value?: boolean;
+ }
+
+ /** Properties of a google.protobuf.StringValue message. */
+ interface IStringValue {
+ value?: string;
+ }
+
+ /** Properties of a google.protobuf.BytesValue message. */
+ interface IBytesValue {
+ value?: Uint8Array;
+ }
+
+ /**
+ * Gets the root definition of the specified common proto file.
+ *
+ * Bundled definitions are:
+ * - google/protobuf/any.proto
+ * - google/protobuf/duration.proto
+ * - google/protobuf/empty.proto
+ * - google/protobuf/field_mask.proto
+ * - google/protobuf/struct.proto
+ * - google/protobuf/timestamp.proto
+ * - google/protobuf/wrappers.proto
+ *
+ * @param file Proto file name
+ * @returns Root definition or `null` if not defined
+ */
+ function get(file: string): (INamespace|null);
+}
+
+/** Runtime message from/to plain object converters. */
+export namespace converter {
+
+ /**
+ * Generates a plain object to runtime message converter specific to the specified message type.
+ * @param mtype Message type
+ * @returns Codegen instance
+ */
+ function fromObject(mtype: Type): Codegen;
+
+ /**
+ * Generates a runtime message to plain object converter specific to the specified message type.
+ * @param mtype Message type
+ * @returns Codegen instance
+ */
+ function toObject(mtype: Type): Codegen;
+}
+
+/**
+ * Generates a decoder specific to the specified message type.
+ * @param mtype Message type
+ * @returns Codegen instance
+ */
+export function decoder(mtype: Type): Codegen;
+
+/**
+ * Generates an encoder specific to the specified message type.
+ * @param mtype Message type
+ * @returns Codegen instance
+ */
+export function encoder(mtype: Type): Codegen;
+
+/** Reflected enum. */
+export class Enum extends ReflectionObject {
+
+ /**
+ * Constructs a new enum instance.
+ * @param name Unique name within its namespace
+ * @param [values] Enum values as an object, by name
+ * @param [options] Declared options
+ * @param [comment] The comment for this enum
+ * @param [comments] The value comments for this enum
+ * @param [valuesOptions] The value options for this enum
+ */
+ constructor(name: string, values?: { [k: string]: number }, options?: { [k: string]: any }, comment?: string, comments?: { [k: string]: string }, valuesOptions?: ({ [k: string]: { [k: string]: any } }|undefined));
+
+ /** Enum values by id. */
+ public valuesById: { [k: number]: string };
+
+ /** Enum values by name. */
+ public values: { [k: string]: number };
+
+ /** Enum comment text. */
+ public comment: (string|null);
+
+ /** Value comment texts, if any. */
+ public comments: { [k: string]: string };
+
+ /** Values options, if any */
+ public valuesOptions?: { [k: string]: { [k: string]: any } };
+
+ /** Reserved ranges, if any. */
+ public reserved: (number[]|string)[];
+
+ /**
+ * Constructs an enum from an enum descriptor.
+ * @param name Enum name
+ * @param json Enum descriptor
+ * @returns Created enum
+ * @throws {TypeError} If arguments are invalid
+ */
+ public static fromJSON(name: string, json: IEnum): Enum;
+
+ /**
+ * Converts this enum to an enum descriptor.
+ * @param [toJSONOptions] JSON conversion options
+ * @returns Enum descriptor
+ */
+ public toJSON(toJSONOptions?: IToJSONOptions): IEnum;
+
+ /**
+ * Adds a value to this enum.
+ * @param name Value name
+ * @param id Value id
+ * @param [comment] Comment, if any
+ * @param {Object.|undefined} [options] Options, if any
+ * @returns `this`
+ * @throws {TypeError} If arguments are invalid
+ * @throws {Error} If there is already a value with this name or id
+ */
+ public add(name: string, id: number, comment?: string, options?: ({ [k: string]: any }|undefined)): Enum;
+
+ /**
+ * Removes a value from this enum
+ * @param name Value name
+ * @returns `this`
+ * @throws {TypeError} If arguments are invalid
+ * @throws {Error} If `name` is not a name of this enum
+ */
+ public remove(name: string): Enum;
+
+ /**
+ * Tests if the specified id is reserved.
+ * @param id Id to test
+ * @returns `true` if reserved, otherwise `false`
+ */
+ public isReservedId(id: number): boolean;
+
+ /**
+ * Tests if the specified name is reserved.
+ * @param name Name to test
+ * @returns `true` if reserved, otherwise `false`
+ */
+ public isReservedName(name: string): boolean;
+}
+
+/** Enum descriptor. */
+export interface IEnum {
+
+ /** Enum values */
+ values: { [k: string]: number };
+
+ /** Enum options */
+ options?: { [k: string]: any };
+}
+
+/** Reflected message field. */
+export class Field extends FieldBase {
+
+ /**
+ * Constructs a new message field instance. Note that {@link MapField|map fields} have their own class.
+ * @param name Unique name within its namespace
+ * @param id Unique id within its namespace
+ * @param type Value type
+ * @param [rule="optional"] Field rule
+ * @param [extend] Extended type if different from parent
+ * @param [options] Declared options
+ */
+ constructor(name: string, id: number, type: string, rule?: (string|{ [k: string]: any }), extend?: (string|{ [k: string]: any }), options?: { [k: string]: any });
+
+ /**
+ * Constructs a field from a field descriptor.
+ * @param name Field name
+ * @param json Field descriptor
+ * @returns Created field
+ * @throws {TypeError} If arguments are invalid
+ */
+ public static fromJSON(name: string, json: IField): Field;
+
+ /** Determines whether this field is packed. Only relevant when repeated and working with proto2. */
+ public readonly packed: boolean;
+
+ /**
+ * Field decorator (TypeScript).
+ * @param fieldId Field id
+ * @param fieldType Field type
+ * @param [fieldRule="optional"] Field rule
+ * @param [defaultValue] Default value
+ * @returns Decorator function
+ */
+ public static d(fieldId: number, fieldType: ("double"|"float"|"int32"|"uint32"|"sint32"|"fixed32"|"sfixed32"|"int64"|"uint64"|"sint64"|"fixed64"|"sfixed64"|"string"|"bool"|"bytes"|object), fieldRule?: ("optional"|"required"|"repeated"), defaultValue?: T): FieldDecorator;
+
+ /**
+ * Field decorator (TypeScript).
+ * @param fieldId Field id
+ * @param fieldType Field type
+ * @param [fieldRule="optional"] Field rule
+ * @returns Decorator function
+ */
+ public static d>(fieldId: number, fieldType: (Constructor|string), fieldRule?: ("optional"|"required"|"repeated")): FieldDecorator;
+}
+
+/** Base class of all reflected message fields. This is not an actual class but here for the sake of having consistent type definitions. */
+export class FieldBase extends ReflectionObject {
+
+ /**
+ * Not an actual constructor. Use {@link Field} instead.
+ * @param name Unique name within its namespace
+ * @param id Unique id within its namespace
+ * @param type Value type
+ * @param [rule="optional"] Field rule
+ * @param [extend] Extended type if different from parent
+ * @param [options] Declared options
+ * @param [comment] Comment associated with this field
+ */
+ constructor(name: string, id: number, type: string, rule?: (string|{ [k: string]: any }), extend?: (string|{ [k: string]: any }), options?: { [k: string]: any }, comment?: string);
+
+ /** Field type. */
+ public type: string;
+
+ /** Unique field id. */
+ public id: number;
+
+ /** Extended type if different from parent. */
+ public extend?: string;
+
+ /** Whether this field is required. */
+ public required: boolean;
+
+ /** Whether this field is optional. */
+ public optional: boolean;
+
+ /** Whether this field is repeated. */
+ public repeated: boolean;
+
+ /** Whether this field is a map or not. */
+ public map: boolean;
+
+ /** Message this field belongs to. */
+ public message: (Type|null);
+
+ /** OneOf this field belongs to, if any, */
+ public partOf: (OneOf|null);
+
+ /** The field type's default value. */
+ public typeDefault: any;
+
+ /** The field's default value on prototypes. */
+ public defaultValue: any;
+
+ /** Whether this field's value should be treated as a long. */
+ public long: boolean;
+
+ /** Whether this field's value is a buffer. */
+ public bytes: boolean;
+
+ /** Resolved type if not a basic type. */
+ public resolvedType: (Type|Enum|null);
+
+ /** Sister-field within the extended type if a declaring extension field. */
+ public extensionField: (Field|null);
+
+ /** Sister-field within the declaring namespace if an extended field. */
+ public declaringField: (Field|null);
+
+ /** Comment for this field. */
+ public comment: (string|null);
+
+ /**
+ * Converts this field to a field descriptor.
+ * @param [toJSONOptions] JSON conversion options
+ * @returns Field descriptor
+ */
+ public toJSON(toJSONOptions?: IToJSONOptions): IField;
+
+ /**
+ * Resolves this field's type references.
+ * @returns `this`
+ * @throws {Error} If any reference cannot be resolved
+ */
+ public resolve(): Field;
+}
+
+/** Field descriptor. */
+export interface IField {
+
+ /** Field rule */
+ rule?: string;
+
+ /** Field type */
+ type: string;
+
+ /** Field id */
+ id: number;
+
+ /** Field options */
+ options?: { [k: string]: any };
+}
+
+/** Extension field descriptor. */
+export interface IExtensionField extends IField {
+
+ /** Extended type */
+ extend: string;
+}
+
+/**
+ * Decorator function as returned by {@link Field.d} and {@link MapField.d} (TypeScript).
+ * @param prototype Target prototype
+ * @param fieldName Field name
+ */
+type FieldDecorator = (prototype: object, fieldName: string) => void;
+
+/**
+ * A node-style callback as used by {@link load} and {@link Root#load}.
+ * @param error Error, if any, otherwise `null`
+ * @param [root] Root, if there hasn't been an error
+ */
+type LoadCallback = (error: (Error|null), root?: Root) => void;
+
+/** Build type, one of `"full"`, `"light"` or `"minimal"`. */
+export const build: string;
+
+/** Reconfigures the library according to the environment. */
+export function configure(): void;
+
+/** Reflected map field. */
+export class MapField extends FieldBase {
+
+ /**
+ * Constructs a new map field instance.
+ * @param name Unique name within its namespace
+ * @param id Unique id within its namespace
+ * @param keyType Key type
+ * @param type Value type
+ * @param [options] Declared options
+ * @param [comment] Comment associated with this field
+ */
+ constructor(name: string, id: number, keyType: string, type: string, options?: { [k: string]: any }, comment?: string);
+
+ /** Key type. */
+ public keyType: string;
+
+ /** Resolved key type if not a basic type. */
+ public resolvedKeyType: (ReflectionObject|null);
+
+ /**
+ * Constructs a map field from a map field descriptor.
+ * @param name Field name
+ * @param json Map field descriptor
+ * @returns Created map field
+ * @throws {TypeError} If arguments are invalid
+ */
+ public static fromJSON(name: string, json: IMapField): MapField;
+
+ /**
+ * Converts this map field to a map field descriptor.
+ * @param [toJSONOptions] JSON conversion options
+ * @returns Map field descriptor
+ */
+ public toJSON(toJSONOptions?: IToJSONOptions): IMapField;
+
+ /**
+ * Map field decorator (TypeScript).
+ * @param fieldId Field id
+ * @param fieldKeyType Field key type
+ * @param fieldValueType Field value type
+ * @returns Decorator function
+ */
+ public static d }>(fieldId: number, fieldKeyType: ("int32"|"uint32"|"sint32"|"fixed32"|"sfixed32"|"int64"|"uint64"|"sint64"|"fixed64"|"sfixed64"|"bool"|"string"), fieldValueType: ("double"|"float"|"int32"|"uint32"|"sint32"|"fixed32"|"sfixed32"|"int64"|"uint64"|"sint64"|"fixed64"|"sfixed64"|"bool"|"string"|"bytes"|object|Constructor<{}>)): FieldDecorator;
+}
+
+/** Map field descriptor. */
+export interface IMapField extends IField {
+
+ /** Key type */
+ keyType: string;
+}
+
+/** Extension map field descriptor. */
+export interface IExtensionMapField extends IMapField {
+
+ /** Extended type */
+ extend: string;
+}
+
+/** Abstract runtime message. */
+export class Message {
+
+ /**
+ * Constructs a new message instance.
+ * @param [properties] Properties to set
+ */
+ constructor(properties?: Properties);
+
+ /** Reference to the reflected type. */
+ public static readonly $type: Type;
+
+ /** Reference to the reflected type. */
+ public readonly $type: Type;
+
+ /**
+ * Creates a new message of this type using the specified properties.
+ * @param [properties] Properties to set
+ * @returns Message instance
+ */
+ public static create>(this: Constructor, properties?: { [k: string]: any }): Message;
+
+ /**
+ * Encodes a message of this type.
+ * @param message Message to encode
+ * @param [writer] Writer to use
+ * @returns Writer
+ */
+ public static encode>(this: Constructor, message: (T|{ [k: string]: any }), writer?: Writer): Writer;
+
+ /**
+ * Encodes a message of this type preceeded by its length as a varint.
+ * @param message Message to encode
+ * @param [writer] Writer to use
+ * @returns Writer
+ */
+ public static encodeDelimited>(this: Constructor, message: (T|{ [k: string]: any }), writer?: Writer): Writer;
+
+ /**
+ * Decodes a message of this type.
+ * @param reader Reader or buffer to decode
+ * @returns Decoded message
+ */
+ public static decode>(this: Constructor, reader: (Reader|Uint8Array)): T;
+
+ /**
+ * Decodes a message of this type preceeded by its length as a varint.
+ * @param reader Reader or buffer to decode
+ * @returns Decoded message
+ */
+ public static decodeDelimited>(this: Constructor, reader: (Reader|Uint8Array)): T;
+
+ /**
+ * Verifies a message of this type.
+ * @param message Plain object to verify
+ * @returns `null` if valid, otherwise the reason why it is not
+ */
+ public static verify(message: { [k: string]: any }): (string|null);
+
+ /**
+ * Creates a new message of this type from a plain object. Also converts values to their respective internal types.
+ * @param object Plain object
+ * @returns Message instance
+ */
+ public static fromObject>(this: Constructor, object: { [k: string]: any }): T;
+
+ /**
+ * Creates a plain object from a message of this type. Also converts values to other types if specified.
+ * @param message Message instance
+ * @param [options] Conversion options
+ * @returns Plain object
+ */
+ public static toObject>(this: Constructor, message: T, options?: IConversionOptions): { [k: string]: any };
+
+ /**
+ * Converts this message to JSON.
+ * @returns JSON object
+ */
+ public toJSON(): { [k: string]: any };
+}
+
+/** Reflected service method. */
+export class Method extends ReflectionObject {
+
+ /**
+ * Constructs a new service method instance.
+ * @param name Method name
+ * @param type Method type, usually `"rpc"`
+ * @param requestType Request message type
+ * @param responseType Response message type
+ * @param [requestStream] Whether the request is streamed
+ * @param [responseStream] Whether the response is streamed
+ * @param [options] Declared options
+ * @param [comment] The comment for this method
+ * @param [parsedOptions] Declared options, properly parsed into an object
+ */
+ constructor(name: string, type: (string|undefined), requestType: string, responseType: string, requestStream?: (boolean|{ [k: string]: any }), responseStream?: (boolean|{ [k: string]: any }), options?: { [k: string]: any }, comment?: string, parsedOptions?: { [k: string]: any });
+
+ /** Method type. */
+ public type: string;
+
+ /** Request type. */
+ public requestType: string;
+
+ /** Whether requests are streamed or not. */
+ public requestStream?: boolean;
+
+ /** Response type. */
+ public responseType: string;
+
+ /** Whether responses are streamed or not. */
+ public responseStream?: boolean;
+
+ /** Resolved request type. */
+ public resolvedRequestType: (Type|null);
+
+ /** Resolved response type. */
+ public resolvedResponseType: (Type|null);
+
+ /** Comment for this method */
+ public comment: (string|null);
+
+ /** Options properly parsed into an object */
+ public parsedOptions: any;
+
+ /**
+ * Constructs a method from a method descriptor.
+ * @param name Method name
+ * @param json Method descriptor
+ * @returns Created method
+ * @throws {TypeError} If arguments are invalid
+ */
+ public static fromJSON(name: string, json: IMethod): Method;
+
+ /**
+ * Converts this method to a method descriptor.
+ * @param [toJSONOptions] JSON conversion options
+ * @returns Method descriptor
+ */
+ public toJSON(toJSONOptions?: IToJSONOptions): IMethod;
+}
+
+/** Method descriptor. */
+export interface IMethod {
+
+ /** Method type */
+ type?: string;
+
+ /** Request type */
+ requestType: string;
+
+ /** Response type */
+ responseType: string;
+
+ /** Whether requests are streamed */
+ requestStream?: boolean;
+
+ /** Whether responses are streamed */
+ responseStream?: boolean;
+
+ /** Method options */
+ options?: { [k: string]: any };
+
+ /** Method comments */
+ comment: string;
+
+ /** Method options properly parsed into an object */
+ parsedOptions?: { [k: string]: any };
+}
+
+/** Reflected namespace. */
+export class Namespace extends NamespaceBase {
+
+ /**
+ * Constructs a new namespace instance.
+ * @param name Namespace name
+ * @param [options] Declared options
+ */
+ constructor(name: string, options?: { [k: string]: any });
+
+ /**
+ * Constructs a namespace from JSON.
+ * @param name Namespace name
+ * @param json JSON object
+ * @returns Created namespace
+ * @throws {TypeError} If arguments are invalid
+ */
+ public static fromJSON(name: string, json: { [k: string]: any }): Namespace;
+
+ /**
+ * Converts an array of reflection objects to JSON.
+ * @param array Object array
+ * @param [toJSONOptions] JSON conversion options
+ * @returns JSON object or `undefined` when array is empty
+ */
+ public static arrayToJSON(array: ReflectionObject[], toJSONOptions?: IToJSONOptions): ({ [k: string]: any }|undefined);
+
+ /**
+ * Tests if the specified id is reserved.
+ * @param reserved Array of reserved ranges and names
+ * @param id Id to test
+ * @returns `true` if reserved, otherwise `false`
+ */
+ public static isReservedId(reserved: ((number[]|string)[]|undefined), id: number): boolean;
+
+ /**
+ * Tests if the specified name is reserved.
+ * @param reserved Array of reserved ranges and names
+ * @param name Name to test
+ * @returns `true` if reserved, otherwise `false`
+ */
+ public static isReservedName(reserved: ((number[]|string)[]|undefined), name: string): boolean;
+}
+
+/** Base class of all reflection objects containing nested objects. This is not an actual class but here for the sake of having consistent type definitions. */
+export abstract class NamespaceBase extends ReflectionObject {
+
+ /** Nested objects by name. */
+ public nested?: { [k: string]: ReflectionObject };
+
+ /** Nested objects of this namespace as an array for iteration. */
+ public readonly nestedArray: ReflectionObject[];
+
+ /**
+ * Converts this namespace to a namespace descriptor.
+ * @param [toJSONOptions] JSON conversion options
+ * @returns Namespace descriptor
+ */
+ public toJSON(toJSONOptions?: IToJSONOptions): INamespace;
+
+ /**
+ * Adds nested objects to this namespace from nested object descriptors.
+ * @param nestedJson Any nested object descriptors
+ * @returns `this`
+ */
+ public addJSON(nestedJson: { [k: string]: AnyNestedObject }): Namespace;
+
+ /**
+ * Gets the nested object of the specified name.
+ * @param name Nested object name
+ * @returns The reflection object or `null` if it doesn't exist
+ */
+ public get(name: string): (ReflectionObject|null);
+
+ /**
+ * Gets the values of the nested {@link Enum|enum} of the specified name.
+ * This methods differs from {@link Namespace#get|get} in that it returns an enum's values directly and throws instead of returning `null`.
+ * @param name Nested enum name
+ * @returns Enum values
+ * @throws {Error} If there is no such enum
+ */
+ public getEnum(name: string): { [k: string]: number };
+
+ /**
+ * Adds a nested object to this namespace.
+ * @param object Nested object to add
+ * @returns `this`
+ * @throws {TypeError} If arguments are invalid
+ * @throws {Error} If there is already a nested object with this name
+ */
+ public add(object: ReflectionObject): Namespace;
+
+ /**
+ * Removes a nested object from this namespace.
+ * @param object Nested object to remove
+ * @returns `this`
+ * @throws {TypeError} If arguments are invalid
+ * @throws {Error} If `object` is not a member of this namespace
+ */
+ public remove(object: ReflectionObject): Namespace;
+
+ /**
+ * Defines additial namespaces within this one if not yet existing.
+ * @param path Path to create
+ * @param [json] Nested types to create from JSON
+ * @returns Pointer to the last namespace created or `this` if path is empty
+ */
+ public define(path: (string|string[]), json?: any): Namespace;
+
+ /**
+ * Resolves this namespace's and all its nested objects' type references. Useful to validate a reflection tree, but comes at a cost.
+ * @returns `this`
+ */
+ public resolveAll(): Namespace;
+
+ /**
+ * Recursively looks up the reflection object matching the specified path in the scope of this namespace.
+ * @param path Path to look up
+ * @param filterTypes Filter types, any combination of the constructors of `protobuf.Type`, `protobuf.Enum`, `protobuf.Service` etc.
+ * @param [parentAlreadyChecked=false] If known, whether the parent has already been checked
+ * @returns Looked up object or `null` if none could be found
+ */
+ public lookup(path: (string|string[]), filterTypes: (any|any[]), parentAlreadyChecked?: boolean): (ReflectionObject|null);
+
+ /**
+ * Looks up the reflection object at the specified path, relative to this namespace.
+ * @param path Path to look up
+ * @param [parentAlreadyChecked=false] Whether the parent has already been checked
+ * @returns Looked up object or `null` if none could be found
+ */
+ public lookup(path: (string|string[]), parentAlreadyChecked?: boolean): (ReflectionObject|null);
+
+ /**
+ * Looks up the {@link Type|type} at the specified path, relative to this namespace.
+ * Besides its signature, this methods differs from {@link Namespace#lookup|lookup} in that it throws instead of returning `null`.
+ * @param path Path to look up
+ * @returns Looked up type
+ * @throws {Error} If `path` does not point to a type
+ */
+ public lookupType(path: (string|string[])): Type;
+
+ /**
+ * Looks up the values of the {@link Enum|enum} at the specified path, relative to this namespace.
+ * Besides its signature, this methods differs from {@link Namespace#lookup|lookup} in that it throws instead of returning `null`.
+ * @param path Path to look up
+ * @returns Looked up enum
+ * @throws {Error} If `path` does not point to an enum
+ */
+ public lookupEnum(path: (string|string[])): Enum;
+
+ /**
+ * Looks up the {@link Type|type} or {@link Enum|enum} at the specified path, relative to this namespace.
+ * Besides its signature, this methods differs from {@link Namespace#lookup|lookup} in that it throws instead of returning `null`.
+ * @param path Path to look up
+ * @returns Looked up type or enum
+ * @throws {Error} If `path` does not point to a type or enum
+ */
+ public lookupTypeOrEnum(path: (string|string[])): Type;
+
+ /**
+ * Looks up the {@link Service|service} at the specified path, relative to this namespace.
+ * Besides its signature, this methods differs from {@link Namespace#lookup|lookup} in that it throws instead of returning `null`.
+ * @param path Path to look up
+ * @returns Looked up service
+ * @throws {Error} If `path` does not point to a service
+ */
+ public lookupService(path: (string|string[])): Service;
+}
+
+/** Namespace descriptor. */
+export interface INamespace {
+
+ /** Namespace options */
+ options?: { [k: string]: any };
+
+ /** Nested object descriptors */
+ nested?: { [k: string]: AnyNestedObject };
+}
+
+/** Any extension field descriptor. */
+type AnyExtensionField = (IExtensionField|IExtensionMapField);
+
+/** Any nested object descriptor. */
+type AnyNestedObject = (IEnum|IType|IService|AnyExtensionField|INamespace|IOneOf);
+
+/** Base class of all reflection objects. */
+export abstract class ReflectionObject {
+
+ /** Options. */
+ public options?: { [k: string]: any };
+
+ /** Parsed Options. */
+ public parsedOptions?: { [k: string]: any[] };
+
+ /** Unique name within its namespace. */
+ public name: string;
+
+ /** Parent namespace. */
+ public parent: (Namespace|null);
+
+ /** Whether already resolved or not. */
+ public resolved: boolean;
+
+ /** Comment text, if any. */
+ public comment: (string|null);
+
+ /** Defining file name. */
+ public filename: (string|null);
+
+ /** Reference to the root namespace. */
+ public readonly root: Root;
+
+ /** Full name including leading dot. */
+ public readonly fullName: string;
+
+ /**
+ * Converts this reflection object to its descriptor representation.
+ * @returns Descriptor
+ */
+ public toJSON(): { [k: string]: any };
+
+ /**
+ * Called when this object is added to a parent.
+ * @param parent Parent added to
+ */
+ public onAdd(parent: ReflectionObject): void;
+
+ /**
+ * Called when this object is removed from a parent.
+ * @param parent Parent removed from
+ */
+ public onRemove(parent: ReflectionObject): void;
+
+ /**
+ * Resolves this objects type references.
+ * @returns `this`
+ */
+ public resolve(): ReflectionObject;
+
+ /**
+ * Gets an option value.
+ * @param name Option name
+ * @returns Option value or `undefined` if not set
+ */
+ public getOption(name: string): any;
+
+ /**
+ * Sets an option.
+ * @param name Option name
+ * @param value Option value
+ * @param [ifNotSet] Sets the option only if it isn't currently set
+ * @returns `this`
+ */
+ public setOption(name: string, value: any, ifNotSet?: boolean): ReflectionObject;
+
+ /**
+ * Sets a parsed option.
+ * @param name parsed Option name
+ * @param value Option value
+ * @param propName dot '.' delimited full path of property within the option to set. if undefined\empty, will add a new option with that value
+ * @returns `this`
+ */
+ public setParsedOption(name: string, value: any, propName: string): ReflectionObject;
+
+ /**
+ * Sets multiple options.
+ * @param options Options to set
+ * @param [ifNotSet] Sets an option only if it isn't currently set
+ * @returns `this`
+ */
+ public setOptions(options: { [k: string]: any }, ifNotSet?: boolean): ReflectionObject;
+
+ /**
+ * Converts this instance to its string representation.
+ * @returns Class name[, space, full name]
+ */
+ public toString(): string;
+}
+
+/** Reflected oneof. */
+export class OneOf extends ReflectionObject {
+
+ /**
+ * Constructs a new oneof instance.
+ * @param name Oneof name
+ * @param [fieldNames] Field names
+ * @param [options] Declared options
+ * @param [comment] Comment associated with this field
+ */
+ constructor(name: string, fieldNames?: (string[]|{ [k: string]: any }), options?: { [k: string]: any }, comment?: string);
+
+ /** Field names that belong to this oneof. */
+ public oneof: string[];
+
+ /** Fields that belong to this oneof as an array for iteration. */
+ public readonly fieldsArray: Field[];
+
+ /** Comment for this field. */
+ public comment: (string|null);
+
+ /**
+ * Constructs a oneof from a oneof descriptor.
+ * @param name Oneof name
+ * @param json Oneof descriptor
+ * @returns Created oneof
+ * @throws {TypeError} If arguments are invalid
+ */
+ public static fromJSON(name: string, json: IOneOf): OneOf;
+
+ /**
+ * Converts this oneof to a oneof descriptor.
+ * @param [toJSONOptions] JSON conversion options
+ * @returns Oneof descriptor
+ */
+ public toJSON(toJSONOptions?: IToJSONOptions): IOneOf;
+
+ /**
+ * Adds a field to this oneof and removes it from its current parent, if any.
+ * @param field Field to add
+ * @returns `this`
+ */
+ public add(field: Field): OneOf;
+
+ /**
+ * Removes a field from this oneof and puts it back to the oneof's parent.
+ * @param field Field to remove
+ * @returns `this`
+ */
+ public remove(field: Field): OneOf;
+
+ /**
+ * OneOf decorator (TypeScript).
+ * @param fieldNames Field names
+ * @returns Decorator function
+ */
+ public static d(...fieldNames: string[]): OneOfDecorator;
+}
+
+/** Oneof descriptor. */
+export interface IOneOf {
+
+ /** Oneof field names */
+ oneof: string[];
+
+ /** Oneof options */
+ options?: { [k: string]: any };
+}
+
+/**
+ * Decorator function as returned by {@link OneOf.d} (TypeScript).
+ * @param prototype Target prototype
+ * @param oneofName OneOf name
+ */
+type OneOfDecorator = (prototype: object, oneofName: string) => void;
+
+/**
+ * Parses the given .proto source and returns an object with the parsed contents.
+ * @param source Source contents
+ * @param [options] Parse options. Defaults to {@link parse.defaults} when omitted.
+ * @returns Parser result
+ */
+export function parse(source: string, options?: IParseOptions): IParserResult;
+
+/** Result object returned from {@link parse}. */
+export interface IParserResult {
+
+ /** Package name, if declared */
+ package: (string|undefined);
+
+ /** Imports, if any */
+ imports: (string[]|undefined);
+
+ /** Weak imports, if any */
+ weakImports: (string[]|undefined);
+
+ /** Syntax, if specified (either `"proto2"` or `"proto3"`) */
+ syntax: (string|undefined);
+
+ /** Populated root instance */
+ root: Root;
+}
+
+/** Options modifying the behavior of {@link parse}. */
+export interface IParseOptions {
+
+ /** Keeps field casing instead of converting to camel case */
+ keepCase?: boolean;
+
+ /** Recognize double-slash comments in addition to doc-block comments. */
+ alternateCommentMode?: boolean;
+
+ /** Use trailing comment when both leading comment and trailing comment exist. */
+ preferTrailingComment?: boolean;
+}
+
+/** Options modifying the behavior of JSON serialization. */
+export interface IToJSONOptions {
+
+ /** Serializes comments. */
+ keepComments?: boolean;
+}
+
+/**
+ * Parses the given .proto source and returns an object with the parsed contents.
+ * @param source Source contents
+ * @param root Root to populate
+ * @param [options] Parse options. Defaults to {@link parse.defaults} when omitted.
+ * @returns Parser result
+ */
+export function parse(source: string, root: Root, options?: IParseOptions): IParserResult;
+
+/** Wire format reader using `Uint8Array` if available, otherwise `Array`. */
+export class Reader {
+
+ /**
+ * Constructs a new reader instance using the specified buffer.
+ * @param buffer Buffer to read from
+ */
+ constructor(buffer: Uint8Array);
+
+ /** Read buffer. */
+ public buf: Uint8Array;
+
+ /** Read buffer position. */
+ public pos: number;
+
+ /** Read buffer length. */
+ public len: number;
+
+ /**
+ * Creates a new reader using the specified buffer.
+ * @param buffer Buffer to read from
+ * @returns A {@link BufferReader} if `buffer` is a Buffer, otherwise a {@link Reader}
+ * @throws {Error} If `buffer` is not a valid buffer
+ */
+ public static create(buffer: (Uint8Array|Buffer)): (Reader|BufferReader);
+
+ /**
+ * Reads a varint as an unsigned 32 bit value.
+ * @returns Value read
+ */
+ public uint32(): number;
+
+ /**
+ * Reads a varint as a signed 32 bit value.
+ * @returns Value read
+ */
+ public int32(): number;
+
+ /**
+ * Reads a zig-zag encoded varint as a signed 32 bit value.
+ * @returns Value read
+ */
+ public sint32(): number;
+
+ /**
+ * Reads a varint as a signed 64 bit value.
+ * @returns Value read
+ */
+ public int64(): Long;
+
+ /**
+ * Reads a varint as an unsigned 64 bit value.
+ * @returns Value read
+ */
+ public uint64(): Long;
+
+ /**
+ * Reads a zig-zag encoded varint as a signed 64 bit value.
+ * @returns Value read
+ */
+ public sint64(): Long;
+
+ /**
+ * Reads a varint as a boolean.
+ * @returns Value read
+ */
+ public bool(): boolean;
+
+ /**
+ * Reads fixed 32 bits as an unsigned 32 bit integer.
+ * @returns Value read
+ */
+ public fixed32(): number;
+
+ /**
+ * Reads fixed 32 bits as a signed 32 bit integer.
+ * @returns Value read
+ */
+ public sfixed32(): number;
+
+ /**
+ * Reads fixed 64 bits.
+ * @returns Value read
+ */
+ public fixed64(): Long;
+
+ /**
+ * Reads zig-zag encoded fixed 64 bits.
+ * @returns Value read
+ */
+ public sfixed64(): Long;
+
+ /**
+ * Reads a float (32 bit) as a number.
+ * @returns Value read
+ */
+ public float(): number;
+
+ /**
+ * Reads a double (64 bit float) as a number.
+ * @returns Value read
+ */
+ public double(): number;
+
+ /**
+ * Reads a sequence of bytes preceeded by its length as a varint.
+ * @returns Value read
+ */
+ public bytes(): Uint8Array;
+
+ /**
+ * Reads a string preceeded by its byte length as a varint.
+ * @returns Value read
+ */
+ public string(): string;
+
+ /**
+ * Skips the specified number of bytes if specified, otherwise skips a varint.
+ * @param [length] Length if known, otherwise a varint is assumed
+ * @returns `this`
+ */
+ public skip(length?: number): Reader;
+
+ /**
+ * Skips the next element of the specified wire type.
+ * @param wireType Wire type received
+ * @returns `this`
+ */
+ public skipType(wireType: number): Reader;
+}
+
+/** Wire format reader using node buffers. */
+export class BufferReader extends Reader {
+
+ /**
+ * Constructs a new buffer reader instance.
+ * @param buffer Buffer to read from
+ */
+ constructor(buffer: Buffer);
+
+ /**
+ * Reads a sequence of bytes preceeded by its length as a varint.
+ * @returns Value read
+ */
+ public bytes(): Buffer;
+}
+
+/** Root namespace wrapping all types, enums, services, sub-namespaces etc. that belong together. */
+export class Root extends NamespaceBase {
+
+ /**
+ * Constructs a new root namespace instance.
+ * @param [options] Top level options
+ */
+ constructor(options?: { [k: string]: any });
+
+ /** Deferred extension fields. */
+ public deferred: Field[];
+
+ /** Resolved file names of loaded files. */
+ public files: string[];
+
+ /**
+ * Loads a namespace descriptor into a root namespace.
+ * @param json Nameespace descriptor
+ * @param [root] Root namespace, defaults to create a new one if omitted
+ * @returns Root namespace
+ */
+ public static fromJSON(json: INamespace, root?: Root): Root;
+
+ /**
+ * Resolves the path of an imported file, relative to the importing origin.
+ * This method exists so you can override it with your own logic in case your imports are scattered over multiple directories.
+ * @param origin The file name of the importing file
+ * @param target The file name being imported
+ * @returns Resolved path to `target` or `null` to skip the file
+ */
+ public resolvePath(origin: string, target: string): (string|null);
+
+ /**
+ * Fetch content from file path or url
+ * This method exists so you can override it with your own logic.
+ * @param path File path or url
+ * @param callback Callback function
+ */
+ public fetch(path: string, callback: FetchCallback): void;
+
+}
+
+/**
+ * Named roots.
+ * This is where pbjs stores generated structures (the option `-r, --root` specifies a name).
+ * Can also be used manually to make roots available across modules.
+ */
+export let roots: { [k: string]: Root };
+
+/** Streaming RPC helpers. */
+export namespace rpc {
+
+ /**
+ * A service method callback as used by {@link rpc.ServiceMethod|ServiceMethod}.
+ *
+ * Differs from {@link RPCImplCallback} in that it is an actual callback of a service method which may not return `response = null`.
+ * @param error Error, if any
+ * @param [response] Response message
+ */
+ type ServiceMethodCallback> = (error: (Error|null), response?: TRes) => void;
+
+ /**
+ * A service method part of a {@link rpc.Service} as created by {@link Service.create}.
+ * @param request Request message or plain object
+ * @param [callback] Node-style callback called with the error, if any, and the response message
+ * @returns Promise if `callback` has been omitted, otherwise `undefined`
+ */
+ type ServiceMethod, TRes extends Message> = (request: (TReq|Properties), callback?: rpc.ServiceMethodCallback) => Promise>;
+
+ /** An RPC service as returned by {@link Service#create}. */
+ class Service extends util.EventEmitter {
+
+ /**
+ * Constructs a new RPC service instance.
+ * @param rpcImpl RPC implementation
+ * @param [requestDelimited=false] Whether requests are length-delimited
+ * @param [responseDelimited=false] Whether responses are length-delimited
+ */
+ constructor(rpcImpl: RPCImpl, requestDelimited?: boolean, responseDelimited?: boolean);
+
+ /** RPC implementation. Becomes `null` once the service is ended. */
+ public rpcImpl: (RPCImpl|null);
+
+ /** Whether requests are length-delimited. */
+ public requestDelimited: boolean;
+
+ /** Whether responses are length-delimited. */
+ public responseDelimited: boolean;
+
+ /**
+ * Calls a service method through {@link rpc.Service#rpcImpl|rpcImpl}.
+ * @param method Reflected or static method
+ * @param requestCtor Request constructor
+ * @param responseCtor Response constructor
+ * @param request Request message or plain object
+ * @param callback Service callback
+ */
+ public rpcCall, TRes extends Message>(method: (Method|rpc.ServiceMethod), requestCtor: Constructor, responseCtor: Constructor, request: (TReq|Properties), callback: rpc.ServiceMethodCallback): void;
+
+ /**
+ * Ends this service and emits the `end` event.
+ * @param [endedByRPC=false] Whether the service has been ended by the RPC implementation.
+ * @returns `this`
+ */
+ public end(endedByRPC?: boolean): rpc.Service;
+ }
+}
+
+/**
+ * RPC implementation passed to {@link Service#create} performing a service request on network level, i.e. by utilizing http requests or websockets.
+ * @param method Reflected or static method being called
+ * @param requestData Request data
+ * @param callback Callback function
+ */
+type RPCImpl = (method: (Method|rpc.ServiceMethod, Message<{}>>), requestData: Uint8Array, callback: RPCImplCallback) => void;
+
+/**
+ * Node-style callback as used by {@link RPCImpl}.
+ * @param error Error, if any, otherwise `null`
+ * @param [response] Response data or `null` to signal end of stream, if there hasn't been an error
+ */
+type RPCImplCallback = (error: (Error|null), response?: (Uint8Array|null)) => void;
+
+/** Reflected service. */
+export class Service extends NamespaceBase {
+
+ /**
+ * Constructs a new service instance.
+ * @param name Service name
+ * @param [options] Service options
+ * @throws {TypeError} If arguments are invalid
+ */
+ constructor(name: string, options?: { [k: string]: any });
+
+ /** Service methods. */
+ public methods: { [k: string]: Method };
+
+ /**
+ * Constructs a service from a service descriptor.
+ * @param name Service name
+ * @param json Service descriptor
+ * @returns Created service
+ * @throws {TypeError} If arguments are invalid
+ */
+ public static fromJSON(name: string, json: IService): Service;
+
+ /**
+ * Converts this service to a service descriptor.
+ * @param [toJSONOptions] JSON conversion options
+ * @returns Service descriptor
+ */
+ public toJSON(toJSONOptions?: IToJSONOptions): IService;
+
+ /** Methods of this service as an array for iteration. */
+ public readonly methodsArray: Method[];
+
+ /**
+ * Creates a runtime service using the specified rpc implementation.
+ * @param rpcImpl RPC implementation
+ * @param [requestDelimited=false] Whether requests are length-delimited
+ * @param [responseDelimited=false] Whether responses are length-delimited
+ * @returns RPC service. Useful where requests and/or responses are streamed.
+ */
+ public create(rpcImpl: RPCImpl, requestDelimited?: boolean, responseDelimited?: boolean): rpc.Service;
+}
+
+/** Service descriptor. */
+export interface IService extends INamespace {
+
+ /** Method descriptors */
+ methods: { [k: string]: IMethod };
+}
+
+/**
+ * Gets the next token and advances.
+ * @returns Next token or `null` on eof
+ */
+type TokenizerHandleNext = () => (string|null);
+
+/**
+ * Peeks for the next token.
+ * @returns Next token or `null` on eof
+ */
+type TokenizerHandlePeek = () => (string|null);
+
+/**
+ * Pushes a token back to the stack.
+ * @param token Token
+ */
+type TokenizerHandlePush = (token: string) => void;
+
+/**
+ * Skips the next token.
+ * @param expected Expected token
+ * @param [optional=false] If optional
+ * @returns Whether the token matched
+ * @throws {Error} If the token didn't match and is not optional
+ */
+type TokenizerHandleSkip = (expected: string, optional?: boolean) => boolean;
+
+/**
+ * Gets the comment on the previous line or, alternatively, the line comment on the specified line.
+ * @param [line] Line number
+ * @returns Comment text or `null` if none
+ */
+type TokenizerHandleCmnt = (line?: number) => (string|null);
+
+/** Handle object returned from {@link tokenize}. */
+export interface ITokenizerHandle {
+
+ /** Gets the next token and advances (`null` on eof) */
+ next: TokenizerHandleNext;
+
+ /** Peeks for the next token (`null` on eof) */
+ peek: TokenizerHandlePeek;
+
+ /** Pushes a token back to the stack */
+ push: TokenizerHandlePush;
+
+ /** Skips a token, returns its presence and advances or, if non-optional and not present, throws */
+ skip: TokenizerHandleSkip;
+
+ /** Gets the comment on the previous line or the line comment on the specified line, if any */
+ cmnt: TokenizerHandleCmnt;
+
+ /** Current line number */
+ line: number;
+}
+
+/**
+ * Tokenizes the given .proto source and returns an object with useful utility functions.
+ * @param source Source contents
+ * @param alternateCommentMode Whether we should activate alternate comment parsing mode.
+ * @returns Tokenizer handle
+ */
+export function tokenize(source: string, alternateCommentMode: boolean): ITokenizerHandle;
+
+export namespace tokenize {
+
+ /**
+ * Unescapes a string.
+ * @param str String to unescape
+ * @returns Unescaped string
+ */
+ function unescape(str: string): string;
+}
+
+/** Reflected message type. */
+export class Type extends NamespaceBase {
+
+ /**
+ * Constructs a new reflected message type instance.
+ * @param name Message name
+ * @param [options] Declared options
+ */
+ constructor(name: string, options?: { [k: string]: any });
+
+ /** Message fields. */
+ public fields: { [k: string]: Field };
+
+ /** Oneofs declared within this namespace, if any. */
+ public oneofs: { [k: string]: OneOf };
+
+ /** Extension ranges, if any. */
+ public extensions: number[][];
+
+ /** Reserved ranges, if any. */
+ public reserved: (number[]|string)[];
+
+ /** Message fields by id. */
+ public readonly fieldsById: { [k: number]: Field };
+
+ /** Fields of this message as an array for iteration. */
+ public readonly fieldsArray: Field[];
+
+ /** Oneofs of this message as an array for iteration. */
+ public readonly oneofsArray: OneOf[];
+
+ /**
+ * The registered constructor, if any registered, otherwise a generic constructor.
+ * Assigning a function replaces the internal constructor. If the function does not extend {@link Message} yet, its prototype will be setup accordingly and static methods will be populated. If it already extends {@link Message}, it will just replace the internal constructor.
+ */
+ public ctor: Constructor<{}>;
+
+ /**
+ * Generates a constructor function for the specified type.
+ * @param mtype Message type
+ * @returns Codegen instance
+ */
+ public static generateConstructor(mtype: Type): Codegen;
+
+ /**
+ * Creates a message type from a message type descriptor.
+ * @param name Message name
+ * @param json Message type descriptor
+ * @returns Created message type
+ */
+ public static fromJSON(name: string, json: IType): Type;
+
+ /**
+ * Converts this message type to a message type descriptor.
+ * @param [toJSONOptions] JSON conversion options
+ * @returns Message type descriptor
+ */
+ public toJSON(toJSONOptions?: IToJSONOptions): IType;
+
+ /**
+ * Adds a nested object to this type.
+ * @param object Nested object to add
+ * @returns `this`
+ * @throws {TypeError} If arguments are invalid
+ * @throws {Error} If there is already a nested object with this name or, if a field, when there is already a field with this id
+ */
+ public add(object: ReflectionObject): Type;
+
+ /**
+ * Removes a nested object from this type.
+ * @param object Nested object to remove
+ * @returns `this`
+ * @throws {TypeError} If arguments are invalid
+ * @throws {Error} If `object` is not a member of this type
+ */
+ public remove(object: ReflectionObject): Type;
+
+ /**
+ * Tests if the specified id is reserved.
+ * @param id Id to test
+ * @returns `true` if reserved, otherwise `false`
+ */
+ public isReservedId(id: number): boolean;
+
+ /**
+ * Tests if the specified name is reserved.
+ * @param name Name to test
+ * @returns `true` if reserved, otherwise `false`
+ */
+ public isReservedName(name: string): boolean;
+
+ /**
+ * Creates a new message of this type using the specified properties.
+ * @param [properties] Properties to set
+ * @returns Message instance
+ */
+ public create(properties?: { [k: string]: any }): Message<{}>;
+
+ /**
+ * Sets up {@link Type#encode|encode}, {@link Type#decode|decode} and {@link Type#verify|verify}.
+ * @returns `this`
+ */
+ public setup(): Type;
+
+ /**
+ * Encodes a message of this type. Does not implicitly {@link Type#verify|verify} messages.
+ * @param message Message instance or plain object
+ * @param [writer] Writer to encode to
+ * @returns writer
+ */
+ public encode(message: (Message<{}>|{ [k: string]: any }), writer?: Writer): Writer;
+
+ /**
+ * Encodes a message of this type preceeded by its byte length as a varint. Does not implicitly {@link Type#verify|verify} messages.
+ * @param message Message instance or plain object
+ * @param [writer] Writer to encode to
+ * @returns writer
+ */
+ public encodeDelimited(message: (Message<{}>|{ [k: string]: any }), writer?: Writer): Writer;
+
+ /**
+ * Decodes a message of this type.
+ * @param reader Reader or buffer to decode from
+ * @param [length] Length of the message, if known beforehand
+ * @returns Decoded message
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {util.ProtocolError<{}>} If required fields are missing
+ */
+ public decode(reader: (Reader|Uint8Array), length?: number): Message<{}>;
+
+ /**
+ * Decodes a message of this type preceeded by its byte length as a varint.
+ * @param reader Reader or buffer to decode from
+ * @returns Decoded message
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {util.ProtocolError} If required fields are missing
+ */
+ public decodeDelimited(reader: (Reader|Uint8Array)): Message<{}>;
+
+ /**
+ * Verifies that field values are valid and that required fields are present.
+ * @param message Plain object to verify
+ * @returns `null` if valid, otherwise the reason why it is not
+ */
+ public verify(message: { [k: string]: any }): (null|string);
+
+ /**
+ * Creates a new message of this type from a plain object. Also converts values to their respective internal types.
+ * @param object Plain object to convert
+ * @returns Message instance
+ */
+ public fromObject(object: { [k: string]: any }): Message<{}>;
+
+ /**
+ * Creates a plain object from a message of this type. Also converts values to other types if specified.
+ * @param message Message instance
+ * @param [options] Conversion options
+ * @returns Plain object
+ */
+ public toObject(message: Message<{}>, options?: IConversionOptions): { [k: string]: any };
+
+ /**
+ * Type decorator (TypeScript).
+ * @param [typeName] Type name, defaults to the constructor's name
+ * @returns Decorator function
+ */
+ public static d>(typeName?: string): TypeDecorator;
+}
+
+/** Message type descriptor. */
+export interface IType extends INamespace {
+
+ /** Oneof descriptors */
+ oneofs?: { [k: string]: IOneOf };
+
+ /** Field descriptors */
+ fields: { [k: string]: IField };
+
+ /** Extension ranges */
+ extensions?: number[][];
+
+ /** Reserved ranges */
+ reserved?: number[][];
+
+ /** Whether a legacy group or not */
+ group?: boolean;
+}
+
+/** Conversion options as used by {@link Type#toObject} and {@link Message.toObject}. */
+export interface IConversionOptions {
+
+ /**
+ * Long conversion type.
+ * Valid values are `String` and `Number` (the global types).
+ * Defaults to copy the present value, which is a possibly unsafe number without and a {@link Long} with a long library.
+ */
+ longs?: Function;
+
+ /**
+ * Enum value conversion type.
+ * Only valid value is `String` (the global type).
+ * Defaults to copy the present value, which is the numeric id.
+ */
+ enums?: Function;
+
+ /**
+ * Bytes value conversion type.
+ * Valid values are `Array` and (a base64 encoded) `String` (the global types).
+ * Defaults to copy the present value, which usually is a Buffer under node and an Uint8Array in the browser.
+ */
+ bytes?: Function;
+
+ /** Also sets default values on the resulting object */
+ defaults?: boolean;
+
+ /** Sets empty arrays for missing repeated fields even if `defaults=false` */
+ arrays?: boolean;
+
+ /** Sets empty objects for missing map fields even if `defaults=false` */
+ objects?: boolean;
+
+ /** Includes virtual oneof properties set to the present field's name, if any */
+ oneofs?: boolean;
+
+ /** Performs additional JSON compatibility conversions, i.e. NaN and Infinity to strings */
+ json?: boolean;
+}
+
+/**
+ * Decorator function as returned by {@link Type.d} (TypeScript).
+ * @param target Target constructor
+ */
+type TypeDecorator> = (target: Constructor) => void;
+
+/** Common type constants. */
+export namespace types {
+
+ /** Basic type wire types. */
+ const basic: {
+ "double": number,
+ "float": number,
+ "int32": number,
+ "uint32": number,
+ "sint32": number,
+ "fixed32": number,
+ "sfixed32": number,
+ "int64": number,
+ "uint64": number,
+ "sint64": number,
+ "fixed64": number,
+ "sfixed64": number,
+ "bool": number,
+ "string": number,
+ "bytes": number
+ };
+
+ /** Basic type defaults. */
+ const defaults: {
+ "double": number,
+ "float": number,
+ "int32": number,
+ "uint32": number,
+ "sint32": number,
+ "fixed32": number,
+ "sfixed32": number,
+ "int64": number,
+ "uint64": number,
+ "sint64": number,
+ "fixed64": number,
+ "sfixed64": number,
+ "bool": boolean,
+ "string": string,
+ "bytes": number[],
+ "message": null
+ };
+
+ /** Basic long type wire types. */
+ const long: {
+ "int64": number,
+ "uint64": number,
+ "sint64": number,
+ "fixed64": number,
+ "sfixed64": number
+ };
+
+ /** Allowed types for map keys with their associated wire type. */
+ const mapKey: {
+ "int32": number,
+ "uint32": number,
+ "sint32": number,
+ "fixed32": number,
+ "sfixed32": number,
+ "int64": number,
+ "uint64": number,
+ "sint64": number,
+ "fixed64": number,
+ "sfixed64": number,
+ "bool": number,
+ "string": number
+ };
+
+ /** Allowed types for packed repeated fields with their associated wire type. */
+ const packed: {
+ "double": number,
+ "float": number,
+ "int32": number,
+ "uint32": number,
+ "sint32": number,
+ "fixed32": number,
+ "sfixed32": number,
+ "int64": number,
+ "uint64": number,
+ "sint64": number,
+ "fixed64": number,
+ "sfixed64": number,
+ "bool": number
+ };
+}
+
+/** Constructor type. */
+export interface Constructor extends Function {
+ new(...params: any[]): T; prototype: T;
+}
+
+/** Properties type. */
+type Properties = { [P in keyof T]?: T[P] };
+
+/**
+ * Any compatible Buffer instance.
+ * This is a minimal stand-alone definition of a Buffer instance. The actual type is that exported by node's typings.
+ */
+export interface Buffer extends Uint8Array {
+}
+
+/**
+ * Any compatible Long instance.
+ * This is a minimal stand-alone definition of a Long instance. The actual type is that exported by long.js.
+ */
+export interface Long {
+
+ /** Low bits */
+ low: number;
+
+ /** High bits */
+ high: number;
+
+ /** Whether unsigned or not */
+ unsigned: boolean;
+}
+
+/**
+ * A OneOf getter as returned by {@link util.oneOfGetter}.
+ * @returns Set field name, if any
+ */
+type OneOfGetter = () => (string|undefined);
+
+/**
+ * A OneOf setter as returned by {@link util.oneOfSetter}.
+ * @param value Field name
+ */
+type OneOfSetter = (value: (string|undefined)) => void;
+
+/** Various utility functions. */
+export namespace util {
+
+ /** Helper class for working with the low and high bits of a 64 bit value. */
+ class LongBits {
+
+ /**
+ * Constructs new long bits.
+ * @param lo Low 32 bits, unsigned
+ * @param hi High 32 bits, unsigned
+ */
+ constructor(lo: number, hi: number);
+
+ /** Low bits. */
+ public lo: number;
+
+ /** High bits. */
+ public hi: number;
+
+ /** Zero bits. */
+ public static zero: util.LongBits;
+
+ /** Zero hash. */
+ public static zeroHash: string;
+
+ /**
+ * Constructs new long bits from the specified number.
+ * @param value Value
+ * @returns Instance
+ */
+ public static fromNumber(value: number): util.LongBits;
+
+ /**
+ * Constructs new long bits from a number, long or string.
+ * @param value Value
+ * @returns Instance
+ */
+ public static from(value: (Long|number|string)): util.LongBits;
+
+ /**
+ * Converts this long bits to a possibly unsafe JavaScript number.
+ * @param [unsigned=false] Whether unsigned or not
+ * @returns Possibly unsafe number
+ */
+ public toNumber(unsigned?: boolean): number;
+
+ /**
+ * Converts this long bits to a long.
+ * @param [unsigned=false] Whether unsigned or not
+ * @returns Long
+ */
+ public toLong(unsigned?: boolean): Long;
+
+ /**
+ * Constructs new long bits from the specified 8 characters long hash.
+ * @param hash Hash
+ * @returns Bits
+ */
+ public static fromHash(hash: string): util.LongBits;
+
+ /**
+ * Converts this long bits to a 8 characters long hash.
+ * @returns Hash
+ */
+ public toHash(): string;
+
+ /**
+ * Zig-zag encodes this long bits.
+ * @returns `this`
+ */
+ public zzEncode(): util.LongBits;
+
+ /**
+ * Zig-zag decodes this long bits.
+ * @returns `this`
+ */
+ public zzDecode(): util.LongBits;
+
+ /**
+ * Calculates the length of this longbits when encoded as a varint.
+ * @returns Length
+ */
+ public length(): number;
+ }
+
+ /** Whether running within node or not. */
+ let isNode: boolean;
+
+ /** Global object reference. */
+ let global: object;
+
+ /** An immuable empty array. */
+ const emptyArray: any[];
+
+ /** An immutable empty object. */
+ const emptyObject: object;
+
+ /**
+ * Tests if the specified value is an integer.
+ * @param value Value to test
+ * @returns `true` if the value is an integer
+ */
+ function isInteger(value: any): boolean;
+
+ /**
+ * Tests if the specified value is a string.
+ * @param value Value to test
+ * @returns `true` if the value is a string
+ */
+ function isString(value: any): boolean;
+
+ /**
+ * Tests if the specified value is a non-null object.
+ * @param value Value to test
+ * @returns `true` if the value is a non-null object
+ */
+ function isObject(value: any): boolean;
+
+ /**
+ * Checks if a property on a message is considered to be present.
+ * This is an alias of {@link util.isSet}.
+ * @param obj Plain object or message instance
+ * @param prop Property name
+ * @returns `true` if considered to be present, otherwise `false`
+ */
+ function isset(obj: object, prop: string): boolean;
+
+ /**
+ * Checks if a property on a message is considered to be present.
+ * @param obj Plain object or message instance
+ * @param prop Property name
+ * @returns `true` if considered to be present, otherwise `false`
+ */
+ function isSet(obj: object, prop: string): boolean;
+
+ /** Node's Buffer class if available. */
+ let Buffer: Constructor;
+
+ /**
+ * Creates a new buffer of whatever type supported by the environment.
+ * @param [sizeOrArray=0] Buffer size or number array
+ * @returns Buffer
+ */
+ function newBuffer(sizeOrArray?: (number|number[])): (Uint8Array|Buffer);
+
+ /** Array implementation used in the browser. `Uint8Array` if supported, otherwise `Array`. */
+ let Array: Constructor;
+
+ /** Long.js's Long class if available. */
+ let Long: Constructor;
+
+ /** Regular expression used to verify 2 bit (`bool`) map keys. */
+ const key2Re: RegExp;
+
+ /** Regular expression used to verify 32 bit (`int32` etc.) map keys. */
+ const key32Re: RegExp;
+
+ /** Regular expression used to verify 64 bit (`int64` etc.) map keys. */
+ const key64Re: RegExp;
+
+ /**
+ * Converts a number or long to an 8 characters long hash string.
+ * @param value Value to convert
+ * @returns Hash
+ */
+ function longToHash(value: (Long|number)): string;
+
+ /**
+ * Converts an 8 characters long hash string to a long or number.
+ * @param hash Hash
+ * @param [unsigned=false] Whether unsigned or not
+ * @returns Original value
+ */
+ function longFromHash(hash: string, unsigned?: boolean): (Long|number);
+
+ /**
+ * Merges the properties of the source object into the destination object.
+ * @param dst Destination object
+ * @param src Source object
+ * @param [ifNotSet=false] Merges only if the key is not already set
+ * @returns Destination object
+ */
+ function merge(dst: { [k: string]: any }, src: { [k: string]: any }, ifNotSet?: boolean): { [k: string]: any };
+
+ /**
+ * Converts the first character of a string to lower case.
+ * @param str String to convert
+ * @returns Converted string
+ */
+ function lcFirst(str: string): string;
+
+ /**
+ * Creates a custom error constructor.
+ * @param name Error name
+ * @returns Custom error constructor
+ */
+ function newError(name: string): Constructor;
+
+ /** Error subclass indicating a protocol specifc error. */
+ class ProtocolError> extends Error {
+
+ /**
+ * Constructs a new protocol error.
+ * @param message Error message
+ * @param [properties] Additional properties
+ */
+ constructor(message: string, properties?: { [k: string]: any });
+
+ /** So far decoded message instance. */
+ public instance: Message;
+ }
+
+ /**
+ * Builds a getter for a oneof's present field name.
+ * @param fieldNames Field names
+ * @returns Unbound getter
+ */
+ function oneOfGetter(fieldNames: string[]): OneOfGetter;
+
+ /**
+ * Builds a setter for a oneof's present field name.
+ * @param fieldNames Field names
+ * @returns Unbound setter
+ */
+ function oneOfSetter(fieldNames: string[]): OneOfSetter;
+
+ /**
+ * Default conversion options used for {@link Message#toJSON} implementations.
+ *
+ * These options are close to proto3's JSON mapping with the exception that internal types like Any are handled just like messages. More precisely:
+ *
+ * - Longs become strings
+ * - Enums become string keys
+ * - Bytes become base64 encoded strings
+ * - (Sub-)Messages become plain objects
+ * - Maps become plain objects with all string keys
+ * - Repeated fields become arrays
+ * - NaN and Infinity for float and double fields become strings
+ *
+ * @see https://developers.google.com/protocol-buffers/docs/proto3?hl=en#json
+ */
+ let toJSONOptions: IConversionOptions;
+
+ /** Node's fs module if available. */
+ let fs: { [k: string]: any };
+
+ /**
+ * Converts an object's values to an array.
+ * @param object Object to convert
+ * @returns Converted array
+ */
+ function toArray(object: { [k: string]: any }): any[];
+
+ /**
+ * Converts an array of keys immediately followed by their respective value to an object, omitting undefined values.
+ * @param array Array to convert
+ * @returns Converted object
+ */
+ function toObject(array: any[]): { [k: string]: any };
+
+ /**
+ * Tests whether the specified name is a reserved word in JS.
+ * @param name Name to test
+ * @returns `true` if reserved, otherwise `false`
+ */
+ function isReserved(name: string): boolean;
+
+ /**
+ * Returns a safe property accessor for the specified property name.
+ * @param prop Property name
+ * @returns Safe accessor
+ */
+ function safeProp(prop: string): string;
+
+ /**
+ * Converts the first character of a string to upper case.
+ * @param str String to convert
+ * @returns Converted string
+ */
+ function ucFirst(str: string): string;
+
+ /**
+ * Converts a string to camel case.
+ * @param str String to convert
+ * @returns Converted string
+ */
+ function camelCase(str: string): string;
+
+ /**
+ * Compares reflected fields by id.
+ * @param a First field
+ * @param b Second field
+ * @returns Comparison value
+ */
+ function compareFieldsById(a: Field, b: Field): number;
+
+ /**
+ * Decorator helper for types (TypeScript).
+ * @param ctor Constructor function
+ * @param [typeName] Type name, defaults to the constructor's name
+ * @returns Reflected type
+ */
+ function decorateType>(ctor: Constructor, typeName?: string): Type;
+
+ /**
+ * Decorator helper for enums (TypeScript).
+ * @param object Enum object
+ * @returns Reflected enum
+ */
+ function decorateEnum(object: object): Enum;
+
+ /**
+ * Sets the value of a property by property path. If a value already exists, it is turned to an array
+ * @param dst Destination object
+ * @param path dot '.' delimited path of the property to set
+ * @param value the value to set
+ * @returns Destination object
+ */
+ function setProperty(dst: { [k: string]: any }, path: string, value: object): { [k: string]: any };
+
+ /** Decorator root (TypeScript). */
+ let decorateRoot: Root;
+
+ /**
+ * Returns a promise from a node-style callback function.
+ * @param fn Function to call
+ * @param ctx Function context
+ * @param params Function arguments
+ * @returns Promisified function
+ */
+ function asPromise(fn: asPromiseCallback, ctx: any, ...params: any[]): Promise;
+
+ /** A minimal base64 implementation for number arrays. */
+ namespace base64 {
+
+ /**
+ * Calculates the byte length of a base64 encoded string.
+ * @param string Base64 encoded string
+ * @returns Byte length
+ */
+ function length(string: string): number;
+
+ /**
+ * Encodes a buffer to a base64 encoded string.
+ * @param buffer Source buffer
+ * @param start Source start
+ * @param end Source end
+ * @returns Base64 encoded string
+ */
+ function encode(buffer: Uint8Array, start: number, end: number): string;
+
+ /**
+ * Decodes a base64 encoded string to a buffer.
+ * @param string Source string
+ * @param buffer Destination buffer
+ * @param offset Destination offset
+ * @returns Number of bytes written
+ * @throws {Error} If encoding is invalid
+ */
+ function decode(string: string, buffer: Uint8Array, offset: number): number;
+
+ /**
+ * Tests if the specified string appears to be base64 encoded.
+ * @param string String to test
+ * @returns `true` if probably base64 encoded, otherwise false
+ */
+ function test(string: string): boolean;
+ }
+
+ /**
+ * Begins generating a function.
+ * @param functionParams Function parameter names
+ * @param [functionName] Function name if not anonymous
+ * @returns Appender that appends code to the function's body
+ */
+ function codegen(functionParams: string[], functionName?: string): Codegen;
+
+ namespace codegen {
+
+ /** When set to `true`, codegen will log generated code to console. Useful for debugging. */
+ let verbose: boolean;
+ }
+
+ /**
+ * Begins generating a function.
+ * @param [functionName] Function name if not anonymous
+ * @returns Appender that appends code to the function's body
+ */
+ function codegen(functionName?: string): Codegen;
+
+ /** A minimal event emitter. */
+ class EventEmitter {
+
+ /** Constructs a new event emitter instance. */
+ constructor();
+
+ /**
+ * Registers an event listener.
+ * @param evt Event name
+ * @param fn Listener
+ * @param [ctx] Listener context
+ * @returns `this`
+ */
+ public on(evt: string, fn: EventEmitterListener, ctx?: any): this;
+
+ /**
+ * Removes an event listener or any matching listeners if arguments are omitted.
+ * @param [evt] Event name. Removes all listeners if omitted.
+ * @param [fn] Listener to remove. Removes all listeners of `evt` if omitted.
+ * @returns `this`
+ */
+ public off(evt?: string, fn?: EventEmitterListener): this;
+
+ /**
+ * Emits an event by calling its listeners with the specified arguments.
+ * @param evt Event name
+ * @param args Arguments
+ * @returns `this`
+ */
+ public emit(evt: string, ...args: any[]): this;
+ }
+
+ /** Reads / writes floats / doubles from / to buffers. */
+ namespace float {
+
+ /**
+ * Writes a 32 bit float to a buffer using little endian byte order.
+ * @param val Value to write
+ * @param buf Target buffer
+ * @param pos Target buffer offset
+ */
+ function writeFloatLE(val: number, buf: Uint8Array, pos: number): void;
+
+ /**
+ * Writes a 32 bit float to a buffer using big endian byte order.
+ * @param val Value to write
+ * @param buf Target buffer
+ * @param pos Target buffer offset
+ */
+ function writeFloatBE(val: number, buf: Uint8Array, pos: number): void;
+
+ /**
+ * Reads a 32 bit float from a buffer using little endian byte order.
+ * @param buf Source buffer
+ * @param pos Source buffer offset
+ * @returns Value read
+ */
+ function readFloatLE(buf: Uint8Array, pos: number): number;
+
+ /**
+ * Reads a 32 bit float from a buffer using big endian byte order.
+ * @param buf Source buffer
+ * @param pos Source buffer offset
+ * @returns Value read
+ */
+ function readFloatBE(buf: Uint8Array, pos: number): number;
+
+ /**
+ * Writes a 64 bit double to a buffer using little endian byte order.
+ * @param val Value to write
+ * @param buf Target buffer
+ * @param pos Target buffer offset
+ */
+ function writeDoubleLE(val: number, buf: Uint8Array, pos: number): void;
+
+ /**
+ * Writes a 64 bit double to a buffer using big endian byte order.
+ * @param val Value to write
+ * @param buf Target buffer
+ * @param pos Target buffer offset
+ */
+ function writeDoubleBE(val: number, buf: Uint8Array, pos: number): void;
+
+ /**
+ * Reads a 64 bit double from a buffer using little endian byte order.
+ * @param buf Source buffer
+ * @param pos Source buffer offset
+ * @returns Value read
+ */
+ function readDoubleLE(buf: Uint8Array, pos: number): number;
+
+ /**
+ * Reads a 64 bit double from a buffer using big endian byte order.
+ * @param buf Source buffer
+ * @param pos Source buffer offset
+ * @returns Value read
+ */
+ function readDoubleBE(buf: Uint8Array, pos: number): number;
+ }
+
+ /**
+ * Fetches the contents of a file.
+ * @param filename File path or url
+ * @param options Fetch options
+ * @param callback Callback function
+ */
+ function fetch(filename: string, options: IFetchOptions, callback: FetchCallback): void;
+
+ /**
+ * Fetches the contents of a file.
+ * @param path File path or url
+ * @param callback Callback function
+ */
+ function fetch(path: string, callback: FetchCallback): void;
+
+ /**
+ * Fetches the contents of a file.
+ * @param path File path or url
+ * @param [options] Fetch options
+ * @returns Promise
+ */
+ function fetch(path: string, options?: IFetchOptions): Promise<(string|Uint8Array)>;
+
+ /**
+ * Requires a module only if available.
+ * @param moduleName Module to require
+ * @returns Required module if available and not empty, otherwise `null`
+ */
+ function inquire(moduleName: string): object;
+
+ /** A minimal path module to resolve Unix, Windows and URL paths alike. */
+ namespace path {
+
+ /**
+ * Tests if the specified path is absolute.
+ * @param path Path to test
+ * @returns `true` if path is absolute
+ */
+ function isAbsolute(path: string): boolean;
+
+ /**
+ * Normalizes the specified path.
+ * @param path Path to normalize
+ * @returns Normalized path
+ */
+ function normalize(path: string): string;
+
+ /**
+ * Resolves the specified include path against the specified origin path.
+ * @param originPath Path to the origin file
+ * @param includePath Include path relative to origin path
+ * @param [alreadyNormalized=false] `true` if both paths are already known to be normalized
+ * @returns Path to the include file
+ */
+ function resolve(originPath: string, includePath: string, alreadyNormalized?: boolean): string;
+ }
+
+ /**
+ * A general purpose buffer pool.
+ * @param alloc Allocator
+ * @param slice Slicer
+ * @param [size=8192] Slab size
+ * @returns Pooled allocator
+ */
+ function pool(alloc: PoolAllocator, slice: PoolSlicer, size?: number): PoolAllocator;
+
+ /** A minimal UTF8 implementation for number arrays. */
+ namespace utf8 {
+
+ /**
+ * Calculates the UTF8 byte length of a string.
+ * @param string String
+ * @returns Byte length
+ */
+ function length(string: string): number;
+
+ /**
+ * Reads UTF8 bytes as a string.
+ * @param buffer Source buffer
+ * @param start Source start
+ * @param end Source end
+ * @returns String read
+ */
+ function read(buffer: Uint8Array, start: number, end: number): string;
+
+ /**
+ * Writes a string as UTF8 bytes.
+ * @param string Source string
+ * @param buffer Destination buffer
+ * @param offset Destination offset
+ * @returns Bytes written
+ */
+ function write(string: string, buffer: Uint8Array, offset: number): number;
+ }
+}
+
+/**
+ * Generates a verifier specific to the specified message type.
+ * @param mtype Message type
+ * @returns Codegen instance
+ */
+export function verifier(mtype: Type): Codegen;
+
+/** Wrappers for common types. */
+export const wrappers: { [k: string]: IWrapper };
+
+/**
+ * From object converter part of an {@link IWrapper}.
+ * @param object Plain object
+ * @returns Message instance
+ */
+type WrapperFromObjectConverter = (this: Type, object: { [k: string]: any }) => Message<{}>;
+
+/**
+ * To object converter part of an {@link IWrapper}.
+ * @param message Message instance
+ * @param [options] Conversion options
+ * @returns Plain object
+ */
+type WrapperToObjectConverter = (this: Type, message: Message<{}>, options?: IConversionOptions) => { [k: string]: any };
+
+/** Common type wrapper part of {@link wrappers}. */
+export interface IWrapper {
+
+ /** From object converter */
+ fromObject?: WrapperFromObjectConverter;
+
+ /** To object converter */
+ toObject?: WrapperToObjectConverter;
+}
+
+/** Wire format writer using `Uint8Array` if available, otherwise `Array`. */
+export class Writer {
+
+ /** Constructs a new writer instance. */
+ constructor();
+
+ /** Current length. */
+ public len: number;
+
+ /** Operations head. */
+ public head: object;
+
+ /** Operations tail */
+ public tail: object;
+
+ /** Linked forked states. */
+ public states: (object|null);
+
+ /**
+ * Creates a new writer.
+ * @returns A {@link BufferWriter} when Buffers are supported, otherwise a {@link Writer}
+ */
+ public static create(): (BufferWriter|Writer);
+
+ /**
+ * Allocates a buffer of the specified size.
+ * @param size Buffer size
+ * @returns Buffer
+ */
+ public static alloc(size: number): Uint8Array;
+
+ /**
+ * Writes an unsigned 32 bit value as a varint.
+ * @param value Value to write
+ * @returns `this`
+ */
+ public uint32(value: number): Writer;
+
+ /**
+ * Writes a signed 32 bit value as a varint.
+ * @param value Value to write
+ * @returns `this`
+ */
+ public int32(value: number): Writer;
+
+ /**
+ * Writes a 32 bit value as a varint, zig-zag encoded.
+ * @param value Value to write
+ * @returns `this`
+ */
+ public sint32(value: number): Writer;
+
+ /**
+ * Writes an unsigned 64 bit value as a varint.
+ * @param value Value to write
+ * @returns `this`
+ * @throws {TypeError} If `value` is a string and no long library is present.
+ */
+ public uint64(value: (Long|number|string)): Writer;
+
+ /**
+ * Writes a signed 64 bit value as a varint.
+ * @param value Value to write
+ * @returns `this`
+ * @throws {TypeError} If `value` is a string and no long library is present.
+ */
+ public int64(value: (Long|number|string)): Writer;
+
+ /**
+ * Writes a signed 64 bit value as a varint, zig-zag encoded.
+ * @param value Value to write
+ * @returns `this`
+ * @throws {TypeError} If `value` is a string and no long library is present.
+ */
+ public sint64(value: (Long|number|string)): Writer;
+
+ /**
+ * Writes a boolish value as a varint.
+ * @param value Value to write
+ * @returns `this`
+ */
+ public bool(value: boolean): Writer;
+
+ /**
+ * Writes an unsigned 32 bit value as fixed 32 bits.
+ * @param value Value to write
+ * @returns `this`
+ */
+ public fixed32(value: number): Writer;
+
+ /**
+ * Writes a signed 32 bit value as fixed 32 bits.
+ * @param value Value to write
+ * @returns `this`
+ */
+ public sfixed32(value: number): Writer;
+
+ /**
+ * Writes an unsigned 64 bit value as fixed 64 bits.
+ * @param value Value to write
+ * @returns `this`
+ * @throws {TypeError} If `value` is a string and no long library is present.
+ */
+ public fixed64(value: (Long|number|string)): Writer;
+
+ /**
+ * Writes a signed 64 bit value as fixed 64 bits.
+ * @param value Value to write
+ * @returns `this`
+ * @throws {TypeError} If `value` is a string and no long library is present.
+ */
+ public sfixed64(value: (Long|number|string)): Writer;
+
+ /**
+ * Writes a float (32 bit).
+ * @param value Value to write
+ * @returns `this`
+ */
+ public float(value: number): Writer;
+
+ /**
+ * Writes a double (64 bit float).
+ * @param value Value to write
+ * @returns `this`
+ */
+ public double(value: number): Writer;
+
+ /**
+ * Writes a sequence of bytes.
+ * @param value Buffer or base64 encoded string to write
+ * @returns `this`
+ */
+ public bytes(value: (Uint8Array|string)): Writer;
+
+ /**
+ * Writes a string.
+ * @param value Value to write
+ * @returns `this`
+ */
+ public string(value: string): Writer;
+
+ /**
+ * Forks this writer's state by pushing it to a stack.
+ * Calling {@link Writer#reset|reset} or {@link Writer#ldelim|ldelim} resets the writer to the previous state.
+ * @returns `this`
+ */
+ public fork(): Writer;
+
+ /**
+ * Resets this instance to the last state.
+ * @returns `this`
+ */
+ public reset(): Writer;
+
+ /**
+ * Resets to the last state and appends the fork state's current write length as a varint followed by its operations.
+ * @returns `this`
+ */
+ public ldelim(): Writer;
+
+ /**
+ * Finishes the write operation.
+ * @returns Finished buffer
+ */
+ public finish(): Uint8Array;
+}
+
+/** Wire format writer using node buffers. */
+export class BufferWriter extends Writer {
+
+ /** Constructs a new buffer writer instance. */
+ constructor();
+
+ /**
+ * Allocates a buffer of the specified size.
+ * @param size Buffer size
+ * @returns Buffer
+ */
+ public static alloc(size: number): Buffer;
+
+ /**
+ * Finishes the write operation.
+ * @returns Finished buffer
+ */
+ public finish(): Buffer;
+}
+
+/**
+ * Callback as used by {@link util.asPromise}.
+ * @param error Error, if any
+ * @param params Additional arguments
+ */
+type asPromiseCallback = (error: (Error|null), ...params: any[]) => void;
+
+/**
+ * Appends code to the function's body or finishes generation.
+ * @param [formatStringOrScope] Format string or, to finish the function, an object of additional scope variables, if any
+ * @param [formatParams] Format parameters
+ * @returns Itself or the generated function if finished
+ * @throws {Error} If format parameter counts do not match
+ */
+type Codegen = (formatStringOrScope?: (string|{ [k: string]: any }), ...formatParams: any[]) => (Codegen|Function);
+
+/**
+ * Event listener as used by {@link util.EventEmitter}.
+ * @param args Arguments
+ */
+type EventEmitterListener = (...args: any[]) => void;
+
+/**
+ * Node-style callback as used by {@link util.fetch}.
+ * @param error Error, if any, otherwise `null`
+ * @param [contents] File contents, if there hasn't been an error
+ */
+type FetchCallback = (error: Error, contents?: string) => void;
+
+/** Options as used by {@link util.fetch}. */
+export interface IFetchOptions {
+
+ /** Whether expecting a binary response */
+ binary?: boolean;
+
+ /** If `true`, forces the use of XMLHttpRequest */
+ xhr?: boolean;
+}
+
+/**
+ * An allocator as used by {@link util.pool}.
+ * @param size Buffer size
+ * @returns Buffer
+ */
+type PoolAllocator = (size: number) => Uint8Array;
+
+/**
+ * A slicer as used by {@link util.pool}.
+ * @param start Start offset
+ * @param end End offset
+ * @returns Buffer slice
+ */
+type PoolSlicer = (this: Uint8Array, start: number, end: number) => Uint8Array;
diff --git a/OpenHarmony/library/src/main/ets/index.js b/OpenHarmony/library/src/main/ets/index.js
new file mode 100644
index 000000000..042042ae5
--- /dev/null
+++ b/OpenHarmony/library/src/main/ets/index.js
@@ -0,0 +1,4 @@
+// full library entry point.
+
+"use strict";
+module.exports = require("./src/index");
diff --git a/OpenHarmony/library/src/main/ets/light.d.ts b/OpenHarmony/library/src/main/ets/light.d.ts
new file mode 100644
index 000000000..d83e7f99c
--- /dev/null
+++ b/OpenHarmony/library/src/main/ets/light.d.ts
@@ -0,0 +1,2 @@
+export as namespace protobuf;
+export * from "./index";
diff --git a/OpenHarmony/library/src/main/ets/light.js b/OpenHarmony/library/src/main/ets/light.js
new file mode 100644
index 000000000..1209e64c1
--- /dev/null
+++ b/OpenHarmony/library/src/main/ets/light.js
@@ -0,0 +1,4 @@
+// light library entry point.
+
+"use strict";
+module.exports = require("./src/index-light");
\ No newline at end of file
diff --git a/OpenHarmony/library/src/main/ets/minimal.d.ts b/OpenHarmony/library/src/main/ets/minimal.d.ts
new file mode 100644
index 000000000..d83e7f99c
--- /dev/null
+++ b/OpenHarmony/library/src/main/ets/minimal.d.ts
@@ -0,0 +1,2 @@
+export as namespace protobuf;
+export * from "./index";
diff --git a/OpenHarmony/library/src/main/ets/minimal.js b/OpenHarmony/library/src/main/ets/minimal.js
new file mode 100644
index 000000000..1f35ec99d
--- /dev/null
+++ b/OpenHarmony/library/src/main/ets/minimal.js
@@ -0,0 +1,4 @@
+// minimal library entry point.
+
+"use strict";
+module.exports = require("./src/index-minimal");
diff --git a/OpenHarmony/library/src/main/ets/scripts/postinstall.js b/OpenHarmony/library/src/main/ets/scripts/postinstall.js
new file mode 100644
index 000000000..bf4ff454c
--- /dev/null
+++ b/OpenHarmony/library/src/main/ets/scripts/postinstall.js
@@ -0,0 +1,32 @@
+"use strict";
+
+var path = require("path"),
+ fs = require("fs"),
+ pkg = require(path.join(__dirname, "..", "package.json"));
+
+// check version scheme used by dependents
+if (!pkg.versionScheme)
+ return;
+
+var warn = process.stderr.isTTY
+ ? "\x1b[30m\x1b[43mWARN\x1b[0m \x1b[35m" + path.basename(process.argv[1], ".js") + "\x1b[0m"
+ : "WARN " + path.basename(process.argv[1], ".js");
+
+var basePkg;
+try {
+ basePkg = JSON.parse(fs.readFileSync(path.join(__dirname, "..", "..", "package.json")));
+} catch (e) {
+ return;
+}
+
+[
+ "dependencies",
+ "devDependencies",
+ "optionalDependencies",
+ "peerDependencies"
+]
+.forEach(function(check) {
+ var version = basePkg && basePkg[check] && basePkg[check][pkg.name];
+ if (typeof version === "string" && version.charAt(0) !== pkg.versionScheme)
+ process.stderr.write(pkg.name + " " + warn + " " + pkg.name + "@" + version + " is configured as a dependency of " + basePkg.name + ". use " + pkg.name + "@" + pkg.versionScheme + version.substring(1) + " instead for API compatibility.\n");
+});
diff --git a/OpenHarmony/library/src/main/ets/src/common.js b/OpenHarmony/library/src/main/ets/src/common.js
new file mode 100644
index 000000000..489ee1c67
--- /dev/null
+++ b/OpenHarmony/library/src/main/ets/src/common.js
@@ -0,0 +1,399 @@
+"use strict";
+module.exports = common;
+
+var commonRe = /\/|\./;
+
+/**
+ * Provides common type definitions.
+ * Can also be used to provide additional google types or your own custom types.
+ * @param {string} name Short name as in `google/protobuf/[name].proto` or full file name
+ * @param {Object.} json JSON definition within `google.protobuf` if a short name, otherwise the file's root definition
+ * @returns {undefined}
+ * @property {INamespace} google/protobuf/any.proto Any
+ * @property {INamespace} google/protobuf/duration.proto Duration
+ * @property {INamespace} google/protobuf/empty.proto Empty
+ * @property {INamespace} google/protobuf/field_mask.proto FieldMask
+ * @property {INamespace} google/protobuf/struct.proto Struct, Value, NullValue and ListValue
+ * @property {INamespace} google/protobuf/timestamp.proto Timestamp
+ * @property {INamespace} google/protobuf/wrappers.proto Wrappers
+ * @example
+ * // manually provides descriptor.proto (assumes google/protobuf/ namespace and .proto extension)
+ * protobuf.common("descriptor", descriptorJson);
+ *
+ * // manually provides a custom definition (uses my.foo namespace)
+ * protobuf.common("my/foo/bar.proto", myFooBarJson);
+ */
+function common(name, json) {
+ if (!commonRe.test(name)) {
+ name = "google/protobuf/" + name + ".proto";
+ json = { nested: { google: { nested: { protobuf: { nested: json } } } } };
+ }
+ common[name] = json;
+}
+
+// Not provided because of limited use (feel free to discuss or to provide yourself):
+//
+// google/protobuf/descriptor.proto
+// google/protobuf/source_context.proto
+// google/protobuf/type.proto
+//
+// Stripped and pre-parsed versions of these non-bundled files are instead available as part of
+// the repository or package within the google/protobuf directory.
+
+common("any", {
+
+ /**
+ * Properties of a google.protobuf.Any message.
+ * @interface IAny
+ * @type {Object}
+ * @property {string} [typeUrl]
+ * @property {Uint8Array} [bytes]
+ * @memberof common
+ */
+ Any: {
+ fields: {
+ type_url: {
+ type: "string",
+ id: 1
+ },
+ value: {
+ type: "bytes",
+ id: 2
+ }
+ }
+ }
+});
+
+var timeType;
+
+common("duration", {
+
+ /**
+ * Properties of a google.protobuf.Duration message.
+ * @interface IDuration
+ * @type {Object}
+ * @property {number|Long} [seconds]
+ * @property {number} [nanos]
+ * @memberof common
+ */
+ Duration: timeType = {
+ fields: {
+ seconds: {
+ type: "int64",
+ id: 1
+ },
+ nanos: {
+ type: "int32",
+ id: 2
+ }
+ }
+ }
+});
+
+common("timestamp", {
+
+ /**
+ * Properties of a google.protobuf.Timestamp message.
+ * @interface ITimestamp
+ * @type {Object}
+ * @property {number|Long} [seconds]
+ * @property {number} [nanos]
+ * @memberof common
+ */
+ Timestamp: timeType
+});
+
+common("empty", {
+
+ /**
+ * Properties of a google.protobuf.Empty message.
+ * @interface IEmpty
+ * @memberof common
+ */
+ Empty: {
+ fields: {}
+ }
+});
+
+common("struct", {
+
+ /**
+ * Properties of a google.protobuf.Struct message.
+ * @interface IStruct
+ * @type {Object}
+ * @property {Object.} [fields]
+ * @memberof common
+ */
+ Struct: {
+ fields: {
+ fields: {
+ keyType: "string",
+ type: "Value",
+ id: 1
+ }
+ }
+ },
+
+ /**
+ * Properties of a google.protobuf.Value message.
+ * @interface IValue
+ * @type {Object}
+ * @property {string} [kind]
+ * @property {0} [nullValue]
+ * @property {number} [numberValue]
+ * @property {string} [stringValue]
+ * @property {boolean} [boolValue]
+ * @property {IStruct} [structValue]
+ * @property {IListValue} [listValue]
+ * @memberof common
+ */
+ Value: {
+ oneofs: {
+ kind: {
+ oneof: [
+ "nullValue",
+ "numberValue",
+ "stringValue",
+ "boolValue",
+ "structValue",
+ "listValue"
+ ]
+ }
+ },
+ fields: {
+ nullValue: {
+ type: "NullValue",
+ id: 1
+ },
+ numberValue: {
+ type: "double",
+ id: 2
+ },
+ stringValue: {
+ type: "string",
+ id: 3
+ },
+ boolValue: {
+ type: "bool",
+ id: 4
+ },
+ structValue: {
+ type: "Struct",
+ id: 5
+ },
+ listValue: {
+ type: "ListValue",
+ id: 6
+ }
+ }
+ },
+
+ NullValue: {
+ values: {
+ NULL_VALUE: 0
+ }
+ },
+
+ /**
+ * Properties of a google.protobuf.ListValue message.
+ * @interface IListValue
+ * @type {Object}
+ * @property {Array.} [values]
+ * @memberof common
+ */
+ ListValue: {
+ fields: {
+ values: {
+ rule: "repeated",
+ type: "Value",
+ id: 1
+ }
+ }
+ }
+});
+
+common("wrappers", {
+
+ /**
+ * Properties of a google.protobuf.DoubleValue message.
+ * @interface IDoubleValue
+ * @type {Object}
+ * @property {number} [value]
+ * @memberof common
+ */
+ DoubleValue: {
+ fields: {
+ value: {
+ type: "double",
+ id: 1
+ }
+ }
+ },
+
+ /**
+ * Properties of a google.protobuf.FloatValue message.
+ * @interface IFloatValue
+ * @type {Object}
+ * @property {number} [value]
+ * @memberof common
+ */
+ FloatValue: {
+ fields: {
+ value: {
+ type: "float",
+ id: 1
+ }
+ }
+ },
+
+ /**
+ * Properties of a google.protobuf.Int64Value message.
+ * @interface IInt64Value
+ * @type {Object}
+ * @property {number|Long} [value]
+ * @memberof common
+ */
+ Int64Value: {
+ fields: {
+ value: {
+ type: "int64",
+ id: 1
+ }
+ }
+ },
+
+ /**
+ * Properties of a google.protobuf.UInt64Value message.
+ * @interface IUInt64Value
+ * @type {Object}
+ * @property {number|Long} [value]
+ * @memberof common
+ */
+ UInt64Value: {
+ fields: {
+ value: {
+ type: "uint64",
+ id: 1
+ }
+ }
+ },
+
+ /**
+ * Properties of a google.protobuf.Int32Value message.
+ * @interface IInt32Value
+ * @type {Object}
+ * @property {number} [value]
+ * @memberof common
+ */
+ Int32Value: {
+ fields: {
+ value: {
+ type: "int32",
+ id: 1
+ }
+ }
+ },
+
+ /**
+ * Properties of a google.protobuf.UInt32Value message.
+ * @interface IUInt32Value
+ * @type {Object}
+ * @property {number} [value]
+ * @memberof common
+ */
+ UInt32Value: {
+ fields: {
+ value: {
+ type: "uint32",
+ id: 1
+ }
+ }
+ },
+
+ /**
+ * Properties of a google.protobuf.BoolValue message.
+ * @interface IBoolValue
+ * @type {Object}
+ * @property {boolean} [value]
+ * @memberof common
+ */
+ BoolValue: {
+ fields: {
+ value: {
+ type: "bool",
+ id: 1
+ }
+ }
+ },
+
+ /**
+ * Properties of a google.protobuf.StringValue message.
+ * @interface IStringValue
+ * @type {Object}
+ * @property {string} [value]
+ * @memberof common
+ */
+ StringValue: {
+ fields: {
+ value: {
+ type: "string",
+ id: 1
+ }
+ }
+ },
+
+ /**
+ * Properties of a google.protobuf.BytesValue message.
+ * @interface IBytesValue
+ * @type {Object}
+ * @property {Uint8Array} [value]
+ * @memberof common
+ */
+ BytesValue: {
+ fields: {
+ value: {
+ type: "bytes",
+ id: 1
+ }
+ }
+ }
+});
+
+common("field_mask", {
+
+ /**
+ * Properties of a google.protobuf.FieldMask message.
+ * @interface IDoubleValue
+ * @type {Object}
+ * @property {number} [value]
+ * @memberof common
+ */
+ FieldMask: {
+ fields: {
+ paths: {
+ rule: "repeated",
+ type: "string",
+ id: 1
+ }
+ }
+ }
+});
+
+/**
+ * Gets the root definition of the specified common proto file.
+ *
+ * Bundled definitions are:
+ * - google/protobuf/any.proto
+ * - google/protobuf/duration.proto
+ * - google/protobuf/empty.proto
+ * - google/protobuf/field_mask.proto
+ * - google/protobuf/struct.proto
+ * - google/protobuf/timestamp.proto
+ * - google/protobuf/wrappers.proto
+ *
+ * @param {string} file Proto file name
+ * @returns {INamespace|null} Root definition or `null` if not defined
+ */
+common.get = function get(file) {
+ return common[file] || null;
+};
diff --git a/OpenHarmony/library/src/main/ets/src/converter.js b/OpenHarmony/library/src/main/ets/src/converter.js
new file mode 100644
index 000000000..c9e68b5be
--- /dev/null
+++ b/OpenHarmony/library/src/main/ets/src/converter.js
@@ -0,0 +1,301 @@
+"use strict";
+/**
+ * Runtime message from/to plain object converters.
+ * @namespace
+ */
+var converter = exports;
+
+var Enum = require("./enum"),
+ util = require("./util");
+
+/**
+ * Generates a partial value fromObject conveter.
+ * @param {Codegen} gen Codegen instance
+ * @param {Field} field Reflected field
+ * @param {number} fieldIndex Field index
+ * @param {string} prop Property reference
+ * @returns {Codegen} Codegen instance
+ * @ignore
+ */
+function genValuePartial_fromObject(gen, field, fieldIndex, prop) {
+ var defaultAlreadyEmitted = false;
+ /* eslint-disable no-unexpected-multiline, block-scoped-var, no-redeclare */
+ if (field.resolvedType) {
+ if (field.resolvedType instanceof Enum) { gen
+ ("switch(d%s){", prop);
+ for (var values = field.resolvedType.values, keys = Object.keys(values), i = 0; i < keys.length; ++i) {
+ // enum unknown values passthrough
+ if (values[keys[i]] === field.typeDefault && !defaultAlreadyEmitted) { gen
+ ("default:")
+ ("if(typeof(d%s)===\"number\"){m%s=d%s;break}", prop, prop, prop);
+ if (!field.repeated) gen // fallback to default value only for
+ // arrays, to avoid leaving holes.
+ ("break"); // for non-repeated fields, just ignore
+ defaultAlreadyEmitted = true;
+ }
+ gen
+ ("case%j:", keys[i])
+ ("case %i:", values[keys[i]])
+ ("m%s=%j", prop, values[keys[i]])
+ ("break");
+ } gen
+ ("}");
+ } else gen
+ ("if(typeof d%s!==\"object\")", prop)
+ ("throw TypeError(%j)", field.fullName + ": object expected")
+ ("m%s=types[%i].fromObject(d%s)", prop, fieldIndex, prop);
+ } else {
+ var isUnsigned = false;
+ switch (field.type) {
+ case "double":
+ case "float": gen
+ ("m%s=Number(d%s)", prop, prop); // also catches "NaN", "Infinity"
+ break;
+ case "uint32":
+ case "fixed32": gen
+ ("m%s=d%s>>>0", prop, prop);
+ break;
+ case "int32":
+ case "sint32":
+ case "sfixed32": gen
+ ("m%s=d%s|0", prop, prop);
+ break;
+ case "uint64":
+ isUnsigned = true;
+ // eslint-disable-line no-fallthrough
+ case "int64":
+ case "sint64":
+ case "fixed64":
+ case "sfixed64": gen
+ ("if(util.Long)")
+ ("(m%s=util.Long.fromValue(d%s)).unsigned=%j", prop, prop, isUnsigned)
+ ("else if(typeof d%s===\"string\")", prop)
+ ("m%s=parseInt(d%s,10)", prop, prop)
+ ("else if(typeof d%s===\"number\")", prop)
+ ("m%s=d%s", prop, prop)
+ ("else if(typeof d%s===\"object\")", prop)
+ ("m%s=new util.LongBits(d%s.low>>>0,d%s.high>>>0).toNumber(%s)", prop, prop, prop, isUnsigned ? "true" : "");
+ break;
+ case "bytes": gen
+ ("if(typeof d%s===\"string\")", prop)
+ ("util.base64.decode(d%s,m%s=util.newBuffer(util.base64.length(d%s)),0)", prop, prop, prop)
+ ("else if(d%s.length >= 0)", prop)
+ ("m%s=d%s", prop, prop);
+ break;
+ case "string": gen
+ ("m%s=String(d%s)", prop, prop);
+ break;
+ case "bool": gen
+ ("m%s=Boolean(d%s)", prop, prop);
+ break;
+ /* default: gen
+ ("m%s=d%s", prop, prop);
+ break; */
+ }
+ }
+ return gen;
+ /* eslint-enable no-unexpected-multiline, block-scoped-var, no-redeclare */
+}
+
+/**
+ * Generates a plain object to runtime message converter specific to the specified message type.
+ * @param {Type} mtype Message type
+ * @returns {Codegen} Codegen instance
+ */
+converter.fromObject = function fromObject(mtype) {
+ /* eslint-disable no-unexpected-multiline, block-scoped-var, no-redeclare */
+ var fields = mtype.fieldsArray;
+ var gen = util.codegen(["d"], mtype.name + "$fromObject")
+ ("if(d instanceof this.ctor)")
+ ("return d");
+ if (!fields.length) return gen
+ ("return new this.ctor");
+ gen
+ ("var m=new this.ctor");
+ for (var i = 0; i < fields.length; ++i) {
+ var field = fields[i].resolve(),
+ prop = util.safeProp(field.name);
+
+ // Map fields
+ if (field.map) { gen
+ ("if(d%s){", prop)
+ ("if(typeof d%s!==\"object\")", prop)
+ ("throw TypeError(%j)", field.fullName + ": object expected")
+ ("m%s={}", prop)
+ ("for(var ks=Object.keys(d%s),i=0;i>>0,m%s.high>>>0).toNumber(%s):m%s", prop, prop, prop, prop, isUnsigned ? "true": "", prop);
+ break;
+ case "bytes": gen
+ ("d%s=o.bytes===String?util.base64.encode(m%s,0,m%s.length):o.bytes===Array?Array.prototype.slice.call(m%s):m%s", prop, prop, prop, prop, prop);
+ break;
+ default: gen
+ ("d%s=m%s", prop, prop);
+ break;
+ }
+ }
+ return gen;
+ /* eslint-enable no-unexpected-multiline, block-scoped-var, no-redeclare */
+}
+
+/**
+ * Generates a runtime message to plain object converter specific to the specified message type.
+ * @param {Type} mtype Message type
+ * @returns {Codegen} Codegen instance
+ */
+converter.toObject = function toObject(mtype) {
+ /* eslint-disable no-unexpected-multiline, block-scoped-var, no-redeclare */
+ var fields = mtype.fieldsArray.slice().sort(util.compareFieldsById);
+ if (!fields.length)
+ return util.codegen()("return {}");
+ var gen = util.codegen(["m", "o"], mtype.name + "$toObject")
+ ("if(!o)")
+ ("o={}")
+ ("var d={}");
+
+ var repeatedFields = [],
+ mapFields = [],
+ normalFields = [],
+ i = 0;
+ for (; i < fields.length; ++i)
+ if (!fields[i].partOf)
+ ( fields[i].resolve().repeated ? repeatedFields
+ : fields[i].map ? mapFields
+ : normalFields).push(fields[i]);
+
+ if (repeatedFields.length) { gen
+ ("if(o.arrays||o.defaults){");
+ for (i = 0; i < repeatedFields.length; ++i) gen
+ ("d%s=[]", util.safeProp(repeatedFields[i].name));
+ gen
+ ("}");
+ }
+
+ if (mapFields.length) { gen
+ ("if(o.objects||o.defaults){");
+ for (i = 0; i < mapFields.length; ++i) gen
+ ("d%s={}", util.safeProp(mapFields[i].name));
+ gen
+ ("}");
+ }
+
+ if (normalFields.length) { gen
+ ("if(o.defaults){");
+ for (i = 0; i < normalFields.length; ++i) {
+ var field = normalFields[i],
+ prop = util.safeProp(field.name);
+ if (field.resolvedType instanceof Enum) gen
+ ("d%s=o.enums===String?%j:%j", prop, field.resolvedType.valuesById[field.typeDefault], field.typeDefault);
+ else if (field.long) gen
+ ("if(util.Long){")
+ ("var n=new util.Long(%i,%i,%j)", field.typeDefault.low, field.typeDefault.high, field.typeDefault.unsigned)
+ ("d%s=o.longs===String?n.toString():o.longs===Number?n.toNumber():n", prop)
+ ("}else")
+ ("d%s=o.longs===String?%j:%i", prop, field.typeDefault.toString(), field.typeDefault.toNumber());
+ else if (field.bytes) {
+ var arrayDefault = "[" + Array.prototype.slice.call(field.typeDefault).join(",") + "]";
+ gen
+ ("if(o.bytes===String)d%s=%j", prop, String.fromCharCode.apply(String, field.typeDefault))
+ ("else{")
+ ("d%s=%s", prop, arrayDefault)
+ ("if(o.bytes!==Array)d%s=util.newBuffer(d%s)", prop, prop)
+ ("}");
+ } else gen
+ ("d%s=%j", prop, field.typeDefault); // also messages (=null)
+ } gen
+ ("}");
+ }
+ var hasKs2 = false;
+ for (i = 0; i < fields.length; ++i) {
+ var field = fields[i],
+ index = mtype._fieldsArray.indexOf(field),
+ prop = util.safeProp(field.name);
+ if (field.map) {
+ if (!hasKs2) { hasKs2 = true; gen
+ ("var ks2");
+ } gen
+ ("if(m%s&&(ks2=Object.keys(m%s)).length){", prop, prop)
+ ("d%s={}", prop)
+ ("for(var j=0;j>>3){");
+
+ var i = 0;
+ for (; i < /* initializes */ mtype.fieldsArray.length; ++i) {
+ var field = mtype._fieldsArray[i].resolve(),
+ type = field.resolvedType instanceof Enum ? "int32" : field.type,
+ ref = "m" + util.safeProp(field.name); gen
+ ("case %i: {", field.id);
+
+ // Map fields
+ if (field.map) { gen
+ ("if(%s===util.emptyObject)", ref)
+ ("%s={}", ref)
+ ("var c2 = r.uint32()+r.pos");
+
+ if (types.defaults[field.keyType] !== undefined) gen
+ ("k=%j", types.defaults[field.keyType]);
+ else gen
+ ("k=null");
+
+ if (types.defaults[type] !== undefined) gen
+ ("value=%j", types.defaults[type]);
+ else gen
+ ("value=null");
+
+ gen
+ ("while(r.pos>>3){")
+ ("case 1: k=r.%s(); break", field.keyType)
+ ("case 2:");
+
+ if (types.basic[type] === undefined) gen
+ ("value=types[%i].decode(r,r.uint32())", i); // can't be groups
+ else gen
+ ("value=r.%s()", type);
+
+ gen
+ ("break")
+ ("default:")
+ ("r.skipType(tag2&7)")
+ ("break")
+ ("}")
+ ("}");
+
+ if (types.long[field.keyType] !== undefined) gen
+ ("%s[typeof k===\"object\"?util.longToHash(k):k]=value", ref);
+ else gen
+ ("%s[k]=value", ref);
+
+ // Repeated fields
+ } else if (field.repeated) { gen
+
+ ("if(!(%s&&%s.length))", ref, ref)
+ ("%s=[]", ref);
+
+ // Packable (always check for forward and backward compatiblity)
+ if (types.packed[type] !== undefined) gen
+ ("if((t&7)===2){")
+ ("var c2=r.uint32()+r.pos")
+ ("while(r.pos>> 0, (field.id << 3 | 4) >>> 0)
+ : gen("types[%i].encode(%s,w.uint32(%i).fork()).ldelim()", fieldIndex, ref, (field.id << 3 | 2) >>> 0);
+}
+
+/**
+ * Generates an encoder specific to the specified message type.
+ * @param {Type} mtype Message type
+ * @returns {Codegen} Codegen instance
+ */
+function encoder(mtype) {
+ /* eslint-disable no-unexpected-multiline, block-scoped-var, no-redeclare */
+ var gen = util.codegen(["m", "w"], mtype.name + "$encode")
+ ("if(!w)")
+ ("w=Writer.create()");
+
+ var i, ref;
+
+ // "when a message is serialized its known fields should be written sequentially by field number"
+ var fields = /* initializes */ mtype.fieldsArray.slice().sort(util.compareFieldsById);
+
+ for (var i = 0; i < fields.length; ++i) {
+ var field = fields[i].resolve(),
+ index = mtype._fieldsArray.indexOf(field),
+ type = field.resolvedType instanceof Enum ? "int32" : field.type,
+ wireType = types.basic[type];
+ ref = "m" + util.safeProp(field.name);
+
+ // Map fields
+ if (field.map) {
+ gen
+ ("if(%s!=null&&Object.hasOwnProperty.call(m,%j)){", ref, field.name) // !== undefined && !== null
+ ("for(var ks=Object.keys(%s),i=0;i>> 0, 8 | types.mapKey[field.keyType], field.keyType);
+ if (wireType === undefined) gen
+ ("types[%i].encode(%s[ks[i]],w.uint32(18).fork()).ldelim().ldelim()", index, ref); // can't be groups
+ else gen
+ (".uint32(%i).%s(%s[ks[i]]).ldelim()", 16 | wireType, type, ref);
+ gen
+ ("}")
+ ("}");
+
+ // Repeated fields
+ } else if (field.repeated) { gen
+ ("if(%s!=null&&%s.length){", ref, ref); // !== undefined && !== null
+
+ // Packed repeated
+ if (field.packed && types.packed[type] !== undefined) { gen
+
+ ("w.uint32(%i).fork()", (field.id << 3 | 2) >>> 0)
+ ("for(var i=0;i<%s.length;++i)", ref)
+ ("w.%s(%s[i])", type, ref)
+ ("w.ldelim()");
+
+ // Non-packed
+ } else { gen
+
+ ("for(var i=0;i<%s.length;++i)", ref);
+ if (wireType === undefined)
+ genTypePartial(gen, field, index, ref + "[i]");
+ else gen
+ ("w.uint32(%i).%s(%s[i])", (field.id << 3 | wireType) >>> 0, type, ref);
+
+ } gen
+ ("}");
+
+ // Non-repeated
+ } else {
+ if (field.optional) gen
+ ("if(%s!=null&&Object.hasOwnProperty.call(m,%j))", ref, field.name); // !== undefined && !== null
+
+ if (wireType === undefined)
+ genTypePartial(gen, field, index, ref);
+ else gen
+ ("w.uint32(%i).%s(%s)", (field.id << 3 | wireType) >>> 0, type, ref);
+
+ }
+ }
+
+ return gen
+ ("return w");
+ /* eslint-enable no-unexpected-multiline, block-scoped-var, no-redeclare */
+}
diff --git a/OpenHarmony/library/src/main/ets/src/enum.js b/OpenHarmony/library/src/main/ets/src/enum.js
new file mode 100644
index 000000000..1c016209f
--- /dev/null
+++ b/OpenHarmony/library/src/main/ets/src/enum.js
@@ -0,0 +1,198 @@
+"use strict";
+module.exports = Enum;
+
+// extends ReflectionObject
+var ReflectionObject = require("./object");
+((Enum.prototype = Object.create(ReflectionObject.prototype)).constructor = Enum).className = "Enum";
+
+var Namespace = require("./namespace"),
+ util = require("./util");
+
+/**
+ * Constructs a new enum instance.
+ * @classdesc Reflected enum.
+ * @extends ReflectionObject
+ * @constructor
+ * @param {string} name Unique name within its namespace
+ * @param {Object.} [values] Enum values as an object, by name
+ * @param {Object.} [options] Declared options
+ * @param {string} [comment] The comment for this enum
+ * @param {Object.} [comments] The value comments for this enum
+ * @param {Object.>|undefined} [valuesOptions] The value options for this enum
+ */
+function Enum(name, values, options, comment, comments, valuesOptions) {
+ ReflectionObject.call(this, name, options);
+
+ if (values && typeof values !== "object")
+ throw TypeError("values must be an object");
+
+ /**
+ * Enum values by id.
+ * @type {Object.}
+ */
+ this.valuesById = {};
+
+ /**
+ * Enum values by name.
+ * @type {Object.}
+ */
+ this.values = Object.create(this.valuesById); // toJSON, marker
+
+ /**
+ * Enum comment text.
+ * @type {string|null}
+ */
+ this.comment = comment;
+
+ /**
+ * Value comment texts, if any.
+ * @type {Object.}
+ */
+ this.comments = comments || {};
+
+ /**
+ * Values options, if any
+ * @type {Object>|undefined}
+ */
+ this.valuesOptions = valuesOptions;
+
+ /**
+ * Reserved ranges, if any.
+ * @type {Array.}
+ */
+ this.reserved = undefined; // toJSON
+
+ // Note that values inherit valuesById on their prototype which makes them a TypeScript-
+ // compatible enum. This is used by pbts to write actual enum definitions that work for
+ // static and reflection code alike instead of emitting generic object definitions.
+
+ if (values)
+ for (var keys = Object.keys(values), i = 0; i < keys.length; ++i)
+ if (typeof values[keys[i]] === "number") // use forward entries only
+ this.valuesById[ this.values[keys[i]] = values[keys[i]] ] = keys[i];
+}
+
+/**
+ * Enum descriptor.
+ * @interface IEnum
+ * @property {Object.} values Enum values
+ * @property {Object.} [options] Enum options
+ */
+
+/**
+ * Constructs an enum from an enum descriptor.
+ * @param {string} name Enum name
+ * @param {IEnum} json Enum descriptor
+ * @returns {Enum} Created enum
+ * @throws {TypeError} If arguments are invalid
+ */
+Enum.fromJSON = function fromJSON(name, json) {
+ var enm = new Enum(name, json.values, json.options, json.comment, json.comments);
+ enm.reserved = json.reserved;
+ return enm;
+};
+
+/**
+ * Converts this enum to an enum descriptor.
+ * @param {IToJSONOptions} [toJSONOptions] JSON conversion options
+ * @returns {IEnum} Enum descriptor
+ */
+Enum.prototype.toJSON = function toJSON(toJSONOptions) {
+ var keepComments = toJSONOptions ? Boolean(toJSONOptions.keepComments) : false;
+ return util.toObject([
+ "options" , this.options,
+ "valuesOptions" , this.valuesOptions,
+ "values" , this.values,
+ "reserved" , this.reserved && this.reserved.length ? this.reserved : undefined,
+ "comment" , keepComments ? this.comment : undefined,
+ "comments" , keepComments ? this.comments : undefined
+ ]);
+};
+
+/**
+ * Adds a value to this enum.
+ * @param {string} name Value name
+ * @param {number} id Value id
+ * @param {string} [comment] Comment, if any
+ * @param {Object.|undefined} [options] Options, if any
+ * @returns {Enum} `this`
+ * @throws {TypeError} If arguments are invalid
+ * @throws {Error} If there is already a value with this name or id
+ */
+Enum.prototype.add = function add(name, id, comment, options) {
+ // utilized by the parser but not by .fromJSON
+
+ if (!util.isString(name))
+ throw TypeError("name must be a string");
+
+ if (!util.isInteger(id))
+ throw TypeError("id must be an integer");
+
+ if (this.values[name] !== undefined)
+ throw Error("duplicate name '" + name + "' in " + this);
+
+ if (this.isReservedId(id))
+ throw Error("id " + id + " is reserved in " + this);
+
+ if (this.isReservedName(name))
+ throw Error("name '" + name + "' is reserved in " + this);
+
+ if (this.valuesById[id] !== undefined) {
+ if (!(this.options && this.options.allow_alias))
+ throw Error("duplicate id " + id + " in " + this);
+ this.values[name] = id;
+ } else
+ this.valuesById[this.values[name] = id] = name;
+
+ if (options) {
+ if (this.valuesOptions === undefined)
+ this.valuesOptions = {};
+ this.valuesOptions[name] = options || null;
+ }
+
+ this.comments[name] = comment || null;
+ return this;
+};
+
+/**
+ * Removes a value from this enum
+ * @param {string} name Value name
+ * @returns {Enum} `this`
+ * @throws {TypeError} If arguments are invalid
+ * @throws {Error} If `name` is not a name of this enum
+ */
+Enum.prototype.remove = function remove(name) {
+
+ if (!util.isString(name))
+ throw TypeError("name must be a string");
+
+ var val = this.values[name];
+ if (val == null)
+ throw Error("name '" + name + "' does not exist in " + this);
+
+ delete this.valuesById[val];
+ delete this.values[name];
+ delete this.comments[name];
+ if (this.valuesOptions)
+ delete this.valuesOptions[name];
+
+ return this;
+};
+
+/**
+ * Tests if the specified id is reserved.
+ * @param {number} id Id to test
+ * @returns {boolean} `true` if reserved, otherwise `false`
+ */
+Enum.prototype.isReservedId = function isReservedId(id) {
+ return Namespace.isReservedId(this.reserved, id);
+};
+
+/**
+ * Tests if the specified name is reserved.
+ * @param {string} name Name to test
+ * @returns {boolean} `true` if reserved, otherwise `false`
+ */
+Enum.prototype.isReservedName = function isReservedName(name) {
+ return Namespace.isReservedName(this.reserved, name);
+};
diff --git a/OpenHarmony/library/src/main/ets/src/field.js b/OpenHarmony/library/src/main/ets/src/field.js
new file mode 100644
index 000000000..e0feb8b43
--- /dev/null
+++ b/OpenHarmony/library/src/main/ets/src/field.js
@@ -0,0 +1,377 @@
+"use strict";
+module.exports = Field;
+
+// extends ReflectionObject
+var ReflectionObject = require("./object");
+((Field.prototype = Object.create(ReflectionObject.prototype)).constructor = Field).className = "Field";
+
+var Enum = require("./enum"),
+ types = require("./types"),
+ util = require("./util");
+
+var Type; // cyclic
+
+var ruleRe = /^required|optional|repeated$/;
+
+/**
+ * Constructs a new message field instance. Note that {@link MapField|map fields} have their own class.
+ * @name Field
+ * @classdesc Reflected message field.
+ * @extends FieldBase
+ * @constructor
+ * @param {string} name Unique name within its namespace
+ * @param {number} id Unique id within its namespace
+ * @param {string} type Value type
+ * @param {string|Object.} [rule="optional"] Field rule
+ * @param {string|Object.} [extend] Extended type if different from parent
+ * @param {Object.} [options] Declared options
+ */
+
+/**
+ * Constructs a field from a field descriptor.
+ * @param {string} name Field name
+ * @param {IField} json Field descriptor
+ * @returns {Field} Created field
+ * @throws {TypeError} If arguments are invalid
+ */
+Field.fromJSON = function fromJSON(name, json) {
+ return new Field(name, json.id, json.type, json.rule, json.extend, json.options, json.comment);
+};
+
+/**
+ * Not an actual constructor. Use {@link Field} instead.
+ * @classdesc Base class of all reflected message fields. This is not an actual class but here for the sake of having consistent type definitions.
+ * @exports FieldBase
+ * @extends ReflectionObject
+ * @constructor
+ * @param {string} name Unique name within its namespace
+ * @param {number} id Unique id within its namespace
+ * @param {string} type Value type
+ * @param {string|Object.} [rule="optional"] Field rule
+ * @param {string|Object.} [extend] Extended type if different from parent
+ * @param {Object.} [options] Declared options
+ * @param {string} [comment] Comment associated with this field
+ */
+function Field(name, id, type, rule, extend, options, comment) {
+
+ if (util.isObject(rule)) {
+ comment = extend;
+ options = rule;
+ rule = extend = undefined;
+ } else if (util.isObject(extend)) {
+ comment = options;
+ options = extend;
+ extend = undefined;
+ }
+
+ ReflectionObject.call(this, name, options);
+
+ if (!util.isInteger(id) || id < 0)
+ throw TypeError("id must be a non-negative integer");
+
+ if (!util.isString(type))
+ throw TypeError("type must be a string");
+
+ if (rule !== undefined && !ruleRe.test(rule = rule.toString().toLowerCase()))
+ throw TypeError("rule must be a string rule");
+
+ if (extend !== undefined && !util.isString(extend))
+ throw TypeError("extend must be a string");
+
+ /**
+ * Field rule, if any.
+ * @type {string|undefined}
+ */
+ if (rule === "proto3_optional") {
+ rule = "optional";
+ }
+ this.rule = rule && rule !== "optional" ? rule : undefined; // toJSON
+
+ /**
+ * Field type.
+ * @type {string}
+ */
+ this.type = type; // toJSON
+
+ /**
+ * Unique field id.
+ * @type {number}
+ */
+ this.id = id; // toJSON, marker
+
+ /**
+ * Extended type if different from parent.
+ * @type {string|undefined}
+ */
+ this.extend = extend || undefined; // toJSON
+
+ /**
+ * Whether this field is required.
+ * @type {boolean}
+ */
+ this.required = rule === "required";
+
+ /**
+ * Whether this field is optional.
+ * @type {boolean}
+ */
+ this.optional = !this.required;
+
+ /**
+ * Whether this field is repeated.
+ * @type {boolean}
+ */
+ this.repeated = rule === "repeated";
+
+ /**
+ * Whether this field is a map or not.
+ * @type {boolean}
+ */
+ this.map = false;
+
+ /**
+ * Message this field belongs to.
+ * @type {Type|null}
+ */
+ this.message = null;
+
+ /**
+ * OneOf this field belongs to, if any,
+ * @type {OneOf|null}
+ */
+ this.partOf = null;
+
+ /**
+ * The field type's default value.
+ * @type {*}
+ */
+ this.typeDefault = null;
+
+ /**
+ * The field's default value on prototypes.
+ * @type {*}
+ */
+ this.defaultValue = null;
+
+ /**
+ * Whether this field's value should be treated as a long.
+ * @type {boolean}
+ */
+ this.long = util.Long ? types.long[type] !== undefined : /* istanbul ignore next */ false;
+
+ /**
+ * Whether this field's value is a buffer.
+ * @type {boolean}
+ */
+ this.bytes = type === "bytes";
+
+ /**
+ * Resolved type if not a basic type.
+ * @type {Type|Enum|null}
+ */
+ this.resolvedType = null;
+
+ /**
+ * Sister-field within the extended type if a declaring extension field.
+ * @type {Field|null}
+ */
+ this.extensionField = null;
+
+ /**
+ * Sister-field within the declaring namespace if an extended field.
+ * @type {Field|null}
+ */
+ this.declaringField = null;
+
+ /**
+ * Internally remembers whether this field is packed.
+ * @type {boolean|null}
+ * @private
+ */
+ this._packed = null;
+
+ /**
+ * Comment for this field.
+ * @type {string|null}
+ */
+ this.comment = comment;
+}
+
+/**
+ * Determines whether this field is packed. Only relevant when repeated and working with proto2.
+ * @name Field#packed
+ * @type {boolean}
+ * @readonly
+ */
+Object.defineProperty(Field.prototype, "packed", {
+ get: function() {
+ // defaults to packed=true if not explicity set to false
+ if (this._packed === null)
+ this._packed = this.getOption("packed") !== false;
+ return this._packed;
+ }
+});
+
+/**
+ * @override
+ */
+Field.prototype.setOption = function setOption(name, value, ifNotSet) {
+ if (name === "packed") // clear cached before setting
+ this._packed = null;
+ return ReflectionObject.prototype.setOption.call(this, name, value, ifNotSet);
+};
+
+/**
+ * Field descriptor.
+ * @interface IField
+ * @property {string} [rule="optional"] Field rule
+ * @property {string} type Field type
+ * @property {number} id Field id
+ * @property {Object.} [options] Field options
+ */
+
+/**
+ * Extension field descriptor.
+ * @interface IExtensionField
+ * @extends IField
+ * @property {string} extend Extended type
+ */
+
+/**
+ * Converts this field to a field descriptor.
+ * @param {IToJSONOptions} [toJSONOptions] JSON conversion options
+ * @returns {IField} Field descriptor
+ */
+Field.prototype.toJSON = function toJSON(toJSONOptions) {
+ var keepComments = toJSONOptions ? Boolean(toJSONOptions.keepComments) : false;
+ return util.toObject([
+ "rule" , this.rule !== "optional" && this.rule || undefined,
+ "type" , this.type,
+ "id" , this.id,
+ "extend" , this.extend,
+ "options" , this.options,
+ "comment" , keepComments ? this.comment : undefined
+ ]);
+};
+
+/**
+ * Resolves this field's type references.
+ * @returns {Field} `this`
+ * @throws {Error} If any reference cannot be resolved
+ */
+Field.prototype.resolve = function resolve() {
+
+ if (this.resolved)
+ return this;
+
+ if ((this.typeDefault = types.defaults[this.type]) === undefined) { // if not a basic type, resolve it
+ this.resolvedType = (this.declaringField ? this.declaringField.parent : this.parent).lookupTypeOrEnum(this.type);
+ if (this.resolvedType instanceof Type)
+ this.typeDefault = null;
+ else // instanceof Enum
+ this.typeDefault = this.resolvedType.values[Object.keys(this.resolvedType.values)[0]]; // first defined
+ } else if (this.options && this.options.proto3_optional) {
+ // proto3 scalar value marked optional; should default to null
+ this.typeDefault = null;
+ }
+
+ // use explicitly set default value if present
+ if (this.options && this.options["default"] != null) {
+ this.typeDefault = this.options["default"];
+ if (this.resolvedType instanceof Enum && typeof this.typeDefault === "string")
+ this.typeDefault = this.resolvedType.values[this.typeDefault];
+ }
+
+ // remove unnecessary options
+ if (this.options) {
+ if (this.options.packed === true || this.options.packed !== undefined && this.resolvedType && !(this.resolvedType instanceof Enum))
+ delete this.options.packed;
+ if (!Object.keys(this.options).length)
+ this.options = undefined;
+ }
+
+ // convert to internal data type if necesssary
+ if (this.long) {
+ this.typeDefault = util.Long.fromNumber(this.typeDefault, this.type.charAt(0) === "u");
+
+ /* istanbul ignore else */
+ if (Object.freeze)
+ Object.freeze(this.typeDefault); // long instances are meant to be immutable anyway (i.e. use small int cache that even requires it)
+
+ } else if (this.bytes && typeof this.typeDefault === "string") {
+ var buf;
+ if (util.base64.test(this.typeDefault))
+ util.base64.decode(this.typeDefault, buf = util.newBuffer(util.base64.length(this.typeDefault)), 0);
+ else
+ util.utf8.write(this.typeDefault, buf = util.newBuffer(util.utf8.length(this.typeDefault)), 0);
+ this.typeDefault = buf;
+ }
+
+ // take special care of maps and repeated fields
+ if (this.map)
+ this.defaultValue = util.emptyObject;
+ else if (this.repeated)
+ this.defaultValue = util.emptyArray;
+ else
+ this.defaultValue = this.typeDefault;
+
+ // ensure proper value on prototype
+ if (this.parent instanceof Type)
+ this.parent.ctor.prototype[this.name] = this.defaultValue;
+
+ return ReflectionObject.prototype.resolve.call(this);
+};
+
+/**
+ * Decorator function as returned by {@link Field.d} and {@link MapField.d} (TypeScript).
+ * @typedef FieldDecorator
+ * @type {function}
+ * @param {Object} prototype Target prototype
+ * @param {string} fieldName Field name
+ * @returns {undefined}
+ */
+
+/**
+ * Field decorator (TypeScript).
+ * @name Field.d
+ * @function
+ * @param {number} fieldId Field id
+ * @param {"double"|"float"|"int32"|"uint32"|"sint32"|"fixed32"|"sfixed32"|"int64"|"uint64"|"sint64"|"fixed64"|"sfixed64"|"string"|"bool"|"bytes"|Object} fieldType Field type
+ * @param {"optional"|"required"|"repeated"} [fieldRule="optional"] Field rule
+ * @param {T} [defaultValue] Default value
+ * @returns {FieldDecorator} Decorator function
+ * @template T extends number | number[] | Long | Long[] | string | string[] | boolean | boolean[] | Uint8Array | Uint8Array[] | Buffer | Buffer[]
+ */
+Field.d = function decorateField(fieldId, fieldType, fieldRule, defaultValue) {
+
+ // submessage: decorate the submessage and use its name as the type
+ if (typeof fieldType === "function")
+ fieldType = util.decorateType(fieldType).name;
+
+ // enum reference: create a reflected copy of the enum and keep reuseing it
+ else if (fieldType && typeof fieldType === "object")
+ fieldType = util.decorateEnum(fieldType).name;
+
+ return function fieldDecorator(prototype, fieldName) {
+ util.decorateType(prototype.constructor)
+ .add(new Field(fieldName, fieldId, fieldType, fieldRule, { "default": defaultValue }));
+ };
+};
+
+/**
+ * Field decorator (TypeScript).
+ * @name Field.d
+ * @function
+ * @param {number} fieldId Field id
+ * @param {Constructor|string} fieldType Field type
+ * @param {"optional"|"required"|"repeated"} [fieldRule="optional"] Field rule
+ * @returns {FieldDecorator} Decorator function
+ * @template T extends Message
+ * @variation 2
+ */
+// like Field.d but without a default value
+
+// Sets up cyclic dependencies (called in index-light)
+Field._configure = function configure(Type_) {
+ Type = Type_;
+};
diff --git a/OpenHarmony/library/src/main/ets/src/index-light.js b/OpenHarmony/library/src/main/ets/src/index-light.js
new file mode 100644
index 000000000..32c6a05cd
--- /dev/null
+++ b/OpenHarmony/library/src/main/ets/src/index-light.js
@@ -0,0 +1,104 @@
+"use strict";
+var protobuf = module.exports = require("./index-minimal");
+
+protobuf.build = "light";
+
+/**
+ * A node-style callback as used by {@link load} and {@link Root#load}.
+ * @typedef LoadCallback
+ * @type {function}
+ * @param {Error|null} error Error, if any, otherwise `null`
+ * @param {Root} [root] Root, if there hasn't been an error
+ * @returns {undefined}
+ */
+
+/**
+ * Loads one or multiple .proto or preprocessed .json files into a common root namespace and calls the callback.
+ * @param {string|string[]} filename One or multiple files to load
+ * @param {Root} root Root namespace, defaults to create a new one if omitted.
+ * @param {LoadCallback} callback Callback function
+ * @returns {undefined}
+ * @see {@link Root#load}
+ */
+function load(filename, root, callback) {
+ if (typeof root === "function") {
+ callback = root;
+ root = new protobuf.Root();
+ } else if (!root)
+ root = new protobuf.Root();
+ return root.load(filename, callback);
+}
+
+/**
+ * Loads one or multiple .proto or preprocessed .json files into a common root namespace and calls the callback.
+ * @name load
+ * @function
+ * @param {string|string[]} filename One or multiple files to load
+ * @param {LoadCallback} callback Callback function
+ * @returns {undefined}
+ * @see {@link Root#load}
+ * @variation 2
+ */
+// function load(filename:string, callback:LoadCallback):undefined
+
+/**
+ * Loads one or multiple .proto or preprocessed .json files into a common root namespace and returns a promise.
+ * @name load
+ * @function
+ * @param {string|string[]} filename One or multiple files to load
+ * @param {Root} [root] Root namespace, defaults to create a new one if omitted.
+ * @returns {Promise} Promise
+ * @see {@link Root#load}
+ * @variation 3
+ */
+// function load(filename:string, [root:Root]):Promise
+
+protobuf.load = load;
+
+/**
+ * Synchronously loads one or multiple .proto or preprocessed .json files into a common root namespace (node only).
+ * @param {string|string[]} filename One or multiple files to load
+ * @param {Root} [root] Root namespace, defaults to create a new one if omitted.
+ * @returns {Root} Root namespace
+ * @throws {Error} If synchronous fetching is not supported (i.e. in browsers) or if a file's syntax is invalid
+ * @see {@link Root#loadSync}
+ */
+function loadSync(filename, root) {
+ if (!root)
+ root = new protobuf.Root();
+ return root.loadSync(filename);
+}
+
+protobuf.loadSync = loadSync;
+
+// Serialization
+protobuf.encoder = require("./encoder");
+protobuf.decoder = require("./decoder");
+protobuf.verifier = require("./verifier");
+protobuf.converter = require("./converter");
+
+// Reflection
+protobuf.ReflectionObject = require("./object");
+protobuf.Namespace = require("./namespace");
+protobuf.Root = require("./root");
+protobuf.Enum = require("./enum");
+protobuf.Type = require("./type");
+protobuf.Field = require("./field");
+protobuf.OneOf = require("./oneof");
+protobuf.MapField = require("./mapfield");
+protobuf.Service = require("./service");
+protobuf.Method = require("./method");
+
+// Runtime
+protobuf.Message = require("./message");
+protobuf.wrappers = require("./wrappers");
+
+// Utility
+protobuf.types = require("./types");
+protobuf.util = require("./util");
+
+// Set up possibly cyclic reflection dependencies
+protobuf.ReflectionObject._configure(protobuf.Root);
+protobuf.Namespace._configure(protobuf.Type, protobuf.Service, protobuf.Enum);
+protobuf.Root._configure(protobuf.Type);
+protobuf.Field._configure(protobuf.Type);
diff --git a/OpenHarmony/library/src/main/ets/src/index-minimal.js b/OpenHarmony/library/src/main/ets/src/index-minimal.js
new file mode 100644
index 000000000..1f4aaea6a
--- /dev/null
+++ b/OpenHarmony/library/src/main/ets/src/index-minimal.js
@@ -0,0 +1,36 @@
+"use strict";
+var protobuf = exports;
+
+/**
+ * Build type, one of `"full"`, `"light"` or `"minimal"`.
+ * @name build
+ * @type {string}
+ * @const
+ */
+protobuf.build = "minimal";
+
+// Serialization
+protobuf.Writer = require("./writer");
+protobuf.BufferWriter = require("./writer_buffer");
+protobuf.Reader = require("./reader");
+protobuf.BufferReader = require("./reader_buffer");
+
+// Utility
+protobuf.util = require("./util/minimal");
+protobuf.rpc = require("./rpc");
+protobuf.roots = require("./roots");
+protobuf.configure = configure;
+
+/* istanbul ignore next */
+/**
+ * Reconfigures the library according to the environment.
+ * @returns {undefined}
+ */
+function configure() {
+ protobuf.util._configure();
+ protobuf.Writer._configure(protobuf.BufferWriter);
+ protobuf.Reader._configure(protobuf.BufferReader);
+}
+
+// Set up buffer utility according to the environment
+configure();
diff --git a/OpenHarmony/library/src/main/ets/src/index.js b/OpenHarmony/library/src/main/ets/src/index.js
new file mode 100644
index 000000000..56bd3d5d7
--- /dev/null
+++ b/OpenHarmony/library/src/main/ets/src/index.js
@@ -0,0 +1,12 @@
+"use strict";
+var protobuf = module.exports = require("./index-light");
+
+protobuf.build = "full";
+
+// Parser
+protobuf.tokenize = require("./tokenize");
+protobuf.parse = require("./parse");
+protobuf.common = require("./common");
+
+// Configure parser
+protobuf.Root._configure(protobuf.Type, protobuf.parse, protobuf.common);
diff --git a/OpenHarmony/library/src/main/ets/src/mapfield.js b/OpenHarmony/library/src/main/ets/src/mapfield.js
new file mode 100644
index 000000000..67c70978f
--- /dev/null
+++ b/OpenHarmony/library/src/main/ets/src/mapfield.js
@@ -0,0 +1,126 @@
+"use strict";
+module.exports = MapField;
+
+// extends Field
+var Field = require("./field");
+((MapField.prototype = Object.create(Field.prototype)).constructor = MapField).className = "MapField";
+
+var types = require("./types"),
+ util = require("./util");
+
+/**
+ * Constructs a new map field instance.
+ * @classdesc Reflected map field.
+ * @extends FieldBase
+ * @constructor
+ * @param {string} name Unique name within its namespace
+ * @param {number} id Unique id within its namespace
+ * @param {string} keyType Key type
+ * @param {string} type Value type
+ * @param {Object.} [options] Declared options
+ * @param {string} [comment] Comment associated with this field
+ */
+function MapField(name, id, keyType, type, options, comment) {
+ Field.call(this, name, id, type, undefined, undefined, options, comment);
+
+ /* istanbul ignore if */
+ if (!util.isString(keyType))
+ throw TypeError("keyType must be a string");
+
+ /**
+ * Key type.
+ * @type {string}
+ */
+ this.keyType = keyType; // toJSON, marker
+
+ /**
+ * Resolved key type if not a basic type.
+ * @type {ReflectionObject|null}
+ */
+ this.resolvedKeyType = null;
+
+ // Overrides Field#map
+ this.map = true;
+}
+
+/**
+ * Map field descriptor.
+ * @interface IMapField
+ * @extends {IField}
+ * @property {string} keyType Key type
+ */
+
+/**
+ * Extension map field descriptor.
+ * @interface IExtensionMapField
+ * @extends IMapField
+ * @property {string} extend Extended type
+ */
+
+/**
+ * Constructs a map field from a map field descriptor.
+ * @param {string} name Field name
+ * @param {IMapField} json Map field descriptor
+ * @returns {MapField} Created map field
+ * @throws {TypeError} If arguments are invalid
+ */
+MapField.fromJSON = function fromJSON(name, json) {
+ return new MapField(name, json.id, json.keyType, json.type, json.options, json.comment);
+};
+
+/**
+ * Converts this map field to a map field descriptor.
+ * @param {IToJSONOptions} [toJSONOptions] JSON conversion options
+ * @returns {IMapField} Map field descriptor
+ */
+MapField.prototype.toJSON = function toJSON(toJSONOptions) {
+ var keepComments = toJSONOptions ? Boolean(toJSONOptions.keepComments) : false;
+ return util.toObject([
+ "keyType" , this.keyType,
+ "type" , this.type,
+ "id" , this.id,
+ "extend" , this.extend,
+ "options" , this.options,
+ "comment" , keepComments ? this.comment : undefined
+ ]);
+};
+
+/**
+ * @override
+ */
+MapField.prototype.resolve = function resolve() {
+ if (this.resolved)
+ return this;
+
+ // Besides a value type, map fields have a key type that may be "any scalar type except for floating point types and bytes"
+ if (types.mapKey[this.keyType] === undefined)
+ throw Error("invalid key type: " + this.keyType);
+
+ return Field.prototype.resolve.call(this);
+};
+
+/**
+ * Map field decorator (TypeScript).
+ * @name MapField.d
+ * @function
+ * @param {number} fieldId Field id
+ * @param {"int32"|"uint32"|"sint32"|"fixed32"|"sfixed32"|"int64"|"uint64"|"sint64"|"fixed64"|"sfixed64"|"bool"|"string"} fieldKeyType Field key type
+ * @param {"double"|"float"|"int32"|"uint32"|"sint32"|"fixed32"|"sfixed32"|"int64"|"uint64"|"sint64"|"fixed64"|"sfixed64"|"bool"|"string"|"bytes"|Object|Constructor<{}>} fieldValueType Field value type
+ * @returns {FieldDecorator} Decorator function
+ * @template T extends { [key: string]: number | Long | string | boolean | Uint8Array | Buffer | number[] | Message<{}> }
+ */
+MapField.d = function decorateMapField(fieldId, fieldKeyType, fieldValueType) {
+
+ // submessage value: decorate the submessage and use its name as the type
+ if (typeof fieldValueType === "function")
+ fieldValueType = util.decorateType(fieldValueType).name;
+
+ // enum reference value: create a reflected copy of the enum and keep reuseing it
+ else if (fieldValueType && typeof fieldValueType === "object")
+ fieldValueType = util.decorateEnum(fieldValueType).name;
+
+ return function mapFieldDecorator(prototype, fieldName) {
+ util.decorateType(prototype.constructor)
+ .add(new MapField(fieldName, fieldId, fieldKeyType, fieldValueType));
+ };
+};
diff --git a/OpenHarmony/library/src/main/ets/src/message.js b/OpenHarmony/library/src/main/ets/src/message.js
new file mode 100644
index 000000000..3f94bf6a8
--- /dev/null
+++ b/OpenHarmony/library/src/main/ets/src/message.js
@@ -0,0 +1,139 @@
+"use strict";
+module.exports = Message;
+
+var util = require("./util/minimal");
+
+/**
+ * Constructs a new message instance.
+ * @classdesc Abstract runtime message.
+ * @constructor
+ * @param {Properties} [properties] Properties to set
+ * @template T extends object = object
+ */
+function Message(properties) {
+ // not used internally
+ if (properties)
+ for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
+ this[keys[i]] = properties[keys[i]];
+}
+
+/**
+ * Reference to the reflected type.
+ * @name Message.$type
+ * @type {Type}
+ * @readonly
+ */
+
+/**
+ * Reference to the reflected type.
+ * @name Message#$type
+ * @type {Type}
+ * @readonly
+ */
+
+/*eslint-disable valid-jsdoc*/
+
+/**
+ * Creates a new message of this type using the specified properties.
+ * @param {Object.} [properties] Properties to set
+ * @returns {Message} Message instance
+ * @template T extends Message
+ * @this Constructor
+ */
+Message.create = function create(properties) {
+ return this.$type.create(properties);
+};
+
+/**
+ * Encodes a message of this type.
+ * @param {T|Object.} message Message to encode
+ * @param {Writer} [writer] Writer to use
+ * @returns {Writer} Writer
+ * @template T extends Message
+ * @this Constructor
+ */
+Message.encode = function encode(message, writer) {
+ return this.$type.encode(message, writer);
+};
+
+/**
+ * Encodes a message of this type preceeded by its length as a varint.
+ * @param {T|Object.} message Message to encode
+ * @param {Writer} [writer] Writer to use
+ * @returns {Writer} Writer
+ * @template T extends Message
+ * @this Constructor
+ */
+Message.encodeDelimited = function encodeDelimited(message, writer) {
+ return this.$type.encodeDelimited(message, writer);
+};
+
+/**
+ * Decodes a message of this type.
+ * @name Message.decode
+ * @function
+ * @param {Reader|Uint8Array} reader Reader or buffer to decode
+ * @returns {T} Decoded message
+ * @template T extends Message
+ * @this Constructor
+ */
+Message.decode = function decode(reader) {
+ return this.$type.decode(reader);
+};
+
+/**
+ * Decodes a message of this type preceeded by its length as a varint.
+ * @name Message.decodeDelimited
+ * @function
+ * @param {Reader|Uint8Array} reader Reader or buffer to decode
+ * @returns {T} Decoded message
+ * @template T extends Message
+ * @this Constructor
+ */
+Message.decodeDelimited = function decodeDelimited(reader) {
+ return this.$type.decodeDelimited(reader);
+};
+
+/**
+ * Verifies a message of this type.
+ * @name Message.verify
+ * @function
+ * @param {Object.} message Plain object to verify
+ * @returns {string|null} `null` if valid, otherwise the reason why it is not
+ */
+Message.verify = function verify(message) {
+ return this.$type.verify(message);
+};
+
+/**
+ * Creates a new message of this type from a plain object. Also converts values to their respective internal types.
+ * @param {Object.} object Plain object
+ * @returns {T} Message instance
+ * @template T extends Message
+ * @this Constructor
+ */
+Message.fromObject = function fromObject(object) {
+ return this.$type.fromObject(object);
+};
+
+/**
+ * Creates a plain object from a message of this type. Also converts values to other types if specified.
+ * @param {T} message Message instance
+ * @param {IConversionOptions} [options] Conversion options
+ * @returns {Object.} Plain object
+ * @template T extends Message
+ * @this Constructor
+ */
+Message.toObject = function toObject(message, options) {
+ return this.$type.toObject(message, options);
+};
+
+/**
+ * Converts this message to JSON.
+ * @returns {Object.} JSON object
+ */
+Message.prototype.toJSON = function toJSON() {
+ return this.$type.toObject(this, util.toJSONOptions);
+};
+
+/*eslint-enable valid-jsdoc*/
\ No newline at end of file
diff --git a/OpenHarmony/library/src/main/ets/src/method.js b/OpenHarmony/library/src/main/ets/src/method.js
new file mode 100644
index 000000000..18a6ab2cf
--- /dev/null
+++ b/OpenHarmony/library/src/main/ets/src/method.js
@@ -0,0 +1,160 @@
+"use strict";
+module.exports = Method;
+
+// extends ReflectionObject
+var ReflectionObject = require("./object");
+((Method.prototype = Object.create(ReflectionObject.prototype)).constructor = Method).className = "Method";
+
+var util = require("./util");
+
+/**
+ * Constructs a new service method instance.
+ * @classdesc Reflected service method.
+ * @extends ReflectionObject
+ * @constructor
+ * @param {string} name Method name
+ * @param {string|undefined} type Method type, usually `"rpc"`
+ * @param {string} requestType Request message type
+ * @param {string} responseType Response message type
+ * @param {boolean|Object.} [requestStream] Whether the request is streamed
+ * @param {boolean|Object.} [responseStream] Whether the response is streamed
+ * @param {Object.} [options] Declared options
+ * @param {string} [comment] The comment for this method
+ * @param {Object.} [parsedOptions] Declared options, properly parsed into an object
+ */
+function Method(name, type, requestType, responseType, requestStream, responseStream, options, comment, parsedOptions) {
+
+ /* istanbul ignore next */
+ if (util.isObject(requestStream)) {
+ options = requestStream;
+ requestStream = responseStream = undefined;
+ } else if (util.isObject(responseStream)) {
+ options = responseStream;
+ responseStream = undefined;
+ }
+
+ /* istanbul ignore if */
+ if (!(type === undefined || util.isString(type)))
+ throw TypeError("type must be a string");
+
+ /* istanbul ignore if */
+ if (!util.isString(requestType))
+ throw TypeError("requestType must be a string");
+
+ /* istanbul ignore if */
+ if (!util.isString(responseType))
+ throw TypeError("responseType must be a string");
+
+ ReflectionObject.call(this, name, options);
+
+ /**
+ * Method type.
+ * @type {string}
+ */
+ this.type = type || "rpc"; // toJSON
+
+ /**
+ * Request type.
+ * @type {string}
+ */
+ this.requestType = requestType; // toJSON, marker
+
+ /**
+ * Whether requests are streamed or not.
+ * @type {boolean|undefined}
+ */
+ this.requestStream = requestStream ? true : undefined; // toJSON
+
+ /**
+ * Response type.
+ * @type {string}
+ */
+ this.responseType = responseType; // toJSON
+
+ /**
+ * Whether responses are streamed or not.
+ * @type {boolean|undefined}
+ */
+ this.responseStream = responseStream ? true : undefined; // toJSON
+
+ /**
+ * Resolved request type.
+ * @type {Type|null}
+ */
+ this.resolvedRequestType = null;
+
+ /**
+ * Resolved response type.
+ * @type {Type|null}
+ */
+ this.resolvedResponseType = null;
+
+ /**
+ * Comment for this method
+ * @type {string|null}
+ */
+ this.comment = comment;
+
+ /**
+ * Options properly parsed into an object
+ */
+ this.parsedOptions = parsedOptions;
+}
+
+/**
+ * Method descriptor.
+ * @interface IMethod
+ * @property {string} [type="rpc"] Method type
+ * @property {string} requestType Request type
+ * @property {string} responseType Response type
+ * @property {boolean} [requestStream=false] Whether requests are streamed
+ * @property {boolean} [responseStream=false] Whether responses are streamed
+ * @property {Object.} [options] Method options
+ * @property {string} comment Method comments
+ * @property {Object.} [parsedOptions] Method options properly parsed into an object
+ */
+
+/**
+ * Constructs a method from a method descriptor.
+ * @param {string} name Method name
+ * @param {IMethod} json Method descriptor
+ * @returns {Method} Created method
+ * @throws {TypeError} If arguments are invalid
+ */
+Method.fromJSON = function fromJSON(name, json) {
+ return new Method(name, json.type, json.requestType, json.responseType, json.requestStream, json.responseStream, json.options, json.comment, json.parsedOptions);
+};
+
+/**
+ * Converts this method to a method descriptor.
+ * @param {IToJSONOptions} [toJSONOptions] JSON conversion options
+ * @returns {IMethod} Method descriptor
+ */
+Method.prototype.toJSON = function toJSON(toJSONOptions) {
+ var keepComments = toJSONOptions ? Boolean(toJSONOptions.keepComments) : false;
+ return util.toObject([
+ "type" , this.type !== "rpc" && /* istanbul ignore next */ this.type || undefined,
+ "requestType" , this.requestType,
+ "requestStream" , this.requestStream,
+ "responseType" , this.responseType,
+ "responseStream" , this.responseStream,
+ "options" , this.options,
+ "comment" , keepComments ? this.comment : undefined,
+ "parsedOptions" , this.parsedOptions,
+ ]);
+};
+
+/**
+ * @override
+ */
+Method.prototype.resolve = function resolve() {
+
+ /* istanbul ignore if */
+ if (this.resolved)
+ return this;
+
+ this.resolvedRequestType = this.parent.lookupType(this.requestType);
+ this.resolvedResponseType = this.parent.lookupType(this.responseType);
+
+ return ReflectionObject.prototype.resolve.call(this);
+};
diff --git a/OpenHarmony/library/src/main/ets/src/namespace.js b/OpenHarmony/library/src/main/ets/src/namespace.js
new file mode 100644
index 000000000..731afc75f
--- /dev/null
+++ b/OpenHarmony/library/src/main/ets/src/namespace.js
@@ -0,0 +1,433 @@
+"use strict";
+module.exports = Namespace;
+
+// extends ReflectionObject
+var ReflectionObject = require("./object");
+((Namespace.prototype = Object.create(ReflectionObject.prototype)).constructor = Namespace).className = "Namespace";
+
+var Field = require("./field"),
+ util = require("./util"),
+ OneOf = require("./oneof");
+
+var Type, // cyclic
+ Service,
+ Enum;
+
+/**
+ * Constructs a new namespace instance.
+ * @name Namespace
+ * @classdesc Reflected namespace.
+ * @extends NamespaceBase
+ * @constructor
+ * @param {string} name Namespace name
+ * @param {Object.} [options] Declared options
+ */
+
+/**
+ * Constructs a namespace from JSON.
+ * @memberof Namespace
+ * @function
+ * @param {string} name Namespace name
+ * @param {Object.} json JSON object
+ * @returns {Namespace} Created namespace
+ * @throws {TypeError} If arguments are invalid
+ */
+Namespace.fromJSON = function fromJSON(name, json) {
+ return new Namespace(name, json.options).addJSON(json.nested);
+};
+
+/**
+ * Converts an array of reflection objects to JSON.
+ * @memberof Namespace
+ * @param {ReflectionObject[]} array Object array
+ * @param {IToJSONOptions} [toJSONOptions] JSON conversion options
+ * @returns {Object.|undefined} JSON object or `undefined` when array is empty
+ */
+function arrayToJSON(array, toJSONOptions) {
+ if (!(array && array.length))
+ return undefined;
+ var obj = {};
+ for (var i = 0; i < array.length; ++i)
+ obj[array[i].name] = array[i].toJSON(toJSONOptions);
+ return obj;
+}
+
+Namespace.arrayToJSON = arrayToJSON;
+
+/**
+ * Tests if the specified id is reserved.
+ * @param {Array.|undefined} reserved Array of reserved ranges and names
+ * @param {number} id Id to test
+ * @returns {boolean} `true` if reserved, otherwise `false`
+ */
+Namespace.isReservedId = function isReservedId(reserved, id) {
+ if (reserved)
+ for (var i = 0; i < reserved.length; ++i)
+ if (typeof reserved[i] !== "string" && reserved[i][0] <= id && reserved[i][1] > id)
+ return true;
+ return false;
+};
+
+/**
+ * Tests if the specified name is reserved.
+ * @param {Array.|undefined} reserved Array of reserved ranges and names
+ * @param {string} name Name to test
+ * @returns {boolean} `true` if reserved, otherwise `false`
+ */
+Namespace.isReservedName = function isReservedName(reserved, name) {
+ if (reserved)
+ for (var i = 0; i < reserved.length; ++i)
+ if (reserved[i] === name)
+ return true;
+ return false;
+};
+
+/**
+ * Not an actual constructor. Use {@link Namespace} instead.
+ * @classdesc Base class of all reflection objects containing nested objects. This is not an actual class but here for the sake of having consistent type definitions.
+ * @exports NamespaceBase
+ * @extends ReflectionObject
+ * @abstract
+ * @constructor
+ * @param {string} name Namespace name
+ * @param {Object.} [options] Declared options
+ * @see {@link Namespace}
+ */
+function Namespace(name, options) {
+ ReflectionObject.call(this, name, options);
+
+ /**
+ * Nested objects by name.
+ * @type {Object.|undefined}
+ */
+ this.nested = undefined; // toJSON
+
+ /**
+ * Cached nested objects as an array.
+ * @type {ReflectionObject[]|null}
+ * @private
+ */
+ this._nestedArray = null;
+}
+
+function clearCache(namespace) {
+ namespace._nestedArray = null;
+ return namespace;
+}
+
+/**
+ * Nested objects of this namespace as an array for iteration.
+ * @name NamespaceBase#nestedArray
+ * @type {ReflectionObject[]}
+ * @readonly
+ */
+Object.defineProperty(Namespace.prototype, "nestedArray", {
+ get: function() {
+ return this._nestedArray || (this._nestedArray = util.toArray(this.nested));
+ }
+});
+
+/**
+ * Namespace descriptor.
+ * @interface INamespace
+ * @property {Object.} [options] Namespace options
+ * @property {Object.} [nested] Nested object descriptors
+ */
+
+/**
+ * Any extension field descriptor.
+ * @typedef AnyExtensionField
+ * @type {IExtensionField|IExtensionMapField}
+ */
+
+/**
+ * Any nested object descriptor.
+ * @typedef AnyNestedObject
+ * @type {IEnum|IType|IService|AnyExtensionField|INamespace|IOneOf}
+ */
+
+/**
+ * Converts this namespace to a namespace descriptor.
+ * @param {IToJSONOptions} [toJSONOptions] JSON conversion options
+ * @returns {INamespace} Namespace descriptor
+ */
+Namespace.prototype.toJSON = function toJSON(toJSONOptions) {
+ return util.toObject([
+ "options" , this.options,
+ "nested" , arrayToJSON(this.nestedArray, toJSONOptions)
+ ]);
+};
+
+/**
+ * Adds nested objects to this namespace from nested object descriptors.
+ * @param {Object.} nestedJson Any nested object descriptors
+ * @returns {Namespace} `this`
+ */
+Namespace.prototype.addJSON = function addJSON(nestedJson) {
+ var ns = this;
+ /* istanbul ignore else */
+ if (nestedJson) {
+ for (var names = Object.keys(nestedJson), i = 0, nested; i < names.length; ++i) {
+ nested = nestedJson[names[i]];
+ ns.add( // most to least likely
+ ( nested.fields !== undefined
+ ? Type.fromJSON
+ : nested.values !== undefined
+ ? Enum.fromJSON
+ : nested.methods !== undefined
+ ? Service.fromJSON
+ : nested.id !== undefined
+ ? Field.fromJSON
+ : Namespace.fromJSON )(names[i], nested)
+ );
+ }
+ }
+ return this;
+};
+
+/**
+ * Gets the nested object of the specified name.
+ * @param {string} name Nested object name
+ * @returns {ReflectionObject|null} The reflection object or `null` if it doesn't exist
+ */
+Namespace.prototype.get = function get(name) {
+ return this.nested && this.nested[name]
+ || null;
+};
+
+/**
+ * Gets the values of the nested {@link Enum|enum} of the specified name.
+ * This methods differs from {@link Namespace#get|get} in that it returns an enum's values directly and throws instead of returning `null`.
+ * @param {string} name Nested enum name
+ * @returns {Object.} Enum values
+ * @throws {Error} If there is no such enum
+ */
+Namespace.prototype.getEnum = function getEnum(name) {
+ if (this.nested && this.nested[name] instanceof Enum)
+ return this.nested[name].values;
+ throw Error("no such enum: " + name);
+};
+
+/**
+ * Adds a nested object to this namespace.
+ * @param {ReflectionObject} object Nested object to add
+ * @returns {Namespace} `this`
+ * @throws {TypeError} If arguments are invalid
+ * @throws {Error} If there is already a nested object with this name
+ */
+Namespace.prototype.add = function add(object) {
+
+ if (!(object instanceof Field && object.extend !== undefined || object instanceof Type || object instanceof OneOf || object instanceof Enum || object instanceof Service || object instanceof Namespace))
+ throw TypeError("object must be a valid nested object");
+
+ if (!this.nested)
+ this.nested = {};
+ else {
+ var prev = this.get(object.name);
+ if (prev) {
+ if (prev instanceof Namespace && object instanceof Namespace && !(prev instanceof Type || prev instanceof Service)) {
+ // replace plain namespace but keep existing nested elements and options
+ var nested = prev.nestedArray;
+ for (var i = 0; i < nested.length; ++i)
+ object.add(nested[i]);
+ this.remove(prev);
+ if (!this.nested)
+ this.nested = {};
+ object.setOptions(prev.options, true);
+
+ } else
+ throw Error("duplicate name '" + object.name + "' in " + this);
+ }
+ }
+ this.nested[object.name] = object;
+ object.onAdd(this);
+ return clearCache(this);
+};
+
+/**
+ * Removes a nested object from this namespace.
+ * @param {ReflectionObject} object Nested object to remove
+ * @returns {Namespace} `this`
+ * @throws {TypeError} If arguments are invalid
+ * @throws {Error} If `object` is not a member of this namespace
+ */
+Namespace.prototype.remove = function remove(object) {
+
+ if (!(object instanceof ReflectionObject))
+ throw TypeError("object must be a ReflectionObject");
+ if (object.parent !== this)
+ throw Error(object + " is not a member of " + this);
+
+ delete this.nested[object.name];
+ if (!Object.keys(this.nested).length)
+ this.nested = undefined;
+
+ object.onRemove(this);
+ return clearCache(this);
+};
+
+/**
+ * Defines additial namespaces within this one if not yet existing.
+ * @param {string|string[]} path Path to create
+ * @param {*} [json] Nested types to create from JSON
+ * @returns {Namespace} Pointer to the last namespace created or `this` if path is empty
+ */
+Namespace.prototype.define = function define(path, json) {
+
+ if (util.isString(path))
+ path = path.split(".");
+ else if (!Array.isArray(path))
+ throw TypeError("illegal path");
+ if (path && path.length && path[0] === "")
+ throw Error("path must be relative");
+
+ var ptr = this;
+ while (path.length > 0) {
+ var part = path.shift();
+ if (ptr.nested && ptr.nested[part]) {
+ ptr = ptr.nested[part];
+ if (!(ptr instanceof Namespace))
+ throw Error("path conflicts with non-namespace objects");
+ } else
+ ptr.add(ptr = new Namespace(part));
+ }
+ if (json)
+ ptr.addJSON(json);
+ return ptr;
+};
+
+/**
+ * Resolves this namespace's and all its nested objects' type references. Useful to validate a reflection tree, but comes at a cost.
+ * @returns {Namespace} `this`
+ */
+Namespace.prototype.resolveAll = function resolveAll() {
+ var nested = this.nestedArray, i = 0;
+ while (i < nested.length)
+ if (nested[i] instanceof Namespace)
+ nested[i++].resolveAll();
+ else
+ nested[i++].resolve();
+ return this.resolve();
+};
+
+/**
+ * Recursively looks up the reflection object matching the specified path in the scope of this namespace.
+ * @param {string|string[]} path Path to look up
+ * @param {*|Array.<*>} filterTypes Filter types, any combination of the constructors of `protobuf.Type`, `protobuf.Enum`, `protobuf.Service` etc.
+ * @param {boolean} [parentAlreadyChecked=false] If known, whether the parent has already been checked
+ * @returns {ReflectionObject|null} Looked up object or `null` if none could be found
+ */
+Namespace.prototype.lookup = function lookup(path, filterTypes, parentAlreadyChecked) {
+
+ /* istanbul ignore next */
+ if (typeof filterTypes === "boolean") {
+ parentAlreadyChecked = filterTypes;
+ filterTypes = undefined;
+ } else if (filterTypes && !Array.isArray(filterTypes))
+ filterTypes = [ filterTypes ];
+
+ if (util.isString(path) && path.length) {
+ if (path === ".")
+ return this.root;
+ path = path.split(".");
+ } else if (!path.length)
+ return this;
+
+ // Start at root if path is absolute
+ if (path[0] === "")
+ return this.root.lookup(path.slice(1), filterTypes);
+
+ // Test if the first part matches any nested object, and if so, traverse if path contains more
+ var found = this.get(path[0]);
+ if (found) {
+ if (path.length === 1) {
+ if (!filterTypes || filterTypes.indexOf(found.constructor) > -1)
+ return found;
+ } else if (found instanceof Namespace && (found = found.lookup(path.slice(1), filterTypes, true)))
+ return found;
+
+ // Otherwise try each nested namespace
+ } else
+ for (var i = 0; i < this.nestedArray.length; ++i)
+ if (this._nestedArray[i] instanceof Namespace && (found = this._nestedArray[i].lookup(path, filterTypes, true)))
+ return found;
+
+ // If there hasn't been a match, try again at the parent
+ if (this.parent === null || parentAlreadyChecked)
+ return null;
+ return this.parent.lookup(path, filterTypes);
+};
+
+/**
+ * Looks up the reflection object at the specified path, relative to this namespace.
+ * @name NamespaceBase#lookup
+ * @function
+ * @param {string|string[]} path Path to look up
+ * @param {boolean} [parentAlreadyChecked=false] Whether the parent has already been checked
+ * @returns {ReflectionObject|null} Looked up object or `null` if none could be found
+ * @variation 2
+ */
+// lookup(path: string, [parentAlreadyChecked: boolean])
+
+/**
+ * Looks up the {@link Type|type} at the specified path, relative to this namespace.
+ * Besides its signature, this methods differs from {@link Namespace#lookup|lookup} in that it throws instead of returning `null`.
+ * @param {string|string[]} path Path to look up
+ * @returns {Type} Looked up type
+ * @throws {Error} If `path` does not point to a type
+ */
+Namespace.prototype.lookupType = function lookupType(path) {
+ var found = this.lookup(path, [ Type ]);
+ if (!found)
+ throw Error("no such type: " + path);
+ return found;
+};
+
+/**
+ * Looks up the values of the {@link Enum|enum} at the specified path, relative to this namespace.
+ * Besides its signature, this methods differs from {@link Namespace#lookup|lookup} in that it throws instead of returning `null`.
+ * @param {string|string[]} path Path to look up
+ * @returns {Enum} Looked up enum
+ * @throws {Error} If `path` does not point to an enum
+ */
+Namespace.prototype.lookupEnum = function lookupEnum(path) {
+ var found = this.lookup(path, [ Enum ]);
+ if (!found)
+ throw Error("no such Enum '" + path + "' in " + this);
+ return found;
+};
+
+/**
+ * Looks up the {@link Type|type} or {@link Enum|enum} at the specified path, relative to this namespace.
+ * Besides its signature, this methods differs from {@link Namespace#lookup|lookup} in that it throws instead of returning `null`.
+ * @param {string|string[]} path Path to look up
+ * @returns {Type} Looked up type or enum
+ * @throws {Error} If `path` does not point to a type or enum
+ */
+Namespace.prototype.lookupTypeOrEnum = function lookupTypeOrEnum(path) {
+ var found = this.lookup(path, [ Type, Enum ]);
+ if (!found)
+ throw Error("no such Type or Enum '" + path + "' in " + this);
+ return found;
+};
+
+/**
+ * Looks up the {@link Service|service} at the specified path, relative to this namespace.
+ * Besides its signature, this methods differs from {@link Namespace#lookup|lookup} in that it throws instead of returning `null`.
+ * @param {string|string[]} path Path to look up
+ * @returns {Service} Looked up service
+ * @throws {Error} If `path` does not point to a service
+ */
+Namespace.prototype.lookupService = function lookupService(path) {
+ var found = this.lookup(path, [ Service ]);
+ if (!found)
+ throw Error("no such Service '" + path + "' in " + this);
+ return found;
+};
+
+// Sets up cyclic dependencies (called in index-light)
+Namespace._configure = function(Type_, Service_, Enum_) {
+ Type = Type_;
+ Service = Service_;
+ Enum = Enum_;
+};
diff --git a/OpenHarmony/library/src/main/ets/src/object.js b/OpenHarmony/library/src/main/ets/src/object.js
new file mode 100644
index 000000000..bd04ceca8
--- /dev/null
+++ b/OpenHarmony/library/src/main/ets/src/object.js
@@ -0,0 +1,243 @@
+"use strict";
+module.exports = ReflectionObject;
+
+ReflectionObject.className = "ReflectionObject";
+
+var util = require("./util");
+
+var Root; // cyclic
+
+/**
+ * Constructs a new reflection object instance.
+ * @classdesc Base class of all reflection objects.
+ * @constructor
+ * @param {string} name Object name
+ * @param {Object.} [options] Declared options
+ * @abstract
+ */
+function ReflectionObject(name, options) {
+
+ if (!util.isString(name))
+ throw TypeError("name must be a string");
+
+ if (options && !util.isObject(options))
+ throw TypeError("options must be an object");
+
+ /**
+ * Options.
+ * @type {Object.|undefined}
+ */
+ this.options = options; // toJSON
+
+ /**
+ * Parsed Options.
+ * @type {Array.>|undefined}
+ */
+ this.parsedOptions = null;
+
+ /**
+ * Unique name within its namespace.
+ * @type {string}
+ */
+ this.name = name;
+
+ /**
+ * Parent namespace.
+ * @type {Namespace|null}
+ */
+ this.parent = null;
+
+ /**
+ * Whether already resolved or not.
+ * @type {boolean}
+ */
+ this.resolved = false;
+
+ /**
+ * Comment text, if any.
+ * @type {string|null}
+ */
+ this.comment = null;
+
+ /**
+ * Defining file name.
+ * @type {string|null}
+ */
+ this.filename = null;
+}
+
+Object.defineProperties(ReflectionObject.prototype, {
+
+ /**
+ * Reference to the root namespace.
+ * @name ReflectionObject#root
+ * @type {Root}
+ * @readonly
+ */
+ root: {
+ get: function() {
+ var ptr = this;
+ while (ptr.parent !== null)
+ ptr = ptr.parent;
+ return ptr;
+ }
+ },
+
+ /**
+ * Full name including leading dot.
+ * @name ReflectionObject#fullName
+ * @type {string}
+ * @readonly
+ */
+ fullName: {
+ get: function() {
+ var path = [ this.name ],
+ ptr = this.parent;
+ while (ptr) {
+ path.unshift(ptr.name);
+ ptr = ptr.parent;
+ }
+ return path.join(".");
+ }
+ }
+});
+
+/**
+ * Converts this reflection object to its descriptor representation.
+ * @returns {Object.} Descriptor
+ * @abstract
+ */
+ReflectionObject.prototype.toJSON = /* istanbul ignore next */ function toJSON() {
+ throw Error(); // not implemented, shouldn't happen
+};
+
+/**
+ * Called when this object is added to a parent.
+ * @param {ReflectionObject} parent Parent added to
+ * @returns {undefined}
+ */
+ReflectionObject.prototype.onAdd = function onAdd(parent) {
+ if (this.parent && this.parent !== parent)
+ this.parent.remove(this);
+ this.parent = parent;
+ this.resolved = false;
+ var root = parent.root;
+ if (root instanceof Root)
+ root._handleAdd(this);
+};
+
+/**
+ * Called when this object is removed from a parent.
+ * @param {ReflectionObject} parent Parent removed from
+ * @returns {undefined}
+ */
+ReflectionObject.prototype.onRemove = function onRemove(parent) {
+ var root = parent.root;
+ if (root instanceof Root)
+ root._handleRemove(this);
+ this.parent = null;
+ this.resolved = false;
+};
+
+/**
+ * Resolves this objects type references.
+ * @returns {ReflectionObject} `this`
+ */
+ReflectionObject.prototype.resolve = function resolve() {
+ if (this.resolved)
+ return this;
+ if (this.root instanceof Root)
+ this.resolved = true; // only if part of a root
+ return this;
+};
+
+/**
+ * Gets an option value.
+ * @param {string} name Option name
+ * @returns {*} Option value or `undefined` if not set
+ */
+ReflectionObject.prototype.getOption = function getOption(name) {
+ if (this.options)
+ return this.options[name];
+ return undefined;
+};
+
+/**
+ * Sets an option.
+ * @param {string} name Option name
+ * @param {*} value Option value
+ * @param {boolean} [ifNotSet] Sets the option only if it isn't currently set
+ * @returns {ReflectionObject} `this`
+ */
+ReflectionObject.prototype.setOption = function setOption(name, value, ifNotSet) {
+ if (!ifNotSet || !this.options || this.options[name] === undefined)
+ (this.options || (this.options = {}))[name] = value;
+ return this;
+};
+
+/**
+ * Sets a parsed option.
+ * @param {string} name parsed Option name
+ * @param {*} value Option value
+ * @param {string} propName dot '.' delimited full path of property within the option to set. if undefined\empty, will add a new option with that value
+ * @returns {ReflectionObject} `this`
+ */
+ReflectionObject.prototype.setParsedOption = function setParsedOption(name, value, propName) {
+ if (!this.parsedOptions) {
+ this.parsedOptions = [];
+ }
+ var parsedOptions = this.parsedOptions;
+ if (propName) {
+ // If setting a sub property of an option then try to merge it
+ // with an existing option
+ var opt = parsedOptions.find(function (opt) {
+ return Object.prototype.hasOwnProperty.call(opt, name);
+ });
+ if (opt) {
+ // If we found an existing option - just merge the property value
+ var newValue = opt[name];
+ util.setProperty(newValue, propName, value);
+ } else {
+ // otherwise, create a new option, set it's property and add it to the list
+ opt = {};
+ opt[name] = util.setProperty({}, propName, value);
+ parsedOptions.push(opt);
+ }
+ } else {
+ // Always create a new option when setting the value of the option itself
+ var newOpt = {};
+ newOpt[name] = value;
+ parsedOptions.push(newOpt);
+ }
+ return this;
+};
+
+/**
+ * Sets multiple options.
+ * @param {Object.} options Options to set
+ * @param {boolean} [ifNotSet] Sets an option only if it isn't currently set
+ * @returns {ReflectionObject} `this`
+ */
+ReflectionObject.prototype.setOptions = function setOptions(options, ifNotSet) {
+ if (options)
+ for (var keys = Object.keys(options), i = 0; i < keys.length; ++i)
+ this.setOption(keys[i], options[keys[i]], ifNotSet);
+ return this;
+};
+
+/**
+ * Converts this instance to its string representation.
+ * @returns {string} Class name[, space, full name]
+ */
+ReflectionObject.prototype.toString = function toString() {
+ var className = this.constructor.className,
+ fullName = this.fullName;
+ if (fullName.length)
+ return className + " " + fullName;
+ return className;
+};
+
+// Sets up cyclic dependencies (called in index-light)
+ReflectionObject._configure = function(Root_) {
+ Root = Root_;
+};
diff --git a/OpenHarmony/library/src/main/ets/src/oneof.js b/OpenHarmony/library/src/main/ets/src/oneof.js
new file mode 100644
index 000000000..ba0e90279
--- /dev/null
+++ b/OpenHarmony/library/src/main/ets/src/oneof.js
@@ -0,0 +1,203 @@
+"use strict";
+module.exports = OneOf;
+
+// extends ReflectionObject
+var ReflectionObject = require("./object");
+((OneOf.prototype = Object.create(ReflectionObject.prototype)).constructor = OneOf).className = "OneOf";
+
+var Field = require("./field"),
+ util = require("./util");
+
+/**
+ * Constructs a new oneof instance.
+ * @classdesc Reflected oneof.
+ * @extends ReflectionObject
+ * @constructor
+ * @param {string} name Oneof name
+ * @param {string[]|Object.} [fieldNames] Field names
+ * @param {Object.} [options] Declared options
+ * @param {string} [comment] Comment associated with this field
+ */
+function OneOf(name, fieldNames, options, comment) {
+ if (!Array.isArray(fieldNames)) {
+ options = fieldNames;
+ fieldNames = undefined;
+ }
+ ReflectionObject.call(this, name, options);
+
+ /* istanbul ignore if */
+ if (!(fieldNames === undefined || Array.isArray(fieldNames)))
+ throw TypeError("fieldNames must be an Array");
+
+ /**
+ * Field names that belong to this oneof.
+ * @type {string[]}
+ */
+ this.oneof = fieldNames || []; // toJSON, marker
+
+ /**
+ * Fields that belong to this oneof as an array for iteration.
+ * @type {Field[]}
+ * @readonly
+ */
+ this.fieldsArray = []; // declared readonly for conformance, possibly not yet added to parent
+
+ /**
+ * Comment for this field.
+ * @type {string|null}
+ */
+ this.comment = comment;
+}
+
+/**
+ * Oneof descriptor.
+ * @interface IOneOf
+ * @property {Array.} oneof Oneof field names
+ * @property {Object.} [options] Oneof options
+ */
+
+/**
+ * Constructs a oneof from a oneof descriptor.
+ * @param {string} name Oneof name
+ * @param {IOneOf} json Oneof descriptor
+ * @returns {OneOf} Created oneof
+ * @throws {TypeError} If arguments are invalid
+ */
+OneOf.fromJSON = function fromJSON(name, json) {
+ return new OneOf(name, json.oneof, json.options, json.comment);
+};
+
+/**
+ * Converts this oneof to a oneof descriptor.
+ * @param {IToJSONOptions} [toJSONOptions] JSON conversion options
+ * @returns {IOneOf} Oneof descriptor
+ */
+OneOf.prototype.toJSON = function toJSON(toJSONOptions) {
+ var keepComments = toJSONOptions ? Boolean(toJSONOptions.keepComments) : false;
+ return util.toObject([
+ "options" , this.options,
+ "oneof" , this.oneof,
+ "comment" , keepComments ? this.comment : undefined
+ ]);
+};
+
+/**
+ * Adds the fields of the specified oneof to the parent if not already done so.
+ * @param {OneOf} oneof The oneof
+ * @returns {undefined}
+ * @inner
+ * @ignore
+ */
+function addFieldsToParent(oneof) {
+ if (oneof.parent)
+ for (var i = 0; i < oneof.fieldsArray.length; ++i)
+ if (!oneof.fieldsArray[i].parent)
+ oneof.parent.add(oneof.fieldsArray[i]);
+}
+
+/**
+ * Adds a field to this oneof and removes it from its current parent, if any.
+ * @param {Field} field Field to add
+ * @returns {OneOf} `this`
+ */
+OneOf.prototype.add = function add(field) {
+
+ /* istanbul ignore if */
+ if (!(field instanceof Field))
+ throw TypeError("field must be a Field");
+
+ if (field.parent && field.parent !== this.parent)
+ field.parent.remove(field);
+ this.oneof.push(field.name);
+ this.fieldsArray.push(field);
+ field.partOf = this; // field.parent remains null
+ addFieldsToParent(this);
+ return this;
+};
+
+/**
+ * Removes a field from this oneof and puts it back to the oneof's parent.
+ * @param {Field} field Field to remove
+ * @returns {OneOf} `this`
+ */
+OneOf.prototype.remove = function remove(field) {
+
+ /* istanbul ignore if */
+ if (!(field instanceof Field))
+ throw TypeError("field must be a Field");
+
+ var index = this.fieldsArray.indexOf(field);
+
+ /* istanbul ignore if */
+ if (index < 0)
+ throw Error(field + " is not a member of " + this);
+
+ this.fieldsArray.splice(index, 1);
+ index = this.oneof.indexOf(field.name);
+
+ /* istanbul ignore else */
+ if (index > -1) // theoretical
+ this.oneof.splice(index, 1);
+
+ field.partOf = null;
+ return this;
+};
+
+/**
+ * @override
+ */
+OneOf.prototype.onAdd = function onAdd(parent) {
+ ReflectionObject.prototype.onAdd.call(this, parent);
+ var self = this;
+ // Collect present fields
+ for (var i = 0; i < this.oneof.length; ++i) {
+ var field = parent.get(this.oneof[i]);
+ if (field && !field.partOf) {
+ field.partOf = self;
+ self.fieldsArray.push(field);
+ }
+ }
+ // Add not yet present fields
+ addFieldsToParent(this);
+};
+
+/**
+ * @override
+ */
+OneOf.prototype.onRemove = function onRemove(parent) {
+ for (var i = 0, field; i < this.fieldsArray.length; ++i)
+ if ((field = this.fieldsArray[i]).parent)
+ field.parent.remove(field);
+ ReflectionObject.prototype.onRemove.call(this, parent);
+};
+
+/**
+ * Decorator function as returned by {@link OneOf.d} (TypeScript).
+ * @typedef OneOfDecorator
+ * @type {function}
+ * @param {Object} prototype Target prototype
+ * @param {string} oneofName OneOf name
+ * @returns {undefined}
+ */
+
+/**
+ * OneOf decorator (TypeScript).
+ * @function
+ * @param {...string} fieldNames Field names
+ * @returns {OneOfDecorator} Decorator function
+ * @template T extends string
+ */
+OneOf.d = function decorateOneOf() {
+ var fieldNames = new Array(arguments.length),
+ index = 0;
+ while (index < arguments.length)
+ fieldNames[index] = arguments[index++];
+ return function oneOfDecorator(prototype, oneofName) {
+ util.decorateType(prototype.constructor)
+ .add(new OneOf(oneofName, fieldNames));
+ Object.defineProperty(prototype, oneofName, {
+ get: util.oneOfGetter(fieldNames),
+ set: util.oneOfSetter(fieldNames)
+ });
+ };
+};
diff --git a/OpenHarmony/library/src/main/ets/src/parse.js b/OpenHarmony/library/src/main/ets/src/parse.js
new file mode 100644
index 000000000..ebb8b9c42
--- /dev/null
+++ b/OpenHarmony/library/src/main/ets/src/parse.js
@@ -0,0 +1,869 @@
+"use strict";
+module.exports = parse;
+
+parse.filename = null;
+parse.defaults = { keepCase: false };
+
+var tokenize = require("./tokenize"),
+ Root = require("./root"),
+ Type = require("./type"),
+ Field = require("./field"),
+ MapField = require("./mapfield"),
+ OneOf = require("./oneof"),
+ Enum = require("./enum"),
+ Service = require("./service"),
+ Method = require("./method"),
+ types = require("./types"),
+ util = require("./util");
+
+var base10Re = /^[1-9][0-9]*$/,
+ base10NegRe = /^-?[1-9][0-9]*$/,
+ base16Re = /^0[x][0-9a-fA-F]+$/,
+ base16NegRe = /^-?0[x][0-9a-fA-F]+$/,
+ base8Re = /^0[0-7]+$/,
+ base8NegRe = /^-?0[0-7]+$/,
+ numberRe = /^(?![eE])[0-9]*(?:\.[0-9]*)?(?:[eE][+-]?[0-9]+)?$/,
+ nameRe = /^[a-zA-Z_][a-zA-Z_0-9]*$/,
+ typeRefRe = /^(?:\.?[a-zA-Z_][a-zA-Z_0-9]*)(?:\.[a-zA-Z_][a-zA-Z_0-9]*)*$/,
+ fqTypeRefRe = /^(?:\.[a-zA-Z_][a-zA-Z_0-9]*)+$/;
+
+/**
+ * Result object returned from {@link parse}.
+ * @interface IParserResult
+ * @property {string|undefined} package Package name, if declared
+ * @property {string[]|undefined} imports Imports, if any
+ * @property {string[]|undefined} weakImports Weak imports, if any
+ * @property {string|undefined} syntax Syntax, if specified (either `"proto2"` or `"proto3"`)
+ * @property {Root} root Populated root instance
+ */
+
+/**
+ * Options modifying the behavior of {@link parse}.
+ * @interface IParseOptions
+ * @property {boolean} [keepCase=false] Keeps field casing instead of converting to camel case
+ * @property {boolean} [alternateCommentMode=false] Recognize double-slash comments in addition to doc-block comments.
+ * @property {boolean} [preferTrailingComment=false] Use trailing comment when both leading comment and trailing comment exist.
+ */
+
+/**
+ * Options modifying the behavior of JSON serialization.
+ * @interface IToJSONOptions
+ * @property {boolean} [keepComments=false] Serializes comments.
+ */
+
+/**
+ * Parses the given .proto source and returns an object with the parsed contents.
+ * @param {string} source Source contents
+ * @param {Root} root Root to populate
+ * @param {IParseOptions} [options] Parse options. Defaults to {@link parse.defaults} when omitted.
+ * @returns {IParserResult} Parser result
+ * @property {string} filename=null Currently processing file name for error reporting, if known
+ * @property {IParseOptions} defaults Default {@link IParseOptions}
+ */
+function parse(source, root, options) {
+ /* eslint-disable callback-return */
+ if (!(root instanceof Root)) {
+ options = root;
+ root = new Root();
+ }
+ if (!options)
+ options = parse.defaults;
+
+ var preferTrailingComment = options.preferTrailingComment || false;
+ var tn = tokenize(source, options.alternateCommentMode || false),
+ next = tn.next,
+ push = tn.push,
+ peek = tn.peek,
+ skip = tn.skip,
+ cmnt = tn.cmnt;
+
+ var head = true,
+ pkg,
+ imports,
+ weakImports,
+ syntax,
+ isProto3 = false;
+
+ var ptr = root;
+
+ var applyCase = options.keepCase ? function(name) { return name; } : util.camelCase;
+
+ /* istanbul ignore next */
+ function illegal(token, name, insideTryCatch) {
+ var filename = parse.filename;
+ if (!insideTryCatch)
+ parse.filename = null;
+ return Error("illegal " + (name || "token") + " '" + token + "' (" + (filename ? filename + ", " : "") + "line " + tn.line + ")");
+ }
+
+ function readString() {
+ var values = [],
+ token;
+ do {
+ /* istanbul ignore if */
+ if ((token = next()) !== "\"" && token !== "'")
+ throw illegal(token);
+
+ values.push(next());
+ skip(token);
+ token = peek();
+ } while (token === "\"" || token === "'");
+ return values.join("");
+ }
+
+ function readValue(acceptTypeRef) {
+ var token = next();
+ switch (token) {
+ case "'":
+ case "\"":
+ push(token);
+ return readString();
+ case "true": case "TRUE":
+ return true;
+ case "false": case "FALSE":
+ return false;
+ }
+ try {
+ return parseNumber(token, /* insideTryCatch */ true);
+ } catch (e) {
+
+ /* istanbul ignore else */
+ if (acceptTypeRef && typeRefRe.test(token))
+ return token;
+
+ /* istanbul ignore next */
+ throw illegal(token, "value");
+ }
+ }
+
+ function readRanges(target, acceptStrings) {
+ var token, start;
+ do {
+ if (acceptStrings && ((token = peek()) === "\"" || token === "'"))
+ target.push(readString());
+ else
+ target.push([ start = parseId(next()), skip("to", true) ? parseId(next()) : start ]);
+ } while (skip(",", true));
+ skip(";");
+ }
+
+ function parseNumber(token, insideTryCatch) {
+ var sign = 1;
+ if (token.charAt(0) === "-") {
+ sign = -1;
+ token = token.substring(1);
+ }
+ switch (token) {
+ case "inf": case "INF": case "Inf":
+ return sign * Infinity;
+ case "nan": case "NAN": case "Nan": case "NaN":
+ return NaN;
+ case "0":
+ return 0;
+ }
+ if (base10Re.test(token))
+ return sign * parseInt(token, 10);
+ if (base16Re.test(token))
+ return sign * parseInt(token, 16);
+ if (base8Re.test(token))
+ return sign * parseInt(token, 8);
+
+ /* istanbul ignore else */
+ if (numberRe.test(token))
+ return sign * parseFloat(token);
+
+ /* istanbul ignore next */
+ throw illegal(token, "number", insideTryCatch);
+ }
+
+ function parseId(token, acceptNegative) {
+ switch (token) {
+ case "max": case "MAX": case "Max":
+ return 536870911;
+ case "0":
+ return 0;
+ }
+
+ /* istanbul ignore if */
+ if (!acceptNegative && token.charAt(0) === "-")
+ throw illegal(token, "id");
+
+ if (base10NegRe.test(token))
+ return parseInt(token, 10);
+ if (base16NegRe.test(token))
+ return parseInt(token, 16);
+
+ /* istanbul ignore else */
+ if (base8NegRe.test(token))
+ return parseInt(token, 8);
+
+ /* istanbul ignore next */
+ throw illegal(token, "id");
+ }
+
+ function parsePackage() {
+
+ /* istanbul ignore if */
+ if (pkg !== undefined)
+ throw illegal("package");
+
+ pkg = next();
+
+ /* istanbul ignore if */
+ if (!typeRefRe.test(pkg))
+ throw illegal(pkg, "name");
+
+ ptr = ptr.define(pkg);
+ skip(";");
+ }
+
+ function parseImport() {
+ var token = peek();
+ var whichImports;
+ switch (token) {
+ case "weak":
+ whichImports = weakImports || (weakImports = []);
+ next();
+ break;
+ case "public":
+ next();
+ // eslint-disable-line no-fallthrough
+ default:
+ whichImports = imports || (imports = []);
+ break;
+ }
+ token = readString();
+ skip(";");
+ whichImports.push(token);
+ }
+
+ function parseSyntax() {
+ skip("=");
+ syntax = readString();
+ isProto3 = syntax === "proto3";
+
+ /* istanbul ignore if */
+ if (!isProto3 && syntax !== "proto2")
+ throw illegal(syntax, "syntax");
+
+ skip(";");
+ }
+
+ function parseCommon(parent, token) {
+ switch (token) {
+
+ case "option":
+ parseOption(parent, token);
+ skip(";");
+ return true;
+
+ case "message":
+ parseType(parent, token);
+ return true;
+
+ case "enum":
+ parseEnum(parent, token);
+ return true;
+
+ case "service":
+ parseService(parent, token);
+ return true;
+
+ case "extend":
+ parseExtension(parent, token);
+ return true;
+ }
+ return false;
+ }
+
+ function ifBlock(obj, fnIf, fnElse) {
+ var trailingLine = tn.line;
+ if (obj) {
+ if(typeof obj.comment !== "string") {
+ obj.comment = cmnt(); // try block-type comment
+ }
+ obj.filename = parse.filename;
+ }
+ if (skip("{", true)) {
+ var token;
+ while ((token = next()) !== "}")
+ fnIf(token);
+ skip(";", true);
+ } else {
+ if (fnElse)
+ fnElse();
+ skip(";");
+ if (obj && (typeof obj.comment !== "string" || preferTrailingComment))
+ obj.comment = cmnt(trailingLine) || obj.comment; // try line-type comment
+ }
+ }
+
+ function parseType(parent, token) {
+
+ /* istanbul ignore if */
+ if (!nameRe.test(token = next()))
+ throw illegal(token, "type name");
+
+ var type = new Type(token);
+ ifBlock(type, function parseType_block(token) {
+ if (parseCommon(type, token))
+ return;
+
+ switch (token) {
+
+ case "map":
+ parseMapField(type, token);
+ break;
+
+ case "required":
+ case "repeated":
+ parseField(type, token);
+ break;
+
+ case "optional":
+ /* istanbul ignore if */
+ if (isProto3) {
+ parseField(type, "proto3_optional");
+ } else {
+ parseField(type, "optional");
+ }
+ break;
+
+ case "oneof":
+ parseOneOf(type, token);
+ break;
+
+ case "extensions":
+ readRanges(type.extensions || (type.extensions = []));
+ break;
+
+ case "reserved":
+ readRanges(type.reserved || (type.reserved = []), true);
+ break;
+
+ default:
+ /* istanbul ignore if */
+ if (!isProto3 || !typeRefRe.test(token))
+ throw illegal(token);
+
+ push(token);
+ parseField(type, "optional");
+ break;
+ }
+ });
+ parent.add(type);
+ }
+
+ function parseField(parent, rule, extend) {
+ var type = next();
+ if (type === "group") {
+ parseGroup(parent, rule);
+ return;
+ }
+ // Type names can consume multiple tokens, in multiple variants:
+ // package.subpackage field tokens: "package.subpackage" [TYPE NAME ENDS HERE] "field"
+ // package . subpackage field tokens: "package" "." "subpackage" [TYPE NAME ENDS HERE] "field"
+ // package. subpackage field tokens: "package." "subpackage" [TYPE NAME ENDS HERE] "field"
+ // package .subpackage field tokens: "package" ".subpackage" [TYPE NAME ENDS HERE] "field"
+ // Keep reading tokens until we get a type name with no period at the end,
+ // and the next token does not start with a period.
+ while (type.endsWith(".") || peek().startsWith(".")) {
+ type += next();
+ }
+
+ /* istanbul ignore if */
+ if (!typeRefRe.test(type))
+ throw illegal(type, "type");
+
+ var name = next();
+
+ /* istanbul ignore if */
+ if (!nameRe.test(name))
+ throw illegal(name, "name");
+
+ name = applyCase(name);
+ skip("=");
+
+ var field = new Field(name, parseId(next()), type, rule, extend);
+ ifBlock(field, function parseField_block(token) {
+
+ /* istanbul ignore else */
+ if (token === "option") {
+ parseOption(field, token);
+ skip(";");
+ } else
+ throw illegal(token);
+
+ }, function parseField_line() {
+ parseInlineOptions(field);
+ });
+
+ if (rule === "proto3_optional") {
+ // for proto3 optional fields, we create a single-member Oneof to mimic "optional" behavior
+ var oneof = new OneOf("_" + name);
+ field.setOption("proto3_optional", true);
+ oneof.add(field);
+ parent.add(oneof);
+ } else {
+ parent.add(field);
+ }
+
+ // JSON defaults to packed=true if not set so we have to set packed=false explicity when
+ // parsing proto2 descriptors without the option, where applicable. This must be done for
+ // all known packable types and anything that could be an enum (= is not a basic type).
+ if (!isProto3 && field.repeated && (types.packed[type] !== undefined || types.basic[type] === undefined))
+ field.setOption("packed", false, /* ifNotSet */ true);
+ }
+
+ function parseGroup(parent, rule) {
+ var name = next();
+
+ /* istanbul ignore if */
+ if (!nameRe.test(name))
+ throw illegal(name, "name");
+
+ var fieldName = util.lcFirst(name);
+ if (name === fieldName)
+ name = util.ucFirst(name);
+ skip("=");
+ var id = parseId(next());
+ var type = new Type(name);
+ type.group = true;
+ var field = new Field(fieldName, id, name, rule);
+ field.filename = parse.filename;
+ ifBlock(type, function parseGroup_block(token) {
+ switch (token) {
+
+ case "option":
+ parseOption(type, token);
+ skip(";");
+ break;
+
+ case "required":
+ case "repeated":
+ parseField(type, token);
+ break;
+
+ case "optional":
+ /* istanbul ignore if */
+ if (isProto3) {
+ parseField(type, "proto3_optional");
+ } else {
+ parseField(type, "optional");
+ }
+ break;
+
+ case "message":
+ parseType(type, token);
+ break;
+
+ case "enum":
+ parseEnum(type, token);
+ break;
+
+ /* istanbul ignore next */
+ default:
+ throw illegal(token); // there are no groups with proto3 semantics
+ }
+ });
+ parent.add(type)
+ .add(field);
+ }
+
+ function parseMapField(parent) {
+ skip("<");
+ var keyType = next();
+
+ /* istanbul ignore if */
+ if (types.mapKey[keyType] === undefined)
+ throw illegal(keyType, "type");
+
+ skip(",");
+ var valueType = next();
+
+ /* istanbul ignore if */
+ if (!typeRefRe.test(valueType))
+ throw illegal(valueType, "type");
+
+ skip(">");
+ var name = next();
+
+ /* istanbul ignore if */
+ if (!nameRe.test(name))
+ throw illegal(name, "name");
+
+ skip("=");
+ var field = new MapField(applyCase(name), parseId(next()), keyType, valueType);
+ ifBlock(field, function parseMapField_block(token) {
+
+ /* istanbul ignore else */
+ if (token === "option") {
+ parseOption(field, token);
+ skip(";");
+ } else
+ throw illegal(token);
+
+ }, function parseMapField_line() {
+ parseInlineOptions(field);
+ });
+ parent.add(field);
+ }
+
+ function parseOneOf(parent, token) {
+
+ /* istanbul ignore if */
+ if (!nameRe.test(token = next()))
+ throw illegal(token, "name");
+
+ var oneof = new OneOf(applyCase(token));
+ ifBlock(oneof, function parseOneOf_block(token) {
+ if (token === "option") {
+ parseOption(oneof, token);
+ skip(";");
+ } else {
+ push(token);
+ parseField(oneof, "optional");
+ }
+ });
+ parent.add(oneof);
+ }
+
+ function parseEnum(parent, token) {
+
+ /* istanbul ignore if */
+ if (!nameRe.test(token = next()))
+ throw illegal(token, "name");
+
+ var enm = new Enum(token);
+ ifBlock(enm, function parseEnum_block(token) {
+ switch(token) {
+ case "option":
+ parseOption(enm, token);
+ skip(";");
+ break;
+
+ case "reserved":
+ readRanges(enm.reserved || (enm.reserved = []), true);
+ break;
+
+ default:
+ parseEnumValue(enm, token);
+ }
+ });
+ parent.add(enm);
+ }
+
+ function parseEnumValue(parent, token) {
+
+ /* istanbul ignore if */
+ if (!nameRe.test(token))
+ throw illegal(token, "name");
+
+ skip("=");
+ var value = parseId(next(), true),
+ dummy = {
+ options: undefined
+ };
+ dummy.setOption = function(name, value) {
+ if (this.options === undefined)
+ this.options = {};
+ this.options[name] = value;
+ };
+ ifBlock(dummy, function parseEnumValue_block(token) {
+
+ /* istanbul ignore else */
+ if (token === "option") {
+ parseOption(dummy, token); // skip
+ skip(";");
+ } else
+ throw illegal(token);
+
+ }, function parseEnumValue_line() {
+ parseInlineOptions(dummy); // skip
+ });
+ parent.add(token, value, dummy.comment, dummy.options);
+ }
+
+ function parseOption(parent, token) {
+ var isCustom = skip("(", true);
+
+ /* istanbul ignore if */
+ if (!typeRefRe.test(token = next()))
+ throw illegal(token, "name");
+
+ var name = token;
+ var option = name;
+ var propName;
+
+ if (isCustom) {
+ skip(")");
+ name = "(" + name + ")";
+ option = name;
+ token = peek();
+ if (fqTypeRefRe.test(token)) {
+ propName = token.slice(1); //remove '.' before property name
+ name += token;
+ next();
+ }
+ }
+ skip("=");
+ var optionValue = parseOptionValue(parent, name);
+ setParsedOption(parent, option, optionValue, propName);
+ }
+
+ function parseOptionValue(parent, name) {
+ // { a: "foo" b { c: "bar" } }
+ if (skip("{", true)) {
+ var objectResult = {};
+
+ while (!skip("}", true)) {
+ /* istanbul ignore if */
+ if (!nameRe.test(token = next())) {
+ throw illegal(token, "name");
+ }
+
+ var value;
+ var propName = token;
+
+ skip(":", true);
+
+ if (peek() === "{")
+ value = parseOptionValue(parent, name + "." + token);
+ else if (peek() === "[") {
+ // option (my_option) = {
+ // repeated_value: [ "foo", "bar" ]
+ // };
+ value = [];
+ var lastValue;
+ if (skip("[", true)) {
+ do {
+ lastValue = readValue(true);
+ value.push(lastValue);
+ } while (skip(",", true));
+ skip("]");
+ if (typeof lastValue !== "undefined") {
+ setOption(parent, name + "." + token, lastValue);
+ }
+ }
+ } else {
+ value = readValue(true);
+ setOption(parent, name + "." + token, value);
+ }
+
+ var prevValue = objectResult[propName];
+
+ if (prevValue)
+ value = [].concat(prevValue).concat(value);
+
+ objectResult[propName] = value;
+
+ // Semicolons and commas can be optional
+ skip(",", true);
+ skip(";", true);
+ }
+
+ return objectResult;
+ }
+
+ var simpleValue = readValue(true);
+ setOption(parent, name, simpleValue);
+ return simpleValue;
+ // Does not enforce a delimiter to be universal
+ }
+
+ function setOption(parent, name, value) {
+ if (parent.setOption)
+ parent.setOption(name, value);
+ }
+
+ function setParsedOption(parent, name, value, propName) {
+ if (parent.setParsedOption)
+ parent.setParsedOption(name, value, propName);
+ }
+
+ function parseInlineOptions(parent) {
+ if (skip("[", true)) {
+ do {
+ parseOption(parent, "option");
+ } while (skip(",", true));
+ skip("]");
+ }
+ return parent;
+ }
+
+ function parseService(parent, token) {
+
+ /* istanbul ignore if */
+ if (!nameRe.test(token = next()))
+ throw illegal(token, "service name");
+
+ var service = new Service(token);
+ ifBlock(service, function parseService_block(token) {
+ if (parseCommon(service, token))
+ return;
+
+ /* istanbul ignore else */
+ if (token === "rpc")
+ parseMethod(service, token);
+ else
+ throw illegal(token);
+ });
+ parent.add(service);
+ }
+
+ function parseMethod(parent, token) {
+ // Get the comment of the preceding line now (if one exists) in case the
+ // method is defined across multiple lines.
+ var commentText = cmnt();
+
+ var type = token;
+
+ /* istanbul ignore if */
+ if (!nameRe.test(token = next()))
+ throw illegal(token, "name");
+
+ var name = token,
+ requestType, requestStream,
+ responseType, responseStream;
+
+ skip("(");
+ if (skip("stream", true))
+ requestStream = true;
+
+ /* istanbul ignore if */
+ if (!typeRefRe.test(token = next()))
+ throw illegal(token);
+
+ requestType = token;
+ skip(")"); skip("returns"); skip("(");
+ if (skip("stream", true))
+ responseStream = true;
+
+ /* istanbul ignore if */
+ if (!typeRefRe.test(token = next()))
+ throw illegal(token);
+
+ responseType = token;
+ skip(")");
+
+ var method = new Method(name, type, requestType, responseType, requestStream, responseStream);
+ method.comment = commentText;
+ ifBlock(method, function parseMethod_block(token) {
+
+ /* istanbul ignore else */
+ if (token === "option") {
+ parseOption(method, token);
+ skip(";");
+ } else
+ throw illegal(token);
+
+ });
+ parent.add(method);
+ }
+
+ function parseExtension(parent, token) {
+
+ /* istanbul ignore if */
+ if (!typeRefRe.test(token = next()))
+ throw illegal(token, "reference");
+
+ var reference = token;
+ ifBlock(null, function parseExtension_block(token) {
+ switch (token) {
+
+ case "required":
+ case "repeated":
+ parseField(parent, token, reference);
+ break;
+
+ case "optional":
+ /* istanbul ignore if */
+ if (isProto3) {
+ parseField(parent, "proto3_optional", reference);
+ } else {
+ parseField(parent, "optional", reference);
+ }
+ break;
+
+ default:
+ /* istanbul ignore if */
+ if (!isProto3 || !typeRefRe.test(token))
+ throw illegal(token);
+ push(token);
+ parseField(parent, "optional", reference);
+ break;
+ }
+ });
+ }
+
+ var token;
+ while ((token = next()) !== null) {
+ switch (token) {
+
+ case "package":
+
+ /* istanbul ignore if */
+ if (!head)
+ throw illegal(token);
+
+ parsePackage();
+ break;
+
+ case "import":
+
+ /* istanbul ignore if */
+ if (!head)
+ throw illegal(token);
+
+ parseImport();
+ break;
+
+ case "syntax":
+
+ /* istanbul ignore if */
+ if (!head)
+ throw illegal(token);
+
+ parseSyntax();
+ break;
+
+ case "option":
+
+ parseOption(ptr, token);
+ skip(";");
+ break;
+
+ default:
+
+ /* istanbul ignore else */
+ if (parseCommon(ptr, token)) {
+ head = false;
+ continue;
+ }
+
+ /* istanbul ignore next */
+ throw illegal(token);
+ }
+ }
+
+ parse.filename = null;
+ return {
+ "package" : pkg,
+ "imports" : imports,
+ weakImports : weakImports,
+ syntax : syntax,
+ root : root
+ };
+}
+
+/**
+ * Parses the given .proto source and returns an object with the parsed contents.
+ * @name parse
+ * @function
+ * @param {string} source Source contents
+ * @param {IParseOptions} [options] Parse options. Defaults to {@link parse.defaults} when omitted.
+ * @returns {IParserResult} Parser result
+ * @property {string} filename=null Currently processing file name for error reporting, if known
+ * @property {IParseOptions} defaults Default {@link IParseOptions}
+ * @variation 2
+ */
diff --git a/OpenHarmony/library/src/main/ets/src/reader.js b/OpenHarmony/library/src/main/ets/src/reader.js
new file mode 100644
index 000000000..fda3be4f0
--- /dev/null
+++ b/OpenHarmony/library/src/main/ets/src/reader.js
@@ -0,0 +1,417 @@
+"use strict";
+module.exports = Reader;
+
+var util = require("./util/minimal");
+
+var BufferReader; // cyclic
+
+var LongBits = util.LongBits,
+ utf8 = util.utf8;
+
+/* istanbul ignore next */
+function indexOutOfRange(reader, writeLength) {
+ return RangeError("index out of range: " + reader.pos + " + " + (writeLength || 1) + " > " + reader.len);
+}
+
+/**
+ * Constructs a new reader instance using the specified buffer.
+ * @classdesc Wire format reader using `Uint8Array` if available, otherwise `Array`.
+ * @constructor
+ * @param {Uint8Array} buffer Buffer to read from
+ */
+function Reader(buffer) {
+
+ /**
+ * Read buffer.
+ * @type {Uint8Array}
+ */
+ this.buf = buffer;
+
+ /**
+ * Read buffer position.
+ * @type {number}
+ */
+ this.pos = 0;
+
+ /**
+ * Read buffer length.
+ * @type {number}
+ */
+ this.len = buffer.length;
+}
+
+var create_array = typeof Uint8Array !== "undefined"
+ ? function create_typed_array(buffer) {
+ if (buffer instanceof Uint8Array || Array.isArray(buffer))
+ return new Reader(buffer);
+ throw Error("illegal buffer");
+ }
+ /* istanbul ignore next */
+ : function create_array(buffer) {
+ if (Array.isArray(buffer))
+ return new Reader(buffer);
+ throw Error("illegal buffer");
+ };
+
+var create = function create() {
+ return util.Buffer
+ ? function create_buffer_setup(buffer) {
+ return (Reader.create = function create_buffer(buffer) {
+ return util.Buffer.isBuffer(buffer)
+ ? new BufferReader(buffer)
+ /* istanbul ignore next */
+ : create_array(buffer);
+ })(buffer);
+ }
+ /* istanbul ignore next */
+ : create_array;
+};
+
+/**
+ * Creates a new reader using the specified buffer.
+ * @function
+ * @param {Uint8Array|Buffer} buffer Buffer to read from
+ * @returns {Reader|BufferReader} A {@link BufferReader} if `buffer` is a Buffer, otherwise a {@link Reader}
+ * @throws {Error} If `buffer` is not a valid buffer
+ */
+Reader.create = create();
+
+Reader.prototype._slice = util.Array.prototype.subarray || /* istanbul ignore next */ util.Array.prototype.slice;
+
+/**
+ * Reads a varint as an unsigned 32 bit value.
+ * @function
+ * @returns {number} Value read
+ */
+Reader.prototype.uint32 = (function read_uint32_setup() {
+ var value = 4294967295; // optimizer type-hint, tends to deopt otherwise (?!)
+ return function read_uint32() {
+ value = ( this.buf[this.pos] & 127 ) >>> 0; if (this.buf[this.pos++] < 128) return value;
+ value = (value | (this.buf[this.pos] & 127) << 7) >>> 0; if (this.buf[this.pos++] < 128) return value;
+ value = (value | (this.buf[this.pos] & 127) << 14) >>> 0; if (this.buf[this.pos++] < 128) return value;
+ value = (value | (this.buf[this.pos] & 127) << 21) >>> 0; if (this.buf[this.pos++] < 128) return value;
+ value = (value | (this.buf[this.pos] & 15) << 28) >>> 0; if (this.buf[this.pos++] < 128) return value;
+
+ /* istanbul ignore if */
+ if ((this.pos += 5) > this.len) {
+ this.pos = this.len;
+ throw indexOutOfRange(this, 10);
+ }
+ return value;
+ };
+})();
+
+/**
+ * Reads a varint as a signed 32 bit value.
+ * @returns {number} Value read
+ */
+Reader.prototype.int32 = function read_int32() {
+ return this.uint32() | 0;
+};
+
+/**
+ * Reads a zig-zag encoded varint as a signed 32 bit value.
+ * @returns {number} Value read
+ */
+Reader.prototype.sint32 = function read_sint32() {
+ var value = this.uint32();
+ return value >>> 1 ^ -(value & 1) | 0;
+};
+
+/* eslint-disable no-invalid-this */
+
+function readLongVarint() {
+ // tends to deopt with local vars for octet etc.
+ var bits = new LongBits(0, 0);
+ var i = 0;
+ if (this.len - this.pos > 4) { // fast route (lo)
+ for (; i < 4; ++i) {
+ // 1st..4th
+ bits.lo = (bits.lo | (this.buf[this.pos] & 127) << i * 7) >>> 0;
+ if (this.buf[this.pos++] < 128)
+ return bits;
+ }
+ // 5th
+ bits.lo = (bits.lo | (this.buf[this.pos] & 127) << 28) >>> 0;
+ bits.hi = (bits.hi | (this.buf[this.pos] & 127) >> 4) >>> 0;
+ if (this.buf[this.pos++] < 128)
+ return bits;
+ i = 0;
+ } else {
+ for (; i < 3; ++i) {
+ /* istanbul ignore if */
+ if (this.pos >= this.len)
+ throw indexOutOfRange(this);
+ // 1st..3th
+ bits.lo = (bits.lo | (this.buf[this.pos] & 127) << i * 7) >>> 0;
+ if (this.buf[this.pos++] < 128)
+ return bits;
+ }
+ // 4th
+ bits.lo = (bits.lo | (this.buf[this.pos++] & 127) << i * 7) >>> 0;
+ return bits;
+ }
+ if (this.len - this.pos > 4) { // fast route (hi)
+ for (; i < 5; ++i) {
+ // 6th..10th
+ bits.hi = (bits.hi | (this.buf[this.pos] & 127) << i * 7 + 3) >>> 0;
+ if (this.buf[this.pos++] < 128)
+ return bits;
+ }
+ } else {
+ for (; i < 5; ++i) {
+ /* istanbul ignore if */
+ if (this.pos >= this.len)
+ throw indexOutOfRange(this);
+ // 6th..10th
+ bits.hi = (bits.hi | (this.buf[this.pos] & 127) << i * 7 + 3) >>> 0;
+ if (this.buf[this.pos++] < 128)
+ return bits;
+ }
+ }
+ /* istanbul ignore next */
+ throw Error("invalid varint encoding");
+}
+
+/* eslint-enable no-invalid-this */
+
+/**
+ * Reads a varint as a signed 64 bit value.
+ * @name Reader#int64
+ * @function
+ * @returns {Long} Value read
+ */
+
+/**
+ * Reads a varint as an unsigned 64 bit value.
+ * @name Reader#uint64
+ * @function
+ * @returns {Long} Value read
+ */
+
+/**
+ * Reads a zig-zag encoded varint as a signed 64 bit value.
+ * @name Reader#sint64
+ * @function
+ * @returns {Long} Value read
+ */
+
+/**
+ * Reads a varint as a boolean.
+ * @returns {boolean} Value read
+ */
+Reader.prototype.bool = function read_bool() {
+ return this.uint32() !== 0;
+};
+
+function readFixed32_end(buf, end) { // note that this uses `end`, not `pos`
+ return (buf[end - 4]
+ | buf[end - 3] << 8
+ | buf[end - 2] << 16
+ | buf[end - 1] << 24) >>> 0;
+}
+
+/**
+ * Reads fixed 32 bits as an unsigned 32 bit integer.
+ * @returns {number} Value read
+ */
+Reader.prototype.fixed32 = function read_fixed32() {
+
+ /* istanbul ignore if */
+ if (this.pos + 4 > this.len)
+ throw indexOutOfRange(this, 4);
+
+ return readFixed32_end(this.buf, this.pos += 4);
+};
+
+/**
+ * Reads fixed 32 bits as a signed 32 bit integer.
+ * @returns {number} Value read
+ */
+Reader.prototype.sfixed32 = function read_sfixed32() {
+
+ /* istanbul ignore if */
+ if (this.pos + 4 > this.len)
+ throw indexOutOfRange(this, 4);
+
+ return readFixed32_end(this.buf, this.pos += 4) | 0;
+};
+
+/* eslint-disable no-invalid-this */
+
+function readFixed64(/* this: Reader */) {
+
+ /* istanbul ignore if */
+ if (this.pos + 8 > this.len)
+ throw indexOutOfRange(this, 8);
+
+ return new LongBits(readFixed32_end(this.buf, this.pos += 4), readFixed32_end(this.buf, this.pos += 4));
+}
+
+/* eslint-enable no-invalid-this */
+
+/**
+ * Reads fixed 64 bits.
+ * @name Reader#fixed64
+ * @function
+ * @returns {Long} Value read
+ */
+
+/**
+ * Reads zig-zag encoded fixed 64 bits.
+ * @name Reader#sfixed64
+ * @function
+ * @returns {Long} Value read
+ */
+
+/**
+ * Reads a float (32 bit) as a number.
+ * @function
+ * @returns {number} Value read
+ */
+Reader.prototype.float = function read_float() {
+
+ /* istanbul ignore if */
+ if (this.pos + 4 > this.len)
+ throw indexOutOfRange(this, 4);
+
+ var value = util.float.readFloatLE(this.buf, this.pos);
+ this.pos += 4;
+ return value;
+};
+
+/**
+ * Reads a double (64 bit float) as a number.
+ * @function
+ * @returns {number} Value read
+ */
+Reader.prototype.double = function read_double() {
+
+ /* istanbul ignore if */
+ if (this.pos + 8 > this.len)
+ throw indexOutOfRange(this, 4);
+
+ var value = util.float.readDoubleLE(this.buf, this.pos);
+ this.pos += 8;
+ return value;
+};
+
+/**
+ * Reads a sequence of bytes preceeded by its length as a varint.
+ * @returns {Uint8Array} Value read
+ */
+Reader.prototype.bytes = function read_bytes() {
+ var length = this.uint32(),
+ start = this.pos,
+ end = this.pos + length;
+
+ /* istanbul ignore if */
+ if (end > this.len)
+ throw indexOutOfRange(this, length);
+
+ this.pos += length;
+ if (Array.isArray(this.buf)) // plain array
+ return this.buf.slice(start, end);
+ return start === end // fix for IE 10/Win8 and others' subarray returning array of size 1
+ ? new this.buf.constructor(0)
+ : this._slice.call(this.buf, start, end);
+};
+
+/**
+ * Reads a string preceeded by its byte length as a varint.
+ * @returns {string} Value read
+ */
+Reader.prototype.string = function read_string() {
+ var bytes = this.bytes();
+ return utf8.read(bytes, 0, bytes.length);
+};
+
+/**
+ * Skips the specified number of bytes if specified, otherwise skips a varint.
+ * @param {number} [length] Length if known, otherwise a varint is assumed
+ * @returns {Reader} `this`
+ */
+Reader.prototype.skip = function skip(length) {
+ if (typeof length === "number") {
+ /* istanbul ignore if */
+ if (this.pos + length > this.len)
+ throw indexOutOfRange(this, length);
+ this.pos += length;
+ } else {
+ do {
+ /* istanbul ignore if */
+ if (this.pos >= this.len)
+ throw indexOutOfRange(this);
+ } while (this.buf[this.pos++] & 128);
+ }
+ return this;
+};
+
+/**
+ * Skips the next element of the specified wire type.
+ * @param {number} wireType Wire type received
+ * @returns {Reader} `this`
+ */
+Reader.prototype.skipType = function(wireType) {
+ switch (wireType) {
+ case 0:
+ this.skip();
+ break;
+ case 1:
+ this.skip(8);
+ break;
+ case 2:
+ this.skip(this.uint32());
+ break;
+ case 3:
+ while ((wireType = this.uint32() & 7) !== 4) {
+ this.skipType(wireType);
+ }
+ break;
+ case 5:
+ this.skip(4);
+ break;
+
+ /* istanbul ignore next */
+ default:
+ throw Error("invalid wire type " + wireType + " at offset " + this.pos);
+ }
+ return this;
+};
+
+Reader._configure = function (BufferReader_) {
+ BufferReader = BufferReader_;
+ Reader.create = create();
+ BufferReader._configure();
+ let fn = '';
+ if (util$5.Long) {
+ fn = "toLong";
+ } else if (util$5.BigInt) {
+ fn = "toBigInt";
+ } else {
+ fn = "toNumber";
+ }
+ util.merge(Reader.prototype, {
+
+ int64: function read_int64() {
+ return readLongVarint.call(this)[fn](false);
+ },
+
+ uint64: function read_uint64() {
+ return readLongVarint.call(this)[fn](true);
+ },
+
+ sint64: function read_sint64() {
+ return readLongVarint.call(this).zzDecode()[fn](false);
+ },
+
+ fixed64: function read_fixed64() {
+ return readFixed64.call(this)[fn](true);
+ },
+
+ sfixed64: function read_sfixed64() {
+ return readFixed64.call(this)[fn](false);
+ }
+
+ });
+};
diff --git a/OpenHarmony/library/src/main/ets/src/reader_buffer.js b/OpenHarmony/library/src/main/ets/src/reader_buffer.js
new file mode 100644
index 000000000..e54742416
--- /dev/null
+++ b/OpenHarmony/library/src/main/ets/src/reader_buffer.js
@@ -0,0 +1,51 @@
+"use strict";
+module.exports = BufferReader;
+
+// extends Reader
+var Reader = require("./reader");
+(BufferReader.prototype = Object.create(Reader.prototype)).constructor = BufferReader;
+
+var util = require("./util/minimal");
+
+/**
+ * Constructs a new buffer reader instance.
+ * @classdesc Wire format reader using node buffers.
+ * @extends Reader
+ * @constructor
+ * @param {Buffer} buffer Buffer to read from
+ */
+function BufferReader(buffer) {
+ Reader.call(this, buffer);
+
+ /**
+ * Read buffer.
+ * @name BufferReader#buf
+ * @type {Buffer}
+ */
+}
+
+BufferReader._configure = function () {
+ /* istanbul ignore else */
+ if (util.Buffer)
+ BufferReader.prototype._slice = util.Buffer.prototype.slice;
+};
+
+
+/**
+ * @override
+ */
+BufferReader.prototype.string = function read_string_buffer() {
+ var len = this.uint32(); // modifies pos
+ return this.buf.utf8Slice
+ ? this.buf.utf8Slice(this.pos, this.pos = Math.min(this.pos + len, this.len))
+ : this.buf.toString("utf-8", this.pos, this.pos = Math.min(this.pos + len, this.len));
+};
+
+/**
+ * Reads a sequence of bytes preceeded by its length as a varint.
+ * @name BufferReader#bytes
+ * @function
+ * @returns {Buffer} Value read
+ */
+
+BufferReader._configure();
diff --git a/OpenHarmony/library/src/main/ets/src/root.js b/OpenHarmony/library/src/main/ets/src/root.js
new file mode 100644
index 000000000..9441a7fc3
--- /dev/null
+++ b/OpenHarmony/library/src/main/ets/src/root.js
@@ -0,0 +1,368 @@
+"use strict";
+module.exports = Root;
+
+// extends Namespace
+var Namespace = require("./namespace");
+((Root.prototype = Object.create(Namespace.prototype)).constructor = Root).className = "Root";
+
+var Field = require("./field"),
+ Enum = require("./enum"),
+ OneOf = require("./oneof"),
+ util = require("./util");
+
+var Type, // cyclic
+ parse, // might be excluded
+ common; // "
+
+/**
+ * Constructs a new root namespace instance.
+ * @classdesc Root namespace wrapping all types, enums, services, sub-namespaces etc. that belong together.
+ * @extends NamespaceBase
+ * @constructor
+ * @param {Object.} [options] Top level options
+ */
+function Root(options) {
+ Namespace.call(this, "", options);
+
+ /**
+ * Deferred extension fields.
+ * @type {Field[]}
+ */
+ this.deferred = [];
+
+ /**
+ * Resolved file names of loaded files.
+ * @type {string[]}
+ */
+ this.files = [];
+}
+
+/**
+ * Loads a namespace descriptor into a root namespace.
+ * @param {INamespace} json Nameespace descriptor
+ * @param {Root} [root] Root namespace, defaults to create a new one if omitted
+ * @returns {Root} Root namespace
+ */
+Root.fromJSON = function fromJSON(json, root) {
+ if (!root)
+ root = new Root();
+ if (json.options)
+ root.setOptions(json.options);
+ return root.addJSON(json.nested);
+};
+
+/**
+ * Resolves the path of an imported file, relative to the importing origin.
+ * This method exists so you can override it with your own logic in case your imports are scattered over multiple directories.
+ * @function
+ * @param {string} origin The file name of the importing file
+ * @param {string} target The file name being imported
+ * @returns {string|null} Resolved path to `target` or `null` to skip the file
+ */
+Root.prototype.resolvePath = util.path.resolve;
+
+/**
+ * Fetch content from file path or url
+ * This method exists so you can override it with your own logic.
+ * @function
+ * @param {string} path File path or url
+ * @param {FetchCallback} callback Callback function
+ * @returns {undefined}
+ */
+Root.prototype.fetch = util.fetch;
+
+// A symbol-like function to safely signal synchronous loading
+/* istanbul ignore next */
+function SYNC() {} // eslint-disable-line no-empty-function
+
+/**
+ * Loads one or multiple .proto or preprocessed .json files into this root namespace and calls the callback.
+ * @param {string|string[]} filename Names of one or multiple files to load
+ * @param {IParseOptions} options Parse options
+ * @param {LoadCallback} callback Callback function
+ * @returns {undefined}
+ */
+Root.prototype.load = function load(filename, options, callback) {
+ if (typeof options === "function") {
+ callback = options;
+ options = undefined;
+ }
+ var self = this;
+ if (!callback)
+ return util.asPromise(load, self, filename, options);
+
+ var sync = callback === SYNC; // undocumented
+
+ // Finishes loading by calling the callback (exactly once)
+ function finish(err, root) {
+ /* istanbul ignore if */
+ if (!callback)
+ return;
+ var cb = callback;
+ callback = null;
+ if (sync)
+ throw err;
+ cb(err, root);
+ }
+
+ // Bundled definition existence checking
+ function getBundledFileName(filename) {
+ var idx = filename.lastIndexOf("google/protobuf/");
+ if (idx > -1) {
+ var altname = filename.substring(idx);
+ if (altname in common) return altname;
+ }
+ return null;
+ }
+
+ // Processes a single file
+ function process(filename, source) {
+ try {
+ if (util.isString(source) && source.charAt(0) === "{")
+ source = JSON.parse(source);
+ if (!util.isString(source))
+ self.setOptions(source.options).addJSON(source.nested);
+ else {
+ parse.filename = filename;
+ var parsed = parse(source, self, options),
+ resolved,
+ i = 0;
+ if (parsed.imports)
+ for (; i < parsed.imports.length; ++i)
+ if (resolved = getBundledFileName(parsed.imports[i]) || self.resolvePath(filename, parsed.imports[i]))
+ fetch(resolved);
+ if (parsed.weakImports)
+ for (i = 0; i < parsed.weakImports.length; ++i)
+ if (resolved = getBundledFileName(parsed.weakImports[i]) || self.resolvePath(filename, parsed.weakImports[i]))
+ fetch(resolved, true);
+ }
+ } catch (err) {
+ finish(err);
+ }
+ if (!sync && !queued)
+ finish(null, self); // only once anyway
+ }
+
+ // Fetches a single file
+ function fetch(filename, weak) {
+ filename = getBundledFileName(filename) || filename;
+
+ // Skip if already loaded / attempted
+ if (self.files.indexOf(filename) > -1)
+ return;
+ self.files.push(filename);
+
+ // Shortcut bundled definitions
+ if (filename in common) {
+ if (sync)
+ process(filename, common[filename]);
+ else {
+ ++queued;
+ setTimeout(function() {
+ --queued;
+ process(filename, common[filename]);
+ });
+ }
+ return;
+ }
+
+ // Otherwise fetch from disk or network
+ if (sync) {
+ var source;
+ try {
+ source = util.fs.readFileSync(filename).toString("utf8");
+ } catch (err) {
+ if (!weak)
+ finish(err);
+ return;
+ }
+ process(filename, source);
+ } else {
+ ++queued;
+ self.fetch(filename, function(err, source) {
+ --queued;
+ /* istanbul ignore if */
+ if (!callback)
+ return; // terminated meanwhile
+ if (err) {
+ /* istanbul ignore else */
+ if (!weak)
+ finish(err);
+ else if (!queued) // can't be covered reliably
+ finish(null, self);
+ return;
+ }
+ process(filename, source);
+ });
+ }
+ }
+ var queued = 0;
+
+ // Assembling the root namespace doesn't require working type
+ // references anymore, so we can load everything in parallel
+ if (util.isString(filename))
+ filename = [ filename ];
+ for (var i = 0, resolved; i < filename.length; ++i)
+ if (resolved = self.resolvePath("", filename[i]))
+ fetch(resolved);
+
+ if (sync)
+ return self;
+ if (!queued)
+ finish(null, self);
+ return undefined;
+};
+// function load(filename:string, options:IParseOptions, callback:LoadCallback):undefined
+
+/**
+ * Loads one or multiple .proto or preprocessed .json files into this root namespace and calls the callback.
+ * @function Root#load
+ * @param {string|string[]} filename Names of one or multiple files to load
+ * @param {LoadCallback} callback Callback function
+ * @returns {undefined}
+ * @variation 2
+ */
+// function load(filename:string, callback:LoadCallback):undefined
+
+/**
+ * Loads one or multiple .proto or preprocessed .json files into this root namespace and returns a promise.
+ * @function Root#load
+ * @param {string|string[]} filename Names of one or multiple files to load
+ * @param {IParseOptions} [options] Parse options. Defaults to {@link parse.defaults} when omitted.
+ * @returns {Promise} Promise
+ * @variation 3
+ */
+// function load(filename:string, [options:IParseOptions]):Promise
+
+/**
+ * Synchronously loads one or multiple .proto or preprocessed .json files into this root namespace (node only).
+ * @function Root#loadSync
+ * @param {string|string[]} filename Names of one or multiple files to load
+ * @param {IParseOptions} [options] Parse options. Defaults to {@link parse.defaults} when omitted.
+ * @returns {Root} Root namespace
+ * @throws {Error} If synchronous fetching is not supported (i.e. in browsers) or if a file's syntax is invalid
+ */
+Root.prototype.loadSync = function loadSync(filename, options) {
+ if (!util.isNode)
+ throw Error("not supported");
+ return this.load(filename, options, SYNC);
+};
+
+/**
+ * @override
+ */
+Root.prototype.resolveAll = function resolveAll() {
+ if (this.deferred.length)
+ throw Error("unresolvable extensions: " + this.deferred.map(function(field) {
+ return "'extend " + field.extend + "' in " + field.parent.fullName;
+ }).join(", "));
+ return Namespace.prototype.resolveAll.call(this);
+};
+
+// only uppercased (and thus conflict-free) children are exposed, see below
+var exposeRe = /^[A-Z]/;
+
+/**
+ * Handles a deferred declaring extension field by creating a sister field to represent it within its extended type.
+ * @param {Root} root Root instance
+ * @param {Field} field Declaring extension field witin the declaring type
+ * @returns {boolean} `true` if successfully added to the extended type, `false` otherwise
+ * @inner
+ * @ignore
+ */
+function tryHandleExtension(root, field) {
+ var extendedType = field.parent.lookup(field.extend);
+ if (extendedType) {
+ var sisterField = new Field(field.fullName, field.id, field.type, field.rule, undefined, field.options);
+ //do not allow to extend same field twice to prevent the error
+ if (extendedType.get(sisterField.name)) {
+ return true;
+ }
+ sisterField.declaringField = field;
+ field.extensionField = sisterField;
+ extendedType.add(sisterField);
+ return true;
+ }
+ return false;
+}
+
+/**
+ * Called when any object is added to this root or its sub-namespaces.
+ * @param {ReflectionObject} object Object added
+ * @returns {undefined}
+ * @private
+ */
+Root.prototype._handleAdd = function _handleAdd(object) {
+ if (object instanceof Field) {
+
+ if (/* an extension field (implies not part of a oneof) */ object.extend !== undefined && /* not already handled */ !object.extensionField)
+ if (!tryHandleExtension(this, object))
+ this.deferred.push(object);
+
+ } else if (object instanceof Enum) {
+
+ if (exposeRe.test(object.name))
+ object.parent[object.name] = object.values; // expose enum values as property of its parent
+
+ } else if (!(object instanceof OneOf)) /* everything else is a namespace */ {
+
+ if (object instanceof Type) // Try to handle any deferred extensions
+ for (var i = 0; i < this.deferred.length;)
+ if (tryHandleExtension(this, this.deferred[i]))
+ this.deferred.splice(i, 1);
+ else
+ ++i;
+ for (var j = 0; j < /* initializes */ object.nestedArray.length; ++j) // recurse into the namespace
+ this._handleAdd(object._nestedArray[j]);
+ if (exposeRe.test(object.name))
+ object.parent[object.name] = object; // expose namespace as property of its parent
+ }
+
+ // The above also adds uppercased (and thus conflict-free) nested types, services and enums as
+ // properties of namespaces just like static code does. This allows using a .d.ts generated for
+ // a static module with reflection-based solutions where the condition is met.
+};
+
+/**
+ * Called when any object is removed from this root or its sub-namespaces.
+ * @param {ReflectionObject} object Object removed
+ * @returns {undefined}
+ * @private
+ */
+Root.prototype._handleRemove = function _handleRemove(object) {
+ if (object instanceof Field) {
+
+ if (/* an extension field */ object.extend !== undefined) {
+ if (/* already handled */ object.extensionField) { // remove its sister field
+ object.extensionField.parent.remove(object.extensionField);
+ object.extensionField = null;
+ } else { // cancel the extension
+ var index = this.deferred.indexOf(object);
+ /* istanbul ignore else */
+ if (index > -1)
+ this.deferred.splice(index, 1);
+ }
+ }
+
+ } else if (object instanceof Enum) {
+
+ if (exposeRe.test(object.name))
+ delete object.parent[object.name]; // unexpose enum values
+
+ } else if (object instanceof Namespace) {
+
+ for (var i = 0; i < /* initializes */ object.nestedArray.length; ++i) // recurse into the namespace
+ this._handleRemove(object._nestedArray[i]);
+
+ if (exposeRe.test(object.name))
+ delete object.parent[object.name]; // unexpose namespaces
+
+ }
+};
+
+// Sets up cyclic dependencies (called in index-light)
+Root._configure = function(Type_, parse_, common_) {
+ Type = Type_;
+ parse = parse_;
+ common = common_;
+};
diff --git a/OpenHarmony/library/src/main/ets/src/roots.js b/OpenHarmony/library/src/main/ets/src/roots.js
new file mode 100644
index 000000000..1d93086dd
--- /dev/null
+++ b/OpenHarmony/library/src/main/ets/src/roots.js
@@ -0,0 +1,18 @@
+"use strict";
+module.exports = {};
+
+/**
+ * Named roots.
+ * This is where pbjs stores generated structures (the option `-r, --root` specifies a name).
+ * Can also be used manually to make roots available across modules.
+ * @name roots
+ * @type {Object.}
+ * @example
+ * // pbjs -r myroot -o compiled.js ...
+ *
+ * // in another module:
+ * require("./compiled.js");
+ *
+ * // in any subsequent module:
+ * var root = protobuf.roots["myroot"];
+ */
diff --git a/OpenHarmony/library/src/main/ets/src/rpc.js b/OpenHarmony/library/src/main/ets/src/rpc.js
new file mode 100644
index 000000000..894e5c7c9
--- /dev/null
+++ b/OpenHarmony/library/src/main/ets/src/rpc.js
@@ -0,0 +1,36 @@
+"use strict";
+
+/**
+ * Streaming RPC helpers.
+ * @namespace
+ */
+var rpc = exports;
+
+/**
+ * RPC implementation passed to {@link Service#create} performing a service request on network level, i.e. by utilizing http requests or websockets.
+ * @typedef RPCImpl
+ * @type {function}
+ * @param {Method|rpc.ServiceMethod,Message<{}>>} method Reflected or static method being called
+ * @param {Uint8Array} requestData Request data
+ * @param {RPCImplCallback} callback Callback function
+ * @returns {undefined}
+ * @example
+ * function rpcImpl(method, requestData, callback) {
+ * if (protobuf.util.lcFirst(method.name) !== "myMethod") // compatible with static code
+ * throw Error("no such method");
+ * asynchronouslyObtainAResponse(requestData, function(err, responseData) {
+ * callback(err, responseData);
+ * });
+ * }
+ */
+
+/**
+ * Node-style callback as used by {@link RPCImpl}.
+ * @typedef RPCImplCallback
+ * @type {function}
+ * @param {Error|null} error Error, if any, otherwise `null`
+ * @param {Uint8Array|null} [response] Response data or `null` to signal end of stream, if there hasn't been an error
+ * @returns {undefined}
+ */
+
+rpc.Service = require("./rpc/service");
diff --git a/OpenHarmony/library/src/main/ets/src/rpc/service.js b/OpenHarmony/library/src/main/ets/src/rpc/service.js
new file mode 100644
index 000000000..757f382eb
--- /dev/null
+++ b/OpenHarmony/library/src/main/ets/src/rpc/service.js
@@ -0,0 +1,142 @@
+"use strict";
+module.exports = Service;
+
+var util = require("../util/minimal");
+
+// Extends EventEmitter
+(Service.prototype = Object.create(util.EventEmitter.prototype)).constructor = Service;
+
+/**
+ * A service method callback as used by {@link rpc.ServiceMethod|ServiceMethod}.
+ *
+ * Differs from {@link RPCImplCallback} in that it is an actual callback of a service method which may not return `response = null`.
+ * @typedef rpc.ServiceMethodCallback
+ * @template TRes extends Message
+ * @type {function}
+ * @param {Error|null} error Error, if any
+ * @param {TRes} [response] Response message
+ * @returns {undefined}
+ */
+
+/**
+ * A service method part of a {@link rpc.Service} as created by {@link Service.create}.
+ * @typedef rpc.ServiceMethod
+ * @template TReq extends Message
+ * @template TRes extends Message
+ * @type {function}
+ * @param {TReq|Properties} request Request message or plain object
+ * @param {rpc.ServiceMethodCallback} [callback] Node-style callback called with the error, if any, and the response message
+ * @returns {Promise>} Promise if `callback` has been omitted, otherwise `undefined`
+ */
+
+/**
+ * Constructs a new RPC service instance.
+ * @classdesc An RPC service as returned by {@link Service#create}.
+ * @exports rpc.Service
+ * @extends util.EventEmitter
+ * @constructor
+ * @param {RPCImpl} rpcImpl RPC implementation
+ * @param {boolean} [requestDelimited=false] Whether requests are length-delimited
+ * @param {boolean} [responseDelimited=false] Whether responses are length-delimited
+ */
+function Service(rpcImpl, requestDelimited, responseDelimited) {
+
+ if (typeof rpcImpl !== "function")
+ throw TypeError("rpcImpl must be a function");
+
+ util.EventEmitter.call(this);
+
+ /**
+ * RPC implementation. Becomes `null` once the service is ended.
+ * @type {RPCImpl|null}
+ */
+ this.rpcImpl = rpcImpl;
+
+ /**
+ * Whether requests are length-delimited.
+ * @type {boolean}
+ */
+ this.requestDelimited = Boolean(requestDelimited);
+
+ /**
+ * Whether responses are length-delimited.
+ * @type {boolean}
+ */
+ this.responseDelimited = Boolean(responseDelimited);
+}
+
+/**
+ * Calls a service method through {@link rpc.Service#rpcImpl|rpcImpl}.
+ * @param {Method|rpc.ServiceMethod} method Reflected or static method
+ * @param {Constructor} requestCtor Request constructor
+ * @param {Constructor} responseCtor Response constructor
+ * @param {TReq|Properties} request Request message or plain object
+ * @param {rpc.ServiceMethodCallback} callback Service callback
+ * @returns {undefined}
+ * @template TReq extends Message
+ * @template TRes extends Message
+ */
+Service.prototype.rpcCall = function rpcCall(method, requestCtor, responseCtor, request, callback) {
+
+ if (!request)
+ throw TypeError("request must be specified");
+
+ var self = this;
+ if (!callback)
+ return util.asPromise(rpcCall, self, method, requestCtor, responseCtor, request);
+
+ if (!self.rpcImpl) {
+ setTimeout(function() { callback(Error("already ended")); }, 0);
+ return undefined;
+ }
+
+ try {
+ return self.rpcImpl(
+ method,
+ requestCtor[self.requestDelimited ? "encodeDelimited" : "encode"](request).finish(),
+ function rpcCallback(err, response) {
+
+ if (err) {
+ self.emit("error", err, method);
+ return callback(err);
+ }
+
+ if (response === null) {
+ self.end(/* endedByRPC */ true);
+ return undefined;
+ }
+
+ if (!(response instanceof responseCtor)) {
+ try {
+ response = responseCtor[self.responseDelimited ? "decodeDelimited" : "decode"](response);
+ } catch (err) {
+ self.emit("error", err, method);
+ return callback(err);
+ }
+ }
+
+ self.emit("data", response, method);
+ return callback(null, response);
+ }
+ );
+ } catch (err) {
+ self.emit("error", err, method);
+ setTimeout(function() { callback(err); }, 0);
+ return undefined;
+ }
+};
+
+/**
+ * Ends this service and emits the `end` event.
+ * @param {boolean} [endedByRPC=false] Whether the service has been ended by the RPC implementation.
+ * @returns {rpc.Service} `this`
+ */
+Service.prototype.end = function end(endedByRPC) {
+ if (this.rpcImpl) {
+ if (!endedByRPC) // signal end to rpcImpl
+ this.rpcImpl(null, null, null);
+ this.rpcImpl = null;
+ this.emit("end").off();
+ }
+ return this;
+};
diff --git a/OpenHarmony/library/src/main/ets/src/service.js b/OpenHarmony/library/src/main/ets/src/service.js
new file mode 100644
index 000000000..bc2c3080c
--- /dev/null
+++ b/OpenHarmony/library/src/main/ets/src/service.js
@@ -0,0 +1,167 @@
+"use strict";
+module.exports = Service;
+
+// extends Namespace
+var Namespace = require("./namespace");
+((Service.prototype = Object.create(Namespace.prototype)).constructor = Service).className = "Service";
+
+var Method = require("./method"),
+ util = require("./util"),
+ rpc = require("./rpc");
+
+/**
+ * Constructs a new service instance.
+ * @classdesc Reflected service.
+ * @extends NamespaceBase
+ * @constructor
+ * @param {string} name Service name
+ * @param {Object.} [options] Service options
+ * @throws {TypeError} If arguments are invalid
+ */
+function Service(name, options) {
+ Namespace.call(this, name, options);
+
+ /**
+ * Service methods.
+ * @type {Object.}
+ */
+ this.methods = {}; // toJSON, marker
+
+ /**
+ * Cached methods as an array.
+ * @type {Method[]|null}
+ * @private
+ */
+ this._methodsArray = null;
+}
+
+/**
+ * Service descriptor.
+ * @interface IService
+ * @extends INamespace
+ * @property {Object.} methods Method descriptors
+ */
+
+/**
+ * Constructs a service from a service descriptor.
+ * @param {string} name Service name
+ * @param {IService} json Service descriptor
+ * @returns {Service} Created service
+ * @throws {TypeError} If arguments are invalid
+ */
+Service.fromJSON = function fromJSON(name, json) {
+ var service = new Service(name, json.options);
+ /* istanbul ignore else */
+ if (json.methods)
+ for (var names = Object.keys(json.methods), i = 0; i < names.length; ++i)
+ service.add(Method.fromJSON(names[i], json.methods[names[i]]));
+ if (json.nested)
+ service.addJSON(json.nested);
+ service.comment = json.comment;
+ return service;
+};
+
+/**
+ * Converts this service to a service descriptor.
+ * @param {IToJSONOptions} [toJSONOptions] JSON conversion options
+ * @returns {IService} Service descriptor
+ */
+Service.prototype.toJSON = function toJSON(toJSONOptions) {
+ var inherited = Namespace.prototype.toJSON.call(this, toJSONOptions);
+ var keepComments = toJSONOptions ? Boolean(toJSONOptions.keepComments) : false;
+ return util.toObject([
+ "options" , inherited && inherited.options || undefined,
+ "methods" , Namespace.arrayToJSON(this.methodsArray, toJSONOptions) || /* istanbul ignore next */ {},
+ "nested" , inherited && inherited.nested || undefined,
+ "comment" , keepComments ? this.comment : undefined
+ ]);
+};
+
+/**
+ * Methods of this service as an array for iteration.
+ * @name Service#methodsArray
+ * @type {Method[]}
+ * @readonly
+ */
+Object.defineProperty(Service.prototype, "methodsArray", {
+ get: function() {
+ return this._methodsArray || (this._methodsArray = util.toArray(this.methods));
+ }
+});
+
+function clearCache(service) {
+ service._methodsArray = null;
+ return service;
+}
+
+/**
+ * @override
+ */
+Service.prototype.get = function get(name) {
+ return this.methods[name]
+ || Namespace.prototype.get.call(this, name);
+};
+
+/**
+ * @override
+ */
+Service.prototype.resolveAll = function resolveAll() {
+ var methods = this.methodsArray;
+ for (var i = 0; i < methods.length; ++i)
+ methods[i].resolve();
+ return Namespace.prototype.resolve.call(this);
+};
+
+/**
+ * @override
+ */
+Service.prototype.add = function add(object) {
+
+ /* istanbul ignore if */
+ if (this.get(object.name))
+ throw Error("duplicate name '" + object.name + "' in " + this);
+
+ if (object instanceof Method) {
+ this.methods[object.name] = object;
+ object.parent = this;
+ return clearCache(this);
+ }
+ return Namespace.prototype.add.call(this, object);
+};
+
+/**
+ * @override
+ */
+Service.prototype.remove = function remove(object) {
+ if (object instanceof Method) {
+
+ /* istanbul ignore if */
+ if (this.methods[object.name] !== object)
+ throw Error(object + " is not a member of " + this);
+
+ delete this.methods[object.name];
+ object.parent = null;
+ return clearCache(this);
+ }
+ return Namespace.prototype.remove.call(this, object);
+};
+
+/**
+ * Creates a runtime service using the specified rpc implementation.
+ * @param {RPCImpl} rpcImpl RPC implementation
+ * @param {boolean} [requestDelimited=false] Whether requests are length-delimited
+ * @param {boolean} [responseDelimited=false] Whether responses are length-delimited
+ * @returns {rpc.Service} RPC service. Useful where requests and/or responses are streamed.
+ */
+Service.prototype.create = function create(rpcImpl, requestDelimited, responseDelimited) {
+ var rpcService = new rpc.Service(rpcImpl, requestDelimited, responseDelimited);
+ for (var i = 0, method; i < /* initializes */ this.methodsArray.length; ++i) {
+ var methodName = util.lcFirst((method = this._methodsArray[i]).resolve().name).replace(/[^$\w_]/g, "");
+ rpcService[methodName] = util.codegen(["r","c"], util.isReserved(methodName) ? methodName + "_" : methodName)("return this.rpcCall(m,q,s,r,c)")({
+ m: method,
+ q: method.resolvedRequestType.ctor,
+ s: method.resolvedResponseType.ctor
+ });
+ }
+ return rpcService;
+};
diff --git a/OpenHarmony/library/src/main/ets/src/tokenize.js b/OpenHarmony/library/src/main/ets/src/tokenize.js
new file mode 100644
index 000000000..bfb784bd2
--- /dev/null
+++ b/OpenHarmony/library/src/main/ets/src/tokenize.js
@@ -0,0 +1,418 @@
+"use strict";
+module.exports = tokenize;
+
+var delimRe = /[\s{}=;:[\],'"()<>]/g,
+ stringDoubleRe = /(?:"([^"\\]*(?:\\.[^"\\]*)*)")/g,
+ stringSingleRe = /(?:'([^'\\]*(?:\\.[^'\\]*)*)')/g;
+
+var setCommentRe = /^ *[*/]+ */,
+ setCommentAltRe = /^\s*\*?\/*/,
+ setCommentSplitRe = /\n/g,
+ whitespaceRe = /\s/,
+ unescapeRe = /\\(.?)/g;
+
+var unescapeMap = {
+ "0": "\0",
+ "r": "\r",
+ "n": "\n",
+ "t": "\t"
+};
+
+/**
+ * Unescapes a string.
+ * @param {string} str String to unescape
+ * @returns {string} Unescaped string
+ * @property {Object.} map Special characters map
+ * @memberof tokenize
+ */
+function unescape(str) {
+ return str.replace(unescapeRe, function($0, $1) {
+ switch ($1) {
+ case "\\":
+ case "":
+ return $1;
+ default:
+ return unescapeMap[$1] || "";
+ }
+ });
+}
+
+tokenize.unescape = unescape;
+
+/**
+ * Gets the next token and advances.
+ * @typedef TokenizerHandleNext
+ * @type {function}
+ * @returns {string|null} Next token or `null` on eof
+ */
+
+/**
+ * Peeks for the next token.
+ * @typedef TokenizerHandlePeek
+ * @type {function}
+ * @returns {string|null} Next token or `null` on eof
+ */
+
+/**
+ * Pushes a token back to the stack.
+ * @typedef TokenizerHandlePush
+ * @type {function}
+ * @param {string} token Token
+ * @returns {undefined}
+ */
+
+/**
+ * Skips the next token.
+ * @typedef TokenizerHandleSkip
+ * @type {function}
+ * @param {string} expected Expected token
+ * @param {boolean} [optional=false] If optional
+ * @returns {boolean} Whether the token matched
+ * @throws {Error} If the token didn't match and is not optional
+ */
+
+/**
+ * Gets the comment on the previous line or, alternatively, the line comment on the specified line.
+ * @typedef TokenizerHandleCmnt
+ * @type {function}
+ * @param {number} [line] Line number
+ * @returns {string|null} Comment text or `null` if none
+ */
+
+/**
+ * Handle object returned from {@link tokenize}.
+ * @interface ITokenizerHandle
+ * @property {TokenizerHandleNext} next Gets the next token and advances (`null` on eof)
+ * @property {TokenizerHandlePeek} peek Peeks for the next token (`null` on eof)
+ * @property {TokenizerHandlePush} push Pushes a token back to the stack
+ * @property {TokenizerHandleSkip} skip Skips a token, returns its presence and advances or, if non-optional and not present, throws
+ * @property {TokenizerHandleCmnt} cmnt Gets the comment on the previous line or the line comment on the specified line, if any
+ * @property {number} line Current line number
+ */
+
+/**
+ * Tokenizes the given .proto source and returns an object with useful utility functions.
+ * @param {string} source Source contents
+ * @param {boolean} alternateCommentMode Whether we should activate alternate comment parsing mode.
+ * @returns {ITokenizerHandle} Tokenizer handle
+ */
+function tokenize(source, alternateCommentMode) {
+ /* eslint-disable callback-return */
+ source = source.toString();
+
+ var offset = 0,
+ length = source.length,
+ line = 1,
+ lastCommentLine = 0,
+ comments = {};
+
+ var stack = [];
+
+ var stringDelim = null;
+
+ /* istanbul ignore next */
+ /**
+ * Creates an error for illegal syntax.
+ * @param {string} subject Subject
+ * @returns {Error} Error created
+ * @inner
+ */
+ function illegal(subject) {
+ return Error("illegal " + subject + " (line " + line + ")");
+ }
+
+ /**
+ * Reads a string till its end.
+ * @returns {string} String read
+ * @inner
+ */
+ function readString() {
+ var re = stringDelim === "'" ? stringSingleRe : stringDoubleRe;
+ re.lastIndex = offset - 1;
+ var match = re.exec(source);
+ if (!match)
+ throw illegal("string");
+ offset = re.lastIndex;
+ push(stringDelim);
+ stringDelim = null;
+ return unescape(match[1]);
+ }
+
+ /**
+ * Gets the character at `pos` within the source.
+ * @param {number} pos Position
+ * @returns {string} Character
+ * @inner
+ */
+ function charAt(pos) {
+ return source.charAt(pos);
+ }
+
+ /**
+ * Sets the current comment text.
+ * @param {number} start Start offset
+ * @param {number} end End offset
+ * @param {boolean} isLeading set if a leading comment
+ * @returns {undefined}
+ * @inner
+ */
+ function setComment(start, end, isLeading) {
+ var comment = {
+ type: source.charAt(start++),
+ lineEmpty: false,
+ leading: isLeading,
+ };
+ var lookback;
+ if (alternateCommentMode) {
+ lookback = 2; // alternate comment parsing: "//" or "/*"
+ } else {
+ lookback = 3; // "///" or "/**"
+ }
+ var commentOffset = start - lookback,
+ c;
+ do {
+ if (--commentOffset < 0 ||
+ (c = source.charAt(commentOffset)) === "\n") {
+ comment.lineEmpty = true;
+ break;
+ }
+ } while (c === " " || c === "\t");
+ var lines = source
+ .substring(start, end)
+ .split(setCommentSplitRe);
+ for (var i = 0; i < lines.length; ++i)
+ lines[i] = lines[i]
+ .replace(alternateCommentMode ? setCommentAltRe : setCommentRe, "")
+ .trim();
+ comment.text = lines
+ .join("\n")
+ .trim();
+
+ comments[line] = comment;
+ lastCommentLine = line;
+ }
+
+ function isDoubleSlashCommentLine(startOffset) {
+ var endOffset = findEndOfLine(startOffset);
+
+ // see if remaining line matches comment pattern
+ var lineText = source.substring(startOffset, endOffset);
+ // look for 1 or 2 slashes since startOffset would already point past
+ // the first slash that started the comment.
+ var isComment = /^\s*\/{1,2}/.test(lineText);
+ return isComment;
+ }
+
+ function findEndOfLine(cursor) {
+ // find end of cursor's line
+ var endOffset = cursor;
+ while (endOffset < length && charAt(endOffset) !== "\n") {
+ endOffset++;
+ }
+ return endOffset;
+ }
+
+ /**
+ * Obtains the next token.
+ * @returns {string|null} Next token or `null` on eof
+ * @inner
+ */
+ function next() {
+ if (stack.length > 0)
+ return stack.shift();
+ if (stringDelim)
+ return readString();
+ var repeat,
+ prev,
+ curr,
+ start,
+ isDoc,
+ isLeadingComment = offset === 0;
+ do {
+ if (offset === length)
+ return null;
+ repeat = false;
+ while (whitespaceRe.test(curr = charAt(offset))) {
+ if (curr === "\n") {
+ isLeadingComment = true;
+ ++line;
+ }
+ if (++offset === length)
+ return null;
+ }
+
+ if (charAt(offset) === "/") {
+ if (++offset === length) {
+ throw illegal("comment");
+ }
+ if (charAt(offset) === "/") { // Line
+ if (!alternateCommentMode) {
+ // check for triple-slash comment
+ isDoc = charAt(start = offset + 1) === "/";
+
+ while (charAt(++offset) !== "\n") {
+ if (offset === length) {
+ return null;
+ }
+ }
+ ++offset;
+ if (isDoc) {
+ setComment(start, offset - 1, isLeadingComment);
+ // Trailing comment cannot not be multi-line,
+ // so leading comment state should be reset to handle potential next comments
+ isLeadingComment = true;
+ }
+ ++line;
+ repeat = true;
+ } else {
+ // check for double-slash comments, consolidating consecutive lines
+ start = offset;
+ isDoc = false;
+ if (isDoubleSlashCommentLine(offset)) {
+ isDoc = true;
+ do {
+ offset = findEndOfLine(offset);
+ if (offset === length) {
+ break;
+ }
+ offset++;
+ if (!isLeadingComment) {
+ // Trailing comment cannot not be multi-line
+ break;
+ }
+ } while (isDoubleSlashCommentLine(offset));
+ } else {
+ offset = Math.min(length, findEndOfLine(offset) + 1);
+ }
+ if (isDoc) {
+ setComment(start, offset, isLeadingComment);
+ isLeadingComment = true;
+ }
+ line++;
+ repeat = true;
+ }
+ } else if ((curr = charAt(offset)) === "*") { /* Block */
+ // check for /** (regular comment mode) or /* (alternate comment mode)
+ start = offset + 1;
+ isDoc = alternateCommentMode || charAt(start) === "*";
+ do {
+ if (curr === "\n") {
+ ++line;
+ }
+ if (++offset === length) {
+ throw illegal("comment");
+ }
+ prev = curr;
+ curr = charAt(offset);
+ } while (prev !== "*" || curr !== "/");
+ ++offset;
+ if (isDoc) {
+ setComment(start, offset - 2, isLeadingComment);
+ isLeadingComment = true;
+ }
+ repeat = true;
+ } else {
+ return "/";
+ }
+ }
+ } while (repeat);
+
+ // offset !== length if we got here
+
+ var end = offset;
+ delimRe.lastIndex = 0;
+ var delim = delimRe.test(charAt(end++));
+ if (!delim)
+ while (end < length && !delimRe.test(charAt(end)))
+ ++end;
+ var token = source.substring(offset, offset = end);
+ if (token === "\"" || token === "'")
+ stringDelim = token;
+ return token;
+ }
+
+ /**
+ * Pushes a token back to the stack.
+ * @param {string} token Token
+ * @returns {undefined}
+ * @inner
+ */
+ function push(token) {
+ stack.push(token);
+ }
+
+ /**
+ * Peeks for the next token.
+ * @returns {string|null} Token or `null` on eof
+ * @inner
+ */
+ function peek() {
+ if (!stack.length) {
+ var token = next();
+ if (token === null)
+ return null;
+ push(token);
+ }
+ return stack[0];
+ }
+
+ /**
+ * Skips a token.
+ * @param {string} expected Expected token
+ * @param {boolean} [optional=false] Whether the token is optional
+ * @returns {boolean} `true` when skipped, `false` if not
+ * @throws {Error} When a required token is not present
+ * @inner
+ */
+ function skip(expected, optional) {
+ var actual = peek(),
+ equals = actual === expected;
+ if (equals) {
+ next();
+ return true;
+ }
+ if (!optional)
+ throw illegal("token '" + actual + "', '" + expected + "' expected");
+ return false;
+ }
+
+ /**
+ * Gets a comment.
+ * @param {number} [trailingLine] Line number if looking for a trailing comment
+ * @returns {string|null} Comment text
+ * @inner
+ */
+ function cmnt(trailingLine) {
+ var ret = null;
+ var comment;
+ if (trailingLine === undefined) {
+ comment = comments[line - 1];
+ delete comments[line - 1];
+ if (comment && (alternateCommentMode || comment.type === "*" || comment.lineEmpty)) {
+ ret = comment.leading ? comment.text : null;
+ }
+ } else {
+ /* istanbul ignore else */
+ if (lastCommentLine < trailingLine) {
+ peek();
+ }
+ comment = comments[trailingLine];
+ delete comments[trailingLine];
+ if (comment && !comment.lineEmpty && (alternateCommentMode || comment.type === "/")) {
+ ret = comment.leading ? null : comment.text;
+ }
+ }
+ return ret;
+ }
+
+ return Object.defineProperty({
+ next: next,
+ peek: peek,
+ push: push,
+ skip: skip,
+ cmnt: cmnt
+ }, "line", {
+ get: function() { return line; }
+ });
+ /* eslint-enable callback-return */
+}
diff --git a/OpenHarmony/library/src/main/ets/src/type.js b/OpenHarmony/library/src/main/ets/src/type.js
new file mode 100644
index 000000000..2e7bda49b
--- /dev/null
+++ b/OpenHarmony/library/src/main/ets/src/type.js
@@ -0,0 +1,589 @@
+"use strict";
+module.exports = Type;
+
+// extends Namespace
+var Namespace = require("./namespace");
+((Type.prototype = Object.create(Namespace.prototype)).constructor = Type).className = "Type";
+
+var Enum = require("./enum"),
+ OneOf = require("./oneof"),
+ Field = require("./field"),
+ MapField = require("./mapfield"),
+ Service = require("./service"),
+ Message = require("./message"),
+ Reader = require("./reader"),
+ Writer = require("./writer"),
+ util = require("./util"),
+ encoder = require("./encoder"),
+ decoder = require("./decoder"),
+ verifier = require("./verifier"),
+ converter = require("./converter"),
+ wrappers = require("./wrappers");
+
+/**
+ * Constructs a new reflected message type instance.
+ * @classdesc Reflected message type.
+ * @extends NamespaceBase
+ * @constructor
+ * @param {string} name Message name
+ * @param {Object.} [options] Declared options
+ */
+function Type(name, options) {
+ Namespace.call(this, name, options);
+
+ /**
+ * Message fields.
+ * @type {Object.}
+ */
+ this.fields = {}; // toJSON, marker
+
+ /**
+ * Oneofs declared within this namespace, if any.
+ * @type {Object.}
+ */
+ this.oneofs = undefined; // toJSON
+
+ /**
+ * Extension ranges, if any.
+ * @type {number[][]}
+ */
+ this.extensions = undefined; // toJSON
+
+ /**
+ * Reserved ranges, if any.
+ * @type {Array.}
+ */
+ this.reserved = undefined; // toJSON
+
+ /*?
+ * Whether this type is a legacy group.
+ * @type {boolean|undefined}
+ */
+ this.group = undefined; // toJSON
+
+ /**
+ * Cached fields by id.
+ * @type {Object.|null}
+ * @private
+ */
+ this._fieldsById = null;
+
+ /**
+ * Cached fields as an array.
+ * @type {Field[]|null}
+ * @private
+ */
+ this._fieldsArray = null;
+
+ /**
+ * Cached oneofs as an array.
+ * @type {OneOf[]|null}
+ * @private
+ */
+ this._oneofsArray = null;
+
+ /**
+ * Cached constructor.
+ * @type {Constructor<{}>}
+ * @private
+ */
+ this._ctor = null;
+}
+
+Object.defineProperties(Type.prototype, {
+
+ /**
+ * Message fields by id.
+ * @name Type#fieldsById
+ * @type {Object.}
+ * @readonly
+ */
+ fieldsById: {
+ get: function() {
+
+ /* istanbul ignore if */
+ if (this._fieldsById)
+ return this._fieldsById;
+
+ this._fieldsById = {};
+ for (var names = Object.keys(this.fields), i = 0; i < names.length; ++i) {
+ var field = this.fields[names[i]],
+ id = field.id;
+
+ /* istanbul ignore if */
+ if (this._fieldsById[id])
+ throw Error("duplicate id " + id + " in " + this);
+
+ this._fieldsById[id] = field;
+ }
+ return this._fieldsById;
+ }
+ },
+
+ /**
+ * Fields of this message as an array for iteration.
+ * @name Type#fieldsArray
+ * @type {Field[]}
+ * @readonly
+ */
+ fieldsArray: {
+ get: function() {
+ return this._fieldsArray || (this._fieldsArray = util.toArray(this.fields));
+ }
+ },
+
+ /**
+ * Oneofs of this message as an array for iteration.
+ * @name Type#oneofsArray
+ * @type {OneOf[]}
+ * @readonly
+ */
+ oneofsArray: {
+ get: function() {
+ return this._oneofsArray || (this._oneofsArray = util.toArray(this.oneofs));
+ }
+ },
+
+ /**
+ * The registered constructor, if any registered, otherwise a generic constructor.
+ * Assigning a function replaces the internal constructor. If the function does not extend {@link Message} yet, its prototype will be setup accordingly and static methods will be populated. If it already extends {@link Message}, it will just replace the internal constructor.
+ * @name Type#ctor
+ * @type {Constructor<{}>}
+ */
+ ctor: {
+ get: function() {
+ return this._ctor || (this.ctor = Type.generateConstructor(this)());
+ },
+ set: function(ctor) {
+
+ // Ensure proper prototype
+ var prototype = ctor.prototype;
+ if (!(prototype instanceof Message)) {
+ (ctor.prototype = new Message()).constructor = ctor;
+ util.merge(ctor.prototype, prototype);
+ }
+
+ // Classes and messages reference their reflected type
+ ctor.$type = ctor.prototype.$type = this;
+
+ // Mix in static methods
+ util.merge(ctor, Message, true);
+
+ this._ctor = ctor;
+
+ // Messages have non-enumerable default values on their prototype
+ var i = 0;
+ for (; i < /* initializes */ this.fieldsArray.length; ++i)
+ this._fieldsArray[i].resolve(); // ensures a proper value
+
+ // Messages have non-enumerable getters and setters for each virtual oneof field
+ var ctorProperties = {};
+ for (i = 0; i < /* initializes */ this.oneofsArray.length; ++i)
+ ctorProperties[this._oneofsArray[i].resolve().name] = {
+ get: util.oneOfGetter(this._oneofsArray[i].oneof),
+ set: util.oneOfSetter(this._oneofsArray[i].oneof)
+ };
+ if (i)
+ Object.defineProperties(ctor.prototype, ctorProperties);
+ }
+ }
+});
+
+/**
+ * Generates a constructor function for the specified type.
+ * @param {Type} mtype Message type
+ * @returns {Codegen} Codegen instance
+ */
+Type.generateConstructor = function generateConstructor(mtype) {
+ /* eslint-disable no-unexpected-multiline */
+ var gen = util.codegen(["p"], mtype.name);
+ // explicitly initialize mutable object/array fields so that these aren't just inherited from the prototype
+ for (var i = 0, field; i < mtype.fieldsArray.length; ++i)
+ if ((field = mtype._fieldsArray[i]).map) gen
+ ("this%s={}", util.safeProp(field.name));
+ else if (field.repeated) gen
+ ("this%s=[]", util.safeProp(field.name));
+ return gen
+ ("if(p)for(var ks=Object.keys(p),i=0;i} [oneofs] Oneof descriptors
+ * @property {Object.} fields Field descriptors
+ * @property {number[][]} [extensions] Extension ranges
+ * @property {number[][]} [reserved] Reserved ranges
+ * @property {boolean} [group=false] Whether a legacy group or not
+ */
+
+/**
+ * Creates a message type from a message type descriptor.
+ * @param {string} name Message name
+ * @param {IType} json Message type descriptor
+ * @returns {Type} Created message type
+ */
+Type.fromJSON = function fromJSON(name, json) {
+ var type = new Type(name, json.options);
+ type.extensions = json.extensions;
+ type.reserved = json.reserved;
+ var names = Object.keys(json.fields),
+ i = 0;
+ for (; i < names.length; ++i)
+ type.add(
+ ( typeof json.fields[names[i]].keyType !== "undefined"
+ ? MapField.fromJSON
+ : Field.fromJSON )(names[i], json.fields[names[i]])
+ );
+ if (json.oneofs)
+ for (names = Object.keys(json.oneofs), i = 0; i < names.length; ++i)
+ type.add(OneOf.fromJSON(names[i], json.oneofs[names[i]]));
+ if (json.nested)
+ for (names = Object.keys(json.nested), i = 0; i < names.length; ++i) {
+ var nested = json.nested[names[i]];
+ type.add( // most to least likely
+ ( nested.id !== undefined
+ ? Field.fromJSON
+ : nested.fields !== undefined
+ ? Type.fromJSON
+ : nested.values !== undefined
+ ? Enum.fromJSON
+ : nested.methods !== undefined
+ ? Service.fromJSON
+ : Namespace.fromJSON )(names[i], nested)
+ );
+ }
+ if (json.extensions && json.extensions.length)
+ type.extensions = json.extensions;
+ if (json.reserved && json.reserved.length)
+ type.reserved = json.reserved;
+ if (json.group)
+ type.group = true;
+ if (json.comment)
+ type.comment = json.comment;
+ return type;
+};
+
+/**
+ * Converts this message type to a message type descriptor.
+ * @param {IToJSONOptions} [toJSONOptions] JSON conversion options
+ * @returns {IType} Message type descriptor
+ */
+Type.prototype.toJSON = function toJSON(toJSONOptions) {
+ var inherited = Namespace.prototype.toJSON.call(this, toJSONOptions);
+ var keepComments = toJSONOptions ? Boolean(toJSONOptions.keepComments) : false;
+ return util.toObject([
+ "options" , inherited && inherited.options || undefined,
+ "oneofs" , Namespace.arrayToJSON(this.oneofsArray, toJSONOptions),
+ "fields" , Namespace.arrayToJSON(this.fieldsArray.filter(function(obj) { return !obj.declaringField; }), toJSONOptions) || {},
+ "extensions" , this.extensions && this.extensions.length ? this.extensions : undefined,
+ "reserved" , this.reserved && this.reserved.length ? this.reserved : undefined,
+ "group" , this.group || undefined,
+ "nested" , inherited && inherited.nested || undefined,
+ "comment" , keepComments ? this.comment : undefined
+ ]);
+};
+
+/**
+ * @override
+ */
+Type.prototype.resolveAll = function resolveAll() {
+ var fields = this.fieldsArray, i = 0;
+ while (i < fields.length)
+ fields[i++].resolve();
+ var oneofs = this.oneofsArray; i = 0;
+ while (i < oneofs.length)
+ oneofs[i++].resolve();
+ return Namespace.prototype.resolveAll.call(this);
+};
+
+/**
+ * @override
+ */
+Type.prototype.get = function get(name) {
+ return this.fields[name]
+ || this.oneofs && this.oneofs[name]
+ || this.nested && this.nested[name]
+ || null;
+};
+
+/**
+ * Adds a nested object to this type.
+ * @param {ReflectionObject} object Nested object to add
+ * @returns {Type} `this`
+ * @throws {TypeError} If arguments are invalid
+ * @throws {Error} If there is already a nested object with this name or, if a field, when there is already a field with this id
+ */
+Type.prototype.add = function add(object) {
+
+ if (this.get(object.name))
+ throw Error("duplicate name '" + object.name + "' in " + this);
+
+ if (object instanceof Field && object.extend === undefined) {
+ // NOTE: Extension fields aren't actual fields on the declaring type, but nested objects.
+ // The root object takes care of adding distinct sister-fields to the respective extended
+ // type instead.
+
+ // avoids calling the getter if not absolutely necessary because it's called quite frequently
+ if (this._fieldsById ? /* istanbul ignore next */ this._fieldsById[object.id] : this.fieldsById[object.id])
+ throw Error("duplicate id " + object.id + " in " + this);
+ if (this.isReservedId(object.id))
+ throw Error("id " + object.id + " is reserved in " + this);
+ if (this.isReservedName(object.name))
+ throw Error("name '" + object.name + "' is reserved in " + this);
+
+ if (object.parent)
+ object.parent.remove(object);
+ this.fields[object.name] = object;
+ object.message = this;
+ object.onAdd(this);
+ return clearCache(this);
+ }
+ if (object instanceof OneOf) {
+ if (!this.oneofs)
+ this.oneofs = {};
+ this.oneofs[object.name] = object;
+ object.onAdd(this);
+ return clearCache(this);
+ }
+ return Namespace.prototype.add.call(this, object);
+};
+
+/**
+ * Removes a nested object from this type.
+ * @param {ReflectionObject} object Nested object to remove
+ * @returns {Type} `this`
+ * @throws {TypeError} If arguments are invalid
+ * @throws {Error} If `object` is not a member of this type
+ */
+Type.prototype.remove = function remove(object) {
+ if (object instanceof Field && object.extend === undefined) {
+ // See Type#add for the reason why extension fields are excluded here.
+
+ /* istanbul ignore if */
+ if (!this.fields || this.fields[object.name] !== object)
+ throw Error(object + " is not a member of " + this);
+
+ delete this.fields[object.name];
+ object.parent = null;
+ object.onRemove(this);
+ return clearCache(this);
+ }
+ if (object instanceof OneOf) {
+
+ /* istanbul ignore if */
+ if (!this.oneofs || this.oneofs[object.name] !== object)
+ throw Error(object + " is not a member of " + this);
+
+ delete this.oneofs[object.name];
+ object.parent = null;
+ object.onRemove(this);
+ return clearCache(this);
+ }
+ return Namespace.prototype.remove.call(this, object);
+};
+
+/**
+ * Tests if the specified id is reserved.
+ * @param {number} id Id to test
+ * @returns {boolean} `true` if reserved, otherwise `false`
+ */
+Type.prototype.isReservedId = function isReservedId(id) {
+ return Namespace.isReservedId(this.reserved, id);
+};
+
+/**
+ * Tests if the specified name is reserved.
+ * @param {string} name Name to test
+ * @returns {boolean} `true` if reserved, otherwise `false`
+ */
+Type.prototype.isReservedName = function isReservedName(name) {
+ return Namespace.isReservedName(this.reserved, name);
+};
+
+/**
+ * Creates a new message of this type using the specified properties.
+ * @param {Object.} [properties] Properties to set
+ * @returns {Message<{}>} Message instance
+ */
+Type.prototype.create = function create(properties) {
+ return new this.ctor(properties);
+};
+
+/**
+ * Sets up {@link Type#encode|encode}, {@link Type#decode|decode} and {@link Type#verify|verify}.
+ * @returns {Type} `this`
+ */
+Type.prototype.setup = function setup() {
+ // Sets up everything at once so that the prototype chain does not have to be re-evaluated
+ // multiple times (V8, soft-deopt prototype-check).
+
+ var fullName = this.fullName,
+ types = [];
+ for (var i = 0; i < /* initializes */ this.fieldsArray.length; ++i)
+ types.push(this._fieldsArray[i].resolve().resolvedType);
+
+ // Replace setup methods with type-specific generated functions
+ this.encode = encoder(this)({
+ Writer : Writer,
+ types : types,
+ util : util
+ });
+ this.decode = decoder(this)({
+ Reader : Reader,
+ types : types,
+ util : util
+ });
+ this.verify = verifier(this)({
+ types : types,
+ util : util
+ });
+ this.fromObject = converter.fromObject(this)({
+ types : types,
+ util : util
+ });
+ this.toObject = converter.toObject(this)({
+ types : types,
+ util : util
+ });
+
+ // Inject custom wrappers for common types
+ var wrapper = wrappers[fullName];
+ if (wrapper) {
+ var originalThis = Object.create(this);
+ // if (wrapper.fromObject) {
+ originalThis.fromObject = this.fromObject;
+ this.fromObject = wrapper.fromObject.bind(originalThis);
+ // }
+ // if (wrapper.toObject) {
+ originalThis.toObject = this.toObject;
+ this.toObject = wrapper.toObject.bind(originalThis);
+ // }
+ }
+
+ return this;
+};
+
+/**
+ * Encodes a message of this type. Does not implicitly {@link Type#verify|verify} messages.
+ * @param {Message<{}>|Object.} message Message instance or plain object
+ * @param {Writer} [writer] Writer to encode to
+ * @returns {Writer} writer
+ */
+Type.prototype.encode = function encode_setup(message, writer) {
+ return this.setup().encode(message, writer); // overrides this method
+};
+
+/**
+ * Encodes a message of this type preceeded by its byte length as a varint. Does not implicitly {@link Type#verify|verify} messages.
+ * @param {Message<{}>|Object.} message Message instance or plain object
+ * @param {Writer} [writer] Writer to encode to
+ * @returns {Writer} writer
+ */
+Type.prototype.encodeDelimited = function encodeDelimited(message, writer) {
+ return this.encode(message, writer && writer.len ? writer.fork() : writer).ldelim();
+};
+
+/**
+ * Decodes a message of this type.
+ * @param {Reader|Uint8Array} reader Reader or buffer to decode from
+ * @param {number} [length] Length of the message, if known beforehand
+ * @returns {Message<{}>} Decoded message
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {util.ProtocolError<{}>} If required fields are missing
+ */
+Type.prototype.decode = function decode_setup(reader, length) {
+ return this.setup().decode(reader, length); // overrides this method
+};
+
+/**
+ * Decodes a message of this type preceeded by its byte length as a varint.
+ * @param {Reader|Uint8Array} reader Reader or buffer to decode from
+ * @returns {Message<{}>} Decoded message
+ * @throws {Error} If the payload is not a reader or valid buffer
+ * @throws {util.ProtocolError} If required fields are missing
+ */
+Type.prototype.decodeDelimited = function decodeDelimited(reader) {
+ if (!(reader instanceof Reader))
+ reader = Reader.create(reader);
+ return this.decode(reader, reader.uint32());
+};
+
+/**
+ * Verifies that field values are valid and that required fields are present.
+ * @param {Object.} message Plain object to verify
+ * @returns {null|string} `null` if valid, otherwise the reason why it is not
+ */
+Type.prototype.verify = function verify_setup(message) {
+ return this.setup().verify(message); // overrides this method
+};
+
+/**
+ * Creates a new message of this type from a plain object. Also converts values to their respective internal types.
+ * @param {Object.} object Plain object to convert
+ * @returns {Message<{}>} Message instance
+ */
+Type.prototype.fromObject = function fromObject(object) {
+ return this.setup().fromObject(object);
+};
+
+/**
+ * Conversion options as used by {@link Type#toObject} and {@link Message.toObject}.
+ * @interface IConversionOptions
+ * @property {Function} [longs] Long conversion type.
+ * Valid values are `String` and `Number` (the global types).
+ * Defaults to copy the present value, which is a possibly unsafe number without and a {@link Long} with a long library.
+ * @property {Function} [enums] Enum value conversion type.
+ * Only valid value is `String` (the global type).
+ * Defaults to copy the present value, which is the numeric id.
+ * @property {Function} [bytes] Bytes value conversion type.
+ * Valid values are `Array` and (a base64 encoded) `String` (the global types).
+ * Defaults to copy the present value, which usually is a Buffer under node and an Uint8Array in the browser.
+ * @property {boolean} [defaults=false] Also sets default values on the resulting object
+ * @property {boolean} [arrays=false] Sets empty arrays for missing repeated fields even if `defaults=false`
+ * @property {boolean} [objects=false] Sets empty objects for missing map fields even if `defaults=false`
+ * @property {boolean} [oneofs=false] Includes virtual oneof properties set to the present field's name, if any
+ * @property {boolean} [json=false] Performs additional JSON compatibility conversions, i.e. NaN and Infinity to strings
+ */
+
+/**
+ * Creates a plain object from a message of this type. Also converts values to other types if specified.
+ * @param {Message<{}>} message Message instance
+ * @param {IConversionOptions} [options] Conversion options
+ * @returns {Object.} Plain object
+ */
+Type.prototype.toObject = function toObject(message, options) {
+ return this.setup().toObject(message, options);
+};
+
+/**
+ * Decorator function as returned by {@link Type.d} (TypeScript).
+ * @typedef TypeDecorator
+ * @type {function}
+ * @param {Constructor} target Target constructor
+ * @returns {undefined}
+ * @template T extends Message
+ */
+
+/**
+ * Type decorator (TypeScript).
+ * @param {string} [typeName] Type name, defaults to the constructor's name
+ * @returns {TypeDecorator} Decorator function
+ * @template T extends Message
+ */
+Type.d = function decorateType(typeName) {
+ return function typeDecorator(target) {
+ util.decorateType(target, typeName);
+ };
+};
diff --git a/OpenHarmony/library/src/main/ets/src/types.js b/OpenHarmony/library/src/main/ets/src/types.js
new file mode 100644
index 000000000..5fda19a69
--- /dev/null
+++ b/OpenHarmony/library/src/main/ets/src/types.js
@@ -0,0 +1,196 @@
+"use strict";
+
+/**
+ * Common type constants.
+ * @namespace
+ */
+var types = exports;
+
+var util = require("./util");
+
+var s = [
+ "double", // 0
+ "float", // 1
+ "int32", // 2
+ "uint32", // 3
+ "sint32", // 4
+ "fixed32", // 5
+ "sfixed32", // 6
+ "int64", // 7
+ "uint64", // 8
+ "sint64", // 9
+ "fixed64", // 10
+ "sfixed64", // 11
+ "bool", // 12
+ "string", // 13
+ "bytes" // 14
+];
+
+function bake(values, offset) {
+ var i = 0, o = {};
+ offset |= 0;
+ while (i < values.length) o[s[i + offset]] = values[i++];
+ return o;
+}
+
+/**
+ * Basic type wire types.
+ * @type {Object.}
+ * @const
+ * @property {number} double=1 Fixed64 wire type
+ * @property {number} float=5 Fixed32 wire type
+ * @property {number} int32=0 Varint wire type
+ * @property {number} uint32=0 Varint wire type
+ * @property {number} sint32=0 Varint wire type
+ * @property {number} fixed32=5 Fixed32 wire type
+ * @property {number} sfixed32=5 Fixed32 wire type
+ * @property {number} int64=0 Varint wire type
+ * @property {number} uint64=0 Varint wire type
+ * @property {number} sint64=0 Varint wire type
+ * @property {number} fixed64=1 Fixed64 wire type
+ * @property {number} sfixed64=1 Fixed64 wire type
+ * @property {number} bool=0 Varint wire type
+ * @property {number} string=2 Ldelim wire type
+ * @property {number} bytes=2 Ldelim wire type
+ */
+types.basic = bake([
+ /* double */ 1,
+ /* float */ 5,
+ /* int32 */ 0,
+ /* uint32 */ 0,
+ /* sint32 */ 0,
+ /* fixed32 */ 5,
+ /* sfixed32 */ 5,
+ /* int64 */ 0,
+ /* uint64 */ 0,
+ /* sint64 */ 0,
+ /* fixed64 */ 1,
+ /* sfixed64 */ 1,
+ /* bool */ 0,
+ /* string */ 2,
+ /* bytes */ 2
+]);
+
+/**
+ * Basic type defaults.
+ * @type {Object.}
+ * @const
+ * @property {number} double=0 Double default
+ * @property {number} float=0 Float default
+ * @property {number} int32=0 Int32 default
+ * @property {number} uint32=0 Uint32 default
+ * @property {number} sint32=0 Sint32 default
+ * @property {number} fixed32=0 Fixed32 default
+ * @property {number} sfixed32=0 Sfixed32 default
+ * @property {number} int64=0 Int64 default
+ * @property {number} uint64=0 Uint64 default
+ * @property {number} sint64=0 Sint32 default
+ * @property {number} fixed64=0 Fixed64 default
+ * @property {number} sfixed64=0 Sfixed64 default
+ * @property {boolean} bool=false Bool default
+ * @property {string} string="" String default
+ * @property {Array.} bytes=Array(0) Bytes default
+ * @property {null} message=null Message default
+ */
+types.defaults = bake([
+ /* double */ 0,
+ /* float */ 0,
+ /* int32 */ 0,
+ /* uint32 */ 0,
+ /* sint32 */ 0,
+ /* fixed32 */ 0,
+ /* sfixed32 */ 0,
+ /* int64 */ 0,
+ /* uint64 */ 0,
+ /* sint64 */ 0,
+ /* fixed64 */ 0,
+ /* sfixed64 */ 0,
+ /* bool */ false,
+ /* string */ "",
+ /* bytes */ util.emptyArray,
+ /* message */ null
+]);
+
+/**
+ * Basic long type wire types.
+ * @type {Object.}
+ * @const
+ * @property {number} int64=0 Varint wire type
+ * @property {number} uint64=0 Varint wire type
+ * @property {number} sint64=0 Varint wire type
+ * @property {number} fixed64=1 Fixed64 wire type
+ * @property {number} sfixed64=1 Fixed64 wire type
+ */
+types.long = bake([
+ /* int64 */ 0,
+ /* uint64 */ 0,
+ /* sint64 */ 0,
+ /* fixed64 */ 1,
+ /* sfixed64 */ 1
+], 7);
+
+/**
+ * Allowed types for map keys with their associated wire type.
+ * @type {Object.}
+ * @const
+ * @property {number} int32=0 Varint wire type
+ * @property {number} uint32=0 Varint wire type
+ * @property {number} sint32=0 Varint wire type
+ * @property {number} fixed32=5 Fixed32 wire type
+ * @property {number} sfixed32=5 Fixed32 wire type
+ * @property {number} int64=0 Varint wire type
+ * @property {number} uint64=0 Varint wire type
+ * @property {number} sint64=0 Varint wire type
+ * @property {number} fixed64=1 Fixed64 wire type
+ * @property {number} sfixed64=1 Fixed64 wire type
+ * @property {number} bool=0 Varint wire type
+ * @property {number} string=2 Ldelim wire type
+ */
+types.mapKey = bake([
+ /* int32 */ 0,
+ /* uint32 */ 0,
+ /* sint32 */ 0,
+ /* fixed32 */ 5,
+ /* sfixed32 */ 5,
+ /* int64 */ 0,
+ /* uint64 */ 0,
+ /* sint64 */ 0,
+ /* fixed64 */ 1,
+ /* sfixed64 */ 1,
+ /* bool */ 0,
+ /* string */ 2
+], 2);
+
+/**
+ * Allowed types for packed repeated fields with their associated wire type.
+ * @type {Object.}
+ * @const
+ * @property {number} double=1 Fixed64 wire type
+ * @property {number} float=5 Fixed32 wire type
+ * @property {number} int32=0 Varint wire type
+ * @property {number} uint32=0 Varint wire type
+ * @property {number} sint32=0 Varint wire type
+ * @property {number} fixed32=5 Fixed32 wire type
+ * @property {number} sfixed32=5 Fixed32 wire type
+ * @property {number} int64=0 Varint wire type
+ * @property {number} uint64=0 Varint wire type
+ * @property {number} sint64=0 Varint wire type
+ * @property {number} fixed64=1 Fixed64 wire type
+ * @property {number} sfixed64=1 Fixed64 wire type
+ * @property {number} bool=0 Varint wire type
+ */
+types.packed = bake([
+ /* double */ 1,
+ /* float */ 5,
+ /* int32 */ 0,
+ /* uint32 */ 0,
+ /* sint32 */ 0,
+ /* fixed32 */ 5,
+ /* sfixed32 */ 5,
+ /* int64 */ 0,
+ /* uint64 */ 0,
+ /* sint64 */ 0,
+ /* fixed64 */ 1,
+ /* sfixed64 */ 1,
+ /* bool */ 0
+]);
diff --git a/OpenHarmony/library/src/main/ets/src/typescript.jsdoc b/OpenHarmony/library/src/main/ets/src/typescript.jsdoc
new file mode 100644
index 000000000..9a6710169
--- /dev/null
+++ b/OpenHarmony/library/src/main/ets/src/typescript.jsdoc
@@ -0,0 +1,15 @@
+/**
+ * Constructor type.
+ * @interface Constructor
+ * @extends Function
+ * @template T
+ * @tstype new(...params: any[]): T; prototype: T;
+ */
+
+/**
+ * Properties type.
+ * @typedef Properties
+ * @template T
+ * @type {Object.}
+ * @tstype { [P in keyof T]?: T[P] }
+ */
diff --git a/OpenHarmony/library/src/main/ets/src/util.js b/OpenHarmony/library/src/main/ets/src/util.js
new file mode 100644
index 000000000..6c508990b
--- /dev/null
+++ b/OpenHarmony/library/src/main/ets/src/util.js
@@ -0,0 +1,212 @@
+"use strict";
+
+/**
+ * Various utility functions.
+ * @namespace
+ */
+var util = module.exports = require("./util/minimal");
+
+var roots = require("./roots");
+
+var Type, // cyclic
+ Enum;
+
+util.codegen = require("@protobufjs/codegen");
+util.fetch = require("@protobufjs/fetch");
+util.path = require("@protobufjs/path");
+
+/**
+ * Node's fs module if available.
+ * @type {Object.}
+ */
+util.fs = util.inquire("fs");
+
+/**
+ * Converts an object's values to an array.
+ * @param {Object.} object Object to convert
+ * @returns {Array.<*>} Converted array
+ */
+util.toArray = function toArray(object) {
+ if (object) {
+ var keys = Object.keys(object),
+ array = new Array(keys.length),
+ index = 0;
+ while (index < keys.length)
+ array[index] = object[keys[index++]];
+ return array;
+ }
+ return [];
+};
+
+/**
+ * Converts an array of keys immediately followed by their respective value to an object, omitting undefined values.
+ * @param {Array.<*>} array Array to convert
+ * @returns {Object.} Converted object
+ */
+util.toObject = function toObject(array) {
+ var object = {},
+ index = 0;
+ while (index < array.length) {
+ var key = array[index++],
+ val = array[index++];
+ if (val !== undefined)
+ object[key] = val;
+ }
+ return object;
+};
+
+var safePropBackslashRe = /\\/g,
+ safePropQuoteRe = /"/g;
+
+/**
+ * Tests whether the specified name is a reserved word in JS.
+ * @param {string} name Name to test
+ * @returns {boolean} `true` if reserved, otherwise `false`
+ */
+util.isReserved = function isReserved(name) {
+ return /^(?:do|if|in|for|let|new|try|var|case|else|enum|eval|false|null|this|true|void|with|break|catch|class|const|super|throw|while|yield|delete|export|import|public|return|static|switch|typeof|default|extends|finally|package|private|continue|debugger|function|arguments|interface|protected|implements|instanceof)$/.test(name);
+};
+
+/**
+ * Returns a safe property accessor for the specified property name.
+ * @param {string} prop Property name
+ * @returns {string} Safe accessor
+ */
+util.safeProp = function safeProp(prop) {
+ if (!/^[$\w_]+$/.test(prop) || util.isReserved(prop))
+ return "[\"" + prop.replace(safePropBackslashRe, "\\\\").replace(safePropQuoteRe, "\\\"") + "\"]";
+ return "." + prop;
+};
+
+/**
+ * Converts the first character of a string to upper case.
+ * @param {string} str String to convert
+ * @returns {string} Converted string
+ */
+util.ucFirst = function ucFirst(str) {
+ return str.charAt(0).toUpperCase() + str.substring(1);
+};
+
+var camelCaseRe = /_([a-z])/g;
+
+/**
+ * Converts a string to camel case.
+ * @param {string} str String to convert
+ * @returns {string} Converted string
+ */
+util.camelCase = function camelCase(str) {
+ return str.substring(0, 1)
+ + str.substring(1)
+ .replace(camelCaseRe, function($0, $1) { return $1.toUpperCase(); });
+};
+
+/**
+ * Compares reflected fields by id.
+ * @param {Field} a First field
+ * @param {Field} b Second field
+ * @returns {number} Comparison value
+ */
+util.compareFieldsById = function compareFieldsById(a, b) {
+ return a.id - b.id;
+};
+
+/**
+ * Decorator helper for types (TypeScript).
+ * @param {Constructor} ctor Constructor function
+ * @param {string} [typeName] Type name, defaults to the constructor's name
+ * @returns {Type} Reflected type
+ * @template T extends Message
+ * @property {Root} root Decorators root
+ */
+util.decorateType = function decorateType(ctor, typeName) {
+
+ /* istanbul ignore if */
+ if (ctor.$type) {
+ if (typeName && ctor.$type.name !== typeName) {
+ util.decorateRoot.remove(ctor.$type);
+ ctor.$type.name = typeName;
+ util.decorateRoot.add(ctor.$type);
+ }
+ return ctor.$type;
+ }
+
+ /* istanbul ignore next */
+ if (!Type)
+ Type = require("./type");
+
+ var type = new Type(typeName || ctor.name);
+ util.decorateRoot.add(type);
+ type.ctor = ctor; // sets up .encode, .decode etc.
+ Object.defineProperty(ctor, "$type", { value: type, enumerable: false });
+ Object.defineProperty(ctor.prototype, "$type", { value: type, enumerable: false });
+ return type;
+};
+
+var decorateEnumIndex = 0;
+
+/**
+ * Decorator helper for enums (TypeScript).
+ * @param {Object} object Enum object
+ * @returns {Enum} Reflected enum
+ */
+util.decorateEnum = function decorateEnum(object) {
+
+ /* istanbul ignore if */
+ if (object.$type)
+ return object.$type;
+
+ /* istanbul ignore next */
+ if (!Enum)
+ Enum = require("./enum");
+
+ var enm = new Enum("Enum" + decorateEnumIndex++, object);
+ util.decorateRoot.add(enm);
+ Object.defineProperty(object, "$type", { value: enm, enumerable: false });
+ return enm;
+};
+
+
+/**
+ * Sets the value of a property by property path. If a value already exists, it is turned to an array
+ * @param {Object.} dst Destination object
+ * @param {string} path dot '.' delimited path of the property to set
+ * @param {Object} value the value to set
+ * @returns {Object.} Destination object
+ */
+util.setProperty = function setProperty(dst, path, value) {
+ function setProp(dst, path, value) {
+ var part = path.shift();
+ if (part === "__proto__" || part === "prototype") {
+ return dst;
+ }
+ if (path.length > 0) {
+ dst[part] = setProp(dst[part] || {}, path, value);
+ } else {
+ var prevValue = dst[part];
+ if (prevValue)
+ value = [].concat(prevValue).concat(value);
+ dst[part] = value;
+ }
+ return dst;
+ }
+
+ if (typeof dst !== "object")
+ throw TypeError("dst must be an object");
+ if (!path)
+ throw TypeError("path must be specified");
+
+ path = path.split(".");
+ return setProp(dst, path, value);
+};
+
+/**
+ * Decorator root (TypeScript).
+ * @name util.decorateRoot
+ * @type {Root}
+ * @readonly
+ */
+Object.defineProperty(util, "decorateRoot", {
+ get: function() {
+ return roots["decorated"] || (roots["decorated"] = new (require("./root"))());
+ }
+});
diff --git a/OpenHarmony/library/src/main/ets/src/util/longbits.js b/OpenHarmony/library/src/main/ets/src/util/longbits.js
new file mode 100644
index 000000000..2420d2070
--- /dev/null
+++ b/OpenHarmony/library/src/main/ets/src/util/longbits.js
@@ -0,0 +1,219 @@
+"use strict";
+module.exports = LongBits;
+
+var util = require("../util/minimal");
+
+/**
+ * Constructs new long bits.
+ * @classdesc Helper class for working with the low and high bits of a 64 bit value.
+ * @memberof util
+ * @constructor
+ * @param {number} lo Low 32 bits, unsigned
+ * @param {number} hi High 32 bits, unsigned
+ */
+function LongBits(lo, hi) {
+
+ // note that the casts below are theoretically unnecessary as of today, but older statically
+ // generated converter code might still call the ctor with signed 32bits. kept for compat.
+
+ /**
+ * Low bits.
+ * @type {number}
+ */
+ this.lo = lo >>> 0;
+
+ /**
+ * High bits.
+ * @type {number}
+ */
+ this.hi = hi >>> 0;
+}
+
+/**
+ * Zero bits.
+ * @memberof util.LongBits
+ * @type {util.LongBits}
+ */
+var zero = LongBits.zero = new LongBits(0, 0);
+
+zero.toNumber = function() { return 0; };
+zero.zzEncode = zero.zzDecode = function() { return this; };
+zero.length = function() { return 1; };
+
+/**
+ * Zero hash.
+ * @memberof util.LongBits
+ * @type {string}
+ */
+var zeroHash = LongBits.zeroHash = "\0\0\0\0\0\0\0\0";
+
+/**
+ * Constructs new long bits from the specified number.
+ * @param {number} value Value
+ * @returns {util.LongBits} Instance
+ */
+LongBits.fromNumber = function fromNumber(value) {
+ if (value === 0)
+ return zero;
+ var sign = value < 0;
+ if (sign)
+ value = -value;
+ var lo = value >>> 0,
+ hi = (value - lo) / 4294967296 >>> 0;
+ if (sign) {
+ hi = ~hi >>> 0;
+ lo = ~lo >>> 0;
+ if (++lo > 4294967295) {
+ lo = 0;
+ if (++hi > 4294967295)
+ hi = 0;
+ }
+ }
+ return new LongBits(lo, hi);
+};
+
+LongBits.fromBigInt = function fromBigInt(value) {
+ if (value === 0n) {
+ return zero;
+ }
+ const uint64 = BigInt.asUintN(64, value);
+ const lo = Number(uint64 & 0xFFFFFFFFn);
+ const hi = Number((uint64 >> 32n) & 0xFFFFFFFFn);
+ return new LongBits(lo >>> 0, hi >>> 0);
+};
+
+/**
+ * Constructs new long bits from a number, long or string.
+ * @param {Long|number|string} value Value
+ * @returns {util.LongBits} Instance
+ */
+LongBits.from = function from(value) {
+ if (typeof value === "number") {
+ return LongBits.fromNumber(value);
+ }
+ if (typeof value === "bigint") {
+ return LongBits.fromBigInt(value);
+ }
+ if (util.isString(value)) {
+ /* istanbul ignore else */
+ if (util.Long)
+ value = util.Long.fromString(value);
+ else
+ return LongBits.fromNumber(parseInt(value, 10));
+ }
+ return value.low || value.high ? new LongBits(value.low >>> 0, value.high >>> 0) : zero;
+};
+
+/**
+ * Converts this long bits to a possibly unsafe JavaScript number.
+ * @param {boolean} [unsigned=false] Whether unsigned or not
+ * @returns {number} Possibly unsafe number
+ */
+LongBits.prototype.toNumber = function toNumber(unsigned) {
+ if (!unsigned && this.hi >>> 31) {
+ var lo = ~this.lo + 1 >>> 0,
+ hi = ~this.hi >>> 0;
+ if (!lo)
+ hi = hi + 1 >>> 0;
+ return -(lo + hi * 4294967296);
+ }
+ return this.lo + this.hi * 4294967296;
+};
+
+LongBits.prototype.toBigInt = function toBigInt(unsigned) {
+ const uint64 = (BigInt(this.hi) << 32n) | BigInt(this.lo);
+ return unsigned ? uint64 : BigInt.asIntN(64, uint64);
+};
+
+/**
+ * Converts this long bits to a long.
+ * @param {boolean} [unsigned=false] Whether unsigned or not
+ * @returns {Long} Long
+ */
+LongBits.prototype.toLong = function toLong(unsigned) {
+ return util.Long
+ ? new util.Long(this.lo | 0, this.hi | 0, Boolean(unsigned))
+ /* istanbul ignore next */
+ : { low: this.lo | 0, high: this.hi | 0, unsigned: Boolean(unsigned) };
+};
+
+var charCodeAt = String.prototype.charCodeAt;
+
+/**
+ * Constructs new long bits from the specified 8 characters long hash.
+ * @param {string} hash Hash
+ * @returns {util.LongBits} Bits
+ */
+LongBits.fromHash = function fromHash(hash) {
+ if (hash === zeroHash)
+ return zero;
+ return new LongBits(
+ ( charCodeAt.call(hash, 0)
+ | charCodeAt.call(hash, 1) << 8
+ | charCodeAt.call(hash, 2) << 16
+ | charCodeAt.call(hash, 3) << 24) >>> 0
+ ,
+ ( charCodeAt.call(hash, 4)
+ | charCodeAt.call(hash, 5) << 8
+ | charCodeAt.call(hash, 6) << 16
+ | charCodeAt.call(hash, 7) << 24) >>> 0
+ );
+};
+
+/**
+ * Converts this long bits to a 8 characters long hash.
+ * @returns {string} Hash
+ */
+LongBits.prototype.toHash = function toHash() {
+ return String.fromCharCode(
+ this.lo & 255,
+ this.lo >>> 8 & 255,
+ this.lo >>> 16 & 255,
+ this.lo >>> 24 ,
+ this.hi & 255,
+ this.hi >>> 8 & 255,
+ this.hi >>> 16 & 255,
+ this.hi >>> 24
+ );
+};
+
+/**
+ * Zig-zag encodes this long bits.
+ * @returns {util.LongBits} `this`
+ */
+LongBits.prototype.zzEncode = function zzEncode() {
+ var mask = this.hi >> 31;
+ this.hi = ((this.hi << 1 | this.lo >>> 31) ^ mask) >>> 0;
+ this.lo = ( this.lo << 1 ^ mask) >>> 0;
+ return this;
+};
+
+/**
+ * Zig-zag decodes this long bits.
+ * @returns {util.LongBits} `this`
+ */
+LongBits.prototype.zzDecode = function zzDecode() {
+ var mask = -(this.lo & 1);
+ this.lo = ((this.lo >>> 1 | this.hi << 31) ^ mask) >>> 0;
+ this.hi = ( this.hi >>> 1 ^ mask) >>> 0;
+ return this;
+};
+
+/**
+ * Calculates the length of this longbits when encoded as a varint.
+ * @returns {number} Length
+ */
+LongBits.prototype.length = function length() {
+ var part0 = this.lo,
+ part1 = (this.lo >>> 28 | this.hi << 4) >>> 0,
+ part2 = this.hi >>> 24;
+ return part2 === 0
+ ? part1 === 0
+ ? part0 < 16384
+ ? part0 < 128 ? 1 : 2
+ : part0 < 2097152 ? 3 : 4
+ : part1 < 16384
+ ? part1 < 128 ? 5 : 6
+ : part1 < 2097152 ? 7 : 8
+ : part2 < 128 ? 9 : 10;
+};
diff --git a/OpenHarmony/library/src/main/ets/src/util/minimal.js b/OpenHarmony/library/src/main/ets/src/util/minimal.js
new file mode 100644
index 000000000..62d683326
--- /dev/null
+++ b/OpenHarmony/library/src/main/ets/src/util/minimal.js
@@ -0,0 +1,438 @@
+"use strict";
+var util = exports;
+
+// used to return a Promise where callback is omitted
+util.asPromise = require("@protobufjs/aspromise");
+
+// converts to / from base64 encoded strings
+util.base64 = require("@protobufjs/base64");
+
+// base class of rpc.Service
+util.EventEmitter = require("@protobufjs/eventemitter");
+
+// float handling accross browsers
+util.float = require("@protobufjs/float");
+
+// requires modules optionally and hides the call from bundlers
+util.inquire = require("@protobufjs/inquire");
+
+// converts to / from utf8 encoded strings
+util.utf8 = require("@protobufjs/utf8");
+
+// provides a node-like buffer pool in the browser
+util.pool = require("@protobufjs/pool");
+
+// utility to work with the low and high bits of a 64 bit value
+util.LongBits = require("./longbits");
+
+/**
+ * Whether running within node or not.
+ * @memberof util
+ * @type {boolean}
+ */
+util.isNode = Boolean(typeof global !== "undefined"
+ && global
+ && global.process
+ && global.process.versions
+ && global.process.versions.node);
+
+/**
+ * Global object reference.
+ * @memberof util
+ * @type {Object}
+ */
+util.global = util.isNode && global
+ || typeof window !== "undefined" && window
+ || typeof self !== "undefined" && self
+ || this; // eslint-disable-line no-invalid-this
+
+/**
+ * An immuable empty array.
+ * @memberof util
+ * @type {Array.<*>}
+ * @const
+ */
+util.emptyArray = Object.freeze ? Object.freeze([]) : /* istanbul ignore next */ []; // used on prototypes
+
+/**
+ * An immutable empty object.
+ * @type {Object}
+ * @const
+ */
+util.emptyObject = Object.freeze ? Object.freeze({}) : /* istanbul ignore next */ {}; // used on prototypes
+
+/**
+ * Tests if the specified value is an integer.
+ * @function
+ * @param {*} value Value to test
+ * @returns {boolean} `true` if the value is an integer
+ */
+util.isInteger = Number.isInteger || /* istanbul ignore next */ function isInteger(value) {
+ return typeof value === "number" && isFinite(value) && Math.floor(value) === value;
+};
+
+/**
+ * Tests if the specified value is a string.
+ * @param {*} value Value to test
+ * @returns {boolean} `true` if the value is a string
+ */
+util.isString = function isString(value) {
+ return typeof value === "string" || value instanceof String;
+};
+
+/**
+ * Tests if the specified value is a non-null object.
+ * @param {*} value Value to test
+ * @returns {boolean} `true` if the value is a non-null object
+ */
+util.isObject = function isObject(value) {
+ return value && typeof value === "object";
+};
+
+/**
+ * Checks if a property on a message is considered to be present.
+ * This is an alias of {@link util.isSet}.
+ * @function
+ * @param {Object} obj Plain object or message instance
+ * @param {string} prop Property name
+ * @returns {boolean} `true` if considered to be present, otherwise `false`
+ */
+util.isset =
+
+/**
+ * Checks if a property on a message is considered to be present.
+ * @param {Object} obj Plain object or message instance
+ * @param {string} prop Property name
+ * @returns {boolean} `true` if considered to be present, otherwise `false`
+ */
+util.isSet = function isSet(obj, prop) {
+ var value = obj[prop];
+ if (value != null && obj.hasOwnProperty(prop)) // eslint-disable-line eqeqeq, no-prototype-builtins
+ return typeof value !== "object" || (Array.isArray(value) ? value.length : Object.keys(value).length) > 0;
+ return false;
+};
+
+/**
+ * Any compatible Buffer instance.
+ * This is a minimal stand-alone definition of a Buffer instance. The actual type is that exported by node's typings.
+ * @interface Buffer
+ * @extends Uint8Array
+ */
+
+/**
+ * Node's Buffer class if available.
+ * @type {Constructor}
+ */
+util.Buffer = (function() {
+ try {
+ var Buffer = util.inquire("buffer").Buffer;
+ // refuse to use non-node buffers if not explicitly assigned (perf reasons):
+ return Buffer.prototype.utf8Write ? Buffer : /* istanbul ignore next */ null;
+ } catch (e) {
+ /* istanbul ignore next */
+ return null;
+ }
+})();
+
+// Internal alias of or polyfull for Buffer.from.
+util._Buffer_from = null;
+
+// Internal alias of or polyfill for Buffer.allocUnsafe.
+util._Buffer_allocUnsafe = null;
+
+/**
+ * Creates a new buffer of whatever type supported by the environment.
+ * @param {number|number[]} [sizeOrArray=0] Buffer size or number array
+ * @returns {Uint8Array|Buffer} Buffer
+ */
+util.newBuffer = function newBuffer(sizeOrArray) {
+ /* istanbul ignore next */
+ return typeof sizeOrArray === "number"
+ ? util.Buffer
+ ? util._Buffer_allocUnsafe(sizeOrArray)
+ : new util.Array(sizeOrArray)
+ : util.Buffer
+ ? util._Buffer_from(sizeOrArray)
+ : typeof Uint8Array === "undefined"
+ ? sizeOrArray
+ : new Uint8Array(sizeOrArray);
+};
+
+/**
+ * Array implementation used in the browser. `Uint8Array` if supported, otherwise `Array`.
+ * @type {Constructor}
+ */
+util.Array = typeof Uint8Array !== "undefined" ? Uint8Array /* istanbul ignore next */ : Array;
+
+/**
+ * Any compatible Long instance.
+ * This is a minimal stand-alone definition of a Long instance. The actual type is that exported by long.js.
+ * @interface Long
+ * @property {number} low Low bits
+ * @property {number} high High bits
+ * @property {boolean} unsigned Whether unsigned or not
+ */
+
+/**
+ * Long.js's Long class if available.
+ * @type {Constructor}
+ */
+util.Long = /* istanbul ignore next */ util.global.dcodeIO && /* istanbul ignore next */ util.global.dcodeIO.Long
+ || /* istanbul ignore next */ util.global.Long
+ || util.inquire("long");
+
+/**
+ * Regular expression used to verify 2 bit (`bool`) map keys.
+ * @type {RegExp}
+ * @const
+ */
+util.key2Re = /^true|false|0|1$/;
+
+/**
+ * Regular expression used to verify 32 bit (`int32` etc.) map keys.
+ * @type {RegExp}
+ * @const
+ */
+util.key32Re = /^-?(?:0|[1-9][0-9]*)$/;
+
+/**
+ * Regular expression used to verify 64 bit (`int64` etc.) map keys.
+ * @type {RegExp}
+ * @const
+ */
+util.key64Re = /^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/;
+
+/**
+ * Converts a number or long to an 8 characters long hash string.
+ * @param {Long|number} value Value to convert
+ * @returns {string} Hash
+ */
+util.longToHash = function longToHash(value) {
+ return value
+ ? util.LongBits.from(value).toHash()
+ : util.LongBits.zeroHash;
+};
+
+/**
+ * Converts an 8 characters long hash string to a long or number.
+ * @param {string} hash Hash
+ * @param {boolean} [unsigned=false] Whether unsigned or not
+ * @returns {Long|number} Original value
+ */
+util.longFromHash = function longFromHash(hash, unsigned) {
+ var bits = util.LongBits.fromHash(hash);
+ if (util.Long)
+ return util.Long.fromBits(bits.lo, bits.hi, unsigned);
+ return bits.toNumber(Boolean(unsigned));
+};
+
+/**
+ * Merges the properties of the source object into the destination object.
+ * @memberof util
+ * @param {Object.} dst Destination object
+ * @param {Object.} src Source object
+ * @param {boolean} [ifNotSet=false] Merges only if the key is not already set
+ * @returns {Object.