feat: 提交资源

This commit is contained in:
han_han9
2025-10-28 21:55:41 +08:00
parent 591f398085
commit 55c4fcd9ae
2146 changed files with 172747 additions and 456 deletions

View File

@@ -0,0 +1,9 @@
{
"ver": "1.2.0",
"importer": "directory",
"imported": true,
"uuid": "e9f0de96-77bc-4964-be28-51de2e418581",
"files": [],
"subMetas": {},
"userData": {}
}

20
assets/scripts/@types/global.d.ts vendored Normal file
View File

@@ -0,0 +1,20 @@
/**
* 全局类型声明
*/
import ProtoDefinitionsType from "../protos/ProtoDefinitions.js";
declare global {
/**
* 全局 ProtoDefinitions 对象
*/
const ProtoDefinitions: typeof ProtoDefinitionsType;
/**
* Window 对象扩展
*/
interface Window {
ProtoDefinitions: typeof ProtoDefinitionsType;
}
}
export {};

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "800b7c9a-8325-496b-884e-d6bee9d107f3",
"files": [],
"subMetas": {},
"userData": {}
}

290
assets/scripts/DialogBox.ts Normal file
View File

@@ -0,0 +1,290 @@
import { _decorator, Button, Component, director, Label, Node, tween, Vec3 } from "cc";
/**
* DialogBox配置选项接口
*/
export interface IDialogBoxOptions {
/** 标题,默认为"提示" */
title?: string;
/** 内容,默认为空 */
content?: string;
/** 确定回调,可选 */
onConfirm?: () => void;
/** 取消回调,可选 */
onCancel?: () => void;
/** 确定按钮文本,默认为"确定" */
confirmText?: string;
/** 取消按钮文本,默认为"取消" */
cancelText?: string;
/** 是否显示取消按钮默认为true */
showCancel?: boolean;
/** 场景中DialogBox节点名称默认为"DialogBox" */
dialogNodeName?: string;
hideClose?: boolean;
}
const { ccclass, property } = _decorator;
/**
* 基础对话框组件
*/
@ccclass("DialogBox")
export class DialogBox extends Component {
// 静态缓存场景中的DialogBox节点
private static sceneDialogBox: DialogBox | null = null;
private static dialogNode: Node | null = null;
@property(Label)
titleLabel: Label = null!;
@property(Label)
contentLabel: Label = null!;
@property(Button)
confirmBtn: Button = null!;
@property(Label)
confirmBtnLabel: Label = null!;
@property(Button)
cancelBtn: Button = null!;
@property(Label)
cancelBtnLabel: Label = null!;
// 回调函数
private onConfirmCallback: (() => void) | null = null;
private onCancelCallback: (() => void) | null = null;
start() {
// 绑定按钮事件
if (this.confirmBtn) {
this.confirmBtn.node.on(Button.EventType.CLICK, this.onConfirmClick, this);
}
if (this.cancelBtn) {
this.cancelBtn.node.on(Button.EventType.CLICK, this.onCancelClick, this);
}
}
/**
* 设置对话框内容
* @param options 配置选项
*/
public setContent(options: IDialogBoxOptions = {}): void {
const {
title = "提示",
content = "",
onConfirm,
onCancel,
confirmText = "确定",
cancelText = "取消",
showCancel = true,
} = options;
// 设置标题和内容
if (this.titleLabel) {
this.titleLabel.string = title;
}
if (this.contentLabel) {
this.contentLabel.string = content;
}
// 设置按钮文本
if (this.confirmBtnLabel) {
this.confirmBtnLabel.string = confirmText;
}
if (this.cancelBtnLabel) {
this.cancelBtnLabel.string = cancelText;
}
// 控制取消按钮显示状态
if (this.cancelBtn) {
this.cancelBtn.node.active = showCancel;
}
// 保存回调函数
this.onConfirmCallback = onConfirm || null;
this.onCancelCallback = onCancel || null;
}
/**
* 显示对话框(带弹出动画)
*/
public show(): void {
this.node.active = true;
// 初始化缩放和透明度
this.node.setScale(Vec3.ZERO);
// 弹出动画缩放从0到1带回弹效果
tween(this.node)
.to(
0.3,
{ scale: Vec3.ONE },
{
easing: "backOut", // 回弹缓动效果
},
)
.start();
}
/**
* 隐藏对话框(带关闭动画)
*/
public hide(): void {
// 停止所有动画
tween(this.node).stop();
// 关闭动画缩放到0
tween(this.node)
.to(
0.2,
{ scale: Vec3.ZERO },
{
easing: "backIn", // 回缩缓动效果
},
)
.call(() => {
// 动画结束后隐藏节点
this.node.active = false;
// 恢复缩放值,为下次显示做准备
this.node.setScale(Vec3.ONE);
})
.start();
// 清理回调
this.onConfirmCallback = null;
this.onCancelCallback = null;
}
/**
* 确定按钮点击事件
*/
private onConfirmClick(): void {
// 执行回调
if (this.onConfirmCallback) {
this.onConfirmCallback();
}
// 隐藏对话框
this.hide();
}
/**
* 取消按钮点击事件
*/
private onCancelClick(): void {
// 执行回调
if (this.onCancelCallback) {
this.onCancelCallback();
}
// 隐藏对话框
this.hide();
}
onDestroy() {
// 清理事件监听
if (this.confirmBtn) {
this.confirmBtn.node.off(Button.EventType.CLICK, this.onConfirmClick, this);
}
if (this.cancelBtn) {
this.cancelBtn.node.off(Button.EventType.CLICK, this.onCancelClick, this);
}
// 停止所有动画
tween(this.node).stop();
// 清理静态引用
if (DialogBox.sceneDialogBox === this) {
DialogBox.sceneDialogBox = null;
DialogBox.dialogNode = null;
}
}
/**
* 静态方法:显示对话框
* @param options 配置选项
*/
public static showDialog(options: IDialogBoxOptions = {}): void {
const { dialogNodeName = "DialogBox" } = options;
// 获取场景中的DialogBox节点
if (!DialogBox.sceneDialogBox || !DialogBox.dialogNode?.isValid) {
DialogBox.findDialogBoxInScene(dialogNodeName);
}
if (!DialogBox.sceneDialogBox) {
return; // 场景中未找到DialogBox节点
}
// 设置内容并显示
DialogBox.sceneDialogBox.setContent(options);
DialogBox.sceneDialogBox.show();
}
/**
* 静态方法:隐藏当前对话框(带动画)
*/
public static hideCurrentDialog(): void {
if (DialogBox.sceneDialogBox) {
DialogBox.sceneDialogBox.hide();
}
}
/**
* 静态方法:立即隐藏当前对话框(无动画)
*/
public static hideCurrentDialogImmediately(): void {
if (DialogBox.sceneDialogBox) {
// 停止所有动画
tween(DialogBox.sceneDialogBox.node).stop();
// 立即隐藏
DialogBox.sceneDialogBox.node.active = false;
DialogBox.sceneDialogBox.node.setScale(Vec3.ONE);
// 清理回调
DialogBox.sceneDialogBox.onConfirmCallback = null;
DialogBox.sceneDialogBox.onCancelCallback = null;
}
}
/**
* 在场景中查找DialogBox节点
* @param nodeName 节点名称
*/
private static findDialogBoxInScene(nodeName: string): void {
const scene = director.getScene();
if (!scene) {
return;
}
// 递归查找DialogBox节点
const findNodeRecursively = (node: Node, targetName: string): Node | null => {
if (node.name === targetName) {
return node;
}
for (const child of node.children) {
const found = findNodeRecursively(child, targetName);
if (found) {
return found;
}
}
return null;
};
const dialogNode = findNodeRecursively(scene, nodeName);
if (dialogNode) {
const dialogComponent = dialogNode.getComponent(DialogBox);
if (dialogComponent) {
DialogBox.sceneDialogBox = dialogComponent;
DialogBox.dialogNode = dialogNode;
// 初始状态为隐藏
dialogNode.active = false;
}
}
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "3e897a15-e06b-4aad-89cd-41d2b92c632e",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,73 @@
/* eslint-disable no-console */
import { _decorator, Component, director } from "cc";
const { ccclass, property } = _decorator;
/**
* DontDestroy 组件
* 挂载此脚本的节点在场景切换时不会被自动销毁
*
* 使用场景:
* - 全局 UI 组件(如 Toast、Loading 等)
* - 音效管理器
* - 网络管理器
* - 其他需要跨场景保持的组件
*/
@ccclass("DontDestroy")
export class DontDestroy extends Component {
/**
* 标识是否已经设置为常驻节点
* 防止重复设置
*/
private _isPersistent: boolean = false;
protected onLoad(): void {
this.makePersistent();
}
/**
* 设置节点为常驻节点
*/
private makePersistent(): void {
if (this._isPersistent) {
console.warn(
`DontDestroy: 节点 ${this.node.name} 已经是常驻节点,无需重复设置`,
);
return;
}
// 设置节点为常驻节点,场景切换时不会被销毁
director.addPersistRootNode(this.node);
this._isPersistent = true;
console.log(`DontDestroy: 节点 ${this.node.name} 已设置为常驻节点`);
}
/**
* 手动移除常驻状态
* 调用此方法后,节点会在下次场景切换时被销毁
*/
public removePersistent(): void {
if (!this._isPersistent) {
console.warn(
`DontDestroy: 节点 ${this.node.name} 不是常驻节点,无需移除`,
);
return;
}
// 从常驻节点列表中移除
director.removePersistRootNode(this.node);
this._isPersistent = false;
console.log(
`DontDestroy: 节点 ${this.node.name} 已从常驻节点列表中移除`,
);
}
/**
* 检查节点是否为常驻节点
*/
public isPersistent(): boolean {
return this._isPersistent;
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "31b953b2-cbca-493e-b3ac-3a1883d9e8dd",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,79 @@
import { _decorator, Component, Label, ProgressBar } from "cc";
const { ccclass, property } = _decorator;
@ccclass("HotupdateLoading")
export class HotupdateLoading extends Component {
@property(Label)
label: Label = null;
@property(ProgressBar)
progressBar: ProgressBar = null;
/** 动画定时器ID */
private animationTimer: NodeJS.Timeout | null = null;
/** 当前动画状态 */
private animationState: number = 0;
/** 动画基础文本 */
private baseText: string = "";
protected onDestroy() {
this.stopTextAnimation();
}
public updateProgress(current: number, total: number) {
this.progressBar.progress = current / total;
this.progressBar.node.active = true;
this.label.string = `正在更新中 ${current}/${total}`;
}
public updateProgressText(text: string, enableAnimation: boolean = false) {
this.stopTextAnimation();
if (enableAnimation) {
this.startTextAnimation(text);
} else {
this.label.string = text;
}
this.progressBar.node.active = false;
}
/**
* 开始文本动画
* @param baseText 基础文本,如"加载中"
* @param interval 动画间隔时间默认500毫秒
*/
public startTextAnimation(baseText: string, interval: number = 500) {
this.stopTextAnimation();
this.baseText = baseText;
this.animationState = 0;
// 立即显示第一帧
this.updateAnimationText();
// 启动定时器
this.animationTimer = setInterval(() => {
this.animationState = (this.animationState + 1) % 4; // 0,1,2,3 循环
this.updateAnimationText();
}, interval);
}
/**
* 停止文本动画
*/
public stopTextAnimation() {
if (this.animationTimer !== null) {
clearInterval(this.animationTimer);
this.animationTimer = null;
}
}
/**
* 更新动画文本显示
*/
private updateAnimationText() {
const dots = ".".repeat(this.animationState);
this.label.string = this.baseText + dots;
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "f182d537-f0f7-4122-95b9-f14e885e9e56",
"files": [],
"subMetas": {},
"userData": {}
}

216
assets/scripts/Startup.ts Normal file
View File

@@ -0,0 +1,216 @@
/* eslint-disable no-console */
import { _decorator, assetManager, AssetManager, Component, director } from "cc";
import HotupdateConfig from "@max-studio/hotupdate/HotupdateConfig";
import { HotupdateEventData } from "@max-studio/hotupdate/HotupdateEvent";
import { HotupdateInstance } from "@max-studio/hotupdate/HotupdateInstance";
import { HotupdateState } from "@max-studio/hotupdate/HotupdateState";
import { DialogBox } from "./DialogBox";
import { HotupdateLoading } from "./HotupdateLoading";
const { ccclass, property } = _decorator;
@ccclass("Startup")
export class Startup extends Component {
@property(HotupdateLoading)
private loading!: HotupdateLoading;
protected onLoad(): void {
HotupdateInstance.getInstance().register(this.onHotupdateEvent.bind(this));
}
protected onDestroy(): void {
HotupdateInstance.getInstance().unregister(this.onHotupdateEvent.bind(this));
}
private onHotupdateEvent(data: HotupdateEventData) {
console.log("HotupdateEvent - msg:", data.msg, "state:", data.state);
switch (data.state) {
case HotupdateState.ERROR_MANIFEST:
DialogBox.showDialog({
title: "更新错误",
content: "清单文件错误,请检查网络连接后重试",
confirmText: "重试",
showCancel: false,
onConfirm: () => {
// 重新尝试热更新
this.tryHotUpdate();
},
});
break;
case HotupdateState.NEW_VERSION_FOUND:
DialogBox.showDialog({
title: "发现新版本",
content: "发现新的游戏内容,是否立即更新?",
confirmText: "立即更新",
cancelText: "稍后更新",
showCancel: true,
onConfirm: () => {
// 开始热更新
this.startHotUpdate();
},
onCancel: () => {
// 跳过更新,进入游戏
void this.enterHall();
},
});
break;
case HotupdateState.UPDATE_FAILED:
DialogBox.showDialog({
title: "更新失败",
content: data.msg || "更新失败,请检查网络连接",
confirmText: "重试",
cancelText: "跳过",
showCancel: true,
onConfirm: () => {
// 重新尝试更新
this.retryUpdate();
},
onCancel: () => {
// 跳过更新,进入游戏
void this.enterHall();
},
});
break;
case HotupdateState.ALREADY_UP_TO_DATE:
void this.enterHall();
break;
case HotupdateState.UPDATE_FINISHED:
// 更新成功,仅打印数据
console.log(
"热更新完成 - state:",
data.state,
"msg:",
data.msg,
"timestamp:",
new Date().toISOString(),
);
void this.enterHall();
break;
case HotupdateState.UPDATE_PROGRESSION:
// 更新进度可以显示进度条或更新UI
this.updateProgress(data);
break;
default:
// 其他状态的处理
console.log("未处理的热更新状态 - state:", data.state, "msg:", data.msg);
break;
}
}
async start() {
this.loading.updateProgressText("正在检查更新...");
void HotupdateInstance.getInstance().checkUpdate(new HotupdateConfig("main"));
}
/**
* 重新尝试热更新
*/
private tryHotUpdate(): void {
this.loading.updateProgressText("正在检查更新...");
void HotupdateInstance.getInstance().checkUpdate(new HotupdateConfig("main"));
}
/**
* 开始热更新
*/
private startHotUpdate(): void {
this.loading.updateProgressText("正在更新...");
HotupdateInstance.getInstance().hotUpdate();
}
/**
* 重试更新
*/
private retryUpdate(): void {
this.loading.updateProgressText("正在更新...");
HotupdateInstance.getInstance().hotUpdate();
}
/**
* 进入游戏
*/
private async enterHall() {
try {
await this.loadBundles("max-core", "max-res", "configs");
const hallBundle = await this.loadBundle("hall");
hallBundle.loadScene("Hall", (err, data) => {
if (err) {
console.error("加载场景失败:", err);
return;
}
this.loading.node.destroy();
console.log("加载场景成功", data);
// 切换到 Hall 场景
director.runScene(data);
});
} catch (err) {
console.log("err", err);
}
}
private async loadBundles(...bundles: string[]) {
for (const bundle of bundles) {
await this.loadBundle(bundle);
}
}
private async loadBundle(bundle: string): Promise<AssetManager.Bundle> {
return new Promise((resolve, reject) => {
assetManager.loadBundle(bundle, (err, data) => {
if (err) {
reject(err);
return;
}
console.log("loadBundle 成功:", bundle);
resolve(data);
});
});
}
/**
* 更新进度
*/
private updateProgress(data: HotupdateEventData): void {
// 获取进度信息
const instance = HotupdateInstance.getInstance();
const downloadedBytes = instance.getDownloadBytes();
const totalBytes = instance.getTotalBytes();
const progress = instance.getDownloadProgress();
console.log(
"更新进度 - progress:",
`${progress}%`,
"downloaded:",
`${(downloadedBytes / 1024 / 1024).toFixed(2)}MB`,
"total:",
`${(totalBytes / 1024 / 1024).toFixed(2)}MB`,
"state:",
data.state,
);
this.loading.updateProgress(downloadedBytes, totalBytes);
}
private onLogin(isLogin: boolean) {
if (isLogin) {
// 登录成功
// const petConfig = PetConfigManager.getInstance().getConfig(1001);
// LogUtils.log("Startup", "petConfig:", petConfig);
// LogUtils.log("Startup", "PetConfig:", petConfig.bundle);
}
}
public onClick() {
// ProtoDefinitions.pkg1.Bar
// LogUtils.log("onClick");
// StorageManager.getInstance().setData("Guide", "newbie_guide_test");
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "3a03f97e-0c94-417b-95d2-e165b9b48ac5",
"files": [],
"subMetas": {},
"userData": {}
}

9
assets/scripts/core.meta Normal file
View File

@@ -0,0 +1,9 @@
{
"ver": "1.2.0",
"importer": "directory",
"imported": true,
"uuid": "9549cd44-0e6f-4b49-b2c3-a134be3c8ec4",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,57 @@
/* eslint-disable no-console */
/**
* 全局 Proto 初始化
*/
// import ProtoDefinitionsModule from "../protos/ProtoDefinitions.js";
import ProtoDefinitionsModule from "../protos/ProtoDefinitions.js";
// @ts-ignore
/**
* 初始化全局 ProtoDefinitions
*/
export class GlobalProtoInit {
// ProtoDefinitionsModule.
private static _initialized = false;
/**
* 初始化全局 Proto 定义
*/
public static init(): void {
if (this._initialized) {
return;
}
try {
// 将 ProtoDefinitions 挂载到全局对象
(globalThis as any).ProtoDefinitions = ProtoDefinitionsModule;
// 同时挂载到 window 对象(浏览器环境)
if (typeof window !== "undefined") {
(window as any).ProtoDefinitions = ProtoDefinitionsModule;
}
this._initialized = true;
console.log(
"GlobalProtoInit",
"ProtoDefinitions 已成功挂载到全局对象",
);
} catch (err) {
console.error(
"GlobalProtoInit",
"初始化 ProtoDefinitions 失败:",
err,
);
}
}
/**
* 检查是否已初始化
*/
public static isInitialized(): boolean {
return this._initialized;
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "4145ae89-a1b6-4f79-88d1-c99b83e3c02d",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "1.2.0",
"importer": "directory",
"imported": true,
"uuid": "54c034a4-1635-4b88-92bf-ce091e158a3b",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,171 @@
import * as $protobuf from "protobufjs";
import Long = require("long");
/** Namespace pkg1. */
export namespace pkg1 {
/** Properties of a Bar. */
interface IBar {
/** Bar bar */
bar?: (number|null);
}
/** Represents a Bar. */
class Bar implements IBar {
/**
* Constructs a new Bar.
* @param [properties] Properties to set
*/
constructor(properties?: pkg1.IBar);
/** Bar bar. */
public bar: number;
/**
* Encodes the specified Bar message. Does not implicitly {@link pkg1.Bar.verify|verify} messages.
* @param message Bar message or plain object to encode
* @param [writer] Writer to encode to
* @returns Writer
*/
public static encode(message: pkg1.IBar, writer?: $protobuf.Writer): $protobuf.Writer;
/**
* Decodes a Bar message from the specified reader or buffer.
* @param reader Reader or buffer to decode from
* @param [length] Message length if known beforehand
* @returns Bar
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): pkg1.Bar;
/**
* Gets the default type url for Bar
* @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
* @returns The default type url
*/
public static getTypeUrl(typeUrlPrefix?: string): string;
}
/** MessageCode enum. */
enum MessageCode {
MSG_UNKNOWN = 0,
MSG_USER = 1001,
MSG_BAR = 1002
}
/** Properties of an Envelope. */
interface IEnvelope {
/** Envelope code */
code?: (number|null);
/** Envelope payload */
payload?: (Uint8Array|null);
}
/** Represents an Envelope. */
class Envelope implements IEnvelope {
/**
* Constructs a new Envelope.
* @param [properties] Properties to set
*/
constructor(properties?: pkg1.IEnvelope);
/** Envelope code. */
public code: number;
/** Envelope payload. */
public payload: Uint8Array;
/**
* Encodes the specified Envelope message. Does not implicitly {@link pkg1.Envelope.verify|verify} messages.
* @param message Envelope message or plain object to encode
* @param [writer] Writer to encode to
* @returns Writer
*/
public static encode(message: pkg1.IEnvelope, writer?: $protobuf.Writer): $protobuf.Writer;
/**
* Decodes an Envelope message from the specified reader or buffer.
* @param reader Reader or buffer to decode from
* @param [length] Message length if known beforehand
* @returns Envelope
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): pkg1.Envelope;
/**
* Gets the default type url for Envelope
* @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
* @returns The default type url
*/
public static getTypeUrl(typeUrlPrefix?: string): string;
}
/** Properties of a User. */
interface IUser {
/** User id */
id?: (number|null);
/** User name */
name?: (string|null);
/** User age */
age?: (number|null);
/** User emails */
emails?: (string[]|null);
}
/** Represents a User. */
class User implements IUser {
/**
* Constructs a new User.
* @param [properties] Properties to set
*/
constructor(properties?: pkg1.IUser);
/** User id. */
public id: number;
/** User name. */
public name: string;
/** User age. */
public age: number;
/** User emails. */
public emails: string[];
/**
* Encodes the specified User message. Does not implicitly {@link pkg1.User.verify|verify} messages.
* @param message User message or plain object to encode
* @param [writer] Writer to encode to
* @returns Writer
*/
public static encode(message: pkg1.IUser, writer?: $protobuf.Writer): $protobuf.Writer;
/**
* Decodes a User message from the specified reader or buffer.
* @param reader Reader or buffer to decode from
* @param [length] Message length if known beforehand
* @returns User
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): pkg1.User;
/**
* Gets the default type url for User
* @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
* @returns The default type url
*/
public static getTypeUrl(typeUrlPrefix?: string): string;
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "a0db76a9-1ddf-4988-8aab-b776b060d11c",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,401 @@
/*eslint-disable block-scoped-var, id-length, no-control-regex, no-magic-numbers, no-prototype-builtins, no-redeclare, no-shadow, no-var, sort-vars*/
"use strict";
var $protobuf = require("protobufjs/minimal");
// Common aliases
var $Reader = $protobuf.Reader, $Writer = $protobuf.Writer, $util = $protobuf.util;
// Exported root namespace
var $root = $protobuf.roots["default"] || ($protobuf.roots["default"] = {});
$root.pkg1 = (function() {
/**
* Namespace pkg1.
* @exports pkg1
* @namespace
*/
var pkg1 = {};
pkg1.Bar = (function() {
/**
* Properties of a Bar.
* @memberof pkg1
* @interface IBar
* @property {number|null} [bar] Bar bar
*/
/**
* Constructs a new Bar.
* @memberof pkg1
* @classdesc Represents a Bar.
* @implements IBar
* @constructor
* @param {pkg1.IBar=} [properties] Properties to set
*/
function Bar(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
}
/**
* Bar bar.
* @member {number} bar
* @memberof pkg1.Bar
* @instance
*/
Bar.prototype.bar = 0;
/**
* Encodes the specified Bar message. Does not implicitly {@link pkg1.Bar.verify|verify} messages.
* @function encode
* @memberof pkg1.Bar
* @static
* @param {pkg1.IBar} message Bar message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
Bar.encode = function encode(message, writer) {
if (!writer)
writer = $Writer.create();
if (message.bar != null && Object.hasOwnProperty.call(message, "bar"))
writer.uint32(/* id 1, wireType 0 =*/8).int32(message.bar);
return writer;
};
/**
* Decodes a Bar message from the specified reader or buffer.
* @function decode
* @memberof pkg1.Bar
* @static
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
* @param {number} [length] Message length if known beforehand
* @returns {pkg1.Bar} Bar
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
Bar.decode = function decode(reader, length, error) {
if (!(reader instanceof $Reader))
reader = $Reader.create(reader);
var end = length === undefined ? reader.len : reader.pos + length, message = new $root.pkg1.Bar();
while (reader.pos < end) {
var tag = reader.uint32();
if (tag === error)
break;
switch (tag >>> 3) {
case 1: {
message.bar = reader.int32();
break;
}
default:
reader.skipType(tag & 7);
break;
}
}
return message;
};
/**
* Gets the default type url for Bar
* @function getTypeUrl
* @memberof pkg1.Bar
* @static
* @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
* @returns {string} The default type url
*/
Bar.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
if (typeUrlPrefix === undefined) {
typeUrlPrefix = "type.googleapis.com";
}
return typeUrlPrefix + "/pkg1.Bar";
};
return Bar;
})();
/**
* MessageCode enum.
* @name pkg1.MessageCode
* @enum {number}
* @property {number} MSG_UNKNOWN=0 MSG_UNKNOWN value
* @property {number} MSG_USER=1001 MSG_USER value
* @property {number} MSG_BAR=1002 MSG_BAR value
*/
pkg1.MessageCode = (function() {
var valuesById = {}, values = Object.create(valuesById);
values[valuesById[0] = "MSG_UNKNOWN"] = 0;
values[valuesById[1001] = "MSG_USER"] = 1001;
values[valuesById[1002] = "MSG_BAR"] = 1002;
return values;
})();
pkg1.Envelope = (function() {
/**
* Properties of an Envelope.
* @memberof pkg1
* @interface IEnvelope
* @property {number|null} [code] Envelope code
* @property {Uint8Array|null} [payload] Envelope payload
*/
/**
* Constructs a new Envelope.
* @memberof pkg1
* @classdesc Represents an Envelope.
* @implements IEnvelope
* @constructor
* @param {pkg1.IEnvelope=} [properties] Properties to set
*/
function Envelope(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
}
/**
* Envelope code.
* @member {number} code
* @memberof pkg1.Envelope
* @instance
*/
Envelope.prototype.code = 0;
/**
* Envelope payload.
* @member {Uint8Array} payload
* @memberof pkg1.Envelope
* @instance
*/
Envelope.prototype.payload = $util.newBuffer([]);
/**
* Encodes the specified Envelope message. Does not implicitly {@link pkg1.Envelope.verify|verify} messages.
* @function encode
* @memberof pkg1.Envelope
* @static
* @param {pkg1.IEnvelope} message Envelope message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
Envelope.encode = function encode(message, writer) {
if (!writer)
writer = $Writer.create();
if (message.code != null && Object.hasOwnProperty.call(message, "code"))
writer.uint32(/* id 1, wireType 0 =*/8).int32(message.code);
if (message.payload != null && Object.hasOwnProperty.call(message, "payload"))
writer.uint32(/* id 2, wireType 2 =*/18).bytes(message.payload);
return writer;
};
/**
* Decodes an Envelope message from the specified reader or buffer.
* @function decode
* @memberof pkg1.Envelope
* @static
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
* @param {number} [length] Message length if known beforehand
* @returns {pkg1.Envelope} Envelope
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
Envelope.decode = function decode(reader, length, error) {
if (!(reader instanceof $Reader))
reader = $Reader.create(reader);
var end = length === undefined ? reader.len : reader.pos + length, message = new $root.pkg1.Envelope();
while (reader.pos < end) {
var tag = reader.uint32();
if (tag === error)
break;
switch (tag >>> 3) {
case 1: {
message.code = reader.int32();
break;
}
case 2: {
message.payload = reader.bytes();
break;
}
default:
reader.skipType(tag & 7);
break;
}
}
return message;
};
/**
* Gets the default type url for Envelope
* @function getTypeUrl
* @memberof pkg1.Envelope
* @static
* @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
* @returns {string} The default type url
*/
Envelope.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
if (typeUrlPrefix === undefined) {
typeUrlPrefix = "type.googleapis.com";
}
return typeUrlPrefix + "/pkg1.Envelope";
};
return Envelope;
})();
pkg1.User = (function() {
/**
* Properties of a User.
* @memberof pkg1
* @interface IUser
* @property {number|null} [id] User id
* @property {string|null} [name] User name
* @property {number|null} [age] User age
* @property {Array.<string>|null} [emails] User emails
*/
/**
* Constructs a new User.
* @memberof pkg1
* @classdesc Represents a User.
* @implements IUser
* @constructor
* @param {pkg1.IUser=} [properties] Properties to set
*/
function User(properties) {
this.emails = [];
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
}
/**
* User id.
* @member {number} id
* @memberof pkg1.User
* @instance
*/
User.prototype.id = 0;
/**
* User name.
* @member {string} name
* @memberof pkg1.User
* @instance
*/
User.prototype.name = "";
/**
* User age.
* @member {number} age
* @memberof pkg1.User
* @instance
*/
User.prototype.age = 0;
/**
* User emails.
* @member {Array.<string>} emails
* @memberof pkg1.User
* @instance
*/
User.prototype.emails = $util.emptyArray;
/**
* Encodes the specified User message. Does not implicitly {@link pkg1.User.verify|verify} messages.
* @function encode
* @memberof pkg1.User
* @static
* @param {pkg1.IUser} message User message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
User.encode = function encode(message, writer) {
if (!writer)
writer = $Writer.create();
if (message.id != null && Object.hasOwnProperty.call(message, "id"))
writer.uint32(/* id 1, wireType 0 =*/8).int32(message.id);
if (message.name != null && Object.hasOwnProperty.call(message, "name"))
writer.uint32(/* id 2, wireType 2 =*/18).string(message.name);
if (message.age != null && Object.hasOwnProperty.call(message, "age"))
writer.uint32(/* id 3, wireType 0 =*/24).int32(message.age);
if (message.emails != null && message.emails.length)
for (var i = 0; i < message.emails.length; ++i)
writer.uint32(/* id 4, wireType 2 =*/34).string(message.emails[i]);
return writer;
};
/**
* Decodes a User message from the specified reader or buffer.
* @function decode
* @memberof pkg1.User
* @static
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
* @param {number} [length] Message length if known beforehand
* @returns {pkg1.User} User
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
User.decode = function decode(reader, length, error) {
if (!(reader instanceof $Reader))
reader = $Reader.create(reader);
var end = length === undefined ? reader.len : reader.pos + length, message = new $root.pkg1.User();
while (reader.pos < end) {
var tag = reader.uint32();
if (tag === error)
break;
switch (tag >>> 3) {
case 1: {
message.id = reader.int32();
break;
}
case 2: {
message.name = reader.string();
break;
}
case 3: {
message.age = reader.int32();
break;
}
case 4: {
if (!(message.emails && message.emails.length))
message.emails = [];
message.emails.push(reader.string());
break;
}
default:
reader.skipType(tag & 7);
break;
}
}
return message;
};
/**
* Gets the default type url for User
* @function getTypeUrl
* @memberof pkg1.User
* @static
* @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
* @returns {string} The default type url
*/
User.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
if (typeUrlPrefix === undefined) {
typeUrlPrefix = "type.googleapis.com";
}
return typeUrlPrefix + "/pkg1.User";
};
return User;
})();
return pkg1;
})();
module.exports = $root;

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "javascript",
"imported": true,
"uuid": "9aaf0cba-df1f-4a1a-85ba-66f65f4faf2d",
"files": [],
"subMetas": {},
"userData": {}
}