From b0334d1f904578203a597be8ceeb5b632fc5af00 Mon Sep 17 00:00:00 2001 From: Akari <60416767+MotooriKashin@users.noreply.github.com> Date: Sat, 21 Sep 2024 17:15:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=20protobuf=20=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0=20(#18)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 优化toastr过渡 * 优化 protobuf 实现 - DmWebViewReply - DmSegMobileReply * 重新实现实时弹幕 --- .gitignore | 3 +- .vscode/tasks.json | 7 + package.json | 6 +- src/danmaku/index.ts | 10 +- .../render/mode8/Player/CommentData.ts | 6 +- src/danmaku/render/mode8/index.ts | 32 +- src/io/com/bapis/README.md | 4 + .../broadcast/message/main/DanmakuEvent.proto | 76 + .../broadcast/message/main/DanmakuEvent.ts | 631 +++ .../bapis/bilibili/broadcast/v1/Auth.proto | 16 + .../com/bapis/bilibili/broadcast/v1/Auth.ts | 184 + .../broadcast/v1/BroadcastFrame.proto | 47 + .../bilibili/broadcast/v1/BroadcastFrame.ts | 304 ++ .../bilibili/broadcast/v1/Heartbeat.proto | 12 + .../bapis/bilibili/broadcast/v1/Heartbeat.ts | 128 + .../bilibili/broadcast/v1/MessageAck.proto | 13 + .../bapis/bilibili/broadcast/v1/MessageAck.ts | 137 + .../bapis/bilibili/broadcast/v1/PATH.ts} | 42 +- .../bapis/bilibili/broadcast/v1/Room.proto | 42 + .../com/bapis/bilibili/broadcast/v1/Room.ts | 622 +++ .../bilibili/broadcast/v1/TargetPath.proto | 9 + .../bapis/bilibili/broadcast/v1/TargetPath.ts | 98 + .../service/dm/v1/DmSegMobileReply.proto | 104 + .../service/dm/v1/DmSegMobileReply.ts | 795 ++++ .../service/dm/v1/DmWebViewReply.proto | 452 ++ .../community/service/dm/v1/DmWebViewReply.ts | 4156 +++++++++++++++++ src/io/com/bapis/bilibili/rpc/status.proto | 15 + src/io/com/bapis/bilibili/rpc/status.ts | 135 + src/io/com/bapis/google/protobuf/any.proto | 154 + src/io/com/bapis/google/protobuf/any.ts | 248 + src/io/com/bilibili/api/x/v2/dm/web/seg.so.ts | 4 +- src/io/com/bilibili/api/x/v2/dm/web/view.ts | 4 +- src/io/protobuf/AnyType.ts | 23 - src/io/protobuf/DanmakuEvent.ts | 58 - src/io/protobuf/DmSegMobileReply.ts | 76 - src/io/protobuf/DmWebViewReply.ts | 97 - src/io/protobuf/HeartbeatReq.ts | 20 - src/io/protobuf/MessageAckReq.ts | 25 - src/io/protobuf/RoomJoinEvent.ts | 19 - src/io/protobuf/RoomLeaveEvent.ts | 19 - src/io/protobuf/RoomMessageEvent.ts | 19 - src/io/protobuf/RoomOnlineEvent.ts | 19 - src/io/protobuf/RoomReq.ts | 41 - src/io/protobuf/RoomResp.ts | 27 - src/io/protobuf/TargetPath.ts | 22 - src/io/protobuf/index.ts | 110 - .../json/bilibili.broadcast.message.main.json | 77 - .../protobuf/json/bilibili.broadcast.v1.json | 270 -- .../bilibili.community.service.dm.v1.json | 327 -- src/io/protobuf/root.ts | 29 - src/main/player/danmaku/index.ts | 291 +- src/main/player/index.ts | 17 +- src/player/auxiliary/danmaku/danmaku.ts | 10 +- src/toastr/index.css | 17 +- src/toastr/index.ts | 2 +- 55 files changed, 8582 insertions(+), 1529 deletions(-) create mode 100644 src/io/com/bapis/README.md create mode 100644 src/io/com/bapis/bilibili/broadcast/message/main/DanmakuEvent.proto create mode 100644 src/io/com/bapis/bilibili/broadcast/message/main/DanmakuEvent.ts create mode 100644 src/io/com/bapis/bilibili/broadcast/v1/Auth.proto create mode 100644 src/io/com/bapis/bilibili/broadcast/v1/Auth.ts create mode 100644 src/io/com/bapis/bilibili/broadcast/v1/BroadcastFrame.proto create mode 100644 src/io/com/bapis/bilibili/broadcast/v1/BroadcastFrame.ts create mode 100644 src/io/com/bapis/bilibili/broadcast/v1/Heartbeat.proto create mode 100644 src/io/com/bapis/bilibili/broadcast/v1/Heartbeat.ts create mode 100644 src/io/com/bapis/bilibili/broadcast/v1/MessageAck.proto create mode 100644 src/io/com/bapis/bilibili/broadcast/v1/MessageAck.ts rename src/io/{protobuf/BroadcastFrame.ts => com/bapis/bilibili/broadcast/v1/PATH.ts} (53%) create mode 100644 src/io/com/bapis/bilibili/broadcast/v1/Room.proto create mode 100644 src/io/com/bapis/bilibili/broadcast/v1/Room.ts create mode 100644 src/io/com/bapis/bilibili/broadcast/v1/TargetPath.proto create mode 100644 src/io/com/bapis/bilibili/broadcast/v1/TargetPath.ts create mode 100644 src/io/com/bapis/bilibili/community/service/dm/v1/DmSegMobileReply.proto create mode 100644 src/io/com/bapis/bilibili/community/service/dm/v1/DmSegMobileReply.ts create mode 100644 src/io/com/bapis/bilibili/community/service/dm/v1/DmWebViewReply.proto create mode 100644 src/io/com/bapis/bilibili/community/service/dm/v1/DmWebViewReply.ts create mode 100644 src/io/com/bapis/bilibili/rpc/status.proto create mode 100644 src/io/com/bapis/bilibili/rpc/status.ts create mode 100644 src/io/com/bapis/google/protobuf/any.proto create mode 100644 src/io/com/bapis/google/protobuf/any.ts delete mode 100644 src/io/protobuf/AnyType.ts delete mode 100644 src/io/protobuf/DanmakuEvent.ts delete mode 100644 src/io/protobuf/DmSegMobileReply.ts delete mode 100644 src/io/protobuf/DmWebViewReply.ts delete mode 100644 src/io/protobuf/HeartbeatReq.ts delete mode 100644 src/io/protobuf/MessageAckReq.ts delete mode 100644 src/io/protobuf/RoomJoinEvent.ts delete mode 100644 src/io/protobuf/RoomLeaveEvent.ts delete mode 100644 src/io/protobuf/RoomMessageEvent.ts delete mode 100644 src/io/protobuf/RoomOnlineEvent.ts delete mode 100644 src/io/protobuf/RoomReq.ts delete mode 100644 src/io/protobuf/RoomResp.ts delete mode 100644 src/io/protobuf/TargetPath.ts delete mode 100644 src/io/protobuf/index.ts delete mode 100644 src/io/protobuf/json/bilibili.broadcast.message.main.json delete mode 100644 src/io/protobuf/json/bilibili.broadcast.v1.json delete mode 100644 src/io/protobuf/json/bilibili.community.service.dm.v1.json delete mode 100644 src/io/protobuf/root.ts diff --git a/.gitignore b/.gitignore index 4aa0f46..02638e7 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ node_modules dist *.crx *.pem -*.map \ No newline at end of file +*.map +*.exe \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json index b1ba047..a0d4eb6 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -11,6 +11,13 @@ "problemMatcher": [], "label": "npm: build", "detail": "node --experimental-strip-types ./src/build/index.ts" + }, + { + "label": "proto2ts", + "type": "shell", + "command": "./protoc --ts_proto_opt=forceLong=bigint --ts_proto_opt=initializeFieldsAsUndefined=false --plugin=protoc-gen-ts_proto=\".\\\\node_modules\\\\.bin\\\\protoc-gen-ts_proto.cmd\" --ts_proto_out=. ${relativeFile}", + "problemMatcher": [], + "detail": "编译当前 proto 文件到 typescript 文件(依赖根目录下的 protoc 编译器)" } ] } \ No newline at end of file diff --git a/package.json b/package.json index d9597a4..46e3564 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,12 @@ { "dependencies": { - "flv.js": "*", - "protobufjs": "*" + "flv.js": "*" }, "devDependencies": { "@types/fs-extra": "*", "esbuild": "*", - "fs-extra": "*" + "fs-extra": "*", + "ts-proto": "*" }, "scripts": { "build": "node --no-warnings --experimental-strip-types ./src/build/index.ts", diff --git a/src/danmaku/index.ts b/src/danmaku/index.ts index dd9b6f0..a4181a6 100644 --- a/src/danmaku/index.ts +++ b/src/danmaku/index.ts @@ -470,7 +470,7 @@ export class Danmaku extends HTMLElement { const dm: IDanmaku = { pool: <0>Number(json[5]), color: Number(json[3]), - ctime: Number(json[4]), + ctime: BigInt(Number(json[4])), idStr: String(json[7]), mode: <1>Number(json[1]), fontsize: Number(json[2]), @@ -544,9 +544,9 @@ export interface IDanmaku { /** 弹幕颜色 */ color: number; /** 弹幕内容 */ - content: string; + content?: string; /** 发送时间戳 */ - ctime: number; + ctime: bigint; /** 字体大小 */ fontsize: number; /** 唯一id,已超过JavaScript整数上限,如非必要切莫转化为数字 */ @@ -566,9 +566,9 @@ export interface IDanmaku { * | :-: | :-: | :-: | * | 普通弹幕 | 字幕弹幕 | 特殊弹幕 | */ - pool: 0 | 1 | 2; + pool?: 0 | 1 | 2; /** 弹幕位于视频中的时间点(单位毫秒) */ - progress: number; + progress?: number; /** 弹幕权重,越高显示优先级越高 */ weight?: number; /** 待定 */ diff --git a/src/danmaku/render/mode8/Player/CommentData.ts b/src/danmaku/render/mode8/Player/CommentData.ts index f2f9412..355fcab 100644 --- a/src/danmaku/render/mode8/Player/CommentData.ts +++ b/src/danmaku/render/mode8/Player/CommentData.ts @@ -46,9 +46,9 @@ export class CommentData { constructor(dm: IDanmaku) { this.size = dm.fontsize; - this.text = dm.content; + dm.content && (this.text = dm.content); this.mode = dm.mode; - this.stime = dm.progress / 1000; - this.date = dm.ctime; + dm.progress && (this.stime = dm.progress / 1000); + this.date = Number(dm.ctime); } } \ No newline at end of file diff --git a/src/danmaku/render/mode8/index.ts b/src/danmaku/render/mode8/index.ts index cb7da74..bb860d3 100644 --- a/src/danmaku/render/mode8/index.ts +++ b/src/danmaku/render/mode8/index.ts @@ -26,21 +26,23 @@ export class Mode8 { } private async prase() { - const s = new Scanner(this.$dm.content - .replace(/(\/n|\\n|\n|\r\n)/g, '\n') - .replace(/(&)|(<)|(>)|(')|(")/g, (a: string) => { - // 处理误当成xml非法字符的转义字符 - return { - '&': '&', - '<': '<', - '>': '>', - ''': '\'', - '"': '"' - }[a] - })); - const p = new Parser(s); - this.#vm.rewind(); - this.#vm.setByteCode(p.parse(this.#vm)); + if (this.$dm.content) { + const s = new Scanner(this.$dm.content + .replace(/(\/n|\\n|\n|\r\n)/g, '\n') + .replace(/(&)|(<)|(>)|(')|(")/g, (a: string) => { + // 处理误当成xml非法字符的转义字符 + return { + '&': '&', + '<': '<', + '>': '>', + ''': '\'', + '"': '"' + }[a] + })); + const p = new Parser(s); + this.#vm.rewind(); + this.#vm.setByteCode(p.parse(this.#vm)); + } } async execute() { diff --git a/src/io/com/bapis/README.md b/src/io/com/bapis/README.md new file mode 100644 index 0000000..c8f7356 --- /dev/null +++ b/src/io/com/bapis/README.md @@ -0,0 +1,4 @@ +要编译proto文件到typescript,须要进行以下操作: + 1. 下载预构建的 [protoc](https://github.com/protocolbuffers/protobuf/releases) 的二进制文件放到本项目根目录 + 2. 在 VSCode 中打开并切换到对应的 proto 文件 + 3. 运行 VSCode 任务 `proto2ts` 即会在 proto 文件同级生成同名的目标(ts)文件 \ No newline at end of file diff --git a/src/io/com/bapis/bilibili/broadcast/message/main/DanmakuEvent.proto b/src/io/com/bapis/bilibili/broadcast/message/main/DanmakuEvent.proto new file mode 100644 index 0000000..e5ebf74 --- /dev/null +++ b/src/io/com/bapis/bilibili/broadcast/message/main/DanmakuEvent.proto @@ -0,0 +1,76 @@ +syntax = "proto3"; + +package bilibili.broadcast.message.main; + +/** 弹幕消息数据 */ +message DanmakuEvent { + /** 弹幕列表 */ + repeated DanmakuElem elems = 1; +} + +/** 弹幕实例 */ +message DanmakuElem { + /** + * 弹幕id + * @deprecated 精度丢失 + */ + int64 id = 1; + /** 弹幕位置:/ms */ + int32 progress = 2; + /** + * 弹幕模式 + * | 1 | 4 | 5 | 6 | 7 | 8 | 9 | + * | :-: | :-: | :-: | :-: | :-: | :-: | :-: | + * | 普通 | 底部 | 顶部 | 逆向 | 高级 | 代码 | BAS | + */ + int32 mode = 3; + /** 弹幕字体 */ + int32 fontsize = 4; + /** 弹幕颜色 */ + uint32 color = 5; + /** 弹幕发送者crc32哈希 */ + string mid_hash = 6; + /** 弹幕文本内容 */ + string content = 7; + /** 弹幕发送时间 时间戳 */ + int64 ctime = 8; + /** 弹幕动作 */ + optional string action = 9; + /** + * 弹幕池 + * | 0 | 1 | 2 | + * | :-: | :-: | :-: | + * | 普通弹幕 | 字幕弹幕 | 特殊弹幕 | + */ + optional int32 pool = 10; + /** 弹幕id字符串 */ + string id_str = 11; +} + +/** 指令弹幕 */ +message CommandDm { + /** 弹幕id */ + int64 id = 1; + /** oid */ + int64 oid = 2; + /** mid */ + int64 mid = 3; + + int32 type = 4; + /** 弹幕指令 */ + string command = 5; + /** 弹幕内容 */ + string content = 6; + /** 弹幕状态 */ + int32 state = 7; + /** 弹幕位置:/ms */ + int32 progress = 8; + /** 创建时间 */ + string ctime = 9; + /** 修改时间 */ + string mtime = 10; + /** 扩展json数据 */ + string extra = 11; + /** 弹幕id_str */ + string idStr = 12; +} \ No newline at end of file diff --git a/src/io/com/bapis/bilibili/broadcast/message/main/DanmakuEvent.ts b/src/io/com/bapis/bilibili/broadcast/message/main/DanmakuEvent.ts new file mode 100644 index 0000000..7c46796 --- /dev/null +++ b/src/io/com/bapis/bilibili/broadcast/message/main/DanmakuEvent.ts @@ -0,0 +1,631 @@ +// Code generated by protoc-gen-ts_proto. DO NOT EDIT. +// versions: +// protoc-gen-ts_proto v2.2.0 +// protoc v5.28.2 +// source: src/io/com/bapis/bilibili/broadcast/message/main/DanmakuEvent.proto + +/* eslint-disable */ +import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire"; + +export const protobufPackage = "bilibili.broadcast.message.main"; + +/** 弹幕消息数据 */ +export interface DanmakuEvent { + /** 弹幕列表 */ + elems: DanmakuElem[]; +} + +/** 弹幕实例 */ +export interface DanmakuElem { + /** + * 弹幕id + * @deprecated 精度丢失 + */ + id: bigint; + /** 弹幕位置:/ms */ + progress: number; + /** + * 弹幕模式 + * | 1 | 4 | 5 | 6 | 7 | 8 | 9 | + * | :-: | :-: | :-: | :-: | :-: | :-: | :-: | + * | 普通 | 底部 | 顶部 | 逆向 | 高级 | 代码 | BAS | + */ + mode: number; + /** 弹幕字体 */ + fontsize: number; + /** 弹幕颜色 */ + color: number; + /** 弹幕发送者crc32哈希 */ + midHash: string; + /** 弹幕文本内容 */ + content: string; + /** 弹幕发送时间 时间戳 */ + ctime: bigint; + /** 弹幕动作 */ + action?: + | string + | undefined; + /** + * 弹幕池 + * | 0 | 1 | 2 | + * | :-: | :-: | :-: | + * | 普通弹幕 | 字幕弹幕 | 特殊弹幕 | + */ + pool?: + | number + | undefined; + /** 弹幕id字符串 */ + idStr: string; +} + +/** 指令弹幕 */ +export interface CommandDm { + /** 弹幕id */ + id: bigint; + /** oid */ + oid: bigint; + /** mid */ + mid: bigint; + type: number; + /** 弹幕指令 */ + command: string; + /** 弹幕内容 */ + content: string; + /** 弹幕状态 */ + state: number; + /** 弹幕位置:/ms */ + progress: number; + /** 创建时间 */ + ctime: string; + /** 修改时间 */ + mtime: string; + /** 扩展json数据 */ + extra: string; + /** 弹幕id_str */ + idStr: string; +} + +function createBaseDanmakuEvent(): DanmakuEvent { + return { elems: [] }; +} + +export const DanmakuEvent: MessageFns = { + encode(message: DanmakuEvent, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + for (const v of message.elems) { + DanmakuElem.encode(v!, writer.uint32(10).fork()).join(); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): DanmakuEvent { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDanmakuEvent(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.elems.push(DanmakuElem.decode(reader, reader.uint32())); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): DanmakuEvent { + return { + elems: globalThis.Array.isArray(object?.elems) ? object.elems.map((e: any) => DanmakuElem.fromJSON(e)) : [], + }; + }, + + toJSON(message: DanmakuEvent): unknown { + const obj: any = {}; + if (message.elems?.length) { + obj.elems = message.elems.map((e) => DanmakuElem.toJSON(e)); + } + return obj; + }, + + create, I>>(base?: I): DanmakuEvent { + return DanmakuEvent.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): DanmakuEvent { + const message = createBaseDanmakuEvent(); + message.elems = object.elems?.map((e) => DanmakuElem.fromPartial(e)) || []; + return message; + }, +}; + +function createBaseDanmakuElem(): DanmakuElem { + return { id: 0n, progress: 0, mode: 0, fontsize: 0, color: 0, midHash: "", content: "", ctime: 0n, idStr: "" }; +} + +export const DanmakuElem: MessageFns = { + encode(message: DanmakuElem, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.id !== 0n) { + if (BigInt.asIntN(64, message.id) !== message.id) { + throw new globalThis.Error("value provided for field message.id of type int64 too large"); + } + writer.uint32(8).int64(message.id); + } + if (message.progress !== 0) { + writer.uint32(16).int32(message.progress); + } + if (message.mode !== 0) { + writer.uint32(24).int32(message.mode); + } + if (message.fontsize !== 0) { + writer.uint32(32).int32(message.fontsize); + } + if (message.color !== 0) { + writer.uint32(40).uint32(message.color); + } + if (message.midHash !== "") { + writer.uint32(50).string(message.midHash); + } + if (message.content !== "") { + writer.uint32(58).string(message.content); + } + if (message.ctime !== 0n) { + if (BigInt.asIntN(64, message.ctime) !== message.ctime) { + throw new globalThis.Error("value provided for field message.ctime of type int64 too large"); + } + writer.uint32(64).int64(message.ctime); + } + if (message.action !== undefined) { + writer.uint32(74).string(message.action); + } + if (message.pool !== undefined) { + writer.uint32(80).int32(message.pool); + } + if (message.idStr !== "") { + writer.uint32(90).string(message.idStr); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): DanmakuElem { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDanmakuElem(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.id = reader.int64() as bigint; + continue; + case 2: + if (tag !== 16) { + break; + } + + message.progress = reader.int32(); + continue; + case 3: + if (tag !== 24) { + break; + } + + message.mode = reader.int32(); + continue; + case 4: + if (tag !== 32) { + break; + } + + message.fontsize = reader.int32(); + continue; + case 5: + if (tag !== 40) { + break; + } + + message.color = reader.uint32(); + continue; + case 6: + if (tag !== 50) { + break; + } + + message.midHash = reader.string(); + continue; + case 7: + if (tag !== 58) { + break; + } + + message.content = reader.string(); + continue; + case 8: + if (tag !== 64) { + break; + } + + message.ctime = reader.int64() as bigint; + continue; + case 9: + if (tag !== 74) { + break; + } + + message.action = reader.string(); + continue; + case 10: + if (tag !== 80) { + break; + } + + message.pool = reader.int32(); + continue; + case 11: + if (tag !== 90) { + break; + } + + message.idStr = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): DanmakuElem { + return { + id: isSet(object.id) ? BigInt(object.id) : 0n, + progress: isSet(object.progress) ? globalThis.Number(object.progress) : 0, + mode: isSet(object.mode) ? globalThis.Number(object.mode) : 0, + fontsize: isSet(object.fontsize) ? globalThis.Number(object.fontsize) : 0, + color: isSet(object.color) ? globalThis.Number(object.color) : 0, + midHash: isSet(object.midHash) ? globalThis.String(object.midHash) : "", + content: isSet(object.content) ? globalThis.String(object.content) : "", + ctime: isSet(object.ctime) ? BigInt(object.ctime) : 0n, + action: isSet(object.action) ? globalThis.String(object.action) : undefined, + pool: isSet(object.pool) ? globalThis.Number(object.pool) : undefined, + idStr: isSet(object.idStr) ? globalThis.String(object.idStr) : "", + }; + }, + + toJSON(message: DanmakuElem): unknown { + const obj: any = {}; + if (message.id !== 0n) { + obj.id = message.id.toString(); + } + if (message.progress !== 0) { + obj.progress = Math.round(message.progress); + } + if (message.mode !== 0) { + obj.mode = Math.round(message.mode); + } + if (message.fontsize !== 0) { + obj.fontsize = Math.round(message.fontsize); + } + if (message.color !== 0) { + obj.color = Math.round(message.color); + } + if (message.midHash !== "") { + obj.midHash = message.midHash; + } + if (message.content !== "") { + obj.content = message.content; + } + if (message.ctime !== 0n) { + obj.ctime = message.ctime.toString(); + } + if (message.action !== undefined) { + obj.action = message.action; + } + if (message.pool !== undefined) { + obj.pool = Math.round(message.pool); + } + if (message.idStr !== "") { + obj.idStr = message.idStr; + } + return obj; + }, + + create, I>>(base?: I): DanmakuElem { + return DanmakuElem.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): DanmakuElem { + const message = createBaseDanmakuElem(); + message.id = object.id ?? 0n; + message.progress = object.progress ?? 0; + message.mode = object.mode ?? 0; + message.fontsize = object.fontsize ?? 0; + message.color = object.color ?? 0; + message.midHash = object.midHash ?? ""; + message.content = object.content ?? ""; + message.ctime = object.ctime ?? 0n; + message.action = object.action ?? undefined; + message.pool = object.pool ?? undefined; + message.idStr = object.idStr ?? ""; + return message; + }, +}; + +function createBaseCommandDm(): CommandDm { + return { + id: 0n, + oid: 0n, + mid: 0n, + type: 0, + command: "", + content: "", + state: 0, + progress: 0, + ctime: "", + mtime: "", + extra: "", + idStr: "", + }; +} + +export const CommandDm: MessageFns = { + encode(message: CommandDm, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.id !== 0n) { + if (BigInt.asIntN(64, message.id) !== message.id) { + throw new globalThis.Error("value provided for field message.id of type int64 too large"); + } + writer.uint32(8).int64(message.id); + } + if (message.oid !== 0n) { + if (BigInt.asIntN(64, message.oid) !== message.oid) { + throw new globalThis.Error("value provided for field message.oid of type int64 too large"); + } + writer.uint32(16).int64(message.oid); + } + if (message.mid !== 0n) { + if (BigInt.asIntN(64, message.mid) !== message.mid) { + throw new globalThis.Error("value provided for field message.mid of type int64 too large"); + } + writer.uint32(24).int64(message.mid); + } + if (message.type !== 0) { + writer.uint32(32).int32(message.type); + } + if (message.command !== "") { + writer.uint32(42).string(message.command); + } + if (message.content !== "") { + writer.uint32(50).string(message.content); + } + if (message.state !== 0) { + writer.uint32(56).int32(message.state); + } + if (message.progress !== 0) { + writer.uint32(64).int32(message.progress); + } + if (message.ctime !== "") { + writer.uint32(74).string(message.ctime); + } + if (message.mtime !== "") { + writer.uint32(82).string(message.mtime); + } + if (message.extra !== "") { + writer.uint32(90).string(message.extra); + } + if (message.idStr !== "") { + writer.uint32(98).string(message.idStr); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): CommandDm { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCommandDm(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.id = reader.int64() as bigint; + continue; + case 2: + if (tag !== 16) { + break; + } + + message.oid = reader.int64() as bigint; + continue; + case 3: + if (tag !== 24) { + break; + } + + message.mid = reader.int64() as bigint; + continue; + case 4: + if (tag !== 32) { + break; + } + + message.type = reader.int32(); + continue; + case 5: + if (tag !== 42) { + break; + } + + message.command = reader.string(); + continue; + case 6: + if (tag !== 50) { + break; + } + + message.content = reader.string(); + continue; + case 7: + if (tag !== 56) { + break; + } + + message.state = reader.int32(); + continue; + case 8: + if (tag !== 64) { + break; + } + + message.progress = reader.int32(); + continue; + case 9: + if (tag !== 74) { + break; + } + + message.ctime = reader.string(); + continue; + case 10: + if (tag !== 82) { + break; + } + + message.mtime = reader.string(); + continue; + case 11: + if (tag !== 90) { + break; + } + + message.extra = reader.string(); + continue; + case 12: + if (tag !== 98) { + break; + } + + message.idStr = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): CommandDm { + return { + id: isSet(object.id) ? BigInt(object.id) : 0n, + oid: isSet(object.oid) ? BigInt(object.oid) : 0n, + mid: isSet(object.mid) ? BigInt(object.mid) : 0n, + type: isSet(object.type) ? globalThis.Number(object.type) : 0, + command: isSet(object.command) ? globalThis.String(object.command) : "", + content: isSet(object.content) ? globalThis.String(object.content) : "", + state: isSet(object.state) ? globalThis.Number(object.state) : 0, + progress: isSet(object.progress) ? globalThis.Number(object.progress) : 0, + ctime: isSet(object.ctime) ? globalThis.String(object.ctime) : "", + mtime: isSet(object.mtime) ? globalThis.String(object.mtime) : "", + extra: isSet(object.extra) ? globalThis.String(object.extra) : "", + idStr: isSet(object.idStr) ? globalThis.String(object.idStr) : "", + }; + }, + + toJSON(message: CommandDm): unknown { + const obj: any = {}; + if (message.id !== 0n) { + obj.id = message.id.toString(); + } + if (message.oid !== 0n) { + obj.oid = message.oid.toString(); + } + if (message.mid !== 0n) { + obj.mid = message.mid.toString(); + } + if (message.type !== 0) { + obj.type = Math.round(message.type); + } + if (message.command !== "") { + obj.command = message.command; + } + if (message.content !== "") { + obj.content = message.content; + } + if (message.state !== 0) { + obj.state = Math.round(message.state); + } + if (message.progress !== 0) { + obj.progress = Math.round(message.progress); + } + if (message.ctime !== "") { + obj.ctime = message.ctime; + } + if (message.mtime !== "") { + obj.mtime = message.mtime; + } + if (message.extra !== "") { + obj.extra = message.extra; + } + if (message.idStr !== "") { + obj.idStr = message.idStr; + } + return obj; + }, + + create, I>>(base?: I): CommandDm { + return CommandDm.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CommandDm { + const message = createBaseCommandDm(); + message.id = object.id ?? 0n; + message.oid = object.oid ?? 0n; + message.mid = object.mid ?? 0n; + message.type = object.type ?? 0; + message.command = object.command ?? ""; + message.content = object.content ?? ""; + message.state = object.state ?? 0; + message.progress = object.progress ?? 0; + message.ctime = object.ctime ?? ""; + message.mtime = object.mtime ?? ""; + message.extra = object.extra ?? ""; + message.idStr = object.idStr ?? ""; + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | boolean | bigint | undefined; + +export type DeepPartial = T extends Builtin ? T + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } + : Partial; + +type KeysOfUnion = T extends T ? keyof T : never; +export type Exact = P extends Builtin ? P + : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; + +function isSet(value: any): boolean { + return value !== null && value !== undefined; +} + +export interface MessageFns { + encode(message: T, writer?: BinaryWriter): BinaryWriter; + decode(input: BinaryReader | Uint8Array, length?: number): T; + fromJSON(object: any): T; + toJSON(message: T): unknown; + create, I>>(base?: I): T; + fromPartial, I>>(object: I): T; +} diff --git a/src/io/com/bapis/bilibili/broadcast/v1/Auth.proto b/src/io/com/bapis/bilibili/broadcast/v1/Auth.proto new file mode 100644 index 0000000..9d9553b --- /dev/null +++ b/src/io/com/bapis/bilibili/broadcast/v1/Auth.proto @@ -0,0 +1,16 @@ +syntax = "proto3"; + +package bilibili.broadcast.v1; + +/** 鉴权请求,通过authorization验证绑定用户mid */ +message AuthReq { + /** 冷启动id,算法uuid,重新起启会变 */ + string guid = 1; + /** 连接id,算法uuid,重连会变 */ + string conn_id = 2; + /** 最后收到的消息id,用于过虑重连后获取未读的消息 */ + int64 last_msg_id = 3; +} + +/** 鉴权返回 */ +message AuthResp {} \ No newline at end of file diff --git a/src/io/com/bapis/bilibili/broadcast/v1/Auth.ts b/src/io/com/bapis/bilibili/broadcast/v1/Auth.ts new file mode 100644 index 0000000..968c498 --- /dev/null +++ b/src/io/com/bapis/bilibili/broadcast/v1/Auth.ts @@ -0,0 +1,184 @@ +// Code generated by protoc-gen-ts_proto. DO NOT EDIT. +// versions: +// protoc-gen-ts_proto v2.2.0 +// protoc v5.28.2 +// source: src/io/com/bapis/bilibili/broadcast/v1/Auth.proto + +/* eslint-disable */ +import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire"; + +export const protobufPackage = "bilibili.broadcast.v1"; + +/** 鉴权请求,通过authorization验证绑定用户mid */ +export interface AuthReq { + /** 冷启动id,算法uuid,重新起启会变 */ + guid: string; + /** 连接id,算法uuid,重连会变 */ + connId: string; + /** 最后收到的消息id,用于过虑重连后获取未读的消息 */ + lastMsgId: bigint; +} + +/** 鉴权返回 */ +export interface AuthResp { +} + +function createBaseAuthReq(): AuthReq { + return { guid: "", connId: "", lastMsgId: 0n }; +} + +export const AuthReq: MessageFns = { + encode(message: AuthReq, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.guid !== "") { + writer.uint32(10).string(message.guid); + } + if (message.connId !== "") { + writer.uint32(18).string(message.connId); + } + if (message.lastMsgId !== 0n) { + if (BigInt.asIntN(64, message.lastMsgId) !== message.lastMsgId) { + throw new globalThis.Error("value provided for field message.lastMsgId of type int64 too large"); + } + writer.uint32(24).int64(message.lastMsgId); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): AuthReq { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseAuthReq(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.guid = reader.string(); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.connId = reader.string(); + continue; + case 3: + if (tag !== 24) { + break; + } + + message.lastMsgId = reader.int64() as bigint; + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): AuthReq { + return { + guid: isSet(object.guid) ? globalThis.String(object.guid) : "", + connId: isSet(object.connId) ? globalThis.String(object.connId) : "", + lastMsgId: isSet(object.lastMsgId) ? BigInt(object.lastMsgId) : 0n, + }; + }, + + toJSON(message: AuthReq): unknown { + const obj: any = {}; + if (message.guid !== "") { + obj.guid = message.guid; + } + if (message.connId !== "") { + obj.connId = message.connId; + } + if (message.lastMsgId !== 0n) { + obj.lastMsgId = message.lastMsgId.toString(); + } + return obj; + }, + + create, I>>(base?: I): AuthReq { + return AuthReq.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): AuthReq { + const message = createBaseAuthReq(); + message.guid = object.guid ?? ""; + message.connId = object.connId ?? ""; + message.lastMsgId = object.lastMsgId ?? 0n; + return message; + }, +}; + +function createBaseAuthResp(): AuthResp { + return {}; +} + +export const AuthResp: MessageFns = { + encode(_: AuthResp, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): AuthResp { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseAuthResp(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(_: any): AuthResp { + return {}; + }, + + toJSON(_: AuthResp): unknown { + const obj: any = {}; + return obj; + }, + + create, I>>(base?: I): AuthResp { + return AuthResp.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(_: I): AuthResp { + const message = createBaseAuthResp(); + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | boolean | bigint | undefined; + +export type DeepPartial = T extends Builtin ? T + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } + : Partial; + +type KeysOfUnion = T extends T ? keyof T : never; +export type Exact = P extends Builtin ? P + : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; + +function isSet(value: any): boolean { + return value !== null && value !== undefined; +} + +export interface MessageFns { + encode(message: T, writer?: BinaryWriter): BinaryWriter; + decode(input: BinaryReader | Uint8Array, length?: number): T; + fromJSON(object: any): T; + toJSON(message: T): unknown; + create, I>>(base?: I): T; + fromPartial, I>>(object: I): T; +} diff --git a/src/io/com/bapis/bilibili/broadcast/v1/BroadcastFrame.proto b/src/io/com/bapis/bilibili/broadcast/v1/BroadcastFrame.proto new file mode 100644 index 0000000..7dbda22 --- /dev/null +++ b/src/io/com/bapis/bilibili/broadcast/v1/BroadcastFrame.proto @@ -0,0 +1,47 @@ +syntax = "proto3"; + +package bilibili.broadcast.v1; + +import "src/io/com/bapis/bilibili/rpc/status.proto"; +import "src/io/com/bapis/google/protobuf/any.proto"; + +message BroadcastFrame { + /** 请求消息信息 */ + FrameOption options = 1; + /** 业务target_path */ + string target_path = 2; + /** 务pb内容 */ + google.protobuf.Any body = 3; +} + +/** 请求消息信息 */ +message FrameOption { + /** + * 消息id + * | | | + * | :-: | :-: | + * | client | 本次连接唯一的消息id,可用于回执 | + * | server | 唯一消息id,可用于上报或者回执 | + */ + optional int64 message_id = 1; + /** + * frame序号 + * | | | + * | :-: | :-: | + * | client | 客户端应该每次请求时frame seq++,会返回对应的对称req/resp | + * | server | 服务端下行消息,只会返回默认值:0 | + */ + int64 sequence = 2; + /** + * 是否进行消息回执(发出MessageAckReq) + * downstream 上只有服务端设置为true,客户端响应 + * upstream 上只有客户端设置为true,服务端响应 + * 响应帧禁止设置is_ack,协议上禁止循环 + * 通常只有业务帧才可能设置is_ack, 因为协议栈(例如心跳、鉴权)另有响应约定 + */ + optional bool is_ack = 3; + /** 业务状态码 */ + optional bilibili.rpc.Status status = 4; + /** 业务ack来源, 仅downstream时候由服务端填写. */ + optional string ack_origin = 5; +} \ No newline at end of file diff --git a/src/io/com/bapis/bilibili/broadcast/v1/BroadcastFrame.ts b/src/io/com/bapis/bilibili/broadcast/v1/BroadcastFrame.ts new file mode 100644 index 0000000..a837809 --- /dev/null +++ b/src/io/com/bapis/bilibili/broadcast/v1/BroadcastFrame.ts @@ -0,0 +1,304 @@ +// Code generated by protoc-gen-ts_proto. DO NOT EDIT. +// versions: +// protoc-gen-ts_proto v2.2.0 +// protoc v5.28.2 +// source: src/io/com/bapis/bilibili/broadcast/v1/BroadcastFrame.proto + +/* eslint-disable */ +import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire"; +import { Any } from "../../../google/protobuf/any"; +import { Status } from "../../rpc/status"; + +export const protobufPackage = "bilibili.broadcast.v1"; + +export interface BroadcastFrame { + /** 请求消息信息 */ + options: + | FrameOption + | undefined; + /** 业务target_path */ + targetPath: string; + /** 务pb内容 */ + body: Any | undefined; +} + +/** 请求消息信息 */ +export interface FrameOption { + /** + * 消息id + * | | | + * | :-: | :-: | + * | client | 本次连接唯一的消息id,可用于回执 | + * | server | 唯一消息id,可用于上报或者回执 | + */ + messageId?: + | bigint + | undefined; + /** + * frame序号 + * | | | + * | :-: | :-: | + * | client | 客户端应该每次请求时frame seq++,会返回对应的对称req/resp | + * | server | 服务端下行消息,只会返回默认值:0 | + */ + sequence: bigint; + /** + * 是否进行消息回执(发出MessageAckReq) + * downstream 上只有服务端设置为true,客户端响应 + * upstream 上只有客户端设置为true,服务端响应 + * 响应帧禁止设置is_ack,协议上禁止循环 + * 通常只有业务帧才可能设置is_ack, 因为协议栈(例如心跳、鉴权)另有响应约定 + */ + isAck?: + | boolean + | undefined; + /** 业务状态码 */ + status?: + | Status + | undefined; + /** 业务ack来源, 仅downstream时候由服务端填写. */ + ackOrigin?: string | undefined; +} + +function createBaseBroadcastFrame(): BroadcastFrame { + return { options: undefined, targetPath: "", body: undefined }; +} + +export const BroadcastFrame: MessageFns = { + encode(message: BroadcastFrame, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.options !== undefined) { + FrameOption.encode(message.options, writer.uint32(10).fork()).join(); + } + if (message.targetPath !== "") { + writer.uint32(18).string(message.targetPath); + } + if (message.body !== undefined) { + Any.encode(message.body, writer.uint32(26).fork()).join(); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): BroadcastFrame { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseBroadcastFrame(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.options = FrameOption.decode(reader, reader.uint32()); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.targetPath = reader.string(); + continue; + case 3: + if (tag !== 26) { + break; + } + + message.body = Any.decode(reader, reader.uint32()); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): BroadcastFrame { + return { + options: isSet(object.options) ? FrameOption.fromJSON(object.options) : undefined, + targetPath: isSet(object.targetPath) ? globalThis.String(object.targetPath) : "", + body: isSet(object.body) ? Any.fromJSON(object.body) : undefined, + }; + }, + + toJSON(message: BroadcastFrame): unknown { + const obj: any = {}; + if (message.options !== undefined) { + obj.options = FrameOption.toJSON(message.options); + } + if (message.targetPath !== "") { + obj.targetPath = message.targetPath; + } + if (message.body !== undefined) { + obj.body = Any.toJSON(message.body); + } + return obj; + }, + + create, I>>(base?: I): BroadcastFrame { + return BroadcastFrame.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): BroadcastFrame { + const message = createBaseBroadcastFrame(); + message.options = (object.options !== undefined && object.options !== null) + ? FrameOption.fromPartial(object.options) + : undefined; + message.targetPath = object.targetPath ?? ""; + message.body = (object.body !== undefined && object.body !== null) ? Any.fromPartial(object.body) : undefined; + return message; + }, +}; + +function createBaseFrameOption(): FrameOption { + return { sequence: 0n }; +} + +export const FrameOption: MessageFns = { + encode(message: FrameOption, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.messageId !== undefined) { + if (BigInt.asIntN(64, message.messageId) !== message.messageId) { + throw new globalThis.Error("value provided for field message.messageId of type int64 too large"); + } + writer.uint32(8).int64(message.messageId); + } + if (message.sequence !== 0n) { + if (BigInt.asIntN(64, message.sequence) !== message.sequence) { + throw new globalThis.Error("value provided for field message.sequence of type int64 too large"); + } + writer.uint32(16).int64(message.sequence); + } + if (message.isAck !== undefined) { + writer.uint32(24).bool(message.isAck); + } + if (message.status !== undefined) { + Status.encode(message.status, writer.uint32(34).fork()).join(); + } + if (message.ackOrigin !== undefined) { + writer.uint32(42).string(message.ackOrigin); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): FrameOption { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseFrameOption(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.messageId = reader.int64() as bigint; + continue; + case 2: + if (tag !== 16) { + break; + } + + message.sequence = reader.int64() as bigint; + continue; + case 3: + if (tag !== 24) { + break; + } + + message.isAck = reader.bool(); + continue; + case 4: + if (tag !== 34) { + break; + } + + message.status = Status.decode(reader, reader.uint32()); + continue; + case 5: + if (tag !== 42) { + break; + } + + message.ackOrigin = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): FrameOption { + return { + messageId: isSet(object.messageId) ? BigInt(object.messageId) : undefined, + sequence: isSet(object.sequence) ? BigInt(object.sequence) : 0n, + isAck: isSet(object.isAck) ? globalThis.Boolean(object.isAck) : undefined, + status: isSet(object.status) ? Status.fromJSON(object.status) : undefined, + ackOrigin: isSet(object.ackOrigin) ? globalThis.String(object.ackOrigin) : undefined, + }; + }, + + toJSON(message: FrameOption): unknown { + const obj: any = {}; + if (message.messageId !== undefined) { + obj.messageId = message.messageId.toString(); + } + if (message.sequence !== 0n) { + obj.sequence = message.sequence.toString(); + } + if (message.isAck !== undefined) { + obj.isAck = message.isAck; + } + if (message.status !== undefined) { + obj.status = Status.toJSON(message.status); + } + if (message.ackOrigin !== undefined) { + obj.ackOrigin = message.ackOrigin; + } + return obj; + }, + + create, I>>(base?: I): FrameOption { + return FrameOption.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): FrameOption { + const message = createBaseFrameOption(); + message.messageId = object.messageId ?? undefined; + message.sequence = object.sequence ?? 0n; + message.isAck = object.isAck ?? undefined; + message.status = (object.status !== undefined && object.status !== null) + ? Status.fromPartial(object.status) + : undefined; + message.ackOrigin = object.ackOrigin ?? undefined; + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | boolean | bigint | undefined; + +export type DeepPartial = T extends Builtin ? T + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } + : Partial; + +type KeysOfUnion = T extends T ? keyof T : never; +export type Exact = P extends Builtin ? P + : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; + +function isSet(value: any): boolean { + return value !== null && value !== undefined; +} + +export interface MessageFns { + encode(message: T, writer?: BinaryWriter): BinaryWriter; + decode(input: BinaryReader | Uint8Array, length?: number): T; + fromJSON(object: any): T; + toJSON(message: T): unknown; + create, I>>(base?: I): T; + fromPartial, I>>(object: I): T; +} diff --git a/src/io/com/bapis/bilibili/broadcast/v1/Heartbeat.proto b/src/io/com/bapis/bilibili/broadcast/v1/Heartbeat.proto new file mode 100644 index 0000000..c1433f8 --- /dev/null +++ b/src/io/com/bapis/bilibili/broadcast/v1/Heartbeat.proto @@ -0,0 +1,12 @@ +syntax = "proto3"; + +package bilibili.broadcast.v1; + +/** + * 心跳请求 + * 心跳保活:成功心跳为4分45秒,重试心跳为30s,三次收不到进行重连(不超过5分45) + */ +message HeartbeatReq{} + +/** 心跳返回 */ +message HeartbeatResp{} \ No newline at end of file diff --git a/src/io/com/bapis/bilibili/broadcast/v1/Heartbeat.ts b/src/io/com/bapis/bilibili/broadcast/v1/Heartbeat.ts new file mode 100644 index 0000000..fb4c5b7 --- /dev/null +++ b/src/io/com/bapis/bilibili/broadcast/v1/Heartbeat.ts @@ -0,0 +1,128 @@ +// Code generated by protoc-gen-ts_proto. DO NOT EDIT. +// versions: +// protoc-gen-ts_proto v2.2.0 +// protoc v5.28.2 +// source: src/io/com/bapis/bilibili/broadcast/v1/Heartbeat.proto + +/* eslint-disable */ +import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire"; + +export const protobufPackage = "bilibili.broadcast.v1"; + +/** + * 心跳请求 + * 心跳保活:成功心跳为4分45秒,重试心跳为30s,三次收不到进行重连(不超过5分45) + */ +export interface HeartbeatReq { +} + +/** 心跳返回 */ +export interface HeartbeatResp { +} + +function createBaseHeartbeatReq(): HeartbeatReq { + return {}; +} + +export const HeartbeatReq: MessageFns = { + encode(_: HeartbeatReq, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): HeartbeatReq { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseHeartbeatReq(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(_: any): HeartbeatReq { + return {}; + }, + + toJSON(_: HeartbeatReq): unknown { + const obj: any = {}; + return obj; + }, + + create, I>>(base?: I): HeartbeatReq { + return HeartbeatReq.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(_: I): HeartbeatReq { + const message = createBaseHeartbeatReq(); + return message; + }, +}; + +function createBaseHeartbeatResp(): HeartbeatResp { + return {}; +} + +export const HeartbeatResp: MessageFns = { + encode(_: HeartbeatResp, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): HeartbeatResp { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseHeartbeatResp(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(_: any): HeartbeatResp { + return {}; + }, + + toJSON(_: HeartbeatResp): unknown { + const obj: any = {}; + return obj; + }, + + create, I>>(base?: I): HeartbeatResp { + return HeartbeatResp.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(_: I): HeartbeatResp { + const message = createBaseHeartbeatResp(); + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | boolean | bigint | undefined; + +export type DeepPartial = T extends Builtin ? T + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } + : Partial; + +type KeysOfUnion = T extends T ? keyof T : never; +export type Exact = P extends Builtin ? P + : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; + +export interface MessageFns { + encode(message: T, writer?: BinaryWriter): BinaryWriter; + decode(input: BinaryReader | Uint8Array, length?: number): T; + fromJSON(object: any): T; + toJSON(message: T): unknown; + create, I>>(base?: I): T; + fromPartial, I>>(object: I): T; +} diff --git a/src/io/com/bapis/bilibili/broadcast/v1/MessageAck.proto b/src/io/com/bapis/bilibili/broadcast/v1/MessageAck.proto new file mode 100644 index 0000000..eeff0cc --- /dev/null +++ b/src/io/com/bapis/bilibili/broadcast/v1/MessageAck.proto @@ -0,0 +1,13 @@ +syntax = "proto3"; + +package bilibili.broadcast.v1; + +/** 消息回执 */ +message MessageAckReq { + /** 消息id */ + int64 ack_id = 1; + /** ack来源,由业务指定用于埋点跟踪 */ + string ack_origin = 2; + /** 消息对应的target_path,方便业务区分和监控统计 */ + string target_path = 3; +} \ No newline at end of file diff --git a/src/io/com/bapis/bilibili/broadcast/v1/MessageAck.ts b/src/io/com/bapis/bilibili/broadcast/v1/MessageAck.ts new file mode 100644 index 0000000..19f9125 --- /dev/null +++ b/src/io/com/bapis/bilibili/broadcast/v1/MessageAck.ts @@ -0,0 +1,137 @@ +// Code generated by protoc-gen-ts_proto. DO NOT EDIT. +// versions: +// protoc-gen-ts_proto v2.2.0 +// protoc v5.28.2 +// source: src/io/com/bapis/bilibili/broadcast/v1/MessageAck.proto + +/* eslint-disable */ +import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire"; + +export const protobufPackage = "bilibili.broadcast.v1"; + +/** 消息回执 */ +export interface MessageAckReq { + /** 消息id */ + ackId: bigint; + /** ack来源,由业务指定用于埋点跟踪 */ + ackOrigin: string; + /** 消息对应的target_path,方便业务区分和监控统计 */ + targetPath: string; +} + +function createBaseMessageAckReq(): MessageAckReq { + return { ackId: 0n, ackOrigin: "", targetPath: "" }; +} + +export const MessageAckReq: MessageFns = { + encode(message: MessageAckReq, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.ackId !== 0n) { + if (BigInt.asIntN(64, message.ackId) !== message.ackId) { + throw new globalThis.Error("value provided for field message.ackId of type int64 too large"); + } + writer.uint32(8).int64(message.ackId); + } + if (message.ackOrigin !== "") { + writer.uint32(18).string(message.ackOrigin); + } + if (message.targetPath !== "") { + writer.uint32(26).string(message.targetPath); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): MessageAckReq { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMessageAckReq(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.ackId = reader.int64() as bigint; + continue; + case 2: + if (tag !== 18) { + break; + } + + message.ackOrigin = reader.string(); + continue; + case 3: + if (tag !== 26) { + break; + } + + message.targetPath = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): MessageAckReq { + return { + ackId: isSet(object.ackId) ? BigInt(object.ackId) : 0n, + ackOrigin: isSet(object.ackOrigin) ? globalThis.String(object.ackOrigin) : "", + targetPath: isSet(object.targetPath) ? globalThis.String(object.targetPath) : "", + }; + }, + + toJSON(message: MessageAckReq): unknown { + const obj: any = {}; + if (message.ackId !== 0n) { + obj.ackId = message.ackId.toString(); + } + if (message.ackOrigin !== "") { + obj.ackOrigin = message.ackOrigin; + } + if (message.targetPath !== "") { + obj.targetPath = message.targetPath; + } + return obj; + }, + + create, I>>(base?: I): MessageAckReq { + return MessageAckReq.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): MessageAckReq { + const message = createBaseMessageAckReq(); + message.ackId = object.ackId ?? 0n; + message.ackOrigin = object.ackOrigin ?? ""; + message.targetPath = object.targetPath ?? ""; + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | boolean | bigint | undefined; + +export type DeepPartial = T extends Builtin ? T + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } + : Partial; + +type KeysOfUnion = T extends T ? keyof T : never; +export type Exact = P extends Builtin ? P + : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; + +function isSet(value: any): boolean { + return value !== null && value !== undefined; +} + +export interface MessageFns { + encode(message: T, writer?: BinaryWriter): BinaryWriter; + decode(input: BinaryReader | Uint8Array, length?: number): T; + fromJSON(object: any): T; + toJSON(message: T): unknown; + create, I>>(base?: I): T; + fromPartial, I>>(object: I): T; +} diff --git a/src/io/protobuf/BroadcastFrame.ts b/src/io/com/bapis/bilibili/broadcast/v1/PATH.ts similarity index 53% rename from src/io/protobuf/BroadcastFrame.ts rename to src/io/com/bapis/bilibili/broadcast/v1/PATH.ts index ead8ad6..19ddf78 100644 --- a/src/io/protobuf/BroadcastFrame.ts +++ b/src/io/com/bapis/bilibili/broadcast/v1/PATH.ts @@ -1,25 +1,7 @@ -import { IAnyType } from "./AnyType"; -import { Protobuf } from "."; - -export class BroadcastFrame { - - static decode(buffer: ArrayBuffer) { - const msg = Protobuf.BroadcastFrame.decode(new Uint8Array(buffer)); - return Protobuf.BroadcastFrame.toObject(msg); - } - - static encode(data: IBroadcastFrame) { - const obj = Protobuf.BroadcastFrame.fromObject(data); - return Protobuf.BroadcastFrame.encode(obj).finish(); - } - - static create(data: IBroadcastFrame) { - return Protobuf.BroadcastFrame.create(data); - } -} - const PACKAGE = '/bilibili.broadcast.v1'; const BROADCAST = '.Broadcast'; + +/** 业务target_path */ export enum PATH { /** 进行鉴权 */ AUTH = `${PACKAGE + BROADCAST}/Auth`, @@ -45,24 +27,4 @@ export enum PATH { HEARTBEATRES = `${PACKAGE}.HeartbeatResp`, /** 心跳,响应 */ MSG_ACK_REQ = `${PACKAGE}.MessageAckReq`, -} - -export interface IBroadcastFrame { - options: IFrameOption; - targetPath: PATH; - body?: IAnyType; -} - -interface IFrameOption { - messageId?: number; - sequence: number; - isAck?: boolean; - status?: IStatus; - ackOrigin?: string; -} - -export interface IStatus { - code: number; - message: string; - details: any[]; } \ No newline at end of file diff --git a/src/io/com/bapis/bilibili/broadcast/v1/Room.proto b/src/io/com/bapis/bilibili/broadcast/v1/Room.proto new file mode 100644 index 0000000..945d508 --- /dev/null +++ b/src/io/com/bapis/bilibili/broadcast/v1/Room.proto @@ -0,0 +1,42 @@ +syntax = "proto3"; + +package bilibili.broadcast.v1; + +import "src/io/com/bapis/google/protobuf/any.proto"; +import "src/io/com/bapis/bilibili/rpc/status.proto"; + +message RoomReq { + /** {type}://{room_id} */ + string id = 1; + oneof event { + RoomJoinEvent join = 2; + RoomLeaveEvent leave = 3; + RoomOnlineEvent online = 4; + RoomMessageEvent msg = 5; + } +} + +message RoomResp { + /** {type}://{room_id} */ + string id = 1; + oneof event { + RoomJoinEvent join = 2; + RoomLeaveEvent leave = 3; + RoomOnlineEvent online = 4; + RoomMessageEvent msg = 5; + RoomErrorEvent err = 6; + } +} + +message RoomJoinEvent {} +message RoomLeaveEvent {} +message RoomOnlineEvent { + int32 online = 1; +} +message RoomMessageEvent { + string target_path = 1; + google.protobuf.Any body = 2; +} +message RoomErrorEvent { + bilibili.rpc.Status status = 1; +} \ No newline at end of file diff --git a/src/io/com/bapis/bilibili/broadcast/v1/Room.ts b/src/io/com/bapis/bilibili/broadcast/v1/Room.ts new file mode 100644 index 0000000..499c3b3 --- /dev/null +++ b/src/io/com/bapis/bilibili/broadcast/v1/Room.ts @@ -0,0 +1,622 @@ +// Code generated by protoc-gen-ts_proto. DO NOT EDIT. +// versions: +// protoc-gen-ts_proto v2.2.0 +// protoc v5.28.2 +// source: src/io/com/bapis/bilibili/broadcast/v1/Room.proto + +/* eslint-disable */ +import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire"; +import { Any } from "../../../google/protobuf/any"; +import { Status } from "../../rpc/status"; + +export const protobufPackage = "bilibili.broadcast.v1"; + +export interface RoomReq { + /** {type}://{room_id} */ + id: string; + join?: RoomJoinEvent | undefined; + leave?: RoomLeaveEvent | undefined; + online?: RoomOnlineEvent | undefined; + msg?: RoomMessageEvent | undefined; +} + +export interface RoomResp { + /** {type}://{room_id} */ + id: string; + join?: RoomJoinEvent | undefined; + leave?: RoomLeaveEvent | undefined; + online?: RoomOnlineEvent | undefined; + msg?: RoomMessageEvent | undefined; + err?: RoomErrorEvent | undefined; +} + +export interface RoomJoinEvent { +} + +export interface RoomLeaveEvent { +} + +export interface RoomOnlineEvent { + online: number; +} + +export interface RoomMessageEvent { + targetPath: string; + body: Any | undefined; +} + +export interface RoomErrorEvent { + status: Status | undefined; +} + +function createBaseRoomReq(): RoomReq { + return { id: "" }; +} + +export const RoomReq: MessageFns = { + encode(message: RoomReq, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.id !== "") { + writer.uint32(10).string(message.id); + } + if (message.join !== undefined) { + RoomJoinEvent.encode(message.join, writer.uint32(18).fork()).join(); + } + if (message.leave !== undefined) { + RoomLeaveEvent.encode(message.leave, writer.uint32(26).fork()).join(); + } + if (message.online !== undefined) { + RoomOnlineEvent.encode(message.online, writer.uint32(34).fork()).join(); + } + if (message.msg !== undefined) { + RoomMessageEvent.encode(message.msg, writer.uint32(42).fork()).join(); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): RoomReq { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseRoomReq(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.id = reader.string(); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.join = RoomJoinEvent.decode(reader, reader.uint32()); + continue; + case 3: + if (tag !== 26) { + break; + } + + message.leave = RoomLeaveEvent.decode(reader, reader.uint32()); + continue; + case 4: + if (tag !== 34) { + break; + } + + message.online = RoomOnlineEvent.decode(reader, reader.uint32()); + continue; + case 5: + if (tag !== 42) { + break; + } + + message.msg = RoomMessageEvent.decode(reader, reader.uint32()); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): RoomReq { + return { + id: isSet(object.id) ? globalThis.String(object.id) : "", + join: isSet(object.join) ? RoomJoinEvent.fromJSON(object.join) : undefined, + leave: isSet(object.leave) ? RoomLeaveEvent.fromJSON(object.leave) : undefined, + online: isSet(object.online) ? RoomOnlineEvent.fromJSON(object.online) : undefined, + msg: isSet(object.msg) ? RoomMessageEvent.fromJSON(object.msg) : undefined, + }; + }, + + toJSON(message: RoomReq): unknown { + const obj: any = {}; + if (message.id !== "") { + obj.id = message.id; + } + if (message.join !== undefined) { + obj.join = RoomJoinEvent.toJSON(message.join); + } + if (message.leave !== undefined) { + obj.leave = RoomLeaveEvent.toJSON(message.leave); + } + if (message.online !== undefined) { + obj.online = RoomOnlineEvent.toJSON(message.online); + } + if (message.msg !== undefined) { + obj.msg = RoomMessageEvent.toJSON(message.msg); + } + return obj; + }, + + create, I>>(base?: I): RoomReq { + return RoomReq.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): RoomReq { + const message = createBaseRoomReq(); + message.id = object.id ?? ""; + message.join = (object.join !== undefined && object.join !== null) + ? RoomJoinEvent.fromPartial(object.join) + : undefined; + message.leave = (object.leave !== undefined && object.leave !== null) + ? RoomLeaveEvent.fromPartial(object.leave) + : undefined; + message.online = (object.online !== undefined && object.online !== null) + ? RoomOnlineEvent.fromPartial(object.online) + : undefined; + message.msg = (object.msg !== undefined && object.msg !== null) + ? RoomMessageEvent.fromPartial(object.msg) + : undefined; + return message; + }, +}; + +function createBaseRoomResp(): RoomResp { + return { id: "" }; +} + +export const RoomResp: MessageFns = { + encode(message: RoomResp, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.id !== "") { + writer.uint32(10).string(message.id); + } + if (message.join !== undefined) { + RoomJoinEvent.encode(message.join, writer.uint32(18).fork()).join(); + } + if (message.leave !== undefined) { + RoomLeaveEvent.encode(message.leave, writer.uint32(26).fork()).join(); + } + if (message.online !== undefined) { + RoomOnlineEvent.encode(message.online, writer.uint32(34).fork()).join(); + } + if (message.msg !== undefined) { + RoomMessageEvent.encode(message.msg, writer.uint32(42).fork()).join(); + } + if (message.err !== undefined) { + RoomErrorEvent.encode(message.err, writer.uint32(50).fork()).join(); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): RoomResp { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseRoomResp(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.id = reader.string(); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.join = RoomJoinEvent.decode(reader, reader.uint32()); + continue; + case 3: + if (tag !== 26) { + break; + } + + message.leave = RoomLeaveEvent.decode(reader, reader.uint32()); + continue; + case 4: + if (tag !== 34) { + break; + } + + message.online = RoomOnlineEvent.decode(reader, reader.uint32()); + continue; + case 5: + if (tag !== 42) { + break; + } + + message.msg = RoomMessageEvent.decode(reader, reader.uint32()); + continue; + case 6: + if (tag !== 50) { + break; + } + + message.err = RoomErrorEvent.decode(reader, reader.uint32()); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): RoomResp { + return { + id: isSet(object.id) ? globalThis.String(object.id) : "", + join: isSet(object.join) ? RoomJoinEvent.fromJSON(object.join) : undefined, + leave: isSet(object.leave) ? RoomLeaveEvent.fromJSON(object.leave) : undefined, + online: isSet(object.online) ? RoomOnlineEvent.fromJSON(object.online) : undefined, + msg: isSet(object.msg) ? RoomMessageEvent.fromJSON(object.msg) : undefined, + err: isSet(object.err) ? RoomErrorEvent.fromJSON(object.err) : undefined, + }; + }, + + toJSON(message: RoomResp): unknown { + const obj: any = {}; + if (message.id !== "") { + obj.id = message.id; + } + if (message.join !== undefined) { + obj.join = RoomJoinEvent.toJSON(message.join); + } + if (message.leave !== undefined) { + obj.leave = RoomLeaveEvent.toJSON(message.leave); + } + if (message.online !== undefined) { + obj.online = RoomOnlineEvent.toJSON(message.online); + } + if (message.msg !== undefined) { + obj.msg = RoomMessageEvent.toJSON(message.msg); + } + if (message.err !== undefined) { + obj.err = RoomErrorEvent.toJSON(message.err); + } + return obj; + }, + + create, I>>(base?: I): RoomResp { + return RoomResp.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): RoomResp { + const message = createBaseRoomResp(); + message.id = object.id ?? ""; + message.join = (object.join !== undefined && object.join !== null) + ? RoomJoinEvent.fromPartial(object.join) + : undefined; + message.leave = (object.leave !== undefined && object.leave !== null) + ? RoomLeaveEvent.fromPartial(object.leave) + : undefined; + message.online = (object.online !== undefined && object.online !== null) + ? RoomOnlineEvent.fromPartial(object.online) + : undefined; + message.msg = (object.msg !== undefined && object.msg !== null) + ? RoomMessageEvent.fromPartial(object.msg) + : undefined; + message.err = (object.err !== undefined && object.err !== null) + ? RoomErrorEvent.fromPartial(object.err) + : undefined; + return message; + }, +}; + +function createBaseRoomJoinEvent(): RoomJoinEvent { + return {}; +} + +export const RoomJoinEvent: MessageFns = { + encode(_: RoomJoinEvent, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): RoomJoinEvent { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseRoomJoinEvent(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(_: any): RoomJoinEvent { + return {}; + }, + + toJSON(_: RoomJoinEvent): unknown { + const obj: any = {}; + return obj; + }, + + create, I>>(base?: I): RoomJoinEvent { + return RoomJoinEvent.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(_: I): RoomJoinEvent { + const message = createBaseRoomJoinEvent(); + return message; + }, +}; + +function createBaseRoomLeaveEvent(): RoomLeaveEvent { + return {}; +} + +export const RoomLeaveEvent: MessageFns = { + encode(_: RoomLeaveEvent, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): RoomLeaveEvent { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseRoomLeaveEvent(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(_: any): RoomLeaveEvent { + return {}; + }, + + toJSON(_: RoomLeaveEvent): unknown { + const obj: any = {}; + return obj; + }, + + create, I>>(base?: I): RoomLeaveEvent { + return RoomLeaveEvent.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(_: I): RoomLeaveEvent { + const message = createBaseRoomLeaveEvent(); + return message; + }, +}; + +function createBaseRoomOnlineEvent(): RoomOnlineEvent { + return { online: 0 }; +} + +export const RoomOnlineEvent: MessageFns = { + encode(message: RoomOnlineEvent, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.online !== 0) { + writer.uint32(8).int32(message.online); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): RoomOnlineEvent { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseRoomOnlineEvent(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.online = reader.int32(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): RoomOnlineEvent { + return { online: isSet(object.online) ? globalThis.Number(object.online) : 0 }; + }, + + toJSON(message: RoomOnlineEvent): unknown { + const obj: any = {}; + if (message.online !== 0) { + obj.online = Math.round(message.online); + } + return obj; + }, + + create, I>>(base?: I): RoomOnlineEvent { + return RoomOnlineEvent.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): RoomOnlineEvent { + const message = createBaseRoomOnlineEvent(); + message.online = object.online ?? 0; + return message; + }, +}; + +function createBaseRoomMessageEvent(): RoomMessageEvent { + return { targetPath: "", body: undefined }; +} + +export const RoomMessageEvent: MessageFns = { + encode(message: RoomMessageEvent, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.targetPath !== "") { + writer.uint32(10).string(message.targetPath); + } + if (message.body !== undefined) { + Any.encode(message.body, writer.uint32(18).fork()).join(); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): RoomMessageEvent { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseRoomMessageEvent(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.targetPath = reader.string(); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.body = Any.decode(reader, reader.uint32()); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): RoomMessageEvent { + return { + targetPath: isSet(object.targetPath) ? globalThis.String(object.targetPath) : "", + body: isSet(object.body) ? Any.fromJSON(object.body) : undefined, + }; + }, + + toJSON(message: RoomMessageEvent): unknown { + const obj: any = {}; + if (message.targetPath !== "") { + obj.targetPath = message.targetPath; + } + if (message.body !== undefined) { + obj.body = Any.toJSON(message.body); + } + return obj; + }, + + create, I>>(base?: I): RoomMessageEvent { + return RoomMessageEvent.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): RoomMessageEvent { + const message = createBaseRoomMessageEvent(); + message.targetPath = object.targetPath ?? ""; + message.body = (object.body !== undefined && object.body !== null) ? Any.fromPartial(object.body) : undefined; + return message; + }, +}; + +function createBaseRoomErrorEvent(): RoomErrorEvent { + return { status: undefined }; +} + +export const RoomErrorEvent: MessageFns = { + encode(message: RoomErrorEvent, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.status !== undefined) { + Status.encode(message.status, writer.uint32(10).fork()).join(); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): RoomErrorEvent { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseRoomErrorEvent(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.status = Status.decode(reader, reader.uint32()); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): RoomErrorEvent { + return { status: isSet(object.status) ? Status.fromJSON(object.status) : undefined }; + }, + + toJSON(message: RoomErrorEvent): unknown { + const obj: any = {}; + if (message.status !== undefined) { + obj.status = Status.toJSON(message.status); + } + return obj; + }, + + create, I>>(base?: I): RoomErrorEvent { + return RoomErrorEvent.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): RoomErrorEvent { + const message = createBaseRoomErrorEvent(); + message.status = (object.status !== undefined && object.status !== null) + ? Status.fromPartial(object.status) + : undefined; + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | boolean | bigint | undefined; + +export type DeepPartial = T extends Builtin ? T + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } + : Partial; + +type KeysOfUnion = T extends T ? keyof T : never; +export type Exact = P extends Builtin ? P + : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; + +function isSet(value: any): boolean { + return value !== null && value !== undefined; +} + +export interface MessageFns { + encode(message: T, writer?: BinaryWriter): BinaryWriter; + decode(input: BinaryReader | Uint8Array, length?: number): T; + fromJSON(object: any): T; + toJSON(message: T): unknown; + create, I>>(base?: I): T; + fromPartial, I>>(object: I): T; +} diff --git a/src/io/com/bapis/bilibili/broadcast/v1/TargetPath.proto b/src/io/com/bapis/bilibili/broadcast/v1/TargetPath.proto new file mode 100644 index 0000000..ef290b4 --- /dev/null +++ b/src/io/com/bapis/bilibili/broadcast/v1/TargetPath.proto @@ -0,0 +1,9 @@ +syntax = "proto3"; + +package bilibili.broadcast.v1; + +/** 业务target_path */ +message TargetPath { + /** 需要订阅的target_paths */ + repeated string target_paths = 1; +} \ No newline at end of file diff --git a/src/io/com/bapis/bilibili/broadcast/v1/TargetPath.ts b/src/io/com/bapis/bilibili/broadcast/v1/TargetPath.ts new file mode 100644 index 0000000..6497afc --- /dev/null +++ b/src/io/com/bapis/bilibili/broadcast/v1/TargetPath.ts @@ -0,0 +1,98 @@ +// Code generated by protoc-gen-ts_proto. DO NOT EDIT. +// versions: +// protoc-gen-ts_proto v2.2.0 +// protoc v5.28.2 +// source: src/io/com/bapis/bilibili/broadcast/v1/TargetPath.proto + +/* eslint-disable */ +import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire"; + +export const protobufPackage = "bilibili.broadcast.v1"; + +/** 业务target_path */ +export interface TargetPath { + /** 需要订阅的target_paths */ + targetPaths: string[]; +} + +function createBaseTargetPath(): TargetPath { + return { targetPaths: [] }; +} + +export const TargetPath: MessageFns = { + encode(message: TargetPath, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + for (const v of message.targetPaths) { + writer.uint32(10).string(v!); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): TargetPath { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseTargetPath(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.targetPaths.push(reader.string()); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): TargetPath { + return { + targetPaths: globalThis.Array.isArray(object?.targetPaths) + ? object.targetPaths.map((e: any) => globalThis.String(e)) + : [], + }; + }, + + toJSON(message: TargetPath): unknown { + const obj: any = {}; + if (message.targetPaths?.length) { + obj.targetPaths = message.targetPaths; + } + return obj; + }, + + create, I>>(base?: I): TargetPath { + return TargetPath.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): TargetPath { + const message = createBaseTargetPath(); + message.targetPaths = object.targetPaths?.map((e) => e) || []; + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | boolean | bigint | undefined; + +export type DeepPartial = T extends Builtin ? T + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } + : Partial; + +type KeysOfUnion = T extends T ? keyof T : never; +export type Exact = P extends Builtin ? P + : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; + +export interface MessageFns { + encode(message: T, writer?: BinaryWriter): BinaryWriter; + decode(input: BinaryReader | Uint8Array, length?: number): T; + fromJSON(object: any): T; + toJSON(message: T): unknown; + create, I>>(base?: I): T; + fromPartial, I>>(object: I): T; +} diff --git a/src/io/com/bapis/bilibili/community/service/dm/v1/DmSegMobileReply.proto b/src/io/com/bapis/bilibili/community/service/dm/v1/DmSegMobileReply.proto new file mode 100644 index 0000000..db43370 --- /dev/null +++ b/src/io/com/bapis/bilibili/community/service/dm/v1/DmSegMobileReply.proto @@ -0,0 +1,104 @@ +syntax = "proto3"; + +package bilibili.community.service.dm.v1; + +/** 弹幕分片数据 */ +message DmSegMobileReply { + /** 弹幕列表 */ + repeated DanmakuElem elems = 1; + /** + * 弹幕区状态 + * | 0 | 1 | + * | :-: | :-: | + * | 打开 | 关闭弹幕区 | + */ + optional int32 state = 2; + /** ai打分 */ + optional DanmakuAIFlag ai_flag = 3; + /** 弹幕渐变色配置 */ + repeated DmColorful colorfulSrc = 5; +} + +/** 弹幕实例 */ +message DanmakuElem { + /** + * 弹幕id + * @deprecated 精度丢失 + */ + int64 id = 1; + /** 弹幕位置:/ms */ + optional int32 progress = 2; + /** + * 弹幕模式 + * | 1 | 4 | 5 | 6 | 7 | 8 | 9 | + * | :-: | :-: | :-: | :-: | :-: | :-: | :-: | + * | 普通 | 底部 | 顶部 | 逆向 | 高级 | 代码 | BAS | + */ + int32 mode = 3; + /** 弹幕字体 */ + int32 fontsize = 4; + /** 弹幕颜色 */ + uint32 color = 5; + /** 弹幕发送者crc32哈希 */ + string mid_hash = 6; + /** 弹幕文本内容 */ + optional string content = 7; + /** 弹幕发送时间 时间戳 */ + int64 ctime = 8; + /** 弹幕权重 越高显示优先级越高 */ + optional int32 weight = 9; + /** 弹幕动作 */ + optional string action = 10; + /** + * 弹幕池 + * | 0 | 1 | 2 | + * | :-: | :-: | :-: | + * | 普通弹幕 | 字幕弹幕 | 特殊弹幕 | + */ + optional int32 pool = 11; + /** 弹幕id字符串 */ + string id_str = 12; + /** + * 弹幕属性位 + * | 0 | 1 | 2 | + * | :-: | :-: | :-: | + * | 保护弹幕 | 直播弹幕 | 高赞弹幕 | + */ + optional int32 attr = 13; + /** 未知 */ + optional string animation = 22; + /** 弹幕渐变色 */ + optional DmColorfulType colorful = 24; + /** 弹幕oid */ + int64 oid = 26; +} + +/** 弹幕渐变色 */ +enum DmColorfulType { + /** 无 */ + NoneType = 0; + /** 大会员渐变色 */ + VipGradualColor = 60001; +} + +/** ai云屏蔽弹幕的配置 */ +message DanmakuAIFlag { + /** 云屏蔽等级 */ + repeated DanmakuFlag dm_flags = 1; +} + +/** 云屏蔽等级 */ +message DanmakuFlag { + /** dmid 弹幕id */ + int64 dmid = 1; + /** 弹幕分 */ + uint32 flag = 2; +} + +/** 弹幕渐变色配置 */ +message DmColorful { + /** 弹幕渐变色 */ + DmColorfulType type = 1; + /** 渐变色图片 */ + string src = 2; +} \ No newline at end of file diff --git a/src/io/com/bapis/bilibili/community/service/dm/v1/DmSegMobileReply.ts b/src/io/com/bapis/bilibili/community/service/dm/v1/DmSegMobileReply.ts new file mode 100644 index 0000000..f7918bb --- /dev/null +++ b/src/io/com/bapis/bilibili/community/service/dm/v1/DmSegMobileReply.ts @@ -0,0 +1,795 @@ +// Code generated by protoc-gen-ts_proto. DO NOT EDIT. +// versions: +// protoc-gen-ts_proto v2.2.0 +// protoc v5.28.2 +// source: src/io/com/bapis/bilibili/community/service/dm/v1/DmSegMobileReply.proto + +/* eslint-disable */ +import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire"; + +export const protobufPackage = "bilibili.community.service.dm.v1"; + +/** 弹幕渐变色 */ +export enum DmColorfulType { + /** NoneType - 无 */ + NoneType = 0, + /** VipGradualColor - 大会员渐变色 */ + VipGradualColor = 60001, + UNRECOGNIZED = -1, +} + +export function dmColorfulTypeFromJSON(object: any): DmColorfulType { + switch (object) { + case 0: + case "NoneType": + return DmColorfulType.NoneType; + case 60001: + case "VipGradualColor": + return DmColorfulType.VipGradualColor; + case -1: + case "UNRECOGNIZED": + default: + return DmColorfulType.UNRECOGNIZED; + } +} + +export function dmColorfulTypeToJSON(object: DmColorfulType): string { + switch (object) { + case DmColorfulType.NoneType: + return "NoneType"; + case DmColorfulType.VipGradualColor: + return "VipGradualColor"; + case DmColorfulType.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} + +/** 弹幕分片数据 */ +export interface DmSegMobileReply { + /** 弹幕列表 */ + elems: DanmakuElem[]; + /** + * 弹幕区状态 + * | 0 | 1 | + * | :-: | :-: | + * | 打开 | 关闭弹幕区 | + */ + state?: + | number + | undefined; + /** ai打分 */ + aiFlag?: + | DanmakuAIFlag + | undefined; + /** 弹幕渐变色配置 */ + colorfulSrc: DmColorful[]; +} + +/** 弹幕实例 */ +export interface DanmakuElem { + /** + * 弹幕id + * @deprecated 精度丢失 + */ + id: bigint; + /** 弹幕位置:/ms */ + progress?: + | number + | undefined; + /** + * 弹幕模式 + * | 1 | 4 | 5 | 6 | 7 | 8 | 9 | + * | :-: | :-: | :-: | :-: | :-: | :-: | :-: | + * | 普通 | 底部 | 顶部 | 逆向 | 高级 | 代码 | BAS | + */ + mode: number; + /** 弹幕字体 */ + fontsize: number; + /** 弹幕颜色 */ + color: number; + /** 弹幕发送者crc32哈希 */ + midHash: string; + /** 弹幕文本内容 */ + content?: + | string + | undefined; + /** 弹幕发送时间 时间戳 */ + ctime: bigint; + /** 弹幕权重 越高显示优先级越高 */ + weight?: + | number + | undefined; + /** 弹幕动作 */ + action?: + | string + | undefined; + /** + * 弹幕池 + * | 0 | 1 | 2 | + * | :-: | :-: | :-: | + * | 普通弹幕 | 字幕弹幕 | 特殊弹幕 | + */ + pool?: + | number + | undefined; + /** 弹幕id字符串 */ + idStr: string; + /** + * 弹幕属性位 + * | 0 | 1 | 2 | + * | :-: | :-: | :-: | + * | 保护弹幕 | 直播弹幕 | 高赞弹幕 | + */ + attr?: + | number + | undefined; + /** 未知 */ + animation?: + | string + | undefined; + /** 弹幕渐变色 */ + colorful?: + | DmColorfulType + | undefined; + /** 弹幕oid */ + oid: bigint; +} + +/** ai云屏蔽弹幕的配置 */ +export interface DanmakuAIFlag { + /** 云屏蔽等级 */ + dmFlags: DanmakuFlag[]; +} + +/** 云屏蔽等级 */ +export interface DanmakuFlag { + /** dmid 弹幕id */ + dmid: bigint; + /** 弹幕分 */ + flag: number; +} + +/** 弹幕渐变色配置 */ +export interface DmColorful { + /** 弹幕渐变色 */ + type: DmColorfulType; + /** 渐变色图片 */ + src: string; +} + +function createBaseDmSegMobileReply(): DmSegMobileReply { + return { elems: [], colorfulSrc: [] }; +} + +export const DmSegMobileReply: MessageFns = { + encode(message: DmSegMobileReply, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + for (const v of message.elems) { + DanmakuElem.encode(v!, writer.uint32(10).fork()).join(); + } + if (message.state !== undefined) { + writer.uint32(16).int32(message.state); + } + if (message.aiFlag !== undefined) { + DanmakuAIFlag.encode(message.aiFlag, writer.uint32(26).fork()).join(); + } + for (const v of message.colorfulSrc) { + DmColorful.encode(v!, writer.uint32(42).fork()).join(); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): DmSegMobileReply { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDmSegMobileReply(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.elems.push(DanmakuElem.decode(reader, reader.uint32())); + continue; + case 2: + if (tag !== 16) { + break; + } + + message.state = reader.int32(); + continue; + case 3: + if (tag !== 26) { + break; + } + + message.aiFlag = DanmakuAIFlag.decode(reader, reader.uint32()); + continue; + case 5: + if (tag !== 42) { + break; + } + + message.colorfulSrc.push(DmColorful.decode(reader, reader.uint32())); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): DmSegMobileReply { + return { + elems: globalThis.Array.isArray(object?.elems) ? object.elems.map((e: any) => DanmakuElem.fromJSON(e)) : [], + state: isSet(object.state) ? globalThis.Number(object.state) : undefined, + aiFlag: isSet(object.aiFlag) ? DanmakuAIFlag.fromJSON(object.aiFlag) : undefined, + colorfulSrc: globalThis.Array.isArray(object?.colorfulSrc) + ? object.colorfulSrc.map((e: any) => DmColorful.fromJSON(e)) + : [], + }; + }, + + toJSON(message: DmSegMobileReply): unknown { + const obj: any = {}; + if (message.elems?.length) { + obj.elems = message.elems.map((e) => DanmakuElem.toJSON(e)); + } + if (message.state !== undefined) { + obj.state = Math.round(message.state); + } + if (message.aiFlag !== undefined) { + obj.aiFlag = DanmakuAIFlag.toJSON(message.aiFlag); + } + if (message.colorfulSrc?.length) { + obj.colorfulSrc = message.colorfulSrc.map((e) => DmColorful.toJSON(e)); + } + return obj; + }, + + create, I>>(base?: I): DmSegMobileReply { + return DmSegMobileReply.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): DmSegMobileReply { + const message = createBaseDmSegMobileReply(); + message.elems = object.elems?.map((e) => DanmakuElem.fromPartial(e)) || []; + message.state = object.state ?? undefined; + message.aiFlag = (object.aiFlag !== undefined && object.aiFlag !== null) + ? DanmakuAIFlag.fromPartial(object.aiFlag) + : undefined; + message.colorfulSrc = object.colorfulSrc?.map((e) => DmColorful.fromPartial(e)) || []; + return message; + }, +}; + +function createBaseDanmakuElem(): DanmakuElem { + return { id: 0n, mode: 0, fontsize: 0, color: 0, midHash: "", ctime: 0n, idStr: "", oid: 0n }; +} + +export const DanmakuElem: MessageFns = { + encode(message: DanmakuElem, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.id !== 0n) { + if (BigInt.asIntN(64, message.id) !== message.id) { + throw new globalThis.Error("value provided for field message.id of type int64 too large"); + } + writer.uint32(8).int64(message.id); + } + if (message.progress !== undefined) { + writer.uint32(16).int32(message.progress); + } + if (message.mode !== 0) { + writer.uint32(24).int32(message.mode); + } + if (message.fontsize !== 0) { + writer.uint32(32).int32(message.fontsize); + } + if (message.color !== 0) { + writer.uint32(40).uint32(message.color); + } + if (message.midHash !== "") { + writer.uint32(50).string(message.midHash); + } + if (message.content !== undefined) { + writer.uint32(58).string(message.content); + } + if (message.ctime !== 0n) { + if (BigInt.asIntN(64, message.ctime) !== message.ctime) { + throw new globalThis.Error("value provided for field message.ctime of type int64 too large"); + } + writer.uint32(64).int64(message.ctime); + } + if (message.weight !== undefined) { + writer.uint32(72).int32(message.weight); + } + if (message.action !== undefined) { + writer.uint32(82).string(message.action); + } + if (message.pool !== undefined) { + writer.uint32(88).int32(message.pool); + } + if (message.idStr !== "") { + writer.uint32(98).string(message.idStr); + } + if (message.attr !== undefined) { + writer.uint32(104).int32(message.attr); + } + if (message.animation !== undefined) { + writer.uint32(178).string(message.animation); + } + if (message.colorful !== undefined) { + writer.uint32(192).int32(message.colorful); + } + if (message.oid !== 0n) { + if (BigInt.asIntN(64, message.oid) !== message.oid) { + throw new globalThis.Error("value provided for field message.oid of type int64 too large"); + } + writer.uint32(208).int64(message.oid); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): DanmakuElem { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDanmakuElem(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.id = reader.int64() as bigint; + continue; + case 2: + if (tag !== 16) { + break; + } + + message.progress = reader.int32(); + continue; + case 3: + if (tag !== 24) { + break; + } + + message.mode = reader.int32(); + continue; + case 4: + if (tag !== 32) { + break; + } + + message.fontsize = reader.int32(); + continue; + case 5: + if (tag !== 40) { + break; + } + + message.color = reader.uint32(); + continue; + case 6: + if (tag !== 50) { + break; + } + + message.midHash = reader.string(); + continue; + case 7: + if (tag !== 58) { + break; + } + + message.content = reader.string(); + continue; + case 8: + if (tag !== 64) { + break; + } + + message.ctime = reader.int64() as bigint; + continue; + case 9: + if (tag !== 72) { + break; + } + + message.weight = reader.int32(); + continue; + case 10: + if (tag !== 82) { + break; + } + + message.action = reader.string(); + continue; + case 11: + if (tag !== 88) { + break; + } + + message.pool = reader.int32(); + continue; + case 12: + if (tag !== 98) { + break; + } + + message.idStr = reader.string(); + continue; + case 13: + if (tag !== 104) { + break; + } + + message.attr = reader.int32(); + continue; + case 22: + if (tag !== 178) { + break; + } + + message.animation = reader.string(); + continue; + case 24: + if (tag !== 192) { + break; + } + + message.colorful = reader.int32() as any; + continue; + case 26: + if (tag !== 208) { + break; + } + + message.oid = reader.int64() as bigint; + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): DanmakuElem { + return { + id: isSet(object.id) ? BigInt(object.id) : 0n, + progress: isSet(object.progress) ? globalThis.Number(object.progress) : undefined, + mode: isSet(object.mode) ? globalThis.Number(object.mode) : 0, + fontsize: isSet(object.fontsize) ? globalThis.Number(object.fontsize) : 0, + color: isSet(object.color) ? globalThis.Number(object.color) : 0, + midHash: isSet(object.midHash) ? globalThis.String(object.midHash) : "", + content: isSet(object.content) ? globalThis.String(object.content) : undefined, + ctime: isSet(object.ctime) ? BigInt(object.ctime) : 0n, + weight: isSet(object.weight) ? globalThis.Number(object.weight) : undefined, + action: isSet(object.action) ? globalThis.String(object.action) : undefined, + pool: isSet(object.pool) ? globalThis.Number(object.pool) : undefined, + idStr: isSet(object.idStr) ? globalThis.String(object.idStr) : "", + attr: isSet(object.attr) ? globalThis.Number(object.attr) : undefined, + animation: isSet(object.animation) ? globalThis.String(object.animation) : undefined, + colorful: isSet(object.colorful) ? dmColorfulTypeFromJSON(object.colorful) : undefined, + oid: isSet(object.oid) ? BigInt(object.oid) : 0n, + }; + }, + + toJSON(message: DanmakuElem): unknown { + const obj: any = {}; + if (message.id !== 0n) { + obj.id = message.id.toString(); + } + if (message.progress !== undefined) { + obj.progress = Math.round(message.progress); + } + if (message.mode !== 0) { + obj.mode = Math.round(message.mode); + } + if (message.fontsize !== 0) { + obj.fontsize = Math.round(message.fontsize); + } + if (message.color !== 0) { + obj.color = Math.round(message.color); + } + if (message.midHash !== "") { + obj.midHash = message.midHash; + } + if (message.content !== undefined) { + obj.content = message.content; + } + if (message.ctime !== 0n) { + obj.ctime = message.ctime.toString(); + } + if (message.weight !== undefined) { + obj.weight = Math.round(message.weight); + } + if (message.action !== undefined) { + obj.action = message.action; + } + if (message.pool !== undefined) { + obj.pool = Math.round(message.pool); + } + if (message.idStr !== "") { + obj.idStr = message.idStr; + } + if (message.attr !== undefined) { + obj.attr = Math.round(message.attr); + } + if (message.animation !== undefined) { + obj.animation = message.animation; + } + if (message.colorful !== undefined) { + obj.colorful = dmColorfulTypeToJSON(message.colorful); + } + if (message.oid !== 0n) { + obj.oid = message.oid.toString(); + } + return obj; + }, + + create, I>>(base?: I): DanmakuElem { + return DanmakuElem.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): DanmakuElem { + const message = createBaseDanmakuElem(); + message.id = object.id ?? 0n; + message.progress = object.progress ?? undefined; + message.mode = object.mode ?? 0; + message.fontsize = object.fontsize ?? 0; + message.color = object.color ?? 0; + message.midHash = object.midHash ?? ""; + message.content = object.content ?? undefined; + message.ctime = object.ctime ?? 0n; + message.weight = object.weight ?? undefined; + message.action = object.action ?? undefined; + message.pool = object.pool ?? undefined; + message.idStr = object.idStr ?? ""; + message.attr = object.attr ?? undefined; + message.animation = object.animation ?? undefined; + message.colorful = object.colorful ?? undefined; + message.oid = object.oid ?? 0n; + return message; + }, +}; + +function createBaseDanmakuAIFlag(): DanmakuAIFlag { + return { dmFlags: [] }; +} + +export const DanmakuAIFlag: MessageFns = { + encode(message: DanmakuAIFlag, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + for (const v of message.dmFlags) { + DanmakuFlag.encode(v!, writer.uint32(10).fork()).join(); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): DanmakuAIFlag { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDanmakuAIFlag(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.dmFlags.push(DanmakuFlag.decode(reader, reader.uint32())); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): DanmakuAIFlag { + return { + dmFlags: globalThis.Array.isArray(object?.dmFlags) ? object.dmFlags.map((e: any) => DanmakuFlag.fromJSON(e)) : [], + }; + }, + + toJSON(message: DanmakuAIFlag): unknown { + const obj: any = {}; + if (message.dmFlags?.length) { + obj.dmFlags = message.dmFlags.map((e) => DanmakuFlag.toJSON(e)); + } + return obj; + }, + + create, I>>(base?: I): DanmakuAIFlag { + return DanmakuAIFlag.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): DanmakuAIFlag { + const message = createBaseDanmakuAIFlag(); + message.dmFlags = object.dmFlags?.map((e) => DanmakuFlag.fromPartial(e)) || []; + return message; + }, +}; + +function createBaseDanmakuFlag(): DanmakuFlag { + return { dmid: 0n, flag: 0 }; +} + +export const DanmakuFlag: MessageFns = { + encode(message: DanmakuFlag, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.dmid !== 0n) { + if (BigInt.asIntN(64, message.dmid) !== message.dmid) { + throw new globalThis.Error("value provided for field message.dmid of type int64 too large"); + } + writer.uint32(8).int64(message.dmid); + } + if (message.flag !== 0) { + writer.uint32(16).uint32(message.flag); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): DanmakuFlag { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDanmakuFlag(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.dmid = reader.int64() as bigint; + continue; + case 2: + if (tag !== 16) { + break; + } + + message.flag = reader.uint32(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): DanmakuFlag { + return { + dmid: isSet(object.dmid) ? BigInt(object.dmid) : 0n, + flag: isSet(object.flag) ? globalThis.Number(object.flag) : 0, + }; + }, + + toJSON(message: DanmakuFlag): unknown { + const obj: any = {}; + if (message.dmid !== 0n) { + obj.dmid = message.dmid.toString(); + } + if (message.flag !== 0) { + obj.flag = Math.round(message.flag); + } + return obj; + }, + + create, I>>(base?: I): DanmakuFlag { + return DanmakuFlag.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): DanmakuFlag { + const message = createBaseDanmakuFlag(); + message.dmid = object.dmid ?? 0n; + message.flag = object.flag ?? 0; + return message; + }, +}; + +function createBaseDmColorful(): DmColorful { + return { type: 0, src: "" }; +} + +export const DmColorful: MessageFns = { + encode(message: DmColorful, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.type !== 0) { + writer.uint32(8).int32(message.type); + } + if (message.src !== "") { + writer.uint32(18).string(message.src); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): DmColorful { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDmColorful(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.type = reader.int32() as any; + continue; + case 2: + if (tag !== 18) { + break; + } + + message.src = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): DmColorful { + return { + type: isSet(object.type) ? dmColorfulTypeFromJSON(object.type) : 0, + src: isSet(object.src) ? globalThis.String(object.src) : "", + }; + }, + + toJSON(message: DmColorful): unknown { + const obj: any = {}; + if (message.type !== 0) { + obj.type = dmColorfulTypeToJSON(message.type); + } + if (message.src !== "") { + obj.src = message.src; + } + return obj; + }, + + create, I>>(base?: I): DmColorful { + return DmColorful.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): DmColorful { + const message = createBaseDmColorful(); + message.type = object.type ?? 0; + message.src = object.src ?? ""; + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | boolean | bigint | undefined; + +export type DeepPartial = T extends Builtin ? T + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } + : Partial; + +type KeysOfUnion = T extends T ? keyof T : never; +export type Exact = P extends Builtin ? P + : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; + +function isSet(value: any): boolean { + return value !== null && value !== undefined; +} + +export interface MessageFns { + encode(message: T, writer?: BinaryWriter): BinaryWriter; + decode(input: BinaryReader | Uint8Array, length?: number): T; + fromJSON(object: any): T; + toJSON(message: T): unknown; + create, I>>(base?: I): T; + fromPartial, I>>(object: I): T; +} diff --git a/src/io/com/bapis/bilibili/community/service/dm/v1/DmWebViewReply.proto b/src/io/com/bapis/bilibili/community/service/dm/v1/DmWebViewReply.proto new file mode 100644 index 0000000..8eb8a18 --- /dev/null +++ b/src/io/com/bapis/bilibili/community/service/dm/v1/DmWebViewReply.proto @@ -0,0 +1,452 @@ +syntax = "proto3"; + +package bilibili.community.service.dm.v1; + +/** 弹幕数据 */ +message DmWebViewReply { + /** 弹幕区是否关闭 */ + optional int32 state = 1; + + optional string text = 2; + + optional string text_side = 3; + /** 分段弹幕配置 */ + DmSegConfig dm_sge = 4; + /** ai云屏蔽弹幕的配置 */ + DanmakuFlagConfig flag = 5; + /** 高级弹幕链接地址 (上传到bfs) */ + repeated string special_dms = 6; + /** check box 是否展示 */ + optional bool check_box = 7; + /** 弹幕数 */ + int64 count = 8; + /** 指令弹幕 */ + repeated CommandDm commandDms = 9; + /** 用户弹幕配置 */ + DanmuWebPlayerConfig player_config = 10; + /* 用户举报弹幕,cid维度屏蔽 */ + repeated string report_filter_content = 11; + + repeated Expressions expressions = 12; + + repeated PostPanel post_panel = 13; + + repeated string activity_metas = 14; + + repeated PostPanelV2 post_panelV2 = 15; + + repeated DmSubView sub_views = 16; + + optional QoeInfo qoe = 17; + + repeated DmMaskWall mask_walls = 18; +} + +message DmSegConfig { + + int64 page_size = 1; + + int64 total = 2; +} + +/** ai云屏蔽弹幕的配置 */ +message DanmakuFlagConfig { + /** 云屏蔽等级 */ + int32 rec_flag = 1; + /** 云屏蔽文案 */ + string rec_text = 2; + /** 云屏蔽开关 */ + int32 rec_switch = 3; +} + +/** 指令弹幕 */ +message CommandDm { + /** 弹幕id */ + int64 id = 1; + /** oid */ + int64 oid = 2; + /** mid */ + int64 mid = 3; + /** 弹幕指令 */ + string command = 4; + /** 弹幕内容 */ + string content = 5; + /** 弹幕位置:/ms */ + int32 progress = 6; + /** 创建时间 */ + string ctime = 7; + /** 修改时间 */ + string mtime = 8; + /** 扩展json数据 */ + string extra = 9; + /** 弹幕id_str */ + string idstr = 10; +} + +/** 具体数值意义 https://info.bilibili.co/pages/viewpage.action?pageId=114161867 */ +message DanmuWebPlayerConfig { + + bool dm_switch = 1; + + optional bool ai_switch = 2 ; + + int32 ai_level = 3 ; + + bool blocktop = 4 ; + + bool blockscroll = 5 ; + + bool blockbottom = 6 ; + + bool blockcolor = 7 ; + + bool blockspecial = 8 ; + + optional bool preventshade = 9 ; + + optional bool dmask = 10 ; + + float opacity = 11 ; + + optional int32 dmarea = 12 ; + + float speedplus = 13 ; + + float fontsize = 14 ; + + optional bool screensync = 15 ; + + optional bool speedsync = 16 ; + + string fontfamily = 17 ; + + bool bold = 18 ; + + optional int32 fontborder = 19 ; + + string draw_type = 20 ; + + int32 senior_mode_switch = 21; +} + +message Expressions { + + repeated Expression data = 1; +} + +message Expression { + + repeated string keyword = 1; + + string url = 2; + + repeated Period period = 3; +} + +message Period { + + optional int64 start = 1; + + int64 end = 2; +} + +message PostPanel { + + int64 start = 1; + + int64 end = 2; + + int64 priority = 3; + + int64 biz_id = 4; + + PostPanelBizType biz_type = 5; + + ClickButton click_button = 6; + + TextInput text_input = 7; + + CheckBox check_box = 8; + + Toast toast = 9; +} + + enum PostPanelBizType { + + PostPanelBizTypeNone = 0; + + PostPanelBizTypeEncourage = 1; + + PostPanelBizTypeFragClose = 4; + + PostPanelBizTypeColorDM = 2; +} + +message ClickButton { + + repeated string portrait_text = 1; + + repeated string landscape_text = 2; + + repeated string portrait_text_focus = 3; + + repeated string landscape_text_focus = 4; + + RenderType render_type = 5; + + bool show = 6; +} + +enum RenderType { + + RenderTypeNone = 0; + + RenderTypeSingle = 1; + + RenderTypeRotation = 2; +} + +message TextInput { + + repeated string portrait_placeholder = 1; + + repeated string landscape_placeholder = 2; + + RenderType render_type = 3; + + bool placeholder_post = 4; + + bool show = 5; + + PostStatus post_status = 7; +} + +enum PostStatus { + + PostStatusNormal = 0; + + PostStatusClosed = 1; +} + +message CheckBox { + + string text = 1; + + CheckboxType type = 2; + + bool default_value = 3; + + bool show = 4; +} + +enum CheckboxType { + + CheckboxTypeNone = 0; + + CheckboxTypeEncourage = 1; +} + +message Toast { + + string text = 1; + + int32 duration = 2; + + bool show = 3; + + Button button = 4; +} + +message Button { + + string text = 1; + + ToastFunctionType action = 2; +} + +enum ToastFunctionType { + + ToastFunctionTypeNone = 0; + + ToastFunctionTypePostPanel = 1; +} + +message PostPanelV2 { + + int64 start = 1; + + int64 end = 2; + + PostPanelBizType biz_type = 3; + + ClickButtonV2 click_button = 4; + + TextInputV2 text_input = 5; + + CheckBoxV2 check_box = 6; + + ToastV2 toast = 7; + + BubbleV2 bubble = 8; + + LabelV2 label = 9; + + PostStatus post_status = 10; +} + +message ClickButtonV2 { + + repeated string portrait_text = 1; + + repeated string landscape_text = 2; + + repeated string portrait_text_focus = 3; + + repeated string landscape_text_focus = 4; + + RenderType render_type = 5; + + bool text_input_post = 6; + + bool exposure_once = 7; + + ExposureType exposure_type = 8; +} + +enum ExposureType { + + ExposureTypeNone = 0; + + ExposureTypeDMSend = 1; +} + +message TextInputV2 { + + repeated string portrait_placeholder = 1; + + repeated string landscape_placeholder = 2; + + RenderType render_type = 3; + + bool placeholder_post = 4; + + int32 text_input_limit = 6; +} + +message CheckBoxV2 { + + string text = 1; + + CheckboxType type = 2; + + bool default_value = 3; +} + +message ToastV2 { + + string text = 1; + + int32 duration = 2; + + ToastButtonV2 toast_buttonV2 = 3; +} + +message ToastButtonV2 { + + string text = 1; + + ToastFunctionType action = 2; +} + +message BubbleV2 { + + string text = 1; + + string url = 2; + + BubbleType bubble_type = 3; + + bool exposure_once = 4; + + ExposureType exposure_type = 5; +} + +enum BubbleType { + + BubbleTypeNone = 0; + + BubbleTypeClickButton = 1; + + BubbleTypeDmSettingPanel = 2; +} + +message LabelV2 { + + string title = 1; + + repeated string content = 2; + + bool exposure_once = 3; + + ExposureType exposure_type = 4; +} + +message DmSubView { + + int32 type = 1; + + int64 oid = 2; + + int64 pid = 3; + + repeated PostPanelV2 post_panel_2 = 4; +} + +message QoeInfo { + + string info = 1; +} + +message DmMaskWall { + + int64 start = 1; + + int64 end = 2; + + string content = 3; + + DmMaskWallContentType content_type = 4; + + DmMaskWallBizType biz_type = 5; + + repeated DmMaskWallContent contents = 6; +} + +enum DmMaskWallContentType { + + DmMaskWallContentTypeUnknown = 0; + + DmMaskWallContentTypeText = 1; + + DmMaskWallContentTypePic = 2; +} + +enum DmMaskWallBizType { + + DmMaskWallBizTypeUnknown = 0; + + DmMaskWallBizTypeOGV = 1; + + DmMaskWallBizTypeBizPic = 2; + + DmMaskWallBizTypeMute = 3; + + DmMaskWallBizTypeRecord = 4; +} + +message DmMaskWallContent { + + DmMaskWallContentType type = 1; + + string content = 2; +} \ No newline at end of file diff --git a/src/io/com/bapis/bilibili/community/service/dm/v1/DmWebViewReply.ts b/src/io/com/bapis/bilibili/community/service/dm/v1/DmWebViewReply.ts new file mode 100644 index 0000000..21e4dd4 --- /dev/null +++ b/src/io/com/bapis/bilibili/community/service/dm/v1/DmWebViewReply.ts @@ -0,0 +1,4156 @@ +// Code generated by protoc-gen-ts_proto. DO NOT EDIT. +// versions: +// protoc-gen-ts_proto v2.2.0 +// protoc v5.28.2 +// source: src/io/com/bapis/bilibili/community/service/dm/v1/DmWebViewReply.proto + +/* eslint-disable */ +import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire"; + +export const protobufPackage = "bilibili.community.service.dm.v1"; + +export enum PostPanelBizType { + PostPanelBizTypeNone = 0, + PostPanelBizTypeEncourage = 1, + PostPanelBizTypeFragClose = 4, + PostPanelBizTypeColorDM = 2, + UNRECOGNIZED = -1, +} + +export function postPanelBizTypeFromJSON(object: any): PostPanelBizType { + switch (object) { + case 0: + case "PostPanelBizTypeNone": + return PostPanelBizType.PostPanelBizTypeNone; + case 1: + case "PostPanelBizTypeEncourage": + return PostPanelBizType.PostPanelBizTypeEncourage; + case 4: + case "PostPanelBizTypeFragClose": + return PostPanelBizType.PostPanelBizTypeFragClose; + case 2: + case "PostPanelBizTypeColorDM": + return PostPanelBizType.PostPanelBizTypeColorDM; + case -1: + case "UNRECOGNIZED": + default: + return PostPanelBizType.UNRECOGNIZED; + } +} + +export function postPanelBizTypeToJSON(object: PostPanelBizType): string { + switch (object) { + case PostPanelBizType.PostPanelBizTypeNone: + return "PostPanelBizTypeNone"; + case PostPanelBizType.PostPanelBizTypeEncourage: + return "PostPanelBizTypeEncourage"; + case PostPanelBizType.PostPanelBizTypeFragClose: + return "PostPanelBizTypeFragClose"; + case PostPanelBizType.PostPanelBizTypeColorDM: + return "PostPanelBizTypeColorDM"; + case PostPanelBizType.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} + +export enum RenderType { + RenderTypeNone = 0, + RenderTypeSingle = 1, + RenderTypeRotation = 2, + UNRECOGNIZED = -1, +} + +export function renderTypeFromJSON(object: any): RenderType { + switch (object) { + case 0: + case "RenderTypeNone": + return RenderType.RenderTypeNone; + case 1: + case "RenderTypeSingle": + return RenderType.RenderTypeSingle; + case 2: + case "RenderTypeRotation": + return RenderType.RenderTypeRotation; + case -1: + case "UNRECOGNIZED": + default: + return RenderType.UNRECOGNIZED; + } +} + +export function renderTypeToJSON(object: RenderType): string { + switch (object) { + case RenderType.RenderTypeNone: + return "RenderTypeNone"; + case RenderType.RenderTypeSingle: + return "RenderTypeSingle"; + case RenderType.RenderTypeRotation: + return "RenderTypeRotation"; + case RenderType.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} + +export enum PostStatus { + PostStatusNormal = 0, + PostStatusClosed = 1, + UNRECOGNIZED = -1, +} + +export function postStatusFromJSON(object: any): PostStatus { + switch (object) { + case 0: + case "PostStatusNormal": + return PostStatus.PostStatusNormal; + case 1: + case "PostStatusClosed": + return PostStatus.PostStatusClosed; + case -1: + case "UNRECOGNIZED": + default: + return PostStatus.UNRECOGNIZED; + } +} + +export function postStatusToJSON(object: PostStatus): string { + switch (object) { + case PostStatus.PostStatusNormal: + return "PostStatusNormal"; + case PostStatus.PostStatusClosed: + return "PostStatusClosed"; + case PostStatus.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} + +export enum CheckboxType { + CheckboxTypeNone = 0, + CheckboxTypeEncourage = 1, + UNRECOGNIZED = -1, +} + +export function checkboxTypeFromJSON(object: any): CheckboxType { + switch (object) { + case 0: + case "CheckboxTypeNone": + return CheckboxType.CheckboxTypeNone; + case 1: + case "CheckboxTypeEncourage": + return CheckboxType.CheckboxTypeEncourage; + case -1: + case "UNRECOGNIZED": + default: + return CheckboxType.UNRECOGNIZED; + } +} + +export function checkboxTypeToJSON(object: CheckboxType): string { + switch (object) { + case CheckboxType.CheckboxTypeNone: + return "CheckboxTypeNone"; + case CheckboxType.CheckboxTypeEncourage: + return "CheckboxTypeEncourage"; + case CheckboxType.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} + +export enum ToastFunctionType { + ToastFunctionTypeNone = 0, + ToastFunctionTypePostPanel = 1, + UNRECOGNIZED = -1, +} + +export function toastFunctionTypeFromJSON(object: any): ToastFunctionType { + switch (object) { + case 0: + case "ToastFunctionTypeNone": + return ToastFunctionType.ToastFunctionTypeNone; + case 1: + case "ToastFunctionTypePostPanel": + return ToastFunctionType.ToastFunctionTypePostPanel; + case -1: + case "UNRECOGNIZED": + default: + return ToastFunctionType.UNRECOGNIZED; + } +} + +export function toastFunctionTypeToJSON(object: ToastFunctionType): string { + switch (object) { + case ToastFunctionType.ToastFunctionTypeNone: + return "ToastFunctionTypeNone"; + case ToastFunctionType.ToastFunctionTypePostPanel: + return "ToastFunctionTypePostPanel"; + case ToastFunctionType.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} + +export enum ExposureType { + ExposureTypeNone = 0, + ExposureTypeDMSend = 1, + UNRECOGNIZED = -1, +} + +export function exposureTypeFromJSON(object: any): ExposureType { + switch (object) { + case 0: + case "ExposureTypeNone": + return ExposureType.ExposureTypeNone; + case 1: + case "ExposureTypeDMSend": + return ExposureType.ExposureTypeDMSend; + case -1: + case "UNRECOGNIZED": + default: + return ExposureType.UNRECOGNIZED; + } +} + +export function exposureTypeToJSON(object: ExposureType): string { + switch (object) { + case ExposureType.ExposureTypeNone: + return "ExposureTypeNone"; + case ExposureType.ExposureTypeDMSend: + return "ExposureTypeDMSend"; + case ExposureType.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} + +export enum BubbleType { + BubbleTypeNone = 0, + BubbleTypeClickButton = 1, + BubbleTypeDmSettingPanel = 2, + UNRECOGNIZED = -1, +} + +export function bubbleTypeFromJSON(object: any): BubbleType { + switch (object) { + case 0: + case "BubbleTypeNone": + return BubbleType.BubbleTypeNone; + case 1: + case "BubbleTypeClickButton": + return BubbleType.BubbleTypeClickButton; + case 2: + case "BubbleTypeDmSettingPanel": + return BubbleType.BubbleTypeDmSettingPanel; + case -1: + case "UNRECOGNIZED": + default: + return BubbleType.UNRECOGNIZED; + } +} + +export function bubbleTypeToJSON(object: BubbleType): string { + switch (object) { + case BubbleType.BubbleTypeNone: + return "BubbleTypeNone"; + case BubbleType.BubbleTypeClickButton: + return "BubbleTypeClickButton"; + case BubbleType.BubbleTypeDmSettingPanel: + return "BubbleTypeDmSettingPanel"; + case BubbleType.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} + +export enum DmMaskWallContentType { + DmMaskWallContentTypeUnknown = 0, + DmMaskWallContentTypeText = 1, + DmMaskWallContentTypePic = 2, + UNRECOGNIZED = -1, +} + +export function dmMaskWallContentTypeFromJSON(object: any): DmMaskWallContentType { + switch (object) { + case 0: + case "DmMaskWallContentTypeUnknown": + return DmMaskWallContentType.DmMaskWallContentTypeUnknown; + case 1: + case "DmMaskWallContentTypeText": + return DmMaskWallContentType.DmMaskWallContentTypeText; + case 2: + case "DmMaskWallContentTypePic": + return DmMaskWallContentType.DmMaskWallContentTypePic; + case -1: + case "UNRECOGNIZED": + default: + return DmMaskWallContentType.UNRECOGNIZED; + } +} + +export function dmMaskWallContentTypeToJSON(object: DmMaskWallContentType): string { + switch (object) { + case DmMaskWallContentType.DmMaskWallContentTypeUnknown: + return "DmMaskWallContentTypeUnknown"; + case DmMaskWallContentType.DmMaskWallContentTypeText: + return "DmMaskWallContentTypeText"; + case DmMaskWallContentType.DmMaskWallContentTypePic: + return "DmMaskWallContentTypePic"; + case DmMaskWallContentType.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} + +export enum DmMaskWallBizType { + DmMaskWallBizTypeUnknown = 0, + DmMaskWallBizTypeOGV = 1, + DmMaskWallBizTypeBizPic = 2, + DmMaskWallBizTypeMute = 3, + DmMaskWallBizTypeRecord = 4, + UNRECOGNIZED = -1, +} + +export function dmMaskWallBizTypeFromJSON(object: any): DmMaskWallBizType { + switch (object) { + case 0: + case "DmMaskWallBizTypeUnknown": + return DmMaskWallBizType.DmMaskWallBizTypeUnknown; + case 1: + case "DmMaskWallBizTypeOGV": + return DmMaskWallBizType.DmMaskWallBizTypeOGV; + case 2: + case "DmMaskWallBizTypeBizPic": + return DmMaskWallBizType.DmMaskWallBizTypeBizPic; + case 3: + case "DmMaskWallBizTypeMute": + return DmMaskWallBizType.DmMaskWallBizTypeMute; + case 4: + case "DmMaskWallBizTypeRecord": + return DmMaskWallBizType.DmMaskWallBizTypeRecord; + case -1: + case "UNRECOGNIZED": + default: + return DmMaskWallBizType.UNRECOGNIZED; + } +} + +export function dmMaskWallBizTypeToJSON(object: DmMaskWallBizType): string { + switch (object) { + case DmMaskWallBizType.DmMaskWallBizTypeUnknown: + return "DmMaskWallBizTypeUnknown"; + case DmMaskWallBizType.DmMaskWallBizTypeOGV: + return "DmMaskWallBizTypeOGV"; + case DmMaskWallBizType.DmMaskWallBizTypeBizPic: + return "DmMaskWallBizTypeBizPic"; + case DmMaskWallBizType.DmMaskWallBizTypeMute: + return "DmMaskWallBizTypeMute"; + case DmMaskWallBizType.DmMaskWallBizTypeRecord: + return "DmMaskWallBizTypeRecord"; + case DmMaskWallBizType.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} + +/** 弹幕数据 */ +export interface DmWebViewReply { + /** 弹幕区是否关闭 */ + state?: number | undefined; + text?: string | undefined; + textSide?: + | string + | undefined; + /** 分段弹幕配置 */ + dmSge: + | DmSegConfig + | undefined; + /** ai云屏蔽弹幕的配置 */ + flag: + | DanmakuFlagConfig + | undefined; + /** 高级弹幕链接地址 (上传到bfs) */ + specialDms: string[]; + /** check box 是否展示 */ + checkBox?: + | boolean + | undefined; + /** 弹幕数 */ + count: bigint; + /** 指令弹幕 */ + commandDms: CommandDm[]; + /** 用户弹幕配置 */ + playerConfig: + | DanmuWebPlayerConfig + | undefined; + /** 用户举报弹幕,cid维度屏蔽 */ + reportFilterContent: string[]; + expressions: Expressions[]; + postPanel: PostPanel[]; + activityMetas: string[]; + postPanelV2: PostPanelV2[]; + subViews: DmSubView[]; + qoe?: QoeInfo | undefined; + maskWalls: DmMaskWall[]; +} + +export interface DmSegConfig { + pageSize: bigint; + total: bigint; +} + +/** ai云屏蔽弹幕的配置 */ +export interface DanmakuFlagConfig { + /** 云屏蔽等级 */ + recFlag: number; + /** 云屏蔽文案 */ + recText: string; + /** 云屏蔽开关 */ + recSwitch: number; +} + +/** 指令弹幕 */ +export interface CommandDm { + /** 弹幕id */ + id: bigint; + /** oid */ + oid: bigint; + /** mid */ + mid: bigint; + /** 弹幕指令 */ + command: string; + /** 弹幕内容 */ + content: string; + /** 弹幕位置:/ms */ + progress: number; + /** 创建时间 */ + ctime: string; + /** 修改时间 */ + mtime: string; + /** 扩展json数据 */ + extra: string; + /** 弹幕id_str */ + idstr: string; +} + +/** 具体数值意义 https://info.bilibili.co/pages/viewpage.action?pageId=114161867 */ +export interface DanmuWebPlayerConfig { + dmSwitch: boolean; + aiSwitch?: boolean | undefined; + aiLevel: number; + blocktop: boolean; + blockscroll: boolean; + blockbottom: boolean; + blockcolor: boolean; + blockspecial: boolean; + preventshade?: boolean | undefined; + dmask?: boolean | undefined; + opacity: number; + dmarea?: number | undefined; + speedplus: number; + fontsize: number; + screensync?: boolean | undefined; + speedsync?: boolean | undefined; + fontfamily: string; + bold: boolean; + fontborder?: number | undefined; + drawType: string; + seniorModeSwitch: number; +} + +export interface Expressions { + data: Expression[]; +} + +export interface Expression { + keyword: string[]; + url: string; + period: Period[]; +} + +export interface Period { + start?: bigint | undefined; + end: bigint; +} + +export interface PostPanel { + start: bigint; + end: bigint; + priority: bigint; + bizId: bigint; + bizType: PostPanelBizType; + clickButton: ClickButton | undefined; + textInput: TextInput | undefined; + checkBox: CheckBox | undefined; + toast: Toast | undefined; +} + +export interface ClickButton { + portraitText: string[]; + landscapeText: string[]; + portraitTextFocus: string[]; + landscapeTextFocus: string[]; + renderType: RenderType; + show: boolean; +} + +export interface TextInput { + portraitPlaceholder: string[]; + landscapePlaceholder: string[]; + renderType: RenderType; + placeholderPost: boolean; + show: boolean; + postStatus: PostStatus; +} + +export interface CheckBox { + text: string; + type: CheckboxType; + defaultValue: boolean; + show: boolean; +} + +export interface Toast { + text: string; + duration: number; + show: boolean; + button: Button | undefined; +} + +export interface Button { + text: string; + action: ToastFunctionType; +} + +export interface PostPanelV2 { + start: bigint; + end: bigint; + bizType: PostPanelBizType; + clickButton: ClickButtonV2 | undefined; + textInput: TextInputV2 | undefined; + checkBox: CheckBoxV2 | undefined; + toast: ToastV2 | undefined; + bubble: BubbleV2 | undefined; + label: LabelV2 | undefined; + postStatus: PostStatus; +} + +export interface ClickButtonV2 { + portraitText: string[]; + landscapeText: string[]; + portraitTextFocus: string[]; + landscapeTextFocus: string[]; + renderType: RenderType; + textInputPost: boolean; + exposureOnce: boolean; + exposureType: ExposureType; +} + +export interface TextInputV2 { + portraitPlaceholder: string[]; + landscapePlaceholder: string[]; + renderType: RenderType; + placeholderPost: boolean; + textInputLimit: number; +} + +export interface CheckBoxV2 { + text: string; + type: CheckboxType; + defaultValue: boolean; +} + +export interface ToastV2 { + text: string; + duration: number; + toastButtonV2: ToastButtonV2 | undefined; +} + +export interface ToastButtonV2 { + text: string; + action: ToastFunctionType; +} + +export interface BubbleV2 { + text: string; + url: string; + bubbleType: BubbleType; + exposureOnce: boolean; + exposureType: ExposureType; +} + +export interface LabelV2 { + title: string; + content: string[]; + exposureOnce: boolean; + exposureType: ExposureType; +} + +export interface DmSubView { + type: number; + oid: bigint; + pid: bigint; + postPanel2: PostPanelV2[]; +} + +export interface QoeInfo { + info: string; +} + +export interface DmMaskWall { + start: bigint; + end: bigint; + content: string; + contentType: DmMaskWallContentType; + bizType: DmMaskWallBizType; + contents: DmMaskWallContent[]; +} + +export interface DmMaskWallContent { + type: DmMaskWallContentType; + content: string; +} + +function createBaseDmWebViewReply(): DmWebViewReply { + return { + dmSge: undefined, + flag: undefined, + specialDms: [], + count: 0n, + commandDms: [], + playerConfig: undefined, + reportFilterContent: [], + expressions: [], + postPanel: [], + activityMetas: [], + postPanelV2: [], + subViews: [], + maskWalls: [], + }; +} + +export const DmWebViewReply: MessageFns = { + encode(message: DmWebViewReply, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.state !== undefined) { + writer.uint32(8).int32(message.state); + } + if (message.text !== undefined) { + writer.uint32(18).string(message.text); + } + if (message.textSide !== undefined) { + writer.uint32(26).string(message.textSide); + } + if (message.dmSge !== undefined) { + DmSegConfig.encode(message.dmSge, writer.uint32(34).fork()).join(); + } + if (message.flag !== undefined) { + DanmakuFlagConfig.encode(message.flag, writer.uint32(42).fork()).join(); + } + for (const v of message.specialDms) { + writer.uint32(50).string(v!); + } + if (message.checkBox !== undefined) { + writer.uint32(56).bool(message.checkBox); + } + if (message.count !== 0n) { + if (BigInt.asIntN(64, message.count) !== message.count) { + throw new globalThis.Error("value provided for field message.count of type int64 too large"); + } + writer.uint32(64).int64(message.count); + } + for (const v of message.commandDms) { + CommandDm.encode(v!, writer.uint32(74).fork()).join(); + } + if (message.playerConfig !== undefined) { + DanmuWebPlayerConfig.encode(message.playerConfig, writer.uint32(82).fork()).join(); + } + for (const v of message.reportFilterContent) { + writer.uint32(90).string(v!); + } + for (const v of message.expressions) { + Expressions.encode(v!, writer.uint32(98).fork()).join(); + } + for (const v of message.postPanel) { + PostPanel.encode(v!, writer.uint32(106).fork()).join(); + } + for (const v of message.activityMetas) { + writer.uint32(114).string(v!); + } + for (const v of message.postPanelV2) { + PostPanelV2.encode(v!, writer.uint32(122).fork()).join(); + } + for (const v of message.subViews) { + DmSubView.encode(v!, writer.uint32(130).fork()).join(); + } + if (message.qoe !== undefined) { + QoeInfo.encode(message.qoe, writer.uint32(138).fork()).join(); + } + for (const v of message.maskWalls) { + DmMaskWall.encode(v!, writer.uint32(146).fork()).join(); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): DmWebViewReply { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDmWebViewReply(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.state = reader.int32(); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.text = reader.string(); + continue; + case 3: + if (tag !== 26) { + break; + } + + message.textSide = reader.string(); + continue; + case 4: + if (tag !== 34) { + break; + } + + message.dmSge = DmSegConfig.decode(reader, reader.uint32()); + continue; + case 5: + if (tag !== 42) { + break; + } + + message.flag = DanmakuFlagConfig.decode(reader, reader.uint32()); + continue; + case 6: + if (tag !== 50) { + break; + } + + message.specialDms.push(reader.string()); + continue; + case 7: + if (tag !== 56) { + break; + } + + message.checkBox = reader.bool(); + continue; + case 8: + if (tag !== 64) { + break; + } + + message.count = reader.int64() as bigint; + continue; + case 9: + if (tag !== 74) { + break; + } + + message.commandDms.push(CommandDm.decode(reader, reader.uint32())); + continue; + case 10: + if (tag !== 82) { + break; + } + + message.playerConfig = DanmuWebPlayerConfig.decode(reader, reader.uint32()); + continue; + case 11: + if (tag !== 90) { + break; + } + + message.reportFilterContent.push(reader.string()); + continue; + case 12: + if (tag !== 98) { + break; + } + + message.expressions.push(Expressions.decode(reader, reader.uint32())); + continue; + case 13: + if (tag !== 106) { + break; + } + + message.postPanel.push(PostPanel.decode(reader, reader.uint32())); + continue; + case 14: + if (tag !== 114) { + break; + } + + message.activityMetas.push(reader.string()); + continue; + case 15: + if (tag !== 122) { + break; + } + + message.postPanelV2.push(PostPanelV2.decode(reader, reader.uint32())); + continue; + case 16: + if (tag !== 130) { + break; + } + + message.subViews.push(DmSubView.decode(reader, reader.uint32())); + continue; + case 17: + if (tag !== 138) { + break; + } + + message.qoe = QoeInfo.decode(reader, reader.uint32()); + continue; + case 18: + if (tag !== 146) { + break; + } + + message.maskWalls.push(DmMaskWall.decode(reader, reader.uint32())); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): DmWebViewReply { + return { + state: isSet(object.state) ? globalThis.Number(object.state) : undefined, + text: isSet(object.text) ? globalThis.String(object.text) : undefined, + textSide: isSet(object.textSide) ? globalThis.String(object.textSide) : undefined, + dmSge: isSet(object.dmSge) ? DmSegConfig.fromJSON(object.dmSge) : undefined, + flag: isSet(object.flag) ? DanmakuFlagConfig.fromJSON(object.flag) : undefined, + specialDms: globalThis.Array.isArray(object?.specialDms) + ? object.specialDms.map((e: any) => globalThis.String(e)) + : [], + checkBox: isSet(object.checkBox) ? globalThis.Boolean(object.checkBox) : undefined, + count: isSet(object.count) ? BigInt(object.count) : 0n, + commandDms: globalThis.Array.isArray(object?.commandDms) + ? object.commandDms.map((e: any) => CommandDm.fromJSON(e)) + : [], + playerConfig: isSet(object.playerConfig) ? DanmuWebPlayerConfig.fromJSON(object.playerConfig) : undefined, + reportFilterContent: globalThis.Array.isArray(object?.reportFilterContent) + ? object.reportFilterContent.map((e: any) => globalThis.String(e)) + : [], + expressions: globalThis.Array.isArray(object?.expressions) + ? object.expressions.map((e: any) => Expressions.fromJSON(e)) + : [], + postPanel: globalThis.Array.isArray(object?.postPanel) + ? object.postPanel.map((e: any) => PostPanel.fromJSON(e)) + : [], + activityMetas: globalThis.Array.isArray(object?.activityMetas) + ? object.activityMetas.map((e: any) => globalThis.String(e)) + : [], + postPanelV2: globalThis.Array.isArray(object?.postPanelV2) + ? object.postPanelV2.map((e: any) => PostPanelV2.fromJSON(e)) + : [], + subViews: globalThis.Array.isArray(object?.subViews) + ? object.subViews.map((e: any) => DmSubView.fromJSON(e)) + : [], + qoe: isSet(object.qoe) ? QoeInfo.fromJSON(object.qoe) : undefined, + maskWalls: globalThis.Array.isArray(object?.maskWalls) + ? object.maskWalls.map((e: any) => DmMaskWall.fromJSON(e)) + : [], + }; + }, + + toJSON(message: DmWebViewReply): unknown { + const obj: any = {}; + if (message.state !== undefined) { + obj.state = Math.round(message.state); + } + if (message.text !== undefined) { + obj.text = message.text; + } + if (message.textSide !== undefined) { + obj.textSide = message.textSide; + } + if (message.dmSge !== undefined) { + obj.dmSge = DmSegConfig.toJSON(message.dmSge); + } + if (message.flag !== undefined) { + obj.flag = DanmakuFlagConfig.toJSON(message.flag); + } + if (message.specialDms?.length) { + obj.specialDms = message.specialDms; + } + if (message.checkBox !== undefined) { + obj.checkBox = message.checkBox; + } + if (message.count !== 0n) { + obj.count = message.count.toString(); + } + if (message.commandDms?.length) { + obj.commandDms = message.commandDms.map((e) => CommandDm.toJSON(e)); + } + if (message.playerConfig !== undefined) { + obj.playerConfig = DanmuWebPlayerConfig.toJSON(message.playerConfig); + } + if (message.reportFilterContent?.length) { + obj.reportFilterContent = message.reportFilterContent; + } + if (message.expressions?.length) { + obj.expressions = message.expressions.map((e) => Expressions.toJSON(e)); + } + if (message.postPanel?.length) { + obj.postPanel = message.postPanel.map((e) => PostPanel.toJSON(e)); + } + if (message.activityMetas?.length) { + obj.activityMetas = message.activityMetas; + } + if (message.postPanelV2?.length) { + obj.postPanelV2 = message.postPanelV2.map((e) => PostPanelV2.toJSON(e)); + } + if (message.subViews?.length) { + obj.subViews = message.subViews.map((e) => DmSubView.toJSON(e)); + } + if (message.qoe !== undefined) { + obj.qoe = QoeInfo.toJSON(message.qoe); + } + if (message.maskWalls?.length) { + obj.maskWalls = message.maskWalls.map((e) => DmMaskWall.toJSON(e)); + } + return obj; + }, + + create, I>>(base?: I): DmWebViewReply { + return DmWebViewReply.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): DmWebViewReply { + const message = createBaseDmWebViewReply(); + message.state = object.state ?? undefined; + message.text = object.text ?? undefined; + message.textSide = object.textSide ?? undefined; + message.dmSge = (object.dmSge !== undefined && object.dmSge !== null) + ? DmSegConfig.fromPartial(object.dmSge) + : undefined; + message.flag = (object.flag !== undefined && object.flag !== null) + ? DanmakuFlagConfig.fromPartial(object.flag) + : undefined; + message.specialDms = object.specialDms?.map((e) => e) || []; + message.checkBox = object.checkBox ?? undefined; + message.count = object.count ?? 0n; + message.commandDms = object.commandDms?.map((e) => CommandDm.fromPartial(e)) || []; + message.playerConfig = (object.playerConfig !== undefined && object.playerConfig !== null) + ? DanmuWebPlayerConfig.fromPartial(object.playerConfig) + : undefined; + message.reportFilterContent = object.reportFilterContent?.map((e) => e) || []; + message.expressions = object.expressions?.map((e) => Expressions.fromPartial(e)) || []; + message.postPanel = object.postPanel?.map((e) => PostPanel.fromPartial(e)) || []; + message.activityMetas = object.activityMetas?.map((e) => e) || []; + message.postPanelV2 = object.postPanelV2?.map((e) => PostPanelV2.fromPartial(e)) || []; + message.subViews = object.subViews?.map((e) => DmSubView.fromPartial(e)) || []; + message.qoe = (object.qoe !== undefined && object.qoe !== null) ? QoeInfo.fromPartial(object.qoe) : undefined; + message.maskWalls = object.maskWalls?.map((e) => DmMaskWall.fromPartial(e)) || []; + return message; + }, +}; + +function createBaseDmSegConfig(): DmSegConfig { + return { pageSize: 0n, total: 0n }; +} + +export const DmSegConfig: MessageFns = { + encode(message: DmSegConfig, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.pageSize !== 0n) { + if (BigInt.asIntN(64, message.pageSize) !== message.pageSize) { + throw new globalThis.Error("value provided for field message.pageSize of type int64 too large"); + } + writer.uint32(8).int64(message.pageSize); + } + if (message.total !== 0n) { + if (BigInt.asIntN(64, message.total) !== message.total) { + throw new globalThis.Error("value provided for field message.total of type int64 too large"); + } + writer.uint32(16).int64(message.total); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): DmSegConfig { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDmSegConfig(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.pageSize = reader.int64() as bigint; + continue; + case 2: + if (tag !== 16) { + break; + } + + message.total = reader.int64() as bigint; + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): DmSegConfig { + return { + pageSize: isSet(object.pageSize) ? BigInt(object.pageSize) : 0n, + total: isSet(object.total) ? BigInt(object.total) : 0n, + }; + }, + + toJSON(message: DmSegConfig): unknown { + const obj: any = {}; + if (message.pageSize !== 0n) { + obj.pageSize = message.pageSize.toString(); + } + if (message.total !== 0n) { + obj.total = message.total.toString(); + } + return obj; + }, + + create, I>>(base?: I): DmSegConfig { + return DmSegConfig.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): DmSegConfig { + const message = createBaseDmSegConfig(); + message.pageSize = object.pageSize ?? 0n; + message.total = object.total ?? 0n; + return message; + }, +}; + +function createBaseDanmakuFlagConfig(): DanmakuFlagConfig { + return { recFlag: 0, recText: "", recSwitch: 0 }; +} + +export const DanmakuFlagConfig: MessageFns = { + encode(message: DanmakuFlagConfig, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.recFlag !== 0) { + writer.uint32(8).int32(message.recFlag); + } + if (message.recText !== "") { + writer.uint32(18).string(message.recText); + } + if (message.recSwitch !== 0) { + writer.uint32(24).int32(message.recSwitch); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): DanmakuFlagConfig { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDanmakuFlagConfig(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.recFlag = reader.int32(); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.recText = reader.string(); + continue; + case 3: + if (tag !== 24) { + break; + } + + message.recSwitch = reader.int32(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): DanmakuFlagConfig { + return { + recFlag: isSet(object.recFlag) ? globalThis.Number(object.recFlag) : 0, + recText: isSet(object.recText) ? globalThis.String(object.recText) : "", + recSwitch: isSet(object.recSwitch) ? globalThis.Number(object.recSwitch) : 0, + }; + }, + + toJSON(message: DanmakuFlagConfig): unknown { + const obj: any = {}; + if (message.recFlag !== 0) { + obj.recFlag = Math.round(message.recFlag); + } + if (message.recText !== "") { + obj.recText = message.recText; + } + if (message.recSwitch !== 0) { + obj.recSwitch = Math.round(message.recSwitch); + } + return obj; + }, + + create, I>>(base?: I): DanmakuFlagConfig { + return DanmakuFlagConfig.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): DanmakuFlagConfig { + const message = createBaseDanmakuFlagConfig(); + message.recFlag = object.recFlag ?? 0; + message.recText = object.recText ?? ""; + message.recSwitch = object.recSwitch ?? 0; + return message; + }, +}; + +function createBaseCommandDm(): CommandDm { + return { + id: 0n, + oid: 0n, + mid: 0n, + command: "", + content: "", + progress: 0, + ctime: "", + mtime: "", + extra: "", + idstr: "", + }; +} + +export const CommandDm: MessageFns = { + encode(message: CommandDm, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.id !== 0n) { + if (BigInt.asIntN(64, message.id) !== message.id) { + throw new globalThis.Error("value provided for field message.id of type int64 too large"); + } + writer.uint32(8).int64(message.id); + } + if (message.oid !== 0n) { + if (BigInt.asIntN(64, message.oid) !== message.oid) { + throw new globalThis.Error("value provided for field message.oid of type int64 too large"); + } + writer.uint32(16).int64(message.oid); + } + if (message.mid !== 0n) { + if (BigInt.asIntN(64, message.mid) !== message.mid) { + throw new globalThis.Error("value provided for field message.mid of type int64 too large"); + } + writer.uint32(24).int64(message.mid); + } + if (message.command !== "") { + writer.uint32(34).string(message.command); + } + if (message.content !== "") { + writer.uint32(42).string(message.content); + } + if (message.progress !== 0) { + writer.uint32(48).int32(message.progress); + } + if (message.ctime !== "") { + writer.uint32(58).string(message.ctime); + } + if (message.mtime !== "") { + writer.uint32(66).string(message.mtime); + } + if (message.extra !== "") { + writer.uint32(74).string(message.extra); + } + if (message.idstr !== "") { + writer.uint32(82).string(message.idstr); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): CommandDm { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCommandDm(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.id = reader.int64() as bigint; + continue; + case 2: + if (tag !== 16) { + break; + } + + message.oid = reader.int64() as bigint; + continue; + case 3: + if (tag !== 24) { + break; + } + + message.mid = reader.int64() as bigint; + continue; + case 4: + if (tag !== 34) { + break; + } + + message.command = reader.string(); + continue; + case 5: + if (tag !== 42) { + break; + } + + message.content = reader.string(); + continue; + case 6: + if (tag !== 48) { + break; + } + + message.progress = reader.int32(); + continue; + case 7: + if (tag !== 58) { + break; + } + + message.ctime = reader.string(); + continue; + case 8: + if (tag !== 66) { + break; + } + + message.mtime = reader.string(); + continue; + case 9: + if (tag !== 74) { + break; + } + + message.extra = reader.string(); + continue; + case 10: + if (tag !== 82) { + break; + } + + message.idstr = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): CommandDm { + return { + id: isSet(object.id) ? BigInt(object.id) : 0n, + oid: isSet(object.oid) ? BigInt(object.oid) : 0n, + mid: isSet(object.mid) ? BigInt(object.mid) : 0n, + command: isSet(object.command) ? globalThis.String(object.command) : "", + content: isSet(object.content) ? globalThis.String(object.content) : "", + progress: isSet(object.progress) ? globalThis.Number(object.progress) : 0, + ctime: isSet(object.ctime) ? globalThis.String(object.ctime) : "", + mtime: isSet(object.mtime) ? globalThis.String(object.mtime) : "", + extra: isSet(object.extra) ? globalThis.String(object.extra) : "", + idstr: isSet(object.idstr) ? globalThis.String(object.idstr) : "", + }; + }, + + toJSON(message: CommandDm): unknown { + const obj: any = {}; + if (message.id !== 0n) { + obj.id = message.id.toString(); + } + if (message.oid !== 0n) { + obj.oid = message.oid.toString(); + } + if (message.mid !== 0n) { + obj.mid = message.mid.toString(); + } + if (message.command !== "") { + obj.command = message.command; + } + if (message.content !== "") { + obj.content = message.content; + } + if (message.progress !== 0) { + obj.progress = Math.round(message.progress); + } + if (message.ctime !== "") { + obj.ctime = message.ctime; + } + if (message.mtime !== "") { + obj.mtime = message.mtime; + } + if (message.extra !== "") { + obj.extra = message.extra; + } + if (message.idstr !== "") { + obj.idstr = message.idstr; + } + return obj; + }, + + create, I>>(base?: I): CommandDm { + return CommandDm.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CommandDm { + const message = createBaseCommandDm(); + message.id = object.id ?? 0n; + message.oid = object.oid ?? 0n; + message.mid = object.mid ?? 0n; + message.command = object.command ?? ""; + message.content = object.content ?? ""; + message.progress = object.progress ?? 0; + message.ctime = object.ctime ?? ""; + message.mtime = object.mtime ?? ""; + message.extra = object.extra ?? ""; + message.idstr = object.idstr ?? ""; + return message; + }, +}; + +function createBaseDanmuWebPlayerConfig(): DanmuWebPlayerConfig { + return { + dmSwitch: false, + aiLevel: 0, + blocktop: false, + blockscroll: false, + blockbottom: false, + blockcolor: false, + blockspecial: false, + opacity: 0, + speedplus: 0, + fontsize: 0, + fontfamily: "", + bold: false, + drawType: "", + seniorModeSwitch: 0, + }; +} + +export const DanmuWebPlayerConfig: MessageFns = { + encode(message: DanmuWebPlayerConfig, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.dmSwitch !== false) { + writer.uint32(8).bool(message.dmSwitch); + } + if (message.aiSwitch !== undefined) { + writer.uint32(16).bool(message.aiSwitch); + } + if (message.aiLevel !== 0) { + writer.uint32(24).int32(message.aiLevel); + } + if (message.blocktop !== false) { + writer.uint32(32).bool(message.blocktop); + } + if (message.blockscroll !== false) { + writer.uint32(40).bool(message.blockscroll); + } + if (message.blockbottom !== false) { + writer.uint32(48).bool(message.blockbottom); + } + if (message.blockcolor !== false) { + writer.uint32(56).bool(message.blockcolor); + } + if (message.blockspecial !== false) { + writer.uint32(64).bool(message.blockspecial); + } + if (message.preventshade !== undefined) { + writer.uint32(72).bool(message.preventshade); + } + if (message.dmask !== undefined) { + writer.uint32(80).bool(message.dmask); + } + if (message.opacity !== 0) { + writer.uint32(93).float(message.opacity); + } + if (message.dmarea !== undefined) { + writer.uint32(96).int32(message.dmarea); + } + if (message.speedplus !== 0) { + writer.uint32(109).float(message.speedplus); + } + if (message.fontsize !== 0) { + writer.uint32(117).float(message.fontsize); + } + if (message.screensync !== undefined) { + writer.uint32(120).bool(message.screensync); + } + if (message.speedsync !== undefined) { + writer.uint32(128).bool(message.speedsync); + } + if (message.fontfamily !== "") { + writer.uint32(138).string(message.fontfamily); + } + if (message.bold !== false) { + writer.uint32(144).bool(message.bold); + } + if (message.fontborder !== undefined) { + writer.uint32(152).int32(message.fontborder); + } + if (message.drawType !== "") { + writer.uint32(162).string(message.drawType); + } + if (message.seniorModeSwitch !== 0) { + writer.uint32(168).int32(message.seniorModeSwitch); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): DanmuWebPlayerConfig { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDanmuWebPlayerConfig(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.dmSwitch = reader.bool(); + continue; + case 2: + if (tag !== 16) { + break; + } + + message.aiSwitch = reader.bool(); + continue; + case 3: + if (tag !== 24) { + break; + } + + message.aiLevel = reader.int32(); + continue; + case 4: + if (tag !== 32) { + break; + } + + message.blocktop = reader.bool(); + continue; + case 5: + if (tag !== 40) { + break; + } + + message.blockscroll = reader.bool(); + continue; + case 6: + if (tag !== 48) { + break; + } + + message.blockbottom = reader.bool(); + continue; + case 7: + if (tag !== 56) { + break; + } + + message.blockcolor = reader.bool(); + continue; + case 8: + if (tag !== 64) { + break; + } + + message.blockspecial = reader.bool(); + continue; + case 9: + if (tag !== 72) { + break; + } + + message.preventshade = reader.bool(); + continue; + case 10: + if (tag !== 80) { + break; + } + + message.dmask = reader.bool(); + continue; + case 11: + if (tag !== 93) { + break; + } + + message.opacity = reader.float(); + continue; + case 12: + if (tag !== 96) { + break; + } + + message.dmarea = reader.int32(); + continue; + case 13: + if (tag !== 109) { + break; + } + + message.speedplus = reader.float(); + continue; + case 14: + if (tag !== 117) { + break; + } + + message.fontsize = reader.float(); + continue; + case 15: + if (tag !== 120) { + break; + } + + message.screensync = reader.bool(); + continue; + case 16: + if (tag !== 128) { + break; + } + + message.speedsync = reader.bool(); + continue; + case 17: + if (tag !== 138) { + break; + } + + message.fontfamily = reader.string(); + continue; + case 18: + if (tag !== 144) { + break; + } + + message.bold = reader.bool(); + continue; + case 19: + if (tag !== 152) { + break; + } + + message.fontborder = reader.int32(); + continue; + case 20: + if (tag !== 162) { + break; + } + + message.drawType = reader.string(); + continue; + case 21: + if (tag !== 168) { + break; + } + + message.seniorModeSwitch = reader.int32(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): DanmuWebPlayerConfig { + return { + dmSwitch: isSet(object.dmSwitch) ? globalThis.Boolean(object.dmSwitch) : false, + aiSwitch: isSet(object.aiSwitch) ? globalThis.Boolean(object.aiSwitch) : undefined, + aiLevel: isSet(object.aiLevel) ? globalThis.Number(object.aiLevel) : 0, + blocktop: isSet(object.blocktop) ? globalThis.Boolean(object.blocktop) : false, + blockscroll: isSet(object.blockscroll) ? globalThis.Boolean(object.blockscroll) : false, + blockbottom: isSet(object.blockbottom) ? globalThis.Boolean(object.blockbottom) : false, + blockcolor: isSet(object.blockcolor) ? globalThis.Boolean(object.blockcolor) : false, + blockspecial: isSet(object.blockspecial) ? globalThis.Boolean(object.blockspecial) : false, + preventshade: isSet(object.preventshade) ? globalThis.Boolean(object.preventshade) : undefined, + dmask: isSet(object.dmask) ? globalThis.Boolean(object.dmask) : undefined, + opacity: isSet(object.opacity) ? globalThis.Number(object.opacity) : 0, + dmarea: isSet(object.dmarea) ? globalThis.Number(object.dmarea) : undefined, + speedplus: isSet(object.speedplus) ? globalThis.Number(object.speedplus) : 0, + fontsize: isSet(object.fontsize) ? globalThis.Number(object.fontsize) : 0, + screensync: isSet(object.screensync) ? globalThis.Boolean(object.screensync) : undefined, + speedsync: isSet(object.speedsync) ? globalThis.Boolean(object.speedsync) : undefined, + fontfamily: isSet(object.fontfamily) ? globalThis.String(object.fontfamily) : "", + bold: isSet(object.bold) ? globalThis.Boolean(object.bold) : false, + fontborder: isSet(object.fontborder) ? globalThis.Number(object.fontborder) : undefined, + drawType: isSet(object.drawType) ? globalThis.String(object.drawType) : "", + seniorModeSwitch: isSet(object.seniorModeSwitch) ? globalThis.Number(object.seniorModeSwitch) : 0, + }; + }, + + toJSON(message: DanmuWebPlayerConfig): unknown { + const obj: any = {}; + if (message.dmSwitch !== false) { + obj.dmSwitch = message.dmSwitch; + } + if (message.aiSwitch !== undefined) { + obj.aiSwitch = message.aiSwitch; + } + if (message.aiLevel !== 0) { + obj.aiLevel = Math.round(message.aiLevel); + } + if (message.blocktop !== false) { + obj.blocktop = message.blocktop; + } + if (message.blockscroll !== false) { + obj.blockscroll = message.blockscroll; + } + if (message.blockbottom !== false) { + obj.blockbottom = message.blockbottom; + } + if (message.blockcolor !== false) { + obj.blockcolor = message.blockcolor; + } + if (message.blockspecial !== false) { + obj.blockspecial = message.blockspecial; + } + if (message.preventshade !== undefined) { + obj.preventshade = message.preventshade; + } + if (message.dmask !== undefined) { + obj.dmask = message.dmask; + } + if (message.opacity !== 0) { + obj.opacity = message.opacity; + } + if (message.dmarea !== undefined) { + obj.dmarea = Math.round(message.dmarea); + } + if (message.speedplus !== 0) { + obj.speedplus = message.speedplus; + } + if (message.fontsize !== 0) { + obj.fontsize = message.fontsize; + } + if (message.screensync !== undefined) { + obj.screensync = message.screensync; + } + if (message.speedsync !== undefined) { + obj.speedsync = message.speedsync; + } + if (message.fontfamily !== "") { + obj.fontfamily = message.fontfamily; + } + if (message.bold !== false) { + obj.bold = message.bold; + } + if (message.fontborder !== undefined) { + obj.fontborder = Math.round(message.fontborder); + } + if (message.drawType !== "") { + obj.drawType = message.drawType; + } + if (message.seniorModeSwitch !== 0) { + obj.seniorModeSwitch = Math.round(message.seniorModeSwitch); + } + return obj; + }, + + create, I>>(base?: I): DanmuWebPlayerConfig { + return DanmuWebPlayerConfig.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): DanmuWebPlayerConfig { + const message = createBaseDanmuWebPlayerConfig(); + message.dmSwitch = object.dmSwitch ?? false; + message.aiSwitch = object.aiSwitch ?? undefined; + message.aiLevel = object.aiLevel ?? 0; + message.blocktop = object.blocktop ?? false; + message.blockscroll = object.blockscroll ?? false; + message.blockbottom = object.blockbottom ?? false; + message.blockcolor = object.blockcolor ?? false; + message.blockspecial = object.blockspecial ?? false; + message.preventshade = object.preventshade ?? undefined; + message.dmask = object.dmask ?? undefined; + message.opacity = object.opacity ?? 0; + message.dmarea = object.dmarea ?? undefined; + message.speedplus = object.speedplus ?? 0; + message.fontsize = object.fontsize ?? 0; + message.screensync = object.screensync ?? undefined; + message.speedsync = object.speedsync ?? undefined; + message.fontfamily = object.fontfamily ?? ""; + message.bold = object.bold ?? false; + message.fontborder = object.fontborder ?? undefined; + message.drawType = object.drawType ?? ""; + message.seniorModeSwitch = object.seniorModeSwitch ?? 0; + return message; + }, +}; + +function createBaseExpressions(): Expressions { + return { data: [] }; +} + +export const Expressions: MessageFns = { + encode(message: Expressions, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + for (const v of message.data) { + Expression.encode(v!, writer.uint32(10).fork()).join(); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): Expressions { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseExpressions(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.data.push(Expression.decode(reader, reader.uint32())); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): Expressions { + return { data: globalThis.Array.isArray(object?.data) ? object.data.map((e: any) => Expression.fromJSON(e)) : [] }; + }, + + toJSON(message: Expressions): unknown { + const obj: any = {}; + if (message.data?.length) { + obj.data = message.data.map((e) => Expression.toJSON(e)); + } + return obj; + }, + + create, I>>(base?: I): Expressions { + return Expressions.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): Expressions { + const message = createBaseExpressions(); + message.data = object.data?.map((e) => Expression.fromPartial(e)) || []; + return message; + }, +}; + +function createBaseExpression(): Expression { + return { keyword: [], url: "", period: [] }; +} + +export const Expression: MessageFns = { + encode(message: Expression, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + for (const v of message.keyword) { + writer.uint32(10).string(v!); + } + if (message.url !== "") { + writer.uint32(18).string(message.url); + } + for (const v of message.period) { + Period.encode(v!, writer.uint32(26).fork()).join(); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): Expression { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseExpression(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.keyword.push(reader.string()); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.url = reader.string(); + continue; + case 3: + if (tag !== 26) { + break; + } + + message.period.push(Period.decode(reader, reader.uint32())); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): Expression { + return { + keyword: globalThis.Array.isArray(object?.keyword) ? object.keyword.map((e: any) => globalThis.String(e)) : [], + url: isSet(object.url) ? globalThis.String(object.url) : "", + period: globalThis.Array.isArray(object?.period) ? object.period.map((e: any) => Period.fromJSON(e)) : [], + }; + }, + + toJSON(message: Expression): unknown { + const obj: any = {}; + if (message.keyword?.length) { + obj.keyword = message.keyword; + } + if (message.url !== "") { + obj.url = message.url; + } + if (message.period?.length) { + obj.period = message.period.map((e) => Period.toJSON(e)); + } + return obj; + }, + + create, I>>(base?: I): Expression { + return Expression.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): Expression { + const message = createBaseExpression(); + message.keyword = object.keyword?.map((e) => e) || []; + message.url = object.url ?? ""; + message.period = object.period?.map((e) => Period.fromPartial(e)) || []; + return message; + }, +}; + +function createBasePeriod(): Period { + return { end: 0n }; +} + +export const Period: MessageFns = { + encode(message: Period, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.start !== undefined) { + if (BigInt.asIntN(64, message.start) !== message.start) { + throw new globalThis.Error("value provided for field message.start of type int64 too large"); + } + writer.uint32(8).int64(message.start); + } + if (message.end !== 0n) { + if (BigInt.asIntN(64, message.end) !== message.end) { + throw new globalThis.Error("value provided for field message.end of type int64 too large"); + } + writer.uint32(16).int64(message.end); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): Period { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBasePeriod(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.start = reader.int64() as bigint; + continue; + case 2: + if (tag !== 16) { + break; + } + + message.end = reader.int64() as bigint; + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): Period { + return { + start: isSet(object.start) ? BigInt(object.start) : undefined, + end: isSet(object.end) ? BigInt(object.end) : 0n, + }; + }, + + toJSON(message: Period): unknown { + const obj: any = {}; + if (message.start !== undefined) { + obj.start = message.start.toString(); + } + if (message.end !== 0n) { + obj.end = message.end.toString(); + } + return obj; + }, + + create, I>>(base?: I): Period { + return Period.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): Period { + const message = createBasePeriod(); + message.start = object.start ?? undefined; + message.end = object.end ?? 0n; + return message; + }, +}; + +function createBasePostPanel(): PostPanel { + return { + start: 0n, + end: 0n, + priority: 0n, + bizId: 0n, + bizType: 0, + clickButton: undefined, + textInput: undefined, + checkBox: undefined, + toast: undefined, + }; +} + +export const PostPanel: MessageFns = { + encode(message: PostPanel, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.start !== 0n) { + if (BigInt.asIntN(64, message.start) !== message.start) { + throw new globalThis.Error("value provided for field message.start of type int64 too large"); + } + writer.uint32(8).int64(message.start); + } + if (message.end !== 0n) { + if (BigInt.asIntN(64, message.end) !== message.end) { + throw new globalThis.Error("value provided for field message.end of type int64 too large"); + } + writer.uint32(16).int64(message.end); + } + if (message.priority !== 0n) { + if (BigInt.asIntN(64, message.priority) !== message.priority) { + throw new globalThis.Error("value provided for field message.priority of type int64 too large"); + } + writer.uint32(24).int64(message.priority); + } + if (message.bizId !== 0n) { + if (BigInt.asIntN(64, message.bizId) !== message.bizId) { + throw new globalThis.Error("value provided for field message.bizId of type int64 too large"); + } + writer.uint32(32).int64(message.bizId); + } + if (message.bizType !== 0) { + writer.uint32(40).int32(message.bizType); + } + if (message.clickButton !== undefined) { + ClickButton.encode(message.clickButton, writer.uint32(50).fork()).join(); + } + if (message.textInput !== undefined) { + TextInput.encode(message.textInput, writer.uint32(58).fork()).join(); + } + if (message.checkBox !== undefined) { + CheckBox.encode(message.checkBox, writer.uint32(66).fork()).join(); + } + if (message.toast !== undefined) { + Toast.encode(message.toast, writer.uint32(74).fork()).join(); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): PostPanel { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBasePostPanel(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.start = reader.int64() as bigint; + continue; + case 2: + if (tag !== 16) { + break; + } + + message.end = reader.int64() as bigint; + continue; + case 3: + if (tag !== 24) { + break; + } + + message.priority = reader.int64() as bigint; + continue; + case 4: + if (tag !== 32) { + break; + } + + message.bizId = reader.int64() as bigint; + continue; + case 5: + if (tag !== 40) { + break; + } + + message.bizType = reader.int32() as any; + continue; + case 6: + if (tag !== 50) { + break; + } + + message.clickButton = ClickButton.decode(reader, reader.uint32()); + continue; + case 7: + if (tag !== 58) { + break; + } + + message.textInput = TextInput.decode(reader, reader.uint32()); + continue; + case 8: + if (tag !== 66) { + break; + } + + message.checkBox = CheckBox.decode(reader, reader.uint32()); + continue; + case 9: + if (tag !== 74) { + break; + } + + message.toast = Toast.decode(reader, reader.uint32()); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): PostPanel { + return { + start: isSet(object.start) ? BigInt(object.start) : 0n, + end: isSet(object.end) ? BigInt(object.end) : 0n, + priority: isSet(object.priority) ? BigInt(object.priority) : 0n, + bizId: isSet(object.bizId) ? BigInt(object.bizId) : 0n, + bizType: isSet(object.bizType) ? postPanelBizTypeFromJSON(object.bizType) : 0, + clickButton: isSet(object.clickButton) ? ClickButton.fromJSON(object.clickButton) : undefined, + textInput: isSet(object.textInput) ? TextInput.fromJSON(object.textInput) : undefined, + checkBox: isSet(object.checkBox) ? CheckBox.fromJSON(object.checkBox) : undefined, + toast: isSet(object.toast) ? Toast.fromJSON(object.toast) : undefined, + }; + }, + + toJSON(message: PostPanel): unknown { + const obj: any = {}; + if (message.start !== 0n) { + obj.start = message.start.toString(); + } + if (message.end !== 0n) { + obj.end = message.end.toString(); + } + if (message.priority !== 0n) { + obj.priority = message.priority.toString(); + } + if (message.bizId !== 0n) { + obj.bizId = message.bizId.toString(); + } + if (message.bizType !== 0) { + obj.bizType = postPanelBizTypeToJSON(message.bizType); + } + if (message.clickButton !== undefined) { + obj.clickButton = ClickButton.toJSON(message.clickButton); + } + if (message.textInput !== undefined) { + obj.textInput = TextInput.toJSON(message.textInput); + } + if (message.checkBox !== undefined) { + obj.checkBox = CheckBox.toJSON(message.checkBox); + } + if (message.toast !== undefined) { + obj.toast = Toast.toJSON(message.toast); + } + return obj; + }, + + create, I>>(base?: I): PostPanel { + return PostPanel.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): PostPanel { + const message = createBasePostPanel(); + message.start = object.start ?? 0n; + message.end = object.end ?? 0n; + message.priority = object.priority ?? 0n; + message.bizId = object.bizId ?? 0n; + message.bizType = object.bizType ?? 0; + message.clickButton = (object.clickButton !== undefined && object.clickButton !== null) + ? ClickButton.fromPartial(object.clickButton) + : undefined; + message.textInput = (object.textInput !== undefined && object.textInput !== null) + ? TextInput.fromPartial(object.textInput) + : undefined; + message.checkBox = (object.checkBox !== undefined && object.checkBox !== null) + ? CheckBox.fromPartial(object.checkBox) + : undefined; + message.toast = (object.toast !== undefined && object.toast !== null) ? Toast.fromPartial(object.toast) : undefined; + return message; + }, +}; + +function createBaseClickButton(): ClickButton { + return { + portraitText: [], + landscapeText: [], + portraitTextFocus: [], + landscapeTextFocus: [], + renderType: 0, + show: false, + }; +} + +export const ClickButton: MessageFns = { + encode(message: ClickButton, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + for (const v of message.portraitText) { + writer.uint32(10).string(v!); + } + for (const v of message.landscapeText) { + writer.uint32(18).string(v!); + } + for (const v of message.portraitTextFocus) { + writer.uint32(26).string(v!); + } + for (const v of message.landscapeTextFocus) { + writer.uint32(34).string(v!); + } + if (message.renderType !== 0) { + writer.uint32(40).int32(message.renderType); + } + if (message.show !== false) { + writer.uint32(48).bool(message.show); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): ClickButton { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseClickButton(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.portraitText.push(reader.string()); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.landscapeText.push(reader.string()); + continue; + case 3: + if (tag !== 26) { + break; + } + + message.portraitTextFocus.push(reader.string()); + continue; + case 4: + if (tag !== 34) { + break; + } + + message.landscapeTextFocus.push(reader.string()); + continue; + case 5: + if (tag !== 40) { + break; + } + + message.renderType = reader.int32() as any; + continue; + case 6: + if (tag !== 48) { + break; + } + + message.show = reader.bool(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): ClickButton { + return { + portraitText: globalThis.Array.isArray(object?.portraitText) + ? object.portraitText.map((e: any) => globalThis.String(e)) + : [], + landscapeText: globalThis.Array.isArray(object?.landscapeText) + ? object.landscapeText.map((e: any) => globalThis.String(e)) + : [], + portraitTextFocus: globalThis.Array.isArray(object?.portraitTextFocus) + ? object.portraitTextFocus.map((e: any) => globalThis.String(e)) + : [], + landscapeTextFocus: globalThis.Array.isArray(object?.landscapeTextFocus) + ? object.landscapeTextFocus.map((e: any) => globalThis.String(e)) + : [], + renderType: isSet(object.renderType) ? renderTypeFromJSON(object.renderType) : 0, + show: isSet(object.show) ? globalThis.Boolean(object.show) : false, + }; + }, + + toJSON(message: ClickButton): unknown { + const obj: any = {}; + if (message.portraitText?.length) { + obj.portraitText = message.portraitText; + } + if (message.landscapeText?.length) { + obj.landscapeText = message.landscapeText; + } + if (message.portraitTextFocus?.length) { + obj.portraitTextFocus = message.portraitTextFocus; + } + if (message.landscapeTextFocus?.length) { + obj.landscapeTextFocus = message.landscapeTextFocus; + } + if (message.renderType !== 0) { + obj.renderType = renderTypeToJSON(message.renderType); + } + if (message.show !== false) { + obj.show = message.show; + } + return obj; + }, + + create, I>>(base?: I): ClickButton { + return ClickButton.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): ClickButton { + const message = createBaseClickButton(); + message.portraitText = object.portraitText?.map((e) => e) || []; + message.landscapeText = object.landscapeText?.map((e) => e) || []; + message.portraitTextFocus = object.portraitTextFocus?.map((e) => e) || []; + message.landscapeTextFocus = object.landscapeTextFocus?.map((e) => e) || []; + message.renderType = object.renderType ?? 0; + message.show = object.show ?? false; + return message; + }, +}; + +function createBaseTextInput(): TextInput { + return { + portraitPlaceholder: [], + landscapePlaceholder: [], + renderType: 0, + placeholderPost: false, + show: false, + postStatus: 0, + }; +} + +export const TextInput: MessageFns = { + encode(message: TextInput, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + for (const v of message.portraitPlaceholder) { + writer.uint32(10).string(v!); + } + for (const v of message.landscapePlaceholder) { + writer.uint32(18).string(v!); + } + if (message.renderType !== 0) { + writer.uint32(24).int32(message.renderType); + } + if (message.placeholderPost !== false) { + writer.uint32(32).bool(message.placeholderPost); + } + if (message.show !== false) { + writer.uint32(40).bool(message.show); + } + if (message.postStatus !== 0) { + writer.uint32(56).int32(message.postStatus); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): TextInput { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseTextInput(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.portraitPlaceholder.push(reader.string()); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.landscapePlaceholder.push(reader.string()); + continue; + case 3: + if (tag !== 24) { + break; + } + + message.renderType = reader.int32() as any; + continue; + case 4: + if (tag !== 32) { + break; + } + + message.placeholderPost = reader.bool(); + continue; + case 5: + if (tag !== 40) { + break; + } + + message.show = reader.bool(); + continue; + case 7: + if (tag !== 56) { + break; + } + + message.postStatus = reader.int32() as any; + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): TextInput { + return { + portraitPlaceholder: globalThis.Array.isArray(object?.portraitPlaceholder) + ? object.portraitPlaceholder.map((e: any) => globalThis.String(e)) + : [], + landscapePlaceholder: globalThis.Array.isArray(object?.landscapePlaceholder) + ? object.landscapePlaceholder.map((e: any) => globalThis.String(e)) + : [], + renderType: isSet(object.renderType) ? renderTypeFromJSON(object.renderType) : 0, + placeholderPost: isSet(object.placeholderPost) ? globalThis.Boolean(object.placeholderPost) : false, + show: isSet(object.show) ? globalThis.Boolean(object.show) : false, + postStatus: isSet(object.postStatus) ? postStatusFromJSON(object.postStatus) : 0, + }; + }, + + toJSON(message: TextInput): unknown { + const obj: any = {}; + if (message.portraitPlaceholder?.length) { + obj.portraitPlaceholder = message.portraitPlaceholder; + } + if (message.landscapePlaceholder?.length) { + obj.landscapePlaceholder = message.landscapePlaceholder; + } + if (message.renderType !== 0) { + obj.renderType = renderTypeToJSON(message.renderType); + } + if (message.placeholderPost !== false) { + obj.placeholderPost = message.placeholderPost; + } + if (message.show !== false) { + obj.show = message.show; + } + if (message.postStatus !== 0) { + obj.postStatus = postStatusToJSON(message.postStatus); + } + return obj; + }, + + create, I>>(base?: I): TextInput { + return TextInput.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): TextInput { + const message = createBaseTextInput(); + message.portraitPlaceholder = object.portraitPlaceholder?.map((e) => e) || []; + message.landscapePlaceholder = object.landscapePlaceholder?.map((e) => e) || []; + message.renderType = object.renderType ?? 0; + message.placeholderPost = object.placeholderPost ?? false; + message.show = object.show ?? false; + message.postStatus = object.postStatus ?? 0; + return message; + }, +}; + +function createBaseCheckBox(): CheckBox { + return { text: "", type: 0, defaultValue: false, show: false }; +} + +export const CheckBox: MessageFns = { + encode(message: CheckBox, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.text !== "") { + writer.uint32(10).string(message.text); + } + if (message.type !== 0) { + writer.uint32(16).int32(message.type); + } + if (message.defaultValue !== false) { + writer.uint32(24).bool(message.defaultValue); + } + if (message.show !== false) { + writer.uint32(32).bool(message.show); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): CheckBox { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCheckBox(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.text = reader.string(); + continue; + case 2: + if (tag !== 16) { + break; + } + + message.type = reader.int32() as any; + continue; + case 3: + if (tag !== 24) { + break; + } + + message.defaultValue = reader.bool(); + continue; + case 4: + if (tag !== 32) { + break; + } + + message.show = reader.bool(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): CheckBox { + return { + text: isSet(object.text) ? globalThis.String(object.text) : "", + type: isSet(object.type) ? checkboxTypeFromJSON(object.type) : 0, + defaultValue: isSet(object.defaultValue) ? globalThis.Boolean(object.defaultValue) : false, + show: isSet(object.show) ? globalThis.Boolean(object.show) : false, + }; + }, + + toJSON(message: CheckBox): unknown { + const obj: any = {}; + if (message.text !== "") { + obj.text = message.text; + } + if (message.type !== 0) { + obj.type = checkboxTypeToJSON(message.type); + } + if (message.defaultValue !== false) { + obj.defaultValue = message.defaultValue; + } + if (message.show !== false) { + obj.show = message.show; + } + return obj; + }, + + create, I>>(base?: I): CheckBox { + return CheckBox.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CheckBox { + const message = createBaseCheckBox(); + message.text = object.text ?? ""; + message.type = object.type ?? 0; + message.defaultValue = object.defaultValue ?? false; + message.show = object.show ?? false; + return message; + }, +}; + +function createBaseToast(): Toast { + return { text: "", duration: 0, show: false, button: undefined }; +} + +export const Toast: MessageFns = { + encode(message: Toast, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.text !== "") { + writer.uint32(10).string(message.text); + } + if (message.duration !== 0) { + writer.uint32(16).int32(message.duration); + } + if (message.show !== false) { + writer.uint32(24).bool(message.show); + } + if (message.button !== undefined) { + Button.encode(message.button, writer.uint32(34).fork()).join(); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): Toast { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseToast(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.text = reader.string(); + continue; + case 2: + if (tag !== 16) { + break; + } + + message.duration = reader.int32(); + continue; + case 3: + if (tag !== 24) { + break; + } + + message.show = reader.bool(); + continue; + case 4: + if (tag !== 34) { + break; + } + + message.button = Button.decode(reader, reader.uint32()); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): Toast { + return { + text: isSet(object.text) ? globalThis.String(object.text) : "", + duration: isSet(object.duration) ? globalThis.Number(object.duration) : 0, + show: isSet(object.show) ? globalThis.Boolean(object.show) : false, + button: isSet(object.button) ? Button.fromJSON(object.button) : undefined, + }; + }, + + toJSON(message: Toast): unknown { + const obj: any = {}; + if (message.text !== "") { + obj.text = message.text; + } + if (message.duration !== 0) { + obj.duration = Math.round(message.duration); + } + if (message.show !== false) { + obj.show = message.show; + } + if (message.button !== undefined) { + obj.button = Button.toJSON(message.button); + } + return obj; + }, + + create, I>>(base?: I): Toast { + return Toast.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): Toast { + const message = createBaseToast(); + message.text = object.text ?? ""; + message.duration = object.duration ?? 0; + message.show = object.show ?? false; + message.button = (object.button !== undefined && object.button !== null) + ? Button.fromPartial(object.button) + : undefined; + return message; + }, +}; + +function createBaseButton(): Button { + return { text: "", action: 0 }; +} + +export const Button: MessageFns