@biliverse/protobuf
v1.1.0
Published
Generated Bilibili protobuf bindings for Biliverse
Readme
@biliverse/protobuf
Generated Bilibili protobuf bindings used by the Biliverse products.
Release changes are recorded in CHANGELOG.md.
This repository is the sole source of the runtime protobuf package. Full API
definitions are maintained in BACNext and Apifox; product repositories import
the generated bindings from @biliverse/protobuf instead of maintaining local
protocol copies. The shared package declares only fields required by its
consumers, with their real types, field numbers, and oneof semantics.
Undeclared fields are retained through protobuf-ts.
import { AIRelateReply } from "@biliverse/protobuf/bilibili/app/viewunite/v1/airelate.js";
import { ModuleType } from "@biliverse/protobuf/bilibili/app/viewunite/common.js";
const reply = AIRelateReply.fromBinary(payload);
for (const module of reply.tab?.modules ?? []) {
if (module.type === ModuleType.RELATED_RECOMMEND && module.data.oneofKind === "relates") {
const cards = module.data.relates.cards;
console.log(cards.length);
}
}Generate
npm run generate compiles every checked-in .proto file with the same
protobuf-ts options used by apple.MapKit: dependency generation, string
64-bit values, and JavaScript output. Relative imports are normalized by the
post-generation fix:imports step.
To generate an external Apple-style proto source tree without changing the
checked-in Biliverse sources, set APPLE_PROTO_ROOT and run
npm run generate:apple-mapkit. The generated files are written under
generated/apple-mapkit/ and are intentionally ignored by the package.
Publishing
Release tags (vX.Y.Z) publish this package to both npmjs and GitHub Packages
through the two release workflows. Consumers that use GitHub Packages should
keep the @biliverse:registry=https://npm.pkg.github.com/ scope mapping and
provide NODE_AUTH_TOKEN through the CI secret store.
ADBlock field migration (v1.1.0)
The Dynamic and legacy View additions, exact field types, and consumer changes
are recorded in the migration record.
Use TabOtype.CmURI for the legacy advertising tab; adTabInfo and
cmUnderPlayer use google.protobuf.Any.
VideoGuide declares no internal fields: consumers remove the whole message
and protobuf-ts retains its undeclared data when the message is kept.
AIRelate adds only cm=1, tab=2, and modules=1 to its response envelope,
reusing the existing shared CM, Module, Relates, and RelateCard types.
These new envelope fields originate from ADBlock commit 950fee1 and were
accepted for migration; they are not claimed to be verified server captures.
import { TabOtype, ViewReply } from "@biliverse/protobuf/bilibili/app/view/v1/view.js";
const reply = ViewReply.fromBinary(payload);
if (reply.tab?.otype === TabOtype.CmURI || reply.tab?.adTabInfo) {
reply.tab = undefined;
}